Class DMXUtils


  • public class DMXUtils
    extends Object
    • Constructor Detail

      • DMXUtils

        public DMXUtils()
    • Method Detail

      • isDMXURL

        public static boolean isDMXURL​(URL url)
        Checks if an URL refers to this DMX installation. The check relies on the "dmx.host.url" system property.
      • loadChildTopics

        public static <T extends DMXObjectList<T> loadChildTopics​(List<T> objects)
      • toMap

        public static Map toMap​(org.codehaus.jettison.json.JSONObject o)
      • toMap

        public static Map toMap​(org.codehaus.jettison.json.JSONObject o,
                                Map map)
      • toList

        public static List toList​(org.codehaus.jettison.json.JSONArray o)
      • toJSONArray

        public static org.codehaus.jettison.json.JSONArray toJSONArray​(Iterable<? extends JSONEnabled> items)
      • getParentTopics

        public static List<Topic> getParentTopics​(Topic topic)
        Finds all parent topics of the given topic by traversing along the child->parent relationship. Only the leaves are returned.

        If the given topic has no parent topics the returned list contains only the given topic.

      • assocAutoTyping

        public 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. The given assoc model is modified in-place. Typically called from a plugin's 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).

        Parameters:
        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.
        Returns:
        a 2-element 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".
      • getConfigDir

        public static String getConfigDir()
        Returns the DMX platform's configuration directory. This is the directory where DMX's config.properties file resides. The path to this file is configurable by the felix.system.properties system property when the platform is launched.

        Plugins can use the configuration directory for storing external plugin-specific resource files. By convention inside that directory there are per-plugin sub directories, named according to the respective plugin's repository name. These directories are created by the administrator.

        So a plugin typically accesses its resource files by e.g.:

        DMXUtils.getConfigDir() + "dmx-linqa/" + fileName

        Returns:
        the DMX platform's configuration directory as derived from the felix.system.properties system property (as configured by administrator), ending with "/". If that system property is not set an empty string is returned, functioning as "current directory". This is the case in particular in development mode, when DMX platform is run via Maven (via Pax Runner). While development create the per-plugin configuration directory inside Pax Runner's `runner` directory, e.g.:
        
                  dmx-platform/
                      runner/
                          dmx-linqa/
                              custom.css