Interface ModelChangeOperations
-
public interface ModelChangeOperations
TheModelChangeOperations
provide methods to alter the OrgModel (add and delete attributes), add/delete entities, change their attributes and add/delete relations between entities.IDs of created entities must start with 1! IDs <= 0 are reserved for special (e.g. system-internal) purposes.
- Author:
- Patrick Schmidt
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addAttribute(SessionToken session, EntityType entType, String attrName, DataType dataType)
Adds a new attribute with the given data type to the given entity type.void
addAttribute(SessionToken session, EntityType entType, String attrName, DataType dataType, int sizeHint)
Adds a new attribute with the given data type to the given entity type.void
addAttribute(SessionToken session, EntityType entType, String attrName, DataType dataType, int sizeHint, String omExtension, String mappedTo, boolean isImported, boolean isReadOnly)
Adds a new attribute with the given data type to the given entity type which is being mapped from the designated org model extension.void
addAttribute(SessionToken session, EntityType entType, String attrName, DataType dataType, String omExtension, String mappedTo, boolean isImported, boolean isReadOnly)
Adds a new attribute with the given data type to the given entity type which is being mapped from the designated org model extension.void
addRelation(SessionToken session, RelationType relType, long id1, long id2)
This method adds a relation of the given type between the two entities identified by the given IDs.long
createAgent(SessionToken session, String agentUserName, String password)
Adds a new Agent with the given (unique!)long
createEntity(SessionToken session, Entity entity)
Creates a new entity with the type and attribute values provided in the givenEntity
object and returns the assigned ID.void
deleteAttribute(SessionToken session, EntityType entType, String attrName)
This method removes an attribute from an entity type.void
deleteEntity(SessionToken session, EntityType entType, long id)
This method deletes the entity with the given ID of the given type.void
deleteEntity(SessionToken session, EntityType entType, long id, boolean recursive)
This method deletes the entity with the given ID of the given type and all its relations.void
deleteRelation(SessionToken session, RelationType relType, long id1, long id2)
This method deletes a relation of the given type between the two entities identified by the given IDs.void
modifyAttribute(SessionToken session, EntityType entType, String attrName, String mappedTo, boolean isImported, boolean isReadOnly)
Changes the mapping properties of the specified attribute.void
modifyAttribute(SessionToken session, EntityType entType, String attrName, String omExt, String mappedTo, boolean isImported, boolean isReadOnly)
Changes the mapping properties of the specified attribute including the org model extension.void
updateEntity(SessionToken session, Entity entity)
Updates an entity with the attribute values provided in the givenEntity
object.
-
-
-
Method Detail
-
addAttribute
void addAttribute(SessionToken session, EntityType entType, String attrName, DataType dataType) throws OrgModelException, DataSourceException
Adds a new attribute with the given data type to the given entity type. Use/seeOrgModelTools.isValidAttributeName(String)
to find out whether a string is a valid attribute name if you're not sure.DataType.NULL
is not allowed as the data type of an attribute!- Parameters:
session
- The session which is used to check for access rights on this method.entType
- the entity type to which the attribute should be addedattrName
- the name of the new attributedataType
- the data type of the attribute to be added- Throws:
IllegalArgumentException
- whenDataType.NULL
is used as data type or the attribute name isn't validOrgModelException
- when the attribute already existsDataSourceException
- when an unrecoverable error occurs while accessing the data source
-
addAttribute
void addAttribute(SessionToken session, EntityType entType, String attrName, DataType dataType, String omExtension, String mappedTo, boolean isImported, boolean isReadOnly) throws OrgModelException, DataSourceException
Adds a new attribute with the given data type to the given entity type which is being mapped from the designated org model extension. Use/seeOrgModelTools.isValidAttributeName(String)
to find out whether a string is a valid attribute name if you're not sure.DataType.NULL
is not allowed as the data type of an attribute!- Parameters:
session
- The session which is used to check for access rights on this method.entType
- the entity type to which the attribute should be addedattrName
- the name of the new attributedataType
- the data type of the attribute to be addedomExtension
- The name of the org model extension which handles the mapping ornull
.mappedTo
- The name of the mapped attribute in the designated org model extension.isImported
- if the mapped attribute should be imported in the OMisReadOnly
- if the mapped attribute should be read-only- Throws:
IllegalArgumentException
- whenDataType.NULL
is used as data type or the attribute name isn't validOrgModelException
- when the attribute already existsDataSourceException
- when an unrecoverable error occurs while accessing the data source
-
addAttribute
void addAttribute(SessionToken session, EntityType entType, String attrName, DataType dataType, int sizeHint) throws OrgModelException, DataSourceException
Adds a new attribute with the given data type to the given entity type. Use/seeOrgModelTools.isValidAttributeName(String)
to find out whether a string is a valid attribute name if you're not sure.DataType.NULL
is not allowed as the data type of an attribute!- Parameters:
session
- The session which is used to check for access rights on this method.entType
- the entity type to which the attribute should be addedattrName
- the name of the new attributedataType
- the data type of the attribute to be addedsizeHint
- the desired size (only for STRING attributes)- Throws:
IllegalArgumentException
- whenDataType.NULL
is used as data type or the attribute name isn't validOrgModelException
- when the attribute already existsDataSourceException
- when an unrecoverable error occurs while accessing the data source
-
addAttribute
void addAttribute(SessionToken session, EntityType entType, String attrName, DataType dataType, int sizeHint, String omExtension, String mappedTo, boolean isImported, boolean isReadOnly) throws OrgModelException, DataSourceException
Adds a new attribute with the given data type to the given entity type which is being mapped from the designated org model extension. Use/seeOrgModelTools.isValidAttributeName(String)
to find out whether a string is a valid attribute name if you're not sure.DataType.NULL
is not allowed as the data type of an attribute!- Parameters:
session
- The session which is used to check for access rights on this method.entType
- the entity type to which the attribute should be addedattrName
- the name of the new attributedataType
- the data type of the attribute to be addedsizeHint
- the desired size (only for STRING attributes)omExtension
- The name of the org model extension which handles the mapping ornull
.mappedTo
- The name of the mapped attribute in the designated org model extension.isImported
- if the mapped attribute should be imported in the OMisReadOnly
- if the mapped attribute should be read-only- Throws:
IllegalArgumentException
- whenDataType.NULL
is used as data type or the attribute name isn't validOrgModelException
- when the attribute already existsDataSourceException
- when an unrecoverable error occurs while accessing the data source
-
modifyAttribute
void modifyAttribute(SessionToken session, EntityType entType, String attrName, String mappedTo, boolean isImported, boolean isReadOnly) throws OrgModelException, DataSourceException
Changes the mapping properties of the specified attribute.- Parameters:
session
- The session which is used to check for access rights on this method.entType
- the entity type to which the attribute belongsattrName
- the name of the attribute to be editedmappedTo
- the name of the mapped attribute in LDAP ornull
isImported
- if the mapped attribute should be imported in the OMisReadOnly
- if the mapped attribute should be read-only- Throws:
OrgModelException
- when the attribute doesn't exist or the attribute is mandatoryDataSourceException
- when an unrecoverable error occurs while accessing the data source
-
modifyAttribute
void modifyAttribute(SessionToken session, EntityType entType, String attrName, String omExt, String mappedTo, boolean isImported, boolean isReadOnly) throws OrgModelException, DataSourceException
Changes the mapping properties of the specified attribute including the org model extension.- Parameters:
session
- The session which is used to check for access rights on this method.entType
- the entity type to which the attribute belongsattrName
- the name of the attribute to be edited. This must not benull
and it has to exist.omExt
- The name of the org model extension from which to map the designated attribute ornull
to remove the mapping. model extension ornull
to remove the mapping.mappedTo
- The name of the mapped attribute in the designated org model extension ornull
to remove the mapping.isImported
- if the mapped attribute should be imported in the OMisReadOnly
- if the mapped attribute should be read-only- Throws:
OrgModelException
- when the attribute doesn't exist or the attribute is mandatoryDataSourceException
- when an unrecoverable error occurs while accessing the data source
-
deleteAttribute
void deleteAttribute(SessionToken session, EntityType entType, String attrName) throws OrgModelException, DataSourceException
This method removes an attribute from an entity type. Mandatory attributes can't be deleted (seeEntityType.getMandatoryAttributes()
andEntityType.hasMandatoryAttribute(String)
).- Parameters:
session
- The session which is used to check for access rights on this method.entType
- the entity type from which to remove the attributeattrName
- the name of the attribute to be deleted- Throws:
IllegalArgumentException
- when the attribute name isn't validOrgModelException
- when the attribute doesn't exist or the attribute is mandatoryDataSourceException
- when an unrecoverable error occurs while accessing the data source
-
createAgent
long createAgent(SessionToken session, String agentUserName, String password) throws OrgModelException, DataSourceException
Adds a new Agent with the given (unique!) user name and password. This method is preferred to creating agent entities usingcreateEntity(SessionToken, Entity)
, because the latter will create an agent with random user name and password, which makes it necessary to change them both afterwards usingupdateEntity(SessionToken, Entity)
.- Parameters:
session
- The session which is used to check for access rights on this method.agentUserName
- the user name of the new agentpassword
- the agent's password- Returns:
- the ID of the new agent entity
- Throws:
OrgModelException
- when an agent with the same user name already existsDataSourceException
- when an unrecoverable error occurs while accessing the data source
-
createEntity
long createEntity(SessionToken session, Entity entity) throws OrgModelException, DataSourceException
Creates a new entity with the type and attribute values provided in the givenEntity
object and returns the assigned ID. All other attributes are set tonull
. An exception is the Agent entity: userName and password will receive a random value, thereforecreateAgent(SessionToken, String, String)
is the preferred way to add new agents to the system.read-only attributes
(other than user name and password) are simply ignored.- Parameters:
session
- The session which is used to check for access rights on this method.entity
- the entity object containing the desired attribute values for the new entity- Returns:
- the ID of the newly created entity
- Throws:
OrgModelException
- when one of the attributes doesn't exist or the value object doesn't have a data type that's compatible to the attribute's data typeDataSourceException
- when an unrecoverable error occurs while accessing the data source
-
updateEntity
void updateEntity(SessionToken session, Entity entity) throws OrgModelException, DataSourceException
Updates an entity with the attribute values provided in the givenEntity
object. The entity to be updated is determined by the attributeid
of the data typeDataType.INTEGER
which must be set within theEntity
object.- Parameters:
session
- The session which is used to check for access rights on this method.entity
- contains the ID of the entity to be updated and the attribute values it should be updated with- Throws:
OrgModelException
- when no entity with the given ID exists, one of the attributes doesn't exist or the value object doesn't have a data type that's compatible to the attribute's data typeDataSourceException
- when an unrecoverable error occurs while accessing the data source
-
deleteEntity
void deleteEntity(SessionToken session, EntityType entType, long id) throws OrgModelException, DataSourceException
This method deletes the entity with the given ID of the given type. Only the entity and its relations will be deleted and no other entity it is related with! This method is equivalent to callingdeleteEntity(entType, id, false)
.- Parameters:
session
- The session which is used to check for access rights on this method.entType
- the type of the entity to be deletedid
- the ID of the entity to be deleted- Throws:
OrgModelException
- when no entity with this ID existsDataSourceException
- when an unrecoverable error occurs while accessing the data source
-
deleteEntity
void deleteEntity(SessionToken session, EntityType entType, long id, boolean recursive) throws OrgModelException, DataSourceException
This method deletes the entity with the given ID of the given type and all its relations. When an OrgPosition or Role is deleted their associated SubstitutionRules will be deleted too (This is mostly a consequence of some SQL related restrictions on SQL constraints).If the boolean parameter is
true
not only the entity will be deleted but also every other entity that in some way depends on it:- hierarchical structures: OrgUnits, ProjectGroups and Roles
- for OrgUnits even their associated OrgPositions will be deleted
- Parameters:
session
- The session which is used to check for access rights on this method.entType
- the type of the entity to be deletedid
- the ID of the entity to be deletedrecursive
-- Throws:
OrgModelException
- when no entity with this ID existsDataSourceException
- when an unrecoverable error occurs while accessing the data source
-
addRelation
void addRelation(SessionToken session, RelationType relType, long id1, long id2) throws OrgModelException, DataSourceException
This method adds a relation of the given type between the two entities identified by the given IDs.As both IDs are simple
long
s, you have to pay extra attention to their order. The following table will show you the required order for each relation type. SeeRelationType
for information about why they are ordered like that.The entity types of the referenced IDs of a relation RelationType id1 id2 OrgPositionOccupation (n:m) OrgPosition Agent OrgPositionDescription (n:m) OrgPosition Role OrgPositionAffiliation (1:m) OrgUnit OrgPosition OrgUnitSubordination (1:m) OrgUnit the subordinate OrgUnit (OrgUnit.supId) OrgUnitManagement (1:m) the managing OrgPosition OrgUnit (OrgUnit.managerId) OrgGroupManagement (1:m) the managing OrgPosition OrgGroup (OrgGroup.managerId) OrgGroupInvolvement (n:m) OrgGroup the involved OrgUnit ProjectGroupSubordination (1:m) ProjectGroup the subordinate ProjectGroup (ProjectGroup.supId) ProjectGroupManagement (1:m) OrgPosition ProjectGroup (ProjectGroup.managerId) ProjectInvolvementOrgPosition (n:m) ProjectGroup the involved OrgPosition ProjectInvolvementOrgUnit (n:m) ProjectGroup the involved OrgUnit AgentAbility (n:m) Agent Ability RoleDescription (n:m) Role Ability RoleSpecialisation (1:m) the more generic Role the specialised Role (Role.supId) OrgPositionSubstitution (1:m) OrgPosition SubstitutionRule OrgPositionSubstitute (1:m) the OrgPosition to substitute the other one SubstitutionRule RoleSubstitution (1:m) Role SubstitutionRule - Parameters:
session
- The session which is used to check for access rights on this method.relType
- the type of the relation to be addedid1
- the ID of the first entity (see table)id2
- the ID of the second entity (see table)- Throws:
OrgModelException
- when one of the entities does not exist, this exact relation already exists, the second entity already is in a relation and can only be in one (this is the case for 1:n relation types), the relation would create a cycle or it was tried to substitute an OrgPosition for itself in a SubstitutionRuleDataSourceException
- when an unrecoverable error occurs while accessing the data source
-
deleteRelation
void deleteRelation(SessionToken session, RelationType relType, long id1, long id2) throws OrgModelException, DataSourceException
This method deletes a relation of the given type between the two entities identified by the given IDs.As both IDs are simple
long
s, you have to pay extra attention to their order. SeeaddRelation(SessionToken, RelationType, long, long)
for more information.- Parameters:
session
- The session which is used to check for access rights on this method.relType
- the type of the relation to be removedid1
- the ID of the first entity (see table)id2
- the ID of the second entity (see table)- Throws:
OrgModelException
- when one of the entities does not exist or this exact relation does not existDataSourceException
- when an unrecoverable error occurs while accessing the data source
-
-