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
All Known Implementing Classes:
PObject, Revision

public interface IPObject extends IChangeListener, IAdaptable, IHasValues, IHasCustomValues
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 Details

    • getPrototype

      IPrototype getPrototype()
    • getDataSvc

      IDataService getDataSvc()
      This is a convenience method, so that everyone, who has a IPObject in hand, can easily get the IDataService as well and doesn't have to do some additional work (since the IPObject 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 the IObjectId from the object's SubterraURI.
      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's SubterraURI.
      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

      Object getValue(String key)
      Specified by:
      getValue in interface IHasValues
      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 returns null for collection fields defined by prototype (empty collection is returned instead).
    • setValue

      void setValue(String key, Object value)
      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 interface IHasValues
      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

      void setEnumerationValue(String key, String value)
      Sets the enumeration value of given field.

      Shortcut for combination of getEnumerationOptionForField(String, String) and setValue(String, Object).

      Parameters:
      key - field name (not null)
      value - enumeration value (option id)
      Throws:
      UnknownKeyException - if the field is not valid or of enumeration type
      Since:
      3.1.1
    • getEnumerationOptionForField

      IEnumOption getEnumerationOptionForField(String key, String optionId)
      Returns wrapped enumeration option for given field.
      Parameters:
      key - field name (not null)
      optionId - option id
      Returns:
      wrapped option (null if and only if optionId is null)
      Throws:
      UnknownKeyException - if the field is not valid or of enumeration type
      Since:
      3.1.1
      See Also:
    • getEnumerationTypeForField

      @NotNull Optional<IEnumType> getEnumerationTypeForField(@NotNull String key)
      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

      Set<String> 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

      ICustomField getIncompatibleCustomFieldPrototype(String key)
      Returns:
      prototype of incompatible custom field key
      Since:
      3.5.1
    • getIncompatibleCustomField

      Object getIncompatibleCustomField(String key)
      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

      IStructure createStructureForKey(String key)
      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 for createStructureForKey(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. Returns true if attempt to resolve did fail. If this method returns true 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 associated IDataService. In case the object is already resolved, calling this method does nothing.
      See Also:
    • save

      void save()
      Saves the content of this object into the associated IDataService.
      See Also:
    • update

      void update()
      Reloads the content of this object from the associated IDataService. This reverts any changes done to this object.

      This method is equivalent to forget() followed by resolve().

      See Also:
    • forget

      void forget()
      Forgets the content of this object. The underlying data are disposed, just the SubterraURI 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 call save() on the destination object in order to make all changes persistent.

      The exact implementation is type-dependent.

      Parameters:
      dest - destination object (not null)
      includeKeys - which keys to include when copying (null means all); can also include custom keys
      excludeKeys - which keys to exclude when copying (null means none); can also include custom keys
      includeAllCustomFields - true if all custom fields should also be copied; if false then only those mentioned in includeKeys and not mentioned in excludeKeys are copied
      notCopiedCustomFields - 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 type
      convertedCopiedCustomFields - 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

      IType getFieldType(String key)
      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

      @NotNull IPObjectPermissions can()
      Since:
      3.8.2
    • getFieldLabel

      @NotNull String getFieldLabel(@NotNull String fieldId)
      Returns label of the field regardless if it is a built-in or custom field.
      Since:
      3.9.0