Enum CoreUtils

    • Enum Constant Detail

      • INSTANCE

        public static final CoreUtils INSTANCE
        Singleton.
    • Method Detail

      • values

        public static CoreUtils[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (CoreUtils c : CoreUtils.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static CoreUtils valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • getInstance

        public static CoreUtils getInstance()
        Provides a default instance using fake DAO, Search and Cache implementations.
        Returns:
        an instance of this class
      • getDao

        public abstract DAO getDao()
        Returns the DAO object.
        Returns:
        a DAO object
      • setDao

        public abstract void setDao​(DAO dao)
        Sets the DAO object.
        Parameters:
        dao - DAO
      • getSearch

        public abstract Search getSearch()
        Returns the Search object.
        Returns:
        Search object
      • setSearch

        public abstract void setSearch​(Search search)
        Sets the Search object.
        Parameters:
        search - Search
      • getCache

        public abstract Cache getCache()
        Returns the Cache object.
        Returns:
        Cache object
      • setCache

        public abstract void setCache​(Cache cache)
        Sets the Cache object.
        Parameters:
        cache - Cache
      • getQueue

        public abstract Queue getQueue()
        Returns the Queue object.
        Returns:
        Queue object
      • setQueue

        public abstract void setQueue​(Queue queue)
        Sets the Queue object.
        Parameters:
        queue - Queue
      • getFileStore

        public abstract FileStore getFileStore()
        Returns the FileStore object.
        Returns:
        FileStore object
      • setFileStore

        public abstract void setFileStore​(FileStore fileStore)
        Sets the FileStore object.
        Parameters:
        fileStore - FileStore
      • addTags

        public abstract List<String> addTags​(List<String> objectTags,
                                             String... tag)
        Adds any number of tags to the set of tags.
        Parameters:
        tag - a tag, must not be null or empty
        objectTags - the object tags
        Returns:
        a new list of tags
      • removeTags

        public abstract List<String> removeTags​(List<String> objectTags,
                                                String... tag)
        Removes a tag from the set of tags.
        Parameters:
        tag - a tag, must not be null or empty
        objectTags - the object
        Returns:
        a new list of tags
      • countChildren

        public abstract Long countChildren​(ParaObject obj,
                                           String type2)
        Count the total number of child objects for this object.
        Parameters:
        type2 - the type of the other object
        obj - the object to execute this method on
        Returns:
        the number of links
      • countLinks

        public abstract Long countLinks​(ParaObject obj,
                                        String type2)
        Count the total number of links between this object and another type of object.
        Parameters:
        type2 - the other type of object
        obj - the object to execute this method on
        Returns:
        the number of links for the given object
      • deleteChildren

        public abstract void deleteChildren​(ParaObject obj,
                                            String type2)
        Deletes all child objects permanently.
        Parameters:
        obj - the object to execute this method on
        type2 - the children's type.
      • findChildren

        public abstract <P extends ParaObjectList<P> findChildren​(ParaObject obj,
                                                                    String type2,
                                                                    String query,
                                                                    Pager... pager)
        Searches through child objects in a one-to-many relationship.
        Type Parameters:
        P - the type of children
        Parameters:
        type2 - the type of children to look for
        obj - the object to execute this method on
        query - a query string
        pager - a Pager
        Returns:
        a list of ParaObject in a one-to-many relationship with this object
      • findLinkedObjects

        public abstract <P extends ParaObjectList<P> findLinkedObjects​(ParaObject obj,
                                                                         String type2,
                                                                         String field,
                                                                         String query,
                                                                         Pager... pager)
        Searches through all linked objects in many-to-many relationships.
        Type Parameters:
        P - type of linked objects
        Parameters:
        type2 - type of linked objects to search for
        obj - the object to execute this method on
        pager - a Pager
        field - the name of the field to target (within a nested field "nstd")
        query - a query string
        Returns:
        a list of linked objects matching the search query
      • getChildren

        public abstract <P extends ParaObjectList<P> getChildren​(ParaObject obj,
                                                                   String type2,
                                                                   Pager... pager)
        Returns all child objects linked to this object.
        Type Parameters:
        P - the type of children
        Parameters:
        type2 - the type of children to look for
        obj - the object to execute this method on
        pager - a Pager
        Returns:
        a list of ParaObject in a one-to-many relationship with this object
      • getChildren

        public abstract <P extends ParaObjectList<P> getChildren​(ParaObject obj,
                                                                   String type2,
                                                                   String field,
                                                                   String term,
                                                                   Pager... pager)
        Returns all child objects linked to this object.
        Type Parameters:
        P - the type of children
        Parameters:
        type2 - the type of children to look for
        field - the field name to use as filter
        term - the field value to use as filter
        obj - the object to execute this method on
        pager - a Pager
        Returns:
        a list of ParaObject in a one-to-many relationship with this object
      • getCreator

        public abstract <P extends ParaObject> P getCreator​(ParaObject obj)
        The user object of the creator.
        Type Parameters:
        P - type of linked objects
        Parameters:
        obj - find the creator of this object
        Returns:
        the user who created this or null if obj.getCreatorid() is null
        See Also:
        User
      • getLinkedObjects

        public abstract <P extends ParaObjectList<P> getLinkedObjects​(ParaObject obj,
                                                                        String type2,
                                                                        Pager... pager)
        Returns all objects linked to the given one. Only applicable to many-to-many relationships.
        Type Parameters:
        P - type of linked objects
        Parameters:
        type2 - type of linked objects to search for
        obj - the object to execute this method on
        pager - a Pager
        Returns:
        a list of linked objects
      • getLinks

        public abstract List<Linker> getLinks​(ParaObject obj,
                                              String type2,
                                              Pager... pager)
        Returns a list of all Linker objects for a given object.
        Parameters:
        obj - the object to execute this method on
        type2 - the other type
        pager - a Pager
        Returns:
        a list of Linker objects
      • getName

        public abstract String getName​(String name,
                                       String id)
        Returns the default name property of an object.
        Parameters:
        name - a name
        id - an id
        Returns:
        a combination of name and id, unless this.name is set
      • getObjectURI

        public abstract String getObjectURI​(ParaObject obj)
        Returns the relative path to the object, e.g. /user/1234
        Parameters:
        obj - an object
        Returns:
        a relative path
      • getParent

        public abstract <P extends ParaObject> P getParent​(ParaObject obj)
        The parent object.
        Type Parameters:
        P - type of linked objects
        Parameters:
        obj - find the parent of this object
        Returns:
        the parent or null if obj.getParentid() is null
      • isLinked

        public abstract boolean isLinked​(ParaObject obj,
                                         String type2,
                                         String id2)
        Checks if this object is linked to another.
        Parameters:
        type2 - the other type
        id2 - the other id
        obj - the object to execute this method on
        Returns:
        true if the two are linked
      • isLinked

        public abstract boolean isLinked​(ParaObject obj,
                                         ParaObject toObj)
        Checks if a given object is linked to this one.
        Parameters:
        toObj - the other object
        obj - the object to execute this method on
        Returns:
        true if linked
      • link

        public abstract String link​(ParaObject obj,
                                    String id2)
        Links two objects in a many-to-many relationship. Only a link is created. Objects are left untouched. The type of the second object is automatically determined on read.
        Parameters:
        id2 - link to the object with this id
        obj - the object to execute this method on
        Returns:
        the id of the Linker object that is created
      • link

        public abstract String link​(ParaObject obj,
                                    String id2,
                                    String metadata)
        Links two objects in a many-to-many relationship. Only a link is created. Objects are left untouched. The type of the second object is automatically determined on read.
        Parameters:
        id2 - link to the object with this id
        obj - the object to execute this method on
        metadata - some string of metadata to be attached to the link object
        Returns:
        the id of the Linker object that is created
      • unlink

        public abstract void unlink​(ParaObject obj,
                                    String type2,
                                    String id2)
        Unlinks an object from this one. Only a link is deleted. Objects are left untouched.
        Parameters:
        type2 - the other type
        obj - the object to execute this method on
        id2 - the other id
      • unlinkAll

        public abstract void unlinkAll​(ParaObject obj)
        Unlinks all objects that are linked to this one. Deletes all Linker objects. Only the links are deleted. Objects are left untouched.
        Parameters:
        obj - the object to execute this method on
      • vote

        public abstract boolean vote​(ParaObject votable,
                                     String userid,
                                     Votable.VoteValue upDown)
        Casts a vote on a given object.
        Parameters:
        votable - the object to vote on
        userid - the voter
        upDown - up or down
        Returns:
        true if the vote was successful
      • vote

        public abstract boolean vote​(ParaObject votable,
                                     String userid,
                                     Votable.VoteValue upDown,
                                     Integer expiresAfter,
                                     Integer lockedAfter)
        Casts a vote on a given object.
        Parameters:
        votable - the object to vote on
        userid - the voter
        upDown - up or down
        expiresAfter - expires after seconds
        lockedAfter - locked after seconds
        Returns:
        true if the vote was successful