Class SubjectAreaHandler
- java.lang.Object
-
- org.odpi.openmetadata.accessservices.subjectarea.handlers.SubjectAreaHandler
-
- Direct Known Subclasses:
SubjectAreaCategoryHandler,SubjectAreaConfigHandler,SubjectAreaGlossaryHandler,SubjectAreaGraphHandler,SubjectAreaProjectHandler,SubjectAreaRelationshipHandler,SubjectAreaTermHandler
public abstract class SubjectAreaHandler extends Object
SubjectAreaProjectHandler manages Project objects from the property server. It runs server-side in the subject Area OMAS and retrieves entities and relationships through the OMRSRepositoryConnector.
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringCATEGORY_ANCHOR_RELATIONSHIP_NAMEprotected static StringCATEGORY_HIERARCHY_LINK_RELATIONSHIP_NAMEprotected static StringCATEGORY_TYPE_NAMEprotected static StringGLOSSARY_TYPE_NAMEprotected InvalidParameterHandlerinvalidParameterHandlerprotected MappersFactorymappersFactoryprotected intmaxPageSizeprotected OMRSAPIHelperoMRSAPIHelperprotected static StringPROJECT_SCOPE_RELATIONSHIP_NAMEprotected static StringPROJECT_TYPE_NAMEprotected static StringTERM_ANCHOR_RELATIONSHIP_NAMEprotected static StringTERM_CATEGORIZATION_RELATIONSHIP_NAMEprotected static StringTERM_TYPE_NAME
-
Constructor Summary
Constructors Constructor Description SubjectAreaHandler(OMRSAPIHelper oMRSAPIHelper, int maxPageSize)Construct the Subject Area Project Handler needed to operate within a single server instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancategoryMatchSearchCriteria(Category category, String searchCriteria, boolean exactValue, boolean ignoreCase)return whether the Category matches the search criteriaprotected voidcheckReadOnly(String methodName, Node node, String operation)Check whether the node is readonly and throw and exception if it isprotected voidcheckRelationshipReadOnly(String methodName, Relationship relationship, String operation)Check whether the relationship is readonly and throw and exception if it is<R extends InstanceHeader,T extends OmasObject>
List<T>convertOmrsToOmas(Collection<R> list, Class<? extends Mapper> mapperInterface)protected <T extends Node>
List<T>findNodes(String userId, String typeEntityName, FindRequest findRequest, boolean exactValue, boolean ignoreCase, Class<? extends INodeMapper<T>> mapperClass, String methodName)List<Relationship>getAllRelationshipForEntity(String restAPIName, String userId, String entityGuid, FindRequest findRequest)Get the relationships keyed off an entity guid.SubjectAreaOMASAPIResponse<Relationship>getAllRelationshipsForEntity(String methodName, String userId, String guid, FindRequest findRequest)Get All relationships for NodeintgetMaxPageSize()List<Node>getNodesFromEntityDetails(Collection<EntityDetail> entityDetails)<T extends Node>
SubjectAreaOMASAPIResponse<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<T extends Node>
SubjectAreaOMASAPIResponse<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 relationshipList<Relationship>getRelationshipsFromRelationships(Collection<Relationship> relationships)protected StringsanitiseFindRequest(String searchCriteria, boolean exactValue, boolean ignoreCase)protected FindRequestsanitiseFindRequest(FindRequest findRequest, boolean exactValue, boolean ignoreCase)Take a FindRequest and sanitise it.protected voidsetUniqueQualifiedNameIfBlank(Node node)Set unique qualifiedName into the supplied Node.protected booleantermMatchSearchCriteria(Term term, String searchCriteria, boolean exactValue, boolean ignoreCase)return whether the Term matches the search criteriaprotected StringvalidateGlossarySummaryDuringCreation(String userId, String methodName, GlossarySummary suppliedGlossary)This method validated for creation.
-
-
-
Field Detail
-
GLOSSARY_TYPE_NAME
protected static final String GLOSSARY_TYPE_NAME
- See Also:
- Constant Field Values
-
CATEGORY_TYPE_NAME
protected static final String CATEGORY_TYPE_NAME
- See Also:
- Constant Field Values
-
TERM_TYPE_NAME
protected static final String TERM_TYPE_NAME
- See Also:
- Constant Field Values
-
PROJECT_TYPE_NAME
protected static final String PROJECT_TYPE_NAME
- See Also:
- Constant Field Values
-
TERM_ANCHOR_RELATIONSHIP_NAME
protected static final String TERM_ANCHOR_RELATIONSHIP_NAME
- See Also:
- Constant Field Values
-
TERM_CATEGORIZATION_RELATIONSHIP_NAME
protected static final String TERM_CATEGORIZATION_RELATIONSHIP_NAME
- See Also:
- Constant Field Values
-
PROJECT_SCOPE_RELATIONSHIP_NAME
protected static final String PROJECT_SCOPE_RELATIONSHIP_NAME
- See Also:
- Constant Field Values
-
CATEGORY_ANCHOR_RELATIONSHIP_NAME
protected static final String CATEGORY_ANCHOR_RELATIONSHIP_NAME
- See Also:
- Constant Field Values
-
CATEGORY_HIERARCHY_LINK_RELATIONSHIP_NAME
protected static final String CATEGORY_HIERARCHY_LINK_RELATIONSHIP_NAME
- See Also:
- Constant Field Values
-
mappersFactory
protected final MappersFactory mappersFactory
-
oMRSAPIHelper
protected final OMRSAPIHelper oMRSAPIHelper
-
maxPageSize
protected final int maxPageSize
-
invalidParameterHandler
protected InvalidParameterHandler invalidParameterHandler
-
-
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 helpermaxPageSize- 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 criteriaexactValue- flag indicating that exact value mathcing should be doneignoreCase- flag indicating that case should be ignored- Returns:
- sanitised find request
-
findNodes
protected <T extends Node> List<T> findNodes(String userId, String typeEntityName, FindRequest findRequest, boolean exactValue, boolean ignoreCase, Class<? extends INodeMapper<T>> mapperClass, String methodName) throws SubjectAreaCheckedException, PropertyServerException, UserNotAuthorizedException, InvalidParameterException
-
getRelatedNodesForEnd1
public <T extends Node> SubjectAreaOMASAPIResponse<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 performedguid- guidrelationshipTypeName- relationship type namemapperClass- mapper class used to get the type name of the Node to returnstartingFrom- retrieve items starting from this locationpageSize- maximum size of the returned items- Returns:
- response containing the the related Nodes if there are any
-
getRelatedNodesForEnd2
public <T extends Node> SubjectAreaOMASAPIResponse<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 performedguid- guidrelationshipTypeName- relationship type namemapperClass- mapper class used to get the type name of the Node to returnstartingFrom- retrieve items starting from this locationpageSize- 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 performedguid- guidfindRequest-FindRequest- Returns:
- the relationships associated with the requested guid
-
getAllRelationshipForEntity
public List<Relationship> getAllRelationshipForEntity(String restAPIName, String userId, String entityGuid, FindRequest findRequest) throws SubjectAreaCheckedException, PropertyServerException, UserNotAuthorizedException, InvalidParameterException
Get the relationships keyed off an entity guid.- Parameters:
restAPIName- rest API nameuserId- user identityentityGuid- globally unique identifierfindRequest-FindRequest- Returns:
List<Relationship>- Throws:
PropertyServerException- something went wrong with the REST call stack.UserNotAuthorizedException- the requesting user is not authorized to issue this request.SubjectAreaCheckedException- standard exception Subject Area OMAS servicesInvalidParameterException
-
getRelationshipsFromRelationships
public List<Relationship> getRelationshipsFromRelationships(Collection<Relationship> relationships)
-
getNodesFromEntityDetails
public List<Node> getNodesFromEntityDetails(Collection<EntityDetail> entityDetails)
-
convertOmrsToOmas
public <R extends InstanceHeader,T extends OmasObject> List<T> convertOmrsToOmas(Collection<R> list, Class<? extends Mapper> mapperInterface)
-
validateGlossarySummaryDuringCreation
protected String validateGlossarySummaryDuringCreation(String userId, String methodName, GlossarySummary suppliedGlossary) throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException, SubjectAreaCheckedException
This method validated for creation.- Parameters:
userId- userId under which the request is performedmethodName- method making the callsuppliedGlossary- glossary to validate against.- Returns:
- SubjectAreaOMASAPIResponse this response is of type ResponseCategory.Category.Glossary if successful, otherwise there is an error response.
- Throws:
PropertyServerException- something went wrong with the REST call stack.UserNotAuthorizedException- the requesting user is not authorized to issue this request.InvalidParameterException- one of the parameters is null or invalidSubjectAreaCheckedException- standard exception Subject Area OMAS services
-
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 matchsearchCriteria- 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 matchsearchCriteria- criteria to use for matchexactValue- 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 methodNamenode- node to checkoperation- 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 methodNamerelationship- relationship to checkoperation- operation being attempted- Throws:
PropertyServerException- exception thrown when the relationship is readonly
-
-