Package mc.core.domain.base.aspect
Class AspectRelation<T extends ComplexEntity>
java.lang.Object
mc.core.system.base.BaseBean
mc.core.domain.base.dobj.AbstractAspect<T>
mc.core.domain.base.aspect.AspectRelation<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(T entity, List<T> relatedList, RelationType relationType) creates for each entity from relatedList a new relation for given entity and relationType if such a relation does not already exist.add(T entity, T related, RelationType relationType) creates a new relation for given entity, related entity and relationType if such a relation does not already exist.booleancheckDeleteOnlyByForce(T entity) checks if this entity has master-slave-relations where it is the slave.voiddeleteRelation(EntityToEntity entToEnt) getAll(T source, List<RelationType> relationTypes, boolean includeSlaveToMaster) getAttributeProfile(EntityToEntity entityToEntity) get attribute profile for e2e.getAttributeProfile(EntityToEntity entityToEntity, boolean createProfileType) get attribute profile for e2e.getRelatedEntities(List<T> entities, List<RelationType> relationTypes, boolean includeSlaveToMaster) Build map of related entitiesgetRelatedEntities(List<T> entities, RelationType relationType, boolean includeSlaveToMaster) Searches for ComplexEntities that are in a Relation of one of the given RelationTypes with given ComplexEntity.Map<RelationType,List<T>> getRelatedEntities(T entity, List<RelationType> relationTypes, boolean includeSlaveToMaster) Searches for ComplexEntities that are in a Relation of one of the given RelationTypes with given ComplexEntity.getRelatedEntities(T entity, RelationType relationType) Searches for ComplexEntities that are in a Relation of given RelationType with given ComplexEntity.getRelatedEntities(T entity, RelationType relationType, boolean includeSlaveToMaster) Searches for ComplexEntities that are in a Relation of given RelationType with given ComplexEntity.getRelations(List<T> entities, List<RelationType> relationTypes) get all relations for given entities (including slaveToMaster)getRelations(T entity, List<RelationType> relationTypes, boolean includeSlaveToMaster) get relations in form ofEntityToEntityobjects for the nodes of relationTypes (if given) and with snapshot flag.getRelations(T entity, RelationType relationType, boolean includeSlaveToMaster) getRelationTypes(ComplexTypeEntity typeEntity) Returns list with relationTypes where given typeEntity is either defined as master or the RolationType is EQUAL and given typeEntity is either entity1 or in entities2.getRelationTypes(ComplexTypeEntity typeEntity, boolean includeSlaveToMaster) Returns list with relationTypes where given typeEntity is either entity1 or in entities2 (includeSlaveToMaster == true)
or (includeSlaveToMaster == false)
where given typeEntity is either defined as master or the relationType is EQUAL and given typeEntity is either entity1 or in entities2intgetTargetRelationsCount(T entity, RelationType relationTypes) voidorderChange(T entity, T relatedEntity, RelationType relationType, boolean decreaseOrder) voidorderSetForList(T entity, Map<EntityToEntity, Integer> prioMap) set prio of EntityToEntity for list of all Relations of this ComplexEntity according to given map.voidrelationRemove(SystemRelationType systemRelationType) voidrelationRemoveAll(SystemRelationType systemRelationType) relationSet(SystemRelationType systemRelationType, T source, T related, int prio) voidremove(T entity, RelationType relationType, T relatedObject) removes relationship of given type between entity and relatedEntity.systemGetAll(SystemRelationType systemRelationType, T source, boolean includeSlaveToMaster)
-
Constructor Details
-
AspectRelation
public AspectRelation()
-
-
Method Details
-
getRelatedEntities
Searches for ComplexEntities that are in a Relation of given RelationType with given ComplexEntity. If RelationType is MASTER_SLAVE returns the entities2 of Relation, for EQUAL-RelationType returns all ComplexEntities except the given. A Relation is stored as EntityToEntity. WARNING: this method assumes that related entity is of same objectClass as given entity!- Parameters:
entity- ComplexEntity, mandatoryrelationType- optional, default is to return all relations- Returns:
- List of ComplexEntity of the same class as given ComplexEntity, if none found return empty list.
-
getRelatedEntities
public List<T> getRelatedEntities(T entity, RelationType relationType, boolean includeSlaveToMaster) Searches for ComplexEntities that are in a Relation of given RelationType with given ComplexEntity. If RelationType is MASTER_SLAVE returns the entities2 of Relation, for EQUAL-RelationType returns all ComplexEntities except the given. A Relation is stored as EntityToEntity.- Parameters:
entity- ComplexEntity, mandatoryrelationType- optional, default is to return all relationsincludeSlaveToMaster- boolean: iftruealso returns the master of MASTER_SLAVE Relations where given ComplexEntity is the slave- Returns:
- List of related ComplexEntity of the same class as given ComplexEntity, if none found return empty List.
-
getRelatedEntities
public Map<RelationType,List<T>> getRelatedEntities(T entity, List<RelationType> relationTypes, boolean includeSlaveToMaster) Searches for ComplexEntities that are in a Relation of one of the given RelationTypes with given ComplexEntity. If RelationType is MASTER_SLAVE returns the entities2 of Relation, for EQUAL-RelationType returns all ComplexEntities except the given. A Relation is stored as EntityToEntity.- Parameters:
entity- ComplexEntity, mandatoryrelationTypes- list of RelationType, mandatory, can be emptyincludeSlaveToMaster- boolean: iftruealso returns the master of MASTER_SLAVE Relations where given ComplexEntity is the slave. in Relations with DependencyType MASTER_SLAVE per default a slave does not see its master. Set this flag to true if also master of slave should be returned. WARNING: this method assumes that related entity is of same objectClass as given entity!- Returns:
- Map with List of related ComplexEntity mapped by RelationType
-
getRelatedEntities
public Map<T,List<T>> getRelatedEntities(List<T> entities, RelationType relationType, boolean includeSlaveToMaster) Searches for ComplexEntities that are in a Relation of one of the given RelationTypes with given ComplexEntity. If RelationType is MASTER_SLAVE returns the entities2 of Relation, for EQUAL-RelationType returns all ComplexEntities except the given. A Relation is stored as EntityToEntity.- Parameters:
entities- list of ComplexEntity, mandatory. If empty returns empty map.relationType- RelationType, mandatoryincludeSlaveToMaster- boolean: iftruealso returns the master of MASTER_SLAVE Relations where given ComplexEntity is the slave. in Relations with DependencyType MASTER_SLAVE per default a slave does not see its master. Set this flag to true if also master of slave should be returned. WARNING: this method assumes that related entity is of same objectClass as given entity!- Returns:
- Map with List of related ComplexEntity mapped to the original objects. If an object has no relations it will not be in the map.
-
getRelatedEntities
public Map<RelationType,Map<T, getRelatedEntitiesList<T>>> (List<T> entities, List<RelationType> relationTypes, boolean includeSlaveToMaster) Build map of related entities- Parameters:
entities-relationTypes-includeSlaveToMaster-- Returns:
- Map on relation type of mapped related objects on given entities
-
getRelations
public List<EntityToEntity> getRelations(T entity, RelationType relationType, boolean includeSlaveToMaster) -
getRelations
public List<EntityToEntity> getRelations(T entity, List<RelationType> relationTypes, boolean includeSlaveToMaster) get relations in form ofEntityToEntityobjects for the nodes of relationTypes (if given) and with snapshot flag. include slaveToMaster relations for slaveToMaster relationType if flag is true. if relationTypes is null or empty, get relations of all types.method is primarily used in channels. NOTE: grouping the result for entities and filtering for MASTER-SLAVE (includeSlaveToMaster) must be done in calling code.
- Parameters:
entity- mandatoryrelationTypes- optional- Returns:
-
getRelations
get all relations for given entities (including slaveToMaster)- Parameters:
entities- mandatoryrelationTypes- optional- Returns:
-
getRelationTypes
Returns list with relationTypes where given typeEntity is either defined as master or the RolationType is EQUAL and given typeEntity is either entity1 or in entities2.- Parameters:
typeEntity- mandatory- Returns:
- List of RelationType or empty list if no such RelationType exist
-
getRelationTypes
public List<RelationType> getRelationTypes(ComplexTypeEntity typeEntity, boolean includeSlaveToMaster) Returns list with relationTypes where given typeEntity is either entity1 or in entities2 (includeSlaveToMaster == true)
or (includeSlaveToMaster == false)
where given typeEntity is either defined as master or the relationType is EQUAL and given typeEntity is either entity1 or in entities2- Parameters:
typeEntity- mandatory- Returns:
- List of RelationType or empty list if no such RelationType exist
-
remove
public void remove(T entity, RelationType relationType, T relatedObject) throws ApplicationException removes relationship of given type between entity and relatedEntity. If relatedEntity is null removes all relationship of given type from entity.
If relation is a master-relation entity is treated as master (entity1), if it is bidirectional any relation of given type involving entity and, if given, relatedEntity will be removed. It is assumed that in a bidirectional relation no relations of entity to itself exist, otherwise they will be removed, too.- Parameters:
entity- mandatory, object from which relations of given type should be removedrelationType- mandatoryrelatedObject- optional, if given, only removes relations to this object, otherwise all of given type- Throws:
ApplicationException
-
deleteRelation
- Throws:
ApplicationException
-
checkDeleteOnlyByForce
checks if this entity has master-slave-relations where it is the slave.- Parameters:
entity- mandatory, must be attached- Throws:
ApplicationException
-
relationSet
public RelationValue<T> relationSet(SystemRelationType systemRelationType, T source, T related, int prio) throws ApplicationException - Throws:
ApplicationException
-
systemGetAll
public RelationValues<T> systemGetAll(SystemRelationType systemRelationType, T source, boolean includeSlaveToMaster) throws ApplicationException - Throws:
ApplicationException
-
getAll
public RelationValues<T> getAll(T source, List<RelationType> relationTypes, boolean includeSlaveToMaster) -
relationRemove
- Throws:
ApplicationException
-
relationRemoveAll
- Throws:
ApplicationException
-
add
public RelationValue<T> add(T entity, T related, RelationType relationType) throws ApplicationException creates a new relation for given entity, related entity and relationType if such a relation does not already exist. Add the new relation at the end of list of related objects of this relationType. for relation exist rules seeadd(ComplexEntity, List, RelationType)- Parameters:
entity- mandatoryrelated- mandatoryrelationType- mandatory- Returns:
- relation value for inserted or existing relation
- Throws:
ApplicationException
-
add
public RelationValues<T> add(T entity, List<T> relatedList, RelationType relationType) throws ApplicationException creates for each entity from relatedList a new relation for given entity and relationType if such a relation does not already exist. Adds the new relations at the end of list of related objects of this relationType.relation exists if relationType is
RelationType.RelationDependency.EQUALand complexEntity/related are either entity1 or entity2, or relationType isRelationType.RelationDependency.MASTER_SLAVEand complexEntity is entity1 and related is entity2. In other words: for EQUAL relationTypes there can only be one relation link between to entities, for MASTER_SLAVE there can be two in reverse directions- Parameters:
entity- mandatoryrelatedList- mandatory, if empty returns empty RelationValuesrelationType- mandatory- Returns:
- relation values for inserted or existing relations
- Throws:
ApplicationException
-
getTargetRelationsCount
-
orderChange
public void orderChange(T entity, T relatedEntity, RelationType relationType, boolean decreaseOrder) throws UserException - Parameters:
entity- mandatoryrelatedEntity- mandatoryrelationType- mandatorydecreaseOrder-- Throws:
UserException
-
orderSetForList
set prio of EntityToEntity for list of all Relations of this ComplexEntity according to given map.- Type Parameters:
T-- Parameters:
entity- the entity for which the list of relations is to be ordered. Can be entity1 or entity2 of relationprioMap- mandatory, key EntityToEntity as key, the prio to set as value- Throws:
UserException
-
getAttributeProfile
get attribute profile for e2e. create if type exists. else return null- Throws:
ApplicationException
-
getAttributeProfile
public EntityProfile getAttributeProfile(EntityToEntity entityToEntity, boolean createProfileType) throws ApplicationException get attribute profile for e2e. create if type exists or createProfileType=true. else return null- Throws:
ApplicationException
-