com.ibm.openpages.api.resource

## Interface IGRCObject

- All Superinterfaces:
    IResource
  All Known Subinterfaces:
    IDocument

      public interface IGRCObject
      extends IResource

  Represents a GRC Object instance.

  GRC Objects contain fields as defined by the type definition for this instance. The field values can be read or modified through this interface and then saved. By default all non-computed fields are included when retrieving or creating a new IGRCObject. Using the `GRCObjectFilter.getFieldFilters()` class you can specify to only include specific fields which reduces overall the size of the object and how quickly that data can be fetched within the platform.

  Example of getting and setting a field on a GRC Object:

       // gets the loss event GRC Object
       IGRCObject lossEvent = resourceService.getResource(lossId);
       // gets the Occurrence Date field,
       // knowing this field is of type Date, it is casted from IField to IDateField
       IDateField occurenceDate = (IDateField) lossEvent.getField("OPSS-LossEv:Occurrence Date");
       // sets the value on the IDateField object
       occurenceDate.setValue(new Date());
       // alternatively, use ResourceUtil handy methods for setting field value
       // without casting
       IField recognitionDate = lossEvent.getField("OPSS-LossEv:Recognition Date");
       com.ibm.openpages.api.resource.util.ResourceUtil.setFieldValue(recognitionDate, new Date());
       // persists all the changes to the GRC Object by saving it
       resourceService.saveResource(lossEvent);

  GRC Objects are related to other GRC Objects in OpenPages via associations. A GRC Object can have one or more parents, one or more children and at most one primary parent association. What associations are allowed for a GRC Object depends on its type definition which specifies which relationships to other type definitions are enabled in the OpenPages schema. From the IGRCObject you can access only the direct parents or children association info which provides summary info only of the associations. By default no associations are returned when you get an IGRCObject due to the additional cost of retrieving associations. If you need to retrieve parents or children you can specify which to return, or both, in the `GRCObjectFilter.getAssociationFilter()`

  Example of getting associations from a GRC Object:

       GRCObjectFilter filter = new GRCObjectFilter(configurationService.getCurrentReportingPeriod());
       filter.getAssociationFilter().setIncludeAssociations(IncludeAssociations.PARENT);
       // gets the loss event GRC Object with parent associations
       IGRCObject lossEvent = resourceService.getResource(lossId);
       // gets the parent associations
       List parents = returnObject.getParents();

  See Also:
    `IResourceService`, `ResourceUtil`, `GRCObjectFilter`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addChildren(java.util.List<Id> children)` Adds children for object creation via `IResourceService.saveResource(IResource)`.
    `void` | `addParents(java.util.List<Id> parents)` Adds additional non-primary parents for object creation via `IResourceService.saveResource(IResource)`.
    `java.util.List<Id>` | `getActiveWorkflowIds()` Returns a list of ids for the active workflows associated with this GRC Object.
    `java.util.Map<Id,java.util.List<OpenPagesException>>` | `getCalcLogs()` Returns a Map of calculation error results if there is, such as circular calculation.
    `java.util.List<IAssociationNode>` | `getChildren()` Returns direct children GRC Object associations defined by the AssociationFilter supplied to the `IResourceService.getGRCObject(Id, GRCObjectFilter)` and `IResourceService.getGRCObject(String, GRCObjectFilter)` methods.
    `IField` | `getField(Id fieldId)` Returns a field based on its field definition Id.
    `IField` | `getField(java.lang.String systemName)` Returns a field based on its system name, if it exists.
    `java.util.List<IField>` | `getFields()` Returns the list of fields that compose this object.
    `java.util.List<IAssociationNode>` | `getParents()` Returns direct parent GRC Object associations defined by the AssociationFilter supplied to the `IResourceService.getGRCObject(Id, GRCObjectFilter)` and `IResourceService.getGRCObject(String, GRCObjectFilter)` methods.
    `Id` | `getPrimaryParent()` Returns the primary parent GRCObject Id.
    `ITypeDefinition` | `getType()` Returns the type definition for this object.
    `java.lang.Boolean` | `hasCalcInQueue()` Returns whether the resource has stale field value(s) and it is updated by the asynchronous calculations.
    `java.lang.Boolean` | `hasCalcLogs()` Returns whether the resource has any calculation errors on fields as well as GRC objects.
    `boolean` | `isCheckedOut()` Returns the checkout state of this object.
    `boolean` | `isLocked()` Returns the lock state of this object.
    `void` | `setPrimaryParent(Id grcObjectId)` Sets the primary parent.
    `void` | `setPrimaryParent(IGRCObject grcObject)` Set the primary parent.

    - ### Methods inherited from interface com.ibm.openpages.api.resource.IResource

      `getCreationDate, getCreator, getDescription, getId, getLastModifiedBy, getModifiedDate, getName, getParentFolder, getPath, isFolder, setDescription, setName, setParentFolder`

- - ### Method Detail

    - #### getPrimaryParent

          Id getPrimaryParent()

      Returns the primary parent GRCObject Id.
      Returns:
        the primary parent GRCObject Id if it exists, otherwise null.

    - #### setPrimaryParent

          void setPrimaryParent(IGRCObject grcObject)

      Set the primary parent.
      Parameters:
        `grcObject` - the primary parent

    - #### setPrimaryParent

          void setPrimaryParent(Id grcObjectId)

      Sets the primary parent.
      Parameters:
        `grcObjectId` - the primary parent GRCObject Id

    - #### getType

          ITypeDefinition getType()

      Returns the type definition for this object.
      Returns:
        the type definition for this object

    - #### getField

          IField getField(java.lang.String systemName)

      Returns a field based on its system name, if it exists. The system names are specified by format of "Field Group:Field name".
      Parameters:
        `systemName` - the system name of the field to retrieve
      Returns:
        a field instance if the system exists, otherwise null

    - #### getField

          IField getField(Id fieldId)

      Returns a field based on its field definition Id.
      Parameters:
        `fieldId` - the field Id to retrieve
      Returns:
        a field instance if the Id exists, otherwise null

    - #### getFields

          java.util.List<IField> getFields()

      Returns the list of fields that compose this object.
      Returns:
        the list of fields that compose this object

    - #### getParents

          java.util.List<IAssociationNode> getParents()

      Returns direct parent GRC Object associations defined by the AssociationFilter supplied to the `IResourceService.getGRCObject(Id, GRCObjectFilter)` and `IResourceService.getGRCObject(String, GRCObjectFilter)` methods. Default behavior of the filter is to return none.
      Returns:
        parent associations defined by the AssociationFilter supplied to the IResourceService getGRCObject methods

    - #### addParents

          void addParents(java.util.List<Id> parents)

      Adds additional non-primary parents for object creation via `IResourceService.saveResource(IResource)`. So far this is not supported for updating object via `IResourceService.saveResource(IResource)`.
      Parameters:
        `parents` -
      Since:
        8.2

    - #### getChildren

          java.util.List<IAssociationNode> getChildren()

      Returns direct children GRC Object associations defined by the AssociationFilter supplied to the `IResourceService.getGRCObject(Id, GRCObjectFilter)` and `IResourceService.getGRCObject(String, GRCObjectFilter)` methods. Default behavior of the filter is to return none.
      Returns:
        children associations defined by the AssociationFilter supplied to the IResourceService getGRCObject methods

    - #### addChildren

          void addChildren(java.util.List<Id> children)

      Adds children for object creation via `IResourceService.saveResource(IResource)`. So far this is not supported for updating object via `IResourceService.saveResource(IResource)`.
      Parameters:
        `parents` -
      Since:
        8.2

    - #### getActiveWorkflowIds

          java.util.List<Id> getActiveWorkflowIds()

      Returns a list of ids for the active workflows associated with this GRC Object.
      Returns:
        ids of IWFProcess objects currently active for this GRC Object.

    - #### isCheckedOut

          boolean isCheckedOut()

      Returns the checkout state of this object.
      Returns:
        true if the object is already checked out, otherwise false

    - #### isLocked

          boolean isLocked()

      Returns the lock state of this object.
      Returns:
        true if the object is locked, otherwise false

    - #### hasCalcInQueue

          java.lang.Boolean hasCalcInQueue()

      Returns whether the resource has stale field value(s) and it is updated by the asynchronous calculations. It is only available when the GRC Object is fetched with `GRCObjectFilter.getIncludeCalcStatus()` value true.
      Returns:
      Since:
        8.2

    - #### hasCalcLogs

          java.lang.Boolean hasCalcLogs()

      Returns whether the resource has any calculation errors on fields as well as GRC objects. It is only available when the GRC Object is fetched with `GRCObjectFilter.getIncludeCalcStatus()` value true.
      Returns:
      Since:
        8.2

    - #### getCalcLogs

          java.util.Map<Id,java.util.List<OpenPagesException>> getCalcLogs()

      Returns a Map of calculation error results if there is, such as circular calculation. Note that this map does not include errors for the field calculation. Refer `IField.getCalcLogs()` for the field calculation errors. It is only available when the GRC Object is fetched with `GRCObjectFilter.getIncludeCalcStatus()` value true.
      Returns:
        a Map whose key is Id of the calculation definition which is retrievable by `ITBRuleService`, and value is the list of the errors.
      Since:
        8.2

Licensed Materials - Property of IBM
OpenPages with Watson (PID: 5725-D51)
© Copyright IBM Corporation 2013, 2022. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.