Class PObject
- All Implemented Interfaces:
IAdaptable
,IChangeListener
,IHasCustomValues
,IHasValues
,IPObject
,IHasChangeListeners
,Serializable
- Direct Known Subclasses:
Revision
IPObject
interface.
Because the backend implementation cooperates with this class, implementors of model-specific type interfaces must extend it.- Author:
- dobisekm
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionPObject
(IDataService dataSvc, IPrototype prototype) Creates an instance of new PObject, which is not yet persistent.PObject
(IDataService dataSvc, com.polarion.subterra.base.data.object.IDataObject dao) Creates resolved PObject, the same asPObject(dataSvc, dao.getId(), dao)
PObject
(IDataService dataSvc, SubterraURI uri) Creates unresolved PObject, actually the same asPObject(dataSvc, uri, null)
PObject
(IDataService dataSvc, SubterraURI uri, com.polarion.subterra.base.data.object.IDataObject dao) Creates the resolved PObject (if dao != null) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChangeListener
(IChangeListener listener) Internal API, do not use.can()
void
ThrowsReadOnlyException
whenisReadOnly()
returns true.<T extends IPObject>
com.polarion.platform.persistence.internal.model.IFieldCopier<T>copy()
Internal method, not an API.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.boolean
For temporary objects (uri==null
) the logic is taken from parent class, the others compare theuris
.boolean
exists()
Internal API, do not use.void
forget()
Forgets the content of this object.getCachedDynamicRoles
(String user) getCustomField
(String key) Shortcut forICustomFieldsService.getCustomField(key, getProtoName(), getContextId())
final com.polarion.subterra.base.data.object.IDataObject
getData()
Returns low level data.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 value) 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 build 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
.getSecurityReferee
(String key) Return security referee for given key.getUri()
int
hashCode()
For temporary objects (uri==null
) the hash code is taken from parent class.boolean
boolean
isInCustomSet
(String customSet) 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
void
markUnresolvable
(RuntimeException cause) void
resolve()
Resolves the object content if not yet resolved.void
save()
Saves the content of this object into the associatedIDataService
.void
setBypassInstanceModificationSecurityCheck
(boolean bypass) void
setCachedDynamicRoles
(String user, Collection<String> roles) void
setCustomField
(String key, Object value) Sets the value of the given custom field.final void
setDao
(com.polarion.subterra.base.data.object.IDataObject dao) Used by backend to resolve the content of this PObject.void
setEnumerationValue
(String key, String value) Sets the enumeration value of given field.void
setInCustomSet
(String customSet, boolean isIn) Internal API, do not use.final void
setURI
(SubterraURI uri) Used by the backend during object creation, must not be called by clients.void
Sets the value of given field.toString()
void
update()
Reloads the content of this object from the associatedIDataService
.
-
Constructor Details
-
PObject
Creates an instance of new PObject, which is not yet persistent. Saving this object will cause call to the creation methods.- Parameters:
dataSvc
-prototype
-
-
PObject
Creates unresolved PObject, actually the same asPObject(dataSvc, uri, null)
-
PObject
public PObject(@NotNull IDataService dataSvc, @NotNull com.polarion.subterra.base.data.object.IDataObject dao) Creates resolved PObject, the same asPObject(dataSvc, dao.getId(), dao)
- Parameters:
dataSvc
-dao
-
-
PObject
public PObject(@NotNull IDataService dataSvc, @NotNull SubterraURI uri, @Nullable com.polarion.subterra.base.data.object.IDataObject dao) Creates the resolved PObject (if dao != null)
-
-
Method Details
-
setDao
public final void setDao(@Nullable com.polarion.subterra.base.data.object.IDataObject dao) Used by backend to resolve the content of this PObject.Should not be called by ordinary clients.
- Parameters:
dao
-
-
setURI
Used by the backend during object creation, must not be called by clients.- Parameters:
uri
-
-
getData
@Nullable public final com.polarion.subterra.base.data.object.IDataObject getData()Returns low level data. Used by backend only. Client calls to this method can result in unpredictable behaviour. -
isPersisted
public boolean isPersisted()- Specified by:
isPersisted
in interfaceIPObject
- Returns:
false
for temporary objects,true
otherwise. Some operations are disallowed on temporary objects (since they don't have uri yet).
-
getPrototype
- Specified by:
getPrototype
in interfaceIPObject
-
getUri
-
getObjectId
Description copied from interface:IPObject
Convenience method to extract theIObjectId
from the object'sSubterraURI
.- Specified by:
getObjectId
in interfaceIPObject
- Returns:
- the
IObjectId
assigned to this object
-
getLocalId
Description copied from interface:IPObject
Convenience method to get the local id- Specified by:
getLocalId
in interfaceIPObject
-
getContextId
- Specified by:
getContextId
in interfaceIPObject
-
getRevision
Description copied from interface:IPObject
Convenience method to extract the revision from the object'sSubterraURI
.- Specified by:
getRevision
in interfaceIPObject
- Returns:
- The revision name or
null
if this object is not taken from any particular revision.
-
getDataRevision
Description copied from interface:IPObject
Returns revision from which the data was actually read.- Specified by:
getDataRevision
in interfaceIPObject
- Returns:
- the
String
representing the id associated with this objects data
-
getLastRevision
Description copied from interface:IPObject
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.)- Specified by:
getLastRevision
in interfaceIPObject
-
getValue
- Specified by:
getValue
in interfaceIHasValues
- Specified by:
getValue
in interfaceIPObject
- 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).
-
getSecurityReferee
Return security referee for given key.Allows to redirect security checking of lists and structures to another object (especially useful for fields which are stored in one object, but are shown as if they were part of another object) when overridden.
- Parameters:
key
- key- Returns:
- security referee or
null
(which allows everything)
-
setBypassInstanceModificationSecurityCheck
public void setBypassInstanceModificationSecurityCheck(boolean bypass) -
isBypassingInstanceModificationSecurityCheck
public boolean isBypassingInstanceModificationSecurityCheck() -
checkReadOnly
public void checkReadOnly()ThrowsReadOnlyException
whenisReadOnly()
returns true.- Since:
- 3.23.10
-
setValue
Description copied from interface:IPObject
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
- Specified by:
setValue
in interfaceIPObject
- Parameters:
key
- Name of field defined by prototype or custom field, which is configured for this object OR already exists in this object.
-
getCustomField
- Specified by:
getCustomField
in interfaceIHasCustomValues
- Parameters:
key
- The value of the given custom field ornull
if no such value exists.
-
setCustomField
Description copied from interface:IHasCustomValues
Sets the value of the given custom field. The value type must be checked against the custom field configuration. If the field configuration does not exist, only theString
value is accepted.- Specified by:
setCustomField
in interfaceIHasCustomValues
-
getCustomFieldsList
- Specified by:
getCustomFieldsList
in interfaceIHasCustomValues
- Returns:
- Collection of
String
names of custom fields, which are defined for this object or exist on this object.
-
getCustomFieldPrototype
Description copied from interface:IHasCustomValues
Shortcut forICustomFieldsService.getCustomField(key, getProtoName(), getContextId())
- Specified by:
getCustomFieldPrototype
in interfaceIHasCustomValues
- See Also:
-
getIncompatibleCustomField
- Specified by:
getIncompatibleCustomField
in interfaceIPObject
- Returns:
- value of incompatible custom field
key
-
getIncompatibleCustomFieldPrototype
- Specified by:
getIncompatibleCustomFieldPrototype
in interfaceIPObject
- Returns:
- prototype of incompatible custom field
key
-
getIncompatibleCustomFieldsList
- Specified by:
getIncompatibleCustomFieldsList
in interfaceIPObject
- 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)
-
isReadOnly
public boolean isReadOnly()Description copied from interface:IPObject
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).
- Specified by:
isReadOnly
in interfaceIPObject
- 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
public boolean isModified()- Specified by:
isModified
in interfaceIPObject
- Returns:
True
is this object was modified since it's load,false
otherwise.
-
createStructureForKey
Description copied from interface:IPObject
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 forIPObject.createStructureForKey(String)
.- Specified by:
createStructureForKey
in interfaceIPObject
- Returns:
- the
IStructure
created for the specified key
-
markUnresolvable
-
addChangeListener
Internal API, do not use.- Specified by:
addChangeListener
in interfaceIHasChangeListeners
- Since:
- 3.19.3
-
isUnresolvable
public boolean isUnresolvable()Description copied from interface:IPObject
This method guarantees that the object is either resolved, or unresolvable.- Specified by:
isUnresolvable
in interfaceIPObject
- 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
public boolean isResolved()- Specified by:
isResolved
in interfaceIPObject
- Returns:
- Returns
true
is data of this object are already loaded,false
otherwise.
-
resolve
public void resolve()Description copied from interface:IPObject
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
public void save()Description copied from interface:IPObject
Saves the content of this object into the associatedIDataService
. -
update
public void update()Description copied from interface:IPObject
Reloads the content of this object from the associatedIDataService
. This reverts any changes done to this object.This method is equivalent to
IPObject.forget()
followed byIPObject.resolve()
. -
forget
public void forget()Description copied from interface:IPObject
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). -
markChanged
public void markChanged()- Specified by:
markChanged
in interfaceIChangeListener
-
exists
public boolean exists()Internal API, do not use. Returns true if the object exists (existing object can be unresolvable because of permissions). The object is resolved, if it exists, as a side effect. -
adapt
- Specified by:
adapt
in interfaceIAdaptable
- Returns:
- The incance of
targetClass
representing this object ornull
if adaptation is not possible.
-
hashCode
public int hashCode()For temporary objects (uri==null
) the hash code is taken from parent class. -
equals
For temporary objects (uri==null
) the logic is taken from parent class, the others compare theuris
. -
getDataSvc
Description copied from interface:IPObject
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.- Specified by:
getDataSvc
in interfaceIPObject
- Returns:
- The data service this object is bound to.
-
toString
-
setCachedDynamicRoles
-
getCachedDynamicRoles
-
isInCustomSet
- Returns:
- whether this object belongs to given custom set (specified by Lucene query)
- Since:
- 3.8.1
- See Also:
-
setInCustomSet
Internal API, do not use.- Since:
- 3.10.1
-
setEnumerationValue
Description copied from interface:IPObject
Sets the enumeration value of given field.Shortcut for combination of
IPObject.getEnumerationOptionForField(String, String)
andIPObject.setValue(String, Object)
.- Specified by:
setEnumerationValue
in interfaceIPObject
- Parameters:
key
- field name (notnull
)value
- enumeration value (option id)
-
getEnumerationOptionForField
Description copied from interface:IPObject
Returns wrapped enumeration option for given field.- Specified by:
getEnumerationOptionForField
in interfaceIPObject
- Parameters:
key
- field name (notnull
)value
- option id- Returns:
- wrapped option (
null
if and only ifoptionId
isnull
) - See Also:
-
getEnumerationTypeForField
- Specified by:
getEnumerationTypeForField
in interfaceIPObject
- Returns:
- the Optional
IEnumType
for the given field if it is of enum or multi-enum type, otherwise returns Optional.empty(). - See Also:
-
copy
@NotNull public <T extends IPObject> com.polarion.platform.persistence.internal.model.IFieldCopier<T> copy()Internal method, not an API. -
copyTo
public void copyTo(@NotNull IPObject dest, @Nullable Set<String> includeKeys, @Nullable Set<String> excludeKeys, boolean includeAllCustomFields, @Nullable Set<String> notCopiedCustomFields, @Nullable Set<String> convertedCopiedCustomFields) Description copied from interface:IPObject
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.
IPObject.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 callIPObject.save()
on the destination object in order to make all changes persistent.The exact implementation is type-dependent.
- Specified by:
copyTo
in interfaceIPObject
- 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.
-
getFieldType
Returns type of the field regardless if it is a build in or custom field.- Specified by:
getFieldType
in interfaceIPObject
- Parameters:
key
- - field key- Returns:
- type or null when the field is not defined.
- Since:
- 3.5.2
-
can
-
getFieldLabel
Description copied from interface:IPObject
Returns label of the field regardless if it is a built-in or custom field.- Specified by:
getFieldLabel
in interfaceIPObject
-