Class SubjectAreaHandler

    • Constructor Detail

      • SubjectAreaHandler

        public SubjectAreaHandler​(OMRSAPIHelper oMRSAPIHelper,
                                  int maxPageSize)
        Construct the Subject Area Project Handler needed to operate within a single server instance.
        Parameters:
        oMRSAPIHelper - omrs API helper
        maxPageSize - maximum page size
    • Method Detail

      • getMaxPageSize

        public int getMaxPageSize()
      • sanitiseFindRequest

        protected String sanitiseFindRequest​(String searchCriteria,
                                             boolean exactValue,
                                             boolean ignoreCase)
      • sanitiseFindRequest

        protected FindRequest sanitiseFindRequest​(FindRequest findRequest,
                                                  boolean exactValue,
                                                  boolean ignoreCase)
        Take a FindRequest and sanitise it. The FindRequest from the user could contain a regex expression which would cause the regex engine to loop. to avoid this, we turn what the user has given us into a literal and then use the exactValue and ignoreCase flags to add to the regular expression in a controlled way.
        Parameters:
        findRequest - supplied find request - that contains the search criteria
        exactValue - flag indicating that exact value mathcing should be done
        ignoreCase - flag indicating that case should be ignored
        Returns:
        sanitised find request
      • getRelatedNodesForEnd1

        public <T extends NodeSubjectAreaOMASAPIResponse<T> getRelatedNodesForEnd1​(String methodName,
                                                                                     String userId,
                                                                                     String guid,
                                                                                     String relationshipTypeName,
                                                                                     Class<? extends INodeMapper<T>> mapperClass,
                                                                                     Integer startingFrom,
                                                                                     Integer pageSize)
        Get the related nodes from end 1 of a given type of relationship
        Parameters:
        methodName - name of the method being called.
        userId - unique identifier for requesting user, under which the request is performed
        guid - guid
        relationshipTypeName - relationship type name
        mapperClass - mapper class used to get the type name of the Node to return
        startingFrom - retrieve items starting from this location
        pageSize - maximum size of the returned items
        Returns:
        response containing the the related Nodes if there are any
      • getRelatedNodesForEnd2

        public <T extends NodeSubjectAreaOMASAPIResponse<T> getRelatedNodesForEnd2​(String methodName,
                                                                                     String userId,
                                                                                     String guid,
                                                                                     String relationshipTypeName,
                                                                                     Class<? extends INodeMapper<T>> mapperClass,
                                                                                     Integer startingFrom,
                                                                                     Integer pageSize)
        Get the related nodes from end 2 of a given type of relationship
        Parameters:
        methodName - name of the method being called.
        userId - unique identifier for requesting user, under which the request is performed
        guid - guid
        relationshipTypeName - relationship type name
        mapperClass - mapper class used to get the type name of the Node to return
        startingFrom - retrieve items starting from this location
        pageSize - maximum size of the returned items
        Returns:
        response containing the the related Nodes if there are any
      • getAllRelationshipsForEntity

        public SubjectAreaOMASAPIResponse<Relationship> getAllRelationshipsForEntity​(String methodName,
                                                                                     String userId,
                                                                                     String guid,
                                                                                     FindRequest findRequest)
        Get All relationships for Node
        Parameters:
        methodName - name of the method being called.
        userId - unique identifier for requesting user, under which the request is performed
        guid - guid
        findRequest - FindRequest
        Returns:
        the relationships associated with the requested guid
      • setUniqueQualifiedNameIfBlank

        protected void setUniqueQualifiedNameIfBlank​(Node node)
        Set unique qualifiedName into the supplied Node. The qualified name needs to be unique and is supplied on an addnEtity omrs call. Prior to the add, we do not know the guid of the entity. We do not want to add an entity, then immediately update it; as these changes to entity identity would be propagated across the cohort. So we set the qualified name by concatinating the supplied seed, an @ symbol and a newly generated UUID. The assumption is that this method is supplied a node that contains a name.
        Parameters:
        node - Node to set the unique qualified name into
      • categoryMatchSearchCriteria

        protected boolean categoryMatchSearchCriteria​(Category category,
                                                      String searchCriteria,
                                                      boolean exactValue,
                                                      boolean ignoreCase)
        return whether the Category matches the search criteria
        Parameters:
        category - category to use for match
        searchCriteria - criteria to use for match
        Returns:
        boolean indicating whether the category matches the search criteria
      • termMatchSearchCriteria

        protected boolean termMatchSearchCriteria​(Term term,
                                                  String searchCriteria,
                                                  boolean exactValue,
                                                  boolean ignoreCase)
        return whether the Term matches the search criteria
        Parameters:
        term - term to use for match
        searchCriteria - criteria to use for match
        exactValue - a boolean, which when set means that only exact matches will be returned, otherwise matches that start with the search criteria will be returned.
        ignoreCase - a boolean, which when set means that case will be ignored, if not set that case will be respected
        Returns:
        boolean indicating whether the term matches the search criteria
      • checkReadOnly

        protected void checkReadOnly​(String methodName,
                                     Node node,
                                     String operation)
                              throws PropertyServerException
        Check whether the node is readonly and throw and exception if it is
        Parameters:
        methodName - calling methodName
        node - node to check
        operation - operation being attempted
        Throws:
        PropertyServerException - exception thrown when the node is readonly
      • checkRelationshipReadOnly

        protected void checkRelationshipReadOnly​(String methodName,
                                                 Relationship relationship,
                                                 String operation)
                                          throws PropertyServerException
        Check whether the relationship is readonly and throw and exception if it is
        Parameters:
        methodName - calling methodName
        relationship - relationship to check
        operation - operation being attempted
        Throws:
        PropertyServerException - exception thrown when the relationship is readonly