public class DMXUtils extends Object
Constructor and Description |
---|
DMXUtils() |
Modifier and Type | Method and Description |
---|---|
static PlayerModel[] |
assocAutoTyping(AssocModel assoc,
String topicTypeUri1,
String topicTypeUri2,
String assocTypeUri,
String roleTypeUri1,
String roleTypeUri2) |
static PlayerModel[] |
assocAutoTyping(AssocModel assoc,
String topicTypeUri1,
String topicTypeUri2,
String assocTypeUri,
String roleTypeUri1,
String roleTypeUri2,
java.util.function.Predicate<PlayerModel[]> playerTest)
Retypes the given association if its players match the given topic types.
|
static <T extends RelatedObjectModel> |
findByAssoc(long assocId,
Iterable<T> objects) |
static <T extends Identifiable> |
findById(long id,
Iterable<T> items) |
static List<Topic> |
getParentTopics(Topic topic)
Finds all parent topics of the given topic by traversing along the child->parent relationship.
|
static PlayerModel[] |
getPlayerModels(AssocModel assoc,
String topicTypeUri1,
String topicTypeUri2) |
static List<Long> |
idList(Iterable<? extends Identifiable> items) |
static int |
indexOfAssoc(long assocId,
Iterable<? extends RelatedObjectModel> objects) |
static boolean |
isDMXURL(URL url)
Checks if an URL refers to this DMX installation.
|
static <T extends DMXObject> |
loadChildTopics(List<T> objects) |
static org.codehaus.jettison.json.JSONArray |
toJSONArray(Iterable<? extends JSONEnabled> items) |
static List |
toList(org.codehaus.jettison.json.JSONArray o) |
static Map |
toMap(org.codehaus.jettison.json.JSONObject o) |
static Map |
toMap(org.codehaus.jettison.json.JSONObject o,
Map map) |
static <M> List<M> |
toModelList(Iterable<? extends DMXObject> objects) |
static String |
topicNames(Iterable<? extends Topic> topics) |
public static boolean isDMXURL(URL url)
public static List<Long> idList(Iterable<? extends Identifiable> items)
public static <T extends Identifiable> T findById(long id, Iterable<T> items)
public static <T extends RelatedObjectModel> T findByAssoc(long assocId, Iterable<T> objects)
public static int indexOfAssoc(long assocId, Iterable<? extends RelatedObjectModel> objects)
public static Map toMap(org.codehaus.jettison.json.JSONObject o)
public static List toList(org.codehaus.jettison.json.JSONArray o)
public static org.codehaus.jettison.json.JSONArray toJSONArray(Iterable<? extends JSONEnabled> items)
public static List<Topic> getParentTopics(Topic topic)
If the given topic has no parent topics the returned list contains only the given topic.
public static PlayerModel[] assocAutoTyping(AssocModel assoc, String topicTypeUri1, String topicTypeUri2, String assocTypeUri, String roleTypeUri1, String roleTypeUri2)
public static PlayerModel[] assocAutoTyping(AssocModel assoc, String topicTypeUri1, String topicTypeUri2, String assocTypeUri, String roleTypeUri1, String roleTypeUri2, java.util.function.Predicate<PlayerModel[]> playerTest)
PreCreateAssoc
.
Read the parameters as follows: if "assoc" connects a "topicTypeUri1" with a "topicTypeUri2" (regardless of 1,2 position) then retype it to "assocTypeUri" and use the role types "roleTypeUri1" and "roleTypeUri2". "roleTypeUri1" is used for the "topicTypeUri1" player, "roleTypeUri2" is used for the "topicTypeUri2" player.
Auto-typing takes place only if the given assoc is of type "Association" (that is a generic assoc without any semantics). If the given assoc is not a generic one, no retyping takes place (null is returned).
Auto-typing is supported only for topic players, and only if they are identified by-ID. If the given assoc has at least one assoc player, or if a topic player is identfied by-URI, no retyping takes place (null is returned).
playerTest
- optional: a predicate tested after a type-match is detected for both players, but
before actual auto-typing takes place. You can prohibit auto-typing by returning
false
. An array of 2 assoc players is passed. [0] is the player that
matches "topicTypeUri1", [1] is the player that matches "topicTypeUri2".
If no predicate is given (null) no additional test is performed before auto-typing.PlayerModel
array if auto-typing took place,
null
otherwise. Convenience to access the assoc's players after retyping.
Element 0 is the player of "topicTypeUri1", Element 1 is the player of "topicTypeUri2".public static PlayerModel[] getPlayerModels(AssocModel assoc, String topicTypeUri1, String topicTypeUri2)
Copyright © 2023. All Rights Reserved.