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()
void
copyTo
(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.void
forget()
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 aIPObject
in hand, can easily get theIDataService
as well and doesn't have to do some additional work (since theIPObject
has 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 theIObjectId
from the object'sSubterraURI
.Convenience method to extract the revision from the object'sSubterraURI
.getUri()
boolean
boolean
boolean
All write attempts on read-only objects will end up with exception.boolean
boolean
This method guarantees that the object is either resolved, or unresolvable.void
resolve()
Resolves the object content if not yet resolved.void
save()
Saves the content of this object into the associatedIDataService
.void
setEnumerationValue
(String key, String value) Sets the enumeration value of given field.void
Sets the value of given field.void
update()
Reloads the content of this object from the associatedIDataService
.Methods inherited from interface com.polarion.platform.persistence.model.IAdaptable
adapt
Methods inherited from interface com.polarion.platform.persistence.model.IChangeListener
markChanged
Methods 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 aIPObject
in hand, can easily get theIDataService
as well and doesn't have to do some additional work (since theIPObject
has this reference anyway.- Returns:
- The data service this object is bound to.
-
isPersisted
boolean isPersisted()- Returns:
false
for temporary objects,true
otherwise. 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 theIObjectId
from the object'sSubterraURI
.- Returns:
- the
IObjectId
assigned 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
null
if 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
String
representing 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:
getValue
in interfaceIHasValues
- Parameters:
key
-- Returns:
- The value of given key. This handles both the ordinary fields (as
defined by prototype) and the custom fields. Returns
null
if the field has no value (or does not exist). Never returnsnull
for 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:
setValue
in 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 (
null
if and only ifoptionId
isnull
) - Throws:
UnknownKeyException
- if the field is not valid or of enumeration type- Since:
- 3.1.1
- See Also:
-
getEnumerationTypeForField
- Returns:
- the Optional
IEnumType
for 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:
true
is this object is read-only,false
otherwise. 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:
True
is this object was modified since it's load,false
otherwise.
-
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
IStructure
created for the specified key
-
isUnresolvable
boolean isUnresolvable()This method guarantees that the object is either resolved, or unresolvable.- Returns:
false
if this object is resolved. Returnstrue
if attempt to resolve did fail. If this method returnstrue
then all attempts to call get/set methods will result in exception.
-
isResolved
boolean isResolved()- Returns:
- Returns
true
is data of this object are already loaded,false
otherwise.
-
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 theSubterraURI
remains. 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 (null
means all); can also include custom keysexcludeKeys
- which keys to exclude when copying (null
means none); can also include custom keysincludeAllCustomFields
-true
if all custom fields should also be copied; iffalse
then only those mentioned inincludeKeys
and not mentioned inexcludeKeys
are 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
-