Querying Data

You can use the DataQuery class to evaluate if specific data (document, document list, folder, folder list) is used in a process definition. To identify the usage of data in a process definition, the following elements are queried:

Using the data query you can retrieve data by specific criteria. It can be used to find data which is used in a process and can also be limited to a specific data type and document type.

Retrieving All Data

Use the following QueryService.java method to retrieve all data.

/**
    * Retrieves all data satisfying the criteria specified in the
    * provided query.
    *
    * @param query The DataQuery.
    * @return A list of Data objects.
*/
   @ExecutionPermission(
         id=ExecutionPermission.Id.readModelData,
         defaults={ExecutionPermission.Default.ALL})
   DataQueryResult getAllData(DataQuery query);

Note that in case of multi-model scenario, referenced data is not retrieved through getAllData method.

Retrieving All Data Used in a Model

Use the following DataQuery.java factory method to find the data used in the specified model.

   /**
    * Creates a query for finding all data used in the specified model.
    *
    * @param modelOid The model to retrieve the data from.
    * @return The configured query.
    */
   public static DataQuery findAllForModel(long modelOid)

Retrieving All Data Used in a Model and Process

To retrieve all data used in a model and process:

/**
    * Creates a query for finding all data used in a specified model and process.
    *
    * @param modelOid The model to retrieve the data from.
    * @param processId The process to search used data for.
    * @return The configured query.
    */
   public static DataQuery findUsedInProcess(long modelOid, String processId)

Retrieving Data of Specified Type

To find data of specified type used in a specified model and process.

   /**
    * Creates a query for finding data of a specified type (see {@link DataTypeConstants}) used in a specified model and process.
    *
    * @param modelOid The model to retrieve the data from.
    * @param processId The process to search used data for.
    * @param dataTypeId The data type from {@link DataTypeConstants}.
    * @return The configured query.
    *
    * @see DataTypeConstants
    */
   public static DataQuery findUsedInProcessHavingDataType(long modelOid,
         String processId, String dataTypeId)

Finding Document Data for Specified Document Type

To find document data used in a specified process having the specified document type assigned.

/**
    * Creates a query for finding document data used in a specified process having the specified {@link DocumentType} assigned.
    *
    * @param modelOid The model to retrieve the data from.
    * @param processId The process to search used data for.
    * @param documentType The document type to search used data for.
    * @return The configured query.
    *
    * @see DocumentType
    * @see DocumentTypeUtils
    */
   public static DataQuery findUsedInProcessHavingDocumentWithDocType(long modelOid,
         String processId, DocumentType documentType)

Finding Document Data for Non-specific Document Type

To find document data used in a specified process having no specific document type assigned. The Default document type is returned.

   /**
    * Creates a query for finding document data used in a specified process having no specific document type assigned.
    *
    * @param modelOid The model to retrieve the data from.
    * @param processId The process to search used data for.
    * @return The configured query.
    */
   public static DataQuery findUsedInProcessHavingDocumentWithoutDocType(
         long modelOid, String processId)