Managing Document Types

A document type object consists of the Document Type ID and the Document Type Schema Location, determined via the class DocumentType.

   public DocumentType(String documentTypeId, String schemaLocation)
   {
      super();
      this.documentTypeId = documentTypeId;
      this.schemaLocation = schemaLocation;
   }

The following sections describe options for managing Document Types:

For general concepts on working with Document Types in the Infinity Process Platform, refer to chapter Document Types of the Concepts documentation.

Setting and retrieving the Meta Data Structure of a Document

The DocumentType class provides the following access on the meta data structure of a document:

Getting the Document Type Id

To retrieve the qualified Id of a particular document type in the repository, use method getDocumentTypeId():

   public String getDocumentTypeId()
   {
      return documentTypeId;
   }

Setting the qualified Id of a specific Document Type

To set the unique qualified Id of a particular document type within the repository, use setDocumentTypeId(String documentTypeId):

   public void setDocumentTypeId(String documentTypeId)
   {
      this.documentTypeId = documentTypeId;
   }

Getting the Schema Location

To retrieve the identifier for the schema location in the repository, use method getSchemaLocation():

   public String getSchemaLocation()
   {
      return schemaLocation;
   }

Setting the Schema Location

Use setSchemaLocation(String schemaLocation) to set the identifier for exactly one XSD schema location in the repository:

   public void setSchemaLocation(String schemaLocation)
   {
      this.schemaLocation = schemaLocation;
   }}

Retrieving the Document Type of a Document

To retrieve the document type of a document, the following method of the Document interface is used:

DocumentType getDocumentType();

Retrieving Document Type Objects of a Model

The class DocumentTypeUtils provides the following method to create DocumentType objects based on the Document and DocumentList data having a TypeDeclaration assigned in a given model:

List<DocumentType> getDeclaredDocumentTypes(DeployedModel model)

Parameter model of type DeployedModel determines the model to search for declared DocumentTypes. The method returns a list of DocumentTypes that are declared within the specified model. Note that using this method does not resolve the DocumentType of Document or DocumentList data referencing a TypeDeclaration from an external model reference.

Retrieving Document Types Used in Specified Data

To retrieve a set of Document Types used in a specified data, the following method is provided:

public static Set<DocumentType> getDocumentTypesFromData(DeployedModel model,
         List<Data> dataList)

Parameters are the deployed model and a list of specified data. The method returns a set of Document Types that are used in the specified data.

Retrieving Data of Type Document or DocumentList

To retrieve data which are of type Document or DocumentList and having a reference to an external TypeDefinition, the class DocumentTypeUtils provides the following method:

List>Data> getReferencedDocumentData(DeployedModel model)

Parameter model of type DeployedModel determines the model to search for data referencing DocumentTypes. The method returns a list of of data referencing DocumentTypes.

Retrieving Data Using Type Definition Defined by Given Document Type

You can retrieve data from a given model, which uses the type definition defined by a given Document Type, via the following method:

public static List<Data> getDataUsingDocumentType(DeployedModel model,
         DocumentType documentType)

Parameters are the model containing the data and type definitions as well as the Document Type to retrieve the matching data for.

Use Cases

Retrieving Documents

To retrieve document(s) using the Document Management Service, the following workflow is performed:

  1. Use one of the following methods of the DocumentManagementService using ID(s), namePattern or an xpathQuery accordingly of the document(s) you want to retrieve: For details on these methods, refer to chapter Managing Documents and Folders.
  2. The system retrieves the document and the corresponding Document Type, if existing, from the Document Repository.
  3. The document is returned to the user.
  4. In case the given document ID is unknown, a DocumentManagementServiceException occurs.

Retrieving the Document Type of a Document

The workflow to retrieve the document type of a document is as follows:

  1. Retrieve a document object from the Document Management Service as described in section Retrieving Documents.
  2. Retrieve the Document Type from the document's object via the following method provided by the DocumentInfo interface:
    DocumentType getDocumentType();

Retrieving the XSD Schema of a Document Type

You can retrieve the XSD schema for a schema location of a document type serialized into a byte[] in the following way:

  1. Retrieve the Document Type from the document's object as described in section Retrieving the Document Type of a Document.
  2. Retrieve the Document Type Schema Location from the Document Type via getSchemaLocation().
  3. Pass the Document Type Schema Location to the DocumentManagementService in order to get the corresponding XSD by using the following method:
    @ExecutionPermission(
        id=ExecutionPermission.Id.readModelData,
        defaults={ExecutionPermission.Default.ALL})
            byte[] getSchemaDefinition(String schemaLocation)
            throws ObjectNotFoundException;
    If the specified schema location cannot be found, an ObjectNotFoundException is thrown. To use this method, you need the permission to read model data.
  4. The system resolves the Document Type Schema Location in the Document Repository and fetches the corresponding XSD from the Document Repository.
  5. The system returns the fetched XSD to the user.

Retrieving the Document Type for a fully-qualified Structured Data Type

If the fully-qualified Structured Data Type is known and it is prepared to be used as Document Type, you can create the Document Type in the following way:

DocumentInfo docInfo = DmsUtils.createDocumentInfo("xyz");
docInfo.setDocumentType(new DocumentType("{http://www.infinity.com/bpm/model/Echos/CompanyDocumentType}CompanyDocumentType", null));

To create a Document Type for which the schema location part will be resolved internally, you can use the following code:

TypeDeclaration typeDeclaration = model.getTypeDeclaration("Composite1");
      
if (typeDeclaration != null)
{
   XpdlType xpdlType = typeDeclaration.getXpdlType();
   if (xpdlType instanceof ExternalReference)
   {
      // external schemas use xref as documentTypeId
      String documentTypeId = ((ExternalReference) xpdlType).getXref();
     
      documentType = new DocumentType(documentTypeId, null);
   }
   else if (xpdlType instanceof SchemaType)
   {
      // internal schemas use a composition of targetNamespace and typeDeclarationId
      XSDSchema xsdSchema = ((SchemaType) xpdlType).getSchema();
      QName documentTypeIdQname = new QName(xsdSchema.getTargetNamespace(), typeDeclaration.getId());
      documentType = new DocumentType(documentTypeIdQname.toString(), null);
   }
}

Assigning a Document's Document Type

There are two options to assign a Document Type to a document:

  1. Assigning by Document Type ID
  2. Assigning by Document Type ID and schema location

Assigning by Document Type ID

To assign the Document Type by a Document Type ID, do the following:

  1. Retrieve a document object from the DMS as described in section Retrieving a Document.
  2. Assign a Document Type to the document by setting the Document Type ID via the DocumentInfo method
    setDocumentType(DocumentType documentType);
  3. Pass the document object to the DocumentManagementService in order to apply changes (using updateDocument).
  4. The system links the document to the Type Declaration the given Document Type ID points to. Refer to section Linking a Document Type for details.

Assigning by Document Type ID and schema location

Another option to assign a Document Type to the document is to set the Document Type ID and the Document Type Schema Location in order to specify a particular Document Type version.

Therefore, use the following method of the DocumentInfo interface:

void setDocumentType(DocumentType documentType)

The parameter is an object of type DocumentType, containing the Document Type ID and Document Type schema location.

Deleting a Document's Document Type

This Use Case describes how to delete a Document Type from a document using the Document Management Service.

  1. Retrieve a document object from the DMS as described in section Retrieving a Document.
  2. Reset the Document Type on the document object, by using the setDocumentType method of the DocumentInfo with parameter null:
    setDocumentType(null);
  3. Pass the document object to the DocumentManagementService in order to apply changes (using updateDocument).
  4. The system unlinks the document from the Type Declaration (see section Unlinking a Document Type).

Updating a Document's Document Type

To update a Document Type of a document, the following workflow is necessary:

  1. Retrieve a document object from the DMS as described in section Retrieving a Document.
  2. Change the Document Type on the document object by changing the Document Type ID by using the setDocumentType(DocumentType documentType) method of the DocumentInfo.
  3. Pass the document object to the DocumentManagementService in order to apply changes (using updateDocument).
  4. The system unlinks the document from the current Type Declaration. Refer to section Unlinking a Document Type for details.
  5. The system links the document to the Type Declaration the given Document Type ID points to. Refer to section Linking a Document Type for details.

Another option to change the Document Type on the document object is to change the Document Type ID and the Document Type Schema Location in order to specify a particular Document Type version.

This section describes how a document is linked to a Type Declaration in the Document Repository.

  1. Get a document object with a Document Type ID set, like described in section Retrieving Documents.
  2. The Type Declaration is resolved in the Document Repository the Document Type ID points to. The Document Type Schema Location of this Type Declaration is determined by the schema location derived from the Type Declaration in a currently active model the Document Type ID refers to.
  3. The system links the given document in the Document Repository to the Type Declaration.

Behavior in specific cases

This section describes how a document is unlinked from a Type Declaration in the Document Repository.

  1. Get a document object with no Document Type set. Refer to section Retrieving Documents for details on getting documents.
  2. The existing link between the document and the Type Declaration is removed in the Document Repository.
  3. Even if no document points to the Type Declaration and to no other Type Declaration in the enclosing XSD any longer, the enclosing XSD will be retained in the Document Repository.

In case the given document is not linked to a Type Declaration, the document unlinking is rejected with an appropriate error message.

The Infinity Process Platform QueryService provides functionality to filter for DocumentQuery types, which can be used to search for documents a particular Document Type, Document Type ID or Document Type Schema Location adheres to.

Filtering on Document Type

  1. Specify the search for documents a particular Document Type adheres to by setting the wanted Document Type ID (DOCUMENT_TYPE_ID) as well as the wanted Document Type Schema Location (DOCUMENT_TYPE_SCHEMA_LOCATION) as a predicate in a Document Query.
  2. Pass the Document Query to the system.
  3. The system collects all documents that maintain a link to the Type Declaration the given Document Type points to.
  4. The system returns all collected documents to the user.

Filtering on Document Type ID

  1. Specify the search for documents a particular Document Type ID adheres to by setting the wanted Document Type ID (DOCUMENT_TYPE_ID) as a predicate in a Document Query.
  2. Pass the Document Query to the system.
  3. The system collects all documents that maintain a link to the Type Declaration the given Document Type points to.
  4. The system returns all collected documents to the user.
public static final FilterableAttribute DOCUMENT_TYPE_ID = new Attribute(
         "attributesTypeId");

Filtering on Document Type Schema Location

  1. Specify the search for documents a particular Document Type adheres to by setting the wanted Document Type Schema Location (DOCUMENT_TYPE_SCHEMA_LOCATION) as a predicate in a Document Query.
  2. Pass the Document Query to the system.
  3. The system collects all documents that maintain a link to the Type Declaration the given Document Type points to.
  4. The system returns all collected documents to the user.
public static final FilterableAttribute DOCUMENT_TYPE_SCHEMA_LOCATION = new Attribute(
         "attributesTypeSchemaLocation");

Replicating the Document Types' XSDs to the Document Repository

This section describes how the XSD of Document Types is replicated from the XPDL models to the Document Repository during model deployment:

  1. The system collects all XSDs that contain Type Declarations that are used as Document Types in the models being deployed, for example:
  2. The system inserts the transitive closure of all collected XSDs into the Document Repository.

In case an external XSD cannot be found, the model deployment is rejected with an appropriate error message.