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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated 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, boolean readOnly, Map<String,String> omExtMapping, Collection<String> writeBackOmExts)
Adds a new attribute with the designated data type to the designated entity type which is being mapped from the designated attributes from the corresponding org model extensions .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)
Deprecated, for removal: This API element is subject to removal in a future version.void
addAttribute(SessionToken session, EntityType entType, String attrName, DataType dataType, String omExtension, String mappedTo, boolean isImported, boolean isReadOnly)
Deprecated, for removal: This API element is subject to removal in a future version.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.void
addStringAttribute(SessionToken session, EntityType entType, String attrName, int sizeHint, boolean readOnly, Map<String,String> omExtMapping, Collection<String> writeBackOmExts)
Adds a newDataType.STRING
attribute of the designated size to the designated entity type which is being mapped from the designated attributes from the corresponding org model extensions .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.Pair<PasswordStrength.PasswordQuality,PasswordStrength>
getPasswordQuality(SessionToken session, String password, Collection<String> blacklist, Locale locale)
void
modifyAttribute(SessionToken session, EntityType entType, String attrName, Boolean readOnly, Map<String,Pair<String,Boolean>> omExtMapping)
Changes the mapping properties and the read-only status of the designated attribute.void
modifyAttribute(SessionToken session, EntityType entType, String attrName, Boolean readOnly, Map<String,String> omExtMapping, Collection<String> writeBackOmExts)
Changes the mapping properties and the read-only status of the designated attribute.void
modifyAttribute(SessionToken session, EntityType entType, String attrName, String mappedTo, boolean isImported, boolean isReadOnly)
Deprecated, for removal: This API element is subject to removal in a future version.void
modifyAttribute(SessionToken session, EntityType entType, String attrName, String omExt, String mappedTo, boolean isImported, boolean isReadOnly)
Deprecated, for removal: This API element is subject to removal in a future version.void
updateEntity(SessionToken session, Entity entity)
Updates an entity with the attribute values provided in the givenEntity
object.
-
-
-
Method Detail
-
getPasswordQuality
Pair<PasswordStrength.PasswordQuality,PasswordStrength> getPasswordQuality(SessionToken session, String password, Collection<String> blacklist, Locale locale)
Gets the quality of the designated password, that is, whether the password will be accepted when creating or updating it for an entity.- Parameters:
session
- The session which is used to check for access rights on this method and which provides the locale for additional information forPasswordStrength
.password
- The new password which to check for its quality.blacklist
- The user details like username and email that should not be used as password. Could benull
or empty.locale
- The locale that should be used to localise additional information forPasswordStrength
.- Returns:
- The password quality and optional additional information to the designated password. If
no plugin for the password strength has been configured or password strength estimation
has been disabled,
PasswordStrength.PasswordQuality.ACCEPTED
andnull
will be returned.
-
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 attribute. This must not containOmeAttributes.ATTR_SEPARATOR
.dataType
- 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
@Deprecated(since="13.0.0", forRemoval=true) void addAttribute(SessionToken session, EntityType entType, String attrName, DataType dataType, String omExtension, String mappedTo, boolean isImported, boolean isReadOnly) throws OrgModelException, DataSourceException
Deprecated, for removal: This API element is subject to removal in a future version.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 attribute. This must not containOmeAttributes.ATTR_SEPARATOR
.dataType
- 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, boolean readOnly, Map<String,String> omExtMapping, Collection<String> writeBackOmExts) throws OrgModelException, DataSourceException
Adds a new attribute with the designated data type to the designated entity type which is being mapped from the designated attributes from the corresponding org model extensions . 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 added.attrName
- The unique (with respect to the entity type) name of the new attribute. This must not contain "_".dataType
- The data type of the attribute to be added.readOnly
- Whether the new attribute should be globally read-only, i. e. for all OM extensions.omExtMapping
- The name of the org model extensions and the corresponding attribute names which the new attribute is mapped in priority order, higher priority first. This may benull
.writeBackOmExts
- The OM extension names (of the designated OM extensions) for which the attribute value should be written back when changed by the system (but not from another OM extension). If this isnull
, the attribute will not be written back for all of the designated OM extensions. UseomExtMapping.keySet()
to make the attribute written back for all OM extensions.- Throws:
IllegalArgumentException
- If the designated data type isDataType.NULL
or the attribute name is invalid, anIllegalArgumentException
will be thrown.OrgModelException
- If an attribute of the designated name already exists, anOrgModelException
will be thrown.DataSourceException
- If there are unrecoverable problems accessing the data source, aDataSourceException
will be thrown.
-
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 attribute. This must not containOmeAttributes.ATTR_SEPARATOR
.dataType
- 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
@Deprecated(since="13.0.0", forRemoval=true) void addAttribute(SessionToken session, EntityType entType, String attrName, DataType dataType, int sizeHint, String omExtension, String mappedTo, boolean isImported, boolean isReadOnly) throws OrgModelException, DataSourceException
Deprecated, for removal: This API element is subject to removal in a future version.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 attribute. This must not containOmeAttributes.ATTR_SEPARATOR
.dataType
- 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
-
addStringAttribute
void addStringAttribute(SessionToken session, EntityType entType, String attrName, int sizeHint, boolean readOnly, Map<String,String> omExtMapping, Collection<String> writeBackOmExts) throws OrgModelException, DataSourceException
Adds a newDataType.STRING
attribute of the designated size to the designated entity type which is being mapped from the designated attributes from the corresponding org model extensions . Use/seeOrgModelTools.isValidAttributeName(String)
to find out whether a string is a valid attribute name if you are 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 added.attrName
- The unique (with respect to the entity type) name of the new attribute. This must not contain "_".sizeHint
- The desired size of the string.readOnly
- Whether the new attribute should be globally read-only, i. e. for all OM extensions.omExtMapping
- The name of the org model extensions and the corresponding attribute names which the new attribute is mapped in priority order, higher priority first. This may benull
.writeBackOmExts
- The OM extension names (of the designated OM extensions) for which the attribute value should be written back when changed by the system (but not from another OM extension). If this isnull
, the attribute will not be written back for all of the designated OM extensions. UseomExtMapping.keySet()
to make the attribute written back for all OM extensions.- Throws:
IllegalArgumentException
- If the designated attribute name is invalid or there is a mapping for a data type other than integer or string, anIllegalArgumentException
will be thrown.OrgModelException
- If an attribute of the designated name already exists, anOrgModelException
will be thrown.DataSourceException
- If there are unrecoverable problems accessing the data source, aDataSourceException
will be thrown.
-
modifyAttribute
@Deprecated(since="13.0.0", forRemoval=true) void modifyAttribute(SessionToken session, EntityType entType, String attrName, String mappedTo, boolean isImported, boolean isReadOnly) throws OrgModelException, DataSourceException
Deprecated, for removal: This API element is subject to removal in a future version.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
@Deprecated(since="13.0.0", forRemoval=true) void modifyAttribute(SessionToken session, EntityType entType, String attrName, String omExt, String mappedTo, boolean isImported, boolean isReadOnly) throws OrgModelException, DataSourceException
Deprecated, for removal: This API element is subject to removal in a future version.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
-
modifyAttribute
void modifyAttribute(SessionToken session, EntityType entType, String attrName, Boolean readOnly, Map<String,String> omExtMapping, Collection<String> writeBackOmExts) throws OrgModelException, DataSourceException
Changes the mapping properties and the read-only status of the designated attribute.- Parameters:
session
- The session which is used to check for access rights on this method.entType
- The entity type of which the attribute should be changed.attrName
- The unique (with respect to the entity type) name of the attribute.readOnly
- Whether the attribute should be globally read-only, i. e. for all OM extensions. Usenull
to not change the read-only status.omExtMapping
- The name of (all) the org model extensions and the corresponding attribute names which the new attribute is mapped in priority order, higher priority first.null
does not change the existing mapping, an empty map will remove the existing mapping.writeBackOmExts
- The OM extension names (of the designated OM extensions) for which the attribute value should be written back when changed by the system (but not from another OM extension). If this isnull
, writing back will not change. Use an empty collection to disable writing back andomExtMapping.keySet()
to make the attribute written back for all OM extensions.- Throws:
IllegalArgumentException
- If the data type of the designated attribute isDataType.FLOAT
orDataType.TIMESTAMP
, anIllegalArgumentException
will be thrown.OrgModelException
- If the designated attribute does not exist or is mandatory, anOrgModelException
will be thrown.DataSourceException
- If there are unrecoverable problems accessing the data source, aDataSourceException
will be thrown.
-
modifyAttribute
void modifyAttribute(SessionToken session, EntityType entType, String attrName, Boolean readOnly, Map<String,Pair<String,Boolean>> omExtMapping) throws OrgModelException, DataSourceException
Changes the mapping properties and the read-only status of the designated attribute.- Parameters:
session
- The session which is used to check for access rights on this method.entType
- The entity type of which the attribute should be changed.attrName
- The unique (with respect to the entity type) name of the attribute.readOnly
- Whether the attribute should be globally read-only, i. e. for all OM extensions. Usenull
to not change the read-only status.omExtMapping
- The name of (all) the org model extensions and the corresponding attribute names which the new attribute is mapped in priority order, higher priority first.null
does not change the existing mapping, an empty map will remove the existing mapping. TheBoolean
specifies whether to write the attribute value back to the corresponding OM extension when changed by the system (but not from another OM extension). Usenull
to keep the current write back status of an existing mapping; in case of a new mappingBoolean.FALSE
will be expected.- Throws:
IllegalArgumentException
- If the data type of the designated attribute isDataType.FLOAT
orDataType.TIMESTAMP
, anIllegalArgumentException
will be thrown.OrgModelException
- If the designated attribute does not exist or is mandatory, anOrgModelException
will be thrown.DataSourceException
- If there are unrecoverable problems accessing the data source, aDataSourceException
will be thrown.
-
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, PasswordPolicyException, 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 existsPasswordPolicyException
- If the designated password is too weak, aPasswordPolicyException
will be thrown.DataSourceException
- when an unrecoverable error occurs while accessing the data source
-
createEntity
long createEntity(SessionToken session, Entity entity) throws OrgModelException, PasswordPolicyException, 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 typePasswordPolicyException
- If the designated entity is an agent with a password and this password is too weak, aPasswordPolicyException
will be thrown.DataSourceException
- when an unrecoverable error occurs while accessing the data source- See Also:
#getPasswordQuality(SessionToken, String)
-
updateEntity
void updateEntity(SessionToken session, Entity entity) throws OrgModelException, PasswordPolicyException, 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 typePasswordPolicyException
- If the designated entity is an agent with a new password and this password is too weak, aPasswordPolicyException
will be thrown.DataSourceException
- when an unrecoverable error occurs while accessing the data source- See Also:
#getPasswordQuality(SessionToken, String)
-
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
-
-