Wednesday 24 April 2019

CMIS: Check the query capabilities of the repository


RepositoryCapabilities provides 'getQueryCapability()', it is used to check the level of query capability support by repository.

Possible values are none, metadataonly, fulltextonly, bothseparate, bothcombined.

none: No queries of any kind can be fulfilled.

metadataonly : Only queries that filter based on object properties can be fulfilled. Specifically, the CONTAINS() predicate function is not supported.

fulltextonly: Only queries that filter based on the full-text content of documents can be fulfilled. Specifically, only the CONTAINS() predicate function can be included in the WHERE clause.

bothseparate: The repository can fulfill queries that filter EITHER on the full-text content of documents OR on their properties, but NOT if both types of filters are included in the same query.

bothcombined: The repository can fulfill queries that filter on both the full-text content of documents and their properties in the same query.

Example
                  CapabilityQuery queryCapability = repoInfo.getCapabilities().getQueryCapability();
                 
                  if(queryCapability == null){
                           System.out.println("Repository is not providing any value");
                  }else if(CapabilityQuery.NONE == queryCapability){
                           System.out.println("Query capability is not supported");
                  }else if(CapabilityQuery.METADATAONLY == queryCapability){
                           System.out.println("Support queries that filter based on object properties");
                  }else if(CapabilityQuery.FULLTEXTONLY == queryCapability){
                           System.out.println("Support queries that filter based on the full-text content of documents");
                  }else if(CapabilityQuery.BOTHSEPARATE == queryCapability){
                           System.out.println("Support queries that filter EITHER on the full-text content of documents OR on their properties, but NOT if both types of filters are included in the same query.");
                  }else if(CapabilityQuery.BOTHCOMBINED == queryCapability){
                           System.out.println("Support that filter on both the full-text content of documents and their properties in the same query.");
                  }


TestCmis.java
package com.sample.util;

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

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.data.RepositoryInfo;
import org.apache.chemistry.opencmis.commons.enums.BindingType;
import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;

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();

  RepositoryInfo repoInfo = session.getRepositoryInfo();

  CapabilityQuery queryCapability = repoInfo.getCapabilities().getQueryCapability();
  
  if(queryCapability == null){
   System.out.println("Repository is not providing any value");
  }else if(CapabilityQuery.NONE == queryCapability){
   System.out.println("Query capability is not supported");
  }else if(CapabilityQuery.METADATAONLY == queryCapability){
   System.out.println("Support queries that filter based on object properties");
  }else if(CapabilityQuery.FULLTEXTONLY == queryCapability){
   System.out.println("Support queries that filter based on the full-text content of documents");
  }else if(CapabilityQuery.BOTHSEPARATE == queryCapability){
   System.out.println("Support queries that filter EITHER on the full-text content of documents OR on their properties, but NOT if both types of filters are included in the same query.");
  }else if(CapabilityQuery.BOTHCOMBINED == queryCapability){
   System.out.println("Support that filter on both the full-text content of documents and their properties in the same query.");
  }

 }

}

Output
Support that filter on both the full-text content of documents and their properties in the same query.



Previous                                                 Next                                                 Home

No comments:

Post a Comment