Wednesday, 24 April 2019

CMIS: Object types


Every cmis object has set of properties, these properties defined by the object type. Within an object, each property is uniquely identified by its property definition id.

Object
Type corresponding to thie object
Document
DocumentType
Folder
FolderType
Item
ItemType
Policy
PolicyType
RelationShip
RelationshipType

What are the properties of cmis object?
Every object has id, name, creationDate and who created the document, lastmodification date etc., These properties are used to get the information about the cmis object.

Let’s see it by an example.
TestCmis.java
package com.sample.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.chemistry.opencmis.client.api.Folder;
import org.apache.chemistry.opencmis.client.api.Property;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.enums.BindingType;

public class TestCmis {

 private static String serverURL = "http://localhost:8080/chemistry-opencmis-server-inmemory-1.1.0/browser";
 private static String repositoryId = "A1";

 public static Session getSession() {
  Map<String, String> parameters = new HashMap<>();
  parameters.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value());

  parameters.put(SessionParameter.USER, "");
  parameters.put(SessionParameter.PASSWORD, "");

  parameters.put(SessionParameter.REPOSITORY_ID, repositoryId);
  parameters.put(SessionParameter.BROWSER_URL, serverURL);

  SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
  return sessionFactory.createSession(parameters);
 }

 public static void main(String args[]) {
  Session session = getSession();

  Folder folder = session.getRootFolder();
  
  List<Property<?>> properties = folder.getProperties();
  
  System.out.println("propertyId | displayName | value");
  for(Property<?> property : properties){
   System.out.println(property.getId() + " | " + property.getDisplayName() + " | " + property.getValue());
  }
 
 }

}


Output
propertyId | displayName | value
cmis:objectId | Object Id | 100
cmis:path | Path | /
cmis:allowedChildObjectTypeIds | Allowed Child Object Type Ids | []
cmis:lastModifiedBy | Last Modified By | Admin
cmis:secondaryObjectTypeIds | Secondary Type Ids | []
cmis:objectTypeId | Object Type Id | cmis:folder
cmis:description | Description | null
cmis:createdBy | Created By | Admin
cmis:baseTypeId | Base Type Id | cmis:folder
cmis:parentId | Parent Id | null
cmis:creationDate | Creation Date | java.util.GregorianCalendar[time=1496383132689,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2017,MONTH=5,WEEK_OF_YEAR=22,WEEK_OF_MONTH=1,DAY_OF_MONTH=2,DAY_OF_YEAR=153,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=5,HOUR_OF_DAY=5,MINUTE=58,SECOND=52,MILLISECOND=689,ZONE_OFFSET=0,DST_OFFSET=0]
cmis:changeToken | Change Token | 1496383132690
cmis:name | Name | RootFolder
cmis:lastModificationDate | Last Modification Date | java.util.GregorianCalendar[time=1496383132690,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2017,MONTH=5,WEEK_OF_YEAR=22,WEEK_OF_MONTH=1,DAY_OF_MONTH=2,DAY_OF_YEAR=153,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=5,HOUR_OF_DAY=5,MINUTE=58,SECOND=52,MILLISECOND=690,ZONE_OFFSET=0,DST_OFFSET=0]

The properties of the cmis object are defined by the property definitions.

What are these property definitions?
Property definitions are used to define the property. For example, take the property ‘lastModificationDate’ of the cmis object, it should be well defined like what is the id of the property, how it should be displayed, what is the query name (CMIS support SQL query syntax, to query the repository, query name is used while running queries) of the property, what is the data type of the property, description of the property, whether user can able to update this property or not etc., Following table summarizes all the attributes of the property ‘lastModificationDate’ of the cmis object.

Attribute
Value
Id
cmis:lastModificationDate
display name
Last Modification Date
description
Last Modification Date
local name
cmis:lastModificationDate
local namespace
Null
query name
cmis:lastModificationDate
property type
DATETIME
cardinality
SINGLE
choice list
Null
default value
Null
is inherited
False
is open choice
Null
is queryable
True
is required
False
updatability
READONLY
extensions
Null

Following program prints all the property definitions of the type FolderType.


TestCmis.java
package com.sample.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.chemistry.opencmis.client.api.Folder;
import org.apache.chemistry.opencmis.client.api.FolderType;
import org.apache.chemistry.opencmis.client.api.Property;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
import org.apache.chemistry.opencmis.commons.enums.BindingType;

public class TestCmis {

 private static String serverURL = "http://localhost:8080/chemistry-opencmis-server-inmemory-1.1.0/browser";
 private static String repositoryId = "A1";

 public static Session getSession() {
  Map<String, String> parameters = new HashMap<>();
  parameters.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value());

  parameters.put(SessionParameter.USER, "");
  parameters.put(SessionParameter.PASSWORD, "");

  parameters.put(SessionParameter.REPOSITORY_ID, repositoryId);
  parameters.put(SessionParameter.BROWSER_URL, serverURL);

  SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
  return sessionFactory.createSession(parameters);
 }

 public static void main(String args[]) {
  Session session = getSession();

  Folder folder = session.getRootFolder();

  FolderType folderType = folder.getFolderType();

  Map<String, PropertyDefinition<?>> propertyDefintions = folderType.getPropertyDefinitions();

  for (String key : propertyDefintions.keySet()) {
   PropertyDefinition propDefinition = propertyDefintions.get(key);
   System.out.println(propDefinition);
  }

 }

}


Output
Property Definition [id=cmis:name, display name=Name, description=Name, local name=cmis:name, local namespace=null, query name=cmis:name, property type=STRING, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=true, updatability=READWRITE][extensions=null]
Property Definition [id=cmis:description, display name=Description, description=Description, local name=cmis:description, local namespace=null, query name=cmis:description, property type=STRING, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=false, is required=false, updatability=READWRITE][extensions=null]
Property Definition [id=cmis:objectId, display name=Object Id, description=Object Id, local name=cmis:objectId, local namespace=null, query name=cmis:objectId, property type=ID, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null]
Property Definition [id=cmis:baseTypeId, display name=Base Type Id, description=Base Type Id, local name=cmis:baseTypeId, local namespace=null, query name=cmis:baseTypeId, property type=ID, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null]
Property Definition [id=cmis:objectTypeId, display name=Object Type Id, description=Object Type Id, local name=cmis:objectTypeId, local namespace=null, query name=cmis:objectTypeId, property type=ID, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=true, updatability=ONCREATE][extensions=null]
Property Definition [id=cmis:secondaryObjectTypeIds, display name=Secondary Type Ids, description=Secondary Type Ids, local name=cmis:secondaryObjectTypeIds, local namespace=null, query name=cmis:secondaryObjectTypeIds, property type=ID, cardinality=MULTI, choice list=null, default value=[], is inherited=false, is open choice=null, is queryable=true, is required=false, updatability=READWRITE][extensions=null]
Property Definition [id=cmis:createdBy, display name=Created By, description=Created By, local name=cmis:createdBy, local namespace=null, query name=cmis:createdBy, property type=STRING, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null]
Property Definition [id=cmis:creationDate, display name=Creation Date, description=Creation Date, local name=cmis:creationDate, local namespace=null, query name=cmis:creationDate, property type=DATETIME, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null]
Property Definition [id=cmis:lastModifiedBy, display name=Last Modified By, description=Last Modified By, local name=cmis:lastModifiedBy, local namespace=null, query name=cmis:lastModifiedBy, property type=STRING, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null]
Property Definition [id=cmis:lastModificationDate, display name=Last Modification Date, description=Last Modification Date, local name=cmis:lastModificationDate, local namespace=null, query name=cmis:lastModificationDate, property type=DATETIME, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=true, is required=false, updatability=READONLY][extensions=null]
Property Definition [id=cmis:changeToken, display name=Change Token, description=Change Token, local name=cmis:changeToken, local namespace=null, query name=cmis:changeToken, property type=STRING, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=false, is required=false, updatability=READONLY][extensions=null]
Property Definition [id=cmis:parentId, display name=Parent Id, description=Parent Id, local name=cmis:parentId, local namespace=null, query name=cmis:parentId, property type=ID, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=false, is required=false, updatability=READONLY][extensions=null]
Property Definition [id=cmis:path, display name=Path, description=Path, local name=cmis:path, local namespace=null, query name=cmis:path, property type=STRING, cardinality=SINGLE, choice list=null, default value=null, is inherited=false, is open choice=null, is queryable=false, is required=false, updatability=READONLY][extensions=null]
Property Definition [id=cmis:allowedChildObjectTypeIds, display name=Allowed Child Object Type Ids, description=Allowed Child Object Type Ids, local name=cmis:allowedChildObjectTypeIds, local namespace=null, query name=cmis:allowedChildObjectTypeIds, property type=ID, cardinality=MULTI, choice list=null, default value=[], is inherited=false, is open choice=null, is queryable=false, is required=false, updatability=READONLY][extensions=null]

Each object-type is uniquely identified within a repository by a system-assigned and immutable object-type identifier, which is of type Id.

For example, following table sumarizes base object types and their ids. Next section talks about base object ids.

Object Type Id
Display Name
Implemented Class
cmis:secondary
Secondary
SecondaryTypeImpl
cmis:item
Item
ItemTypeImpl
cmis:relationship
Relationship
RelationshipTypeImpl
cmis:policy
Policy
PolicyTypeImpl
cmis:folder
Folder
FolderTypeImpl
cmis:document
Document
DocumentTypeImpl

Can I able to create custom types?

Yes, depends on the repository support level, you can crate new custom types by extending the existing base types. You can alslo perform updation and deletion of custom types. I will explain how to create new custom types in my later posts.


Previous                                                 Next                                                 Home

No comments:

Post a Comment