Wednesday, 24 April 2019

Cmis: getTypeChildren: Get type children of a type


Session interface provides 'getTypeChildren' method, it is used to get the type children of a type.

ItemIterable<ObjectType> getTypeChildren(String typeId, boolean includePropertyDefinitions)
Gets the type children of a type.

Parameter
Description
typeId
If typeId is null, it returns all the base types, else it returns the type children of given type.
includePropertyDefinitions
If it is true, the result includes the property definitions, else not.

Following statement gets all the base types.
ItemIterable<ObjectType> baseObjectTypes = session.getTypeChildren(null, false);

Following application prints all the base types.

TestCmis.java
package com.sample.util;

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

import org.apache.chemistry.opencmis.client.api.ItemIterable;
import org.apache.chemistry.opencmis.client.api.ObjectType;
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();

  ItemIterable<ObjectType> baseObjectTypes = session.getTypeChildren(null, false);

  for (ObjectType objType : baseObjectTypes) {
   System.out.println(objType);
  }

 }

}


Output
Type Definition [base id=CMIS_SECONDARY, id=cmis:secondary, display Name=Secondary, description=Secondary, local name=cmis:secondary, local namespace=http://apache.org, query name=cmis:secondary, parent id=null, is controllable ACL=false, is controllable policy=false, is creatable=false, is fileable=false, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=false, canDelete=false][extensions=null]][extensions=null]
Type Definition [base id=CMIS_ITEM, id=cmis:item, display Name=Item, description=Item, local name=cmis:item, local namespace=http://apache.org, query name=cmis:item, parent id=null, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=true, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=false, canDelete=false][extensions=null]][extensions=null]
Type Definition [base id=CMIS_RELATIONSHIP, id=cmis:relationship, display Name=Relationship, description=Relationship, local name=cmis:relationship, local namespace=http://apache.org, query name=cmis:relationship, parent id=null, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=false, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=false, canDelete=false][extensions=null]][extensions=null]
Type Definition [base id=CMIS_POLICY, id=cmis:policy, display Name=Policy, description=Policy, local name=cmis:policy, local namespace=http://apache.org, query name=cmis:policy, parent id=null, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=false, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=false, canDelete=false][extensions=null]][extensions=null]
Type Definition [base id=CMIS_FOLDER, id=cmis:folder, display Name=Folder, description=Folder, local name=cmis:folder, local namespace=http://apache.org, query name=cmis:folder, parent id=null, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=true, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=false, canDelete=false][extensions=null]][extensions=null]
Type Definition [base id=CMIS_DOCUMENT, id=cmis:document, display Name=Document, description=Document, local name=cmis:document, local namespace=http://apache.org, query name=cmis:document, parent id=null, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=true, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=false, canDelete=false][extensions=null]][extensions=null]

Following statement gets all the child types for "cmis:document".
ItemIterable<ObjectType> baseObjectTypes = session.getTypeChildren("cmis:document", false);

Following is the complete working application.


TestCmis.java
package com.sample.util;

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

import org.apache.chemistry.opencmis.client.api.ItemIterable;
import org.apache.chemistry.opencmis.client.api.ObjectType;
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();

  ItemIterable<ObjectType> baseObjectTypes = session.getTypeChildren("cmis:document", false);

  for (ObjectType objType : baseObjectTypes) {
   System.out.println(objType);
  }

 }

}


Output
Type Definition [base id=CMIS_DOCUMENT, id=MyDocType1, display Name=My Type 1 Level 1, description=Builtin InMemory type definition MyDocType1, local name=MyDocType1, local namespace=http://apache.org, query name=MyDocType1, parent id=cmis:document, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=true, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=true, canDelete=true][extensions=null]][extensions=null]
Type Definition [base id=CMIS_DOCUMENT, id=MyDocType2, display Name=My Type 2 Level 1, description=Builtin InMemory type definition MyDocType2, local name=MyDocType2, local namespace=http://apache.org, query name=MyDocType2, parent id=cmis:document, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=true, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=true, canDelete=true][extensions=null]][extensions=null]
Type Definition [base id=CMIS_DOCUMENT, id=ComplexType, display Name=Complex type with properties, Level 1, description=Builtin InMemory type definition ComplexType, local name=ComplexType, local namespace=http://apache.org, query name=ComplexType, parent id=cmis:document, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=true, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=true, canDelete=true][extensions=null]][extensions=null]
Type Definition [base id=CMIS_DOCUMENT, id=DocumentTopLevel, display Name=Document type with properties, Level 1, description=Builtin InMemory type definition DocumentTopLevel, local name=DocumentTopLevel, local namespace=http://apache.org, query name=DocumentTopLevel, parent id=cmis:document, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=true, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=true, canDelete=true][extensions=null]][extensions=null]
Type Definition [base id=CMIS_DOCUMENT, id=VersionableType, display Name=Versioned Type, description=Builtin InMemory type definition VersionableType, local name=VersionableType, local namespace=http://apache.org, query name=VersionableType, parent id=cmis:document, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=true, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=true, canDelete=true][extensions=null]][extensions=null]
Type Definition [base id=CMIS_DOCUMENT, id=BigContentFakeType, display Name=BigContentFakeType, description=Builtin InMemory type definition for big content streams. Content is ignored and replaced by random bytes, local name=BigContentFakeType, local namespace=http://apache.org, query name=BigContentFakeType, parent id=cmis:document, is controllable ACL=true, is controllable policy=true, is creatable=true, is fileable=true, is fulltext indexed=false, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=TypeMutability [canCreate=true, canUpdate=true, canDelete=true][extensions=null]][extensions=null]
Type Definition [base id=CMIS_DOCUMENT, id=audioFile, display Name=Audio File, description=Audio Content (compressed or uncompressed), local name=audioFile, local namespace=apache, query name=AUDIO_FILE, parent id=cmis:document, is controllable ACL=true, is controllable policy=false, is creatable=true, is fileable=true, is fulltext indexed=true, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=null][extensions=[TypeMutability []: [create []: true, update []: true, delete []: true]]]
Type Definition [base id=CMIS_DOCUMENT, id=emailDocument, display Name=Email Document, description=Document of type Email, local name=emailDocument, local namespace=apache, query name=EMAIL_DOCUMENT, parent id=cmis:document, is controllable ACL=true, is controllable policy=false, is creatable=true, is fileable=true, is fulltext indexed=true, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=null][extensions=[TypeMutability []: [create []: true, update []: true, delete []: true]]]
Type Definition [base id=CMIS_DOCUMENT, id=exifImage, display Name=EXIF Image, description=Image with EXIF tags, local name=exifImage, local namespace=apache, query name=EXIF_IMAGE, parent id=cmis:document, is controllable ACL=true, is controllable policy=false, is creatable=true, is fileable=true, is fulltext indexed=true, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=null][extensions=[TypeMutability []: [create []: true, update []: true, delete []: true]]]
Type Definition [base id=CMIS_DOCUMENT, id=officeDocument, display Name=Office Document, description=Document of type Office, local name=officeDocument, local namespace=apache, query name=OFFICE_DOCUMENT, parent id=cmis:document, is controllable ACL=true, is controllable policy=false, is creatable=true, is fileable=true, is fulltext indexed=true, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=null][extensions=[TypeMutability []: [create []: true, update []: true, delete []: true]]]
Type Definition [base id=CMIS_DOCUMENT, id=videoFile, display Name=Video File, description=Video Movies, local name=videoFile, local namespace=apache, query name=VIDEO_FILE, parent id=cmis:document, is controllable ACL=true, is controllable policy=false, is creatable=true, is fileable=true, is fulltext indexed=true, is included in supertype query=true, is queryable=true, property definitions={}, typeMutability=null][extensions=[TypeMutability []: [create []: true, update []: true, delete []: true]]]





Previous                                                 Next                                                 Home

No comments:

Post a Comment