Interface IPObject
- All Superinterfaces:
IAdaptable,IChangeListener,IHasCustomValues,IHasValues
- All Known Subinterfaces:
IAttachment,IAttachmentBase,IBaseline,IBaselineCollection,IBuild,IBuildArtifact,ICategory,IComment,ICommentBase<T>,IDocumentWorkflowSignature,IGroupEntity,IGroupUniqueObject,IModule,IModuleAttachment,IModuleComment,IPlan,IProject,IProjectGroup,IPrototype,IRevision,IRichPage,IRichPageAttachment,IRichPageComment,IScript,ITestRun,ITestRunAttachment,ITestRunComment,ITestRunWorkflowSignature,ITimePoint,ITrackerBuild,ITrackerProject,ITrackerRevision,ITrackerUser,IUniqueObject,IUser,IUserGroup,IWatchList,IWikiPage,IWikiPageAttachment,IWithLinkedOslcResources,IWorkflowObject,IWorkflowSignature,IWorkItem,IWorkItemWorkflowSignature,IWorkRecord
This is the super class of all the persistent objects.
The basic class defines the ways to access the prototype, ID and to perform
the reflexive examination of the object.
The derived faces should contribute the model specific methods.
- Author:
- dobisekm
-
Method Summary
Modifier and TypeMethodDescriptioncan()voidcopyTo(IPObject dest, Set<String> includeKeys, Set<String> excludeKeys, boolean includeAllCustomFields, Set<String> notCopiedCustomFields, Set<String> convertedCopiedCustomFields) Copies the content of this IPObject to a given IPObject.Creates the instance of structure object, which corresponds to model definition.voidforget()Forgets the content of this object.Returns revision from which the data was actually read.This is a convenience method, so that everyone, who has aIPObjectin hand, can easily get theIDataServiceas well and doesn't have to do some additional work (since theIPObjecthas this reference anyway.getEnumerationOptionForField(String key, String optionId) Returns wrapped enumeration option for given field.getFieldLabel(String fieldId) Returns label of the field regardless if it is a built-in or custom field.getFieldType(String key) Returns type of the field regardless if it is a built-in or custom field.Returns the last revision in the History of this object.Convenience method to get the local idConvenience method to extract theIObjectIdfrom the object'sSubterraURI.Convenience method to extract the revision from the object'sSubterraURI.getUri()booleanbooleanbooleanAll write attempts on read-only objects will end up with exception.booleanbooleanThis method guarantees that the object is either resolved, or unresolvable.voidresolve()Resolves the object content if not yet resolved.voidsave()Saves the content of this object into the associatedIDataService.voidsetEnumerationValue(String key, String value) Sets the enumeration value of given field.voidSets the value of given field.voidupdate()Reloads the content of this object from the associatedIDataService.Methods inherited from interface com.polarion.platform.persistence.model.IAdaptable
adaptMethods inherited from interface com.polarion.platform.persistence.model.IChangeListener
markChangedMethods inherited from interface com.polarion.platform.persistence.model.IHasCustomValues
getCustomField, getCustomFieldPrototype, getCustomFieldsList, setCustomField
-
Method Details
-
getPrototype
IPrototype getPrototype() -
getDataSvc
IDataService getDataSvc()This is a convenience method, so that everyone, who has aIPObjectin hand, can easily get theIDataServiceas well and doesn't have to do some additional work (since theIPObjecthas this reference anyway.- Returns:
- The data service this object is bound to.
-
isPersisted
boolean isPersisted()- Returns:
falsefor temporary objects,trueotherwise. Some operations are disallowed on temporary objects (since they don't have uri yet).
-
getUri
SubterraURI getUri()- Returns:
- The object's URI.
- Throws:
IllegalStateException- if this is a temporary object (which does not have the ID yet).
-
getObjectId
IObjectId getObjectId()Convenience method to extract theIObjectIdfrom the object'sSubterraURI.- Returns:
- the
IObjectIdassigned to this object - Throws:
IllegalStateException- if this is a temporary object (which does not have the ID yet).
-
getLocalId
ILocalId getLocalId()Convenience method to get the local id -
getContextId
IContextId getContextId() -
getRevision
String getRevision()Convenience method to extract the revision from the object'sSubterraURI.- Returns:
- The revision name or
nullif this object is not taken from any particular revision. - Throws:
IllegalStateException- if this is a temporary object (which does not have the ID yet).
-
getDataRevision
String getDataRevision()Returns revision from which the data was actually read.- Returns:
- the
Stringrepresenting the id associated with this objects data
-
getLastRevision
String getLastRevision()Returns the last revision in the History of this object. (Does not return revisions from included child objects like Work Items or Document Workflow Signatures.)- Since:
- 3.6.0
-
getValue
- Specified by:
getValuein interfaceIHasValues- Parameters:
key-- Returns:
- The value of given key. This handles both the ordinary fields (as
defined by prototype) and the custom fields. Returns
nullif the field has no value (or does not exist). Never returnsnullfor collection fields defined by prototype (empty collection is returned instead).
-
setValue
Sets the value of given field. This works with both ordinary fields (as defined by prototype) and the custom fields. But the field correctness is checked, therefore it's not possible to set value of unknown custom field.- Specified by:
setValuein interfaceIHasValues- Parameters:
key- Name of field defined by prototype or custom field, which is configured for this object OR already exists in this object.value-- Throws:
IllegalArgumentException- If the key is not valid or the value has wrong type.
-
setEnumerationValue
Sets the enumeration value of given field.Shortcut for combination of
getEnumerationOptionForField(String, String)andsetValue(String, Object).- Parameters:
key- field name (notnull)value- enumeration value (option id)- Throws:
UnknownKeyException- if the field is not valid or of enumeration type- Since:
- 3.1.1
-
getEnumerationOptionForField
Returns wrapped enumeration option for given field.- Parameters:
key- field name (notnull)optionId- option id- Returns:
- wrapped option (
nullif and only ifoptionIdisnull) - Throws:
UnknownKeyException- if the field is not valid or of enumeration type- Since:
- 3.1.1
- See Also:
-
getEnumerationTypeForField
- Returns:
- the Optional
IEnumTypefor the given field if it is of enum or multi-enum type, otherwise returns Optional.empty(). - Since:
- 3.21.1
- See Also:
-
getIncompatibleCustomFieldsList
- Returns:
- Set of names of custom fields which are persisted in this work item but not compatible with their current definition (i. e. persisted as a String but currently defined to be an Integer)
- Since:
- 3.5.1
-
getIncompatibleCustomFieldPrototype
- Returns:
- prototype of incompatible custom field
key - Since:
- 3.5.1
-
getIncompatibleCustomField
- Returns:
- value of incompatible custom field
key - Since:
- 3.5.1
-
isReadOnly
boolean isReadOnly()All write attempts on read-only objects will end up with exception.Temporary objects are never read-only, even their fields, which are defined as read-only in prototype can be written to temporary objects (since they are likely needed during the creation).
- Returns:
trueis this object is read-only,falseotherwise. There are several reasons for object to be read-only: it can be marked on prototype or recognized from the URL (which points to particular version of the object) or when the current transaction is read-only.
-
isModified
boolean isModified()- Returns:
Trueis this object was modified since it's load,falseotherwise.
-
createStructureForKey
Creates the instance of structure object, which corresponds to model definition. Use the dot notation, if the structure is under another structure (e.g. mystructure.substructure) This is a shortcut method forcreateStructureForKey(String).- Parameters:
key-- Returns:
- the
IStructurecreated for the specified key
-
isUnresolvable
boolean isUnresolvable()This method guarantees that the object is either resolved, or unresolvable.- Returns:
falseif this object is resolved. Returnstrueif attempt to resolve did fail. If this method returnstruethen all attempts to call get/set methods will result in exception.
-
isResolved
boolean isResolved()- Returns:
- Returns
trueis data of this object are already loaded,falseotherwise.
-
resolve
void resolve()Resolves the object content if not yet resolved. (reads it from the associatedIDataService. In case the object is already resolved, calling this method does nothing. -
save
void save()Saves the content of this object into the associatedIDataService. -
update
void update()Reloads the content of this object from the associatedIDataService. This reverts any changes done to this object.This method is equivalent to
forget()followed byresolve(). -
forget
void forget()Forgets the content of this object. The underlying data are disposed, just theSubterraURIremains. This disposes any changes made to this object (if not saved before). -
copyTo
void copyTo(@NotNull IPObject dest, @Nullable Set<String> includeKeys, @Nullable Set<String> excludeKeys, boolean includeAllCustomFields, @Nullable Set<String> notCopiedCustomFields, @Nullable Set<String> convertedCopiedCustomFields) Copies the content of this IPObject to a given IPObject.Both objects must be of the same prototype.
New persistent objects may be created in the process.
save()may be called on any object (this object, the destination object or any new object) during the execution of this method. However the caller must callsave()on the destination object in order to make all changes persistent.The exact implementation is type-dependent.
- Parameters:
dest- destination object (notnull)includeKeys- which keys to include when copying (nullmeans all); can also include custom keysexcludeKeys- which keys to exclude when copying (nullmeans none); can also include custom keysincludeAllCustomFields-trueif all custom fields should also be copied; iffalsethen only those mentioned inincludeKeysand not mentioned inexcludeKeysare copiednotCopiedCustomFields- custom fields that could not be copied (output); note that since 3.5.1 this is always an empty set, because the 'incompatibleCustomFields' feature is used for custom fields of this typeconvertedCopiedCustomFields- custom fields which were converted rather than exact copies (output). Since 3.5.1 this also includes incompatible custom fields.- Since:
- 3.2.0
-
getFieldType
Returns type of the field regardless if it is a built-in or custom field.- Parameters:
key- - field key- Returns:
- type or null when the field is not defined.
- Since:
- 3.5.2
-
can
- Since:
- 3.8.2
-
getFieldLabel
Returns label of the field regardless if it is a built-in or custom field.- Since:
- 3.9.0
-