Java Code Examples for org.apache.chemistry.opencmis.commons.enums.CapabilityJoin

The following examples show how to use org.apache.chemistry.opencmis.commons.enums.CapabilityJoin. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: iaf   Source File: CmisUtils.java    License: Apache License 2.0 6 votes vote down vote up
private static RepositoryCapabilities xml2capabilities(Element cmisResult) {
	Element repositoryCapabilitiesXml = XmlUtils.getFirstChildTag(cmisResult, "repositoryCapabilities");
	RepositoryCapabilitiesImpl repositoryCapabilities = new RepositoryCapabilitiesImpl();

	repositoryCapabilities.setAllVersionsSearchable(CmisUtils.parseBooleanAttr(repositoryCapabilitiesXml, "allVersionsSearchable"));
	repositoryCapabilities.setSupportsGetDescendants(CmisUtils.parseBooleanAttr(repositoryCapabilitiesXml, "supportsGetDescendants"));
	repositoryCapabilities.setSupportsGetFolderTree(CmisUtils.parseBooleanAttr(repositoryCapabilitiesXml, "supportsGetFolderTree"));
	repositoryCapabilities.setSupportsMultifiling(CmisUtils.parseBooleanAttr(repositoryCapabilitiesXml, "supportsMultifiling"));
	repositoryCapabilities.setIsPwcSearchable(CmisUtils.parseBooleanAttr(repositoryCapabilitiesXml, "isPwcSearchable"));
	repositoryCapabilities.setIsPwcUpdatable(CmisUtils.parseBooleanAttr(repositoryCapabilitiesXml, "isPwcUpdatable"));
	repositoryCapabilities.setSupportsUnfiling(CmisUtils.parseBooleanAttr(repositoryCapabilitiesXml, "supportsUnfiling"));
	repositoryCapabilities.setSupportsVersionSpecificFiling(CmisUtils.parseBooleanAttr(repositoryCapabilitiesXml, "supportsVersionSpecificFiling"));
	repositoryCapabilities.setCapabilityAcl(CapabilityAcl.valueOf(repositoryCapabilitiesXml.getAttribute("aclCapability")));
	repositoryCapabilities.setCapabilityChanges(CapabilityChanges.valueOf(repositoryCapabilitiesXml.getAttribute("changesCapability")));
	repositoryCapabilities.setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates.valueOf(repositoryCapabilitiesXml.getAttribute("contentStreamUpdatesCapability")));
	repositoryCapabilities.setCreatablePropertyTypes(CmisUtils.xml2creatablePropertyTypes(repositoryCapabilitiesXml));
	repositoryCapabilities.setCapabilityJoin(CapabilityJoin.valueOf(repositoryCapabilitiesXml.getAttribute("joinCapability")));
	repositoryCapabilities.setNewTypeSettableAttributes(CmisUtils.xml2newTypeSettableAttributes(repositoryCapabilitiesXml));
	repositoryCapabilities.setCapabilityOrderBy(CapabilityOrderBy.valueOf(repositoryCapabilitiesXml.getAttribute("orderByCapability")));
	repositoryCapabilities.setCapabilityQuery(CapabilityQuery.valueOf(repositoryCapabilitiesXml.getAttribute("queryCapability")));
	repositoryCapabilities.setCapabilityRendition(CapabilityRenditions.valueOf(repositoryCapabilitiesXml.getAttribute("renditionsCapability")));

	return repositoryCapabilities;
}
 
Example 2
private ResultSet executeQueryImpl(SearchParameters searchParameters)
    {
        CMISQueryOptions options = CMISQueryOptions.create(searchParameters);
        options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);

        CapabilityJoin joinSupport = CapabilityJoin.INNERANDOUTER;
        BaseTypeId[] validScopes = CmisFunctionEvaluationContext.ALFRESCO_SCOPES;
        CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext();
        functionContext.setCmisDictionaryService(cmisDictionaryService);
        functionContext.setValidScopes(validScopes);

        CMISQueryParser parser = new CMISQueryParser(options, cmisDictionaryService, joinSupport);
        org.alfresco.repo.search.impl.querymodel.Query queryModelQuery = parser.parse(new DBQueryModelFactory(), functionContext);

// TODO: Remove as this appears to be dead code
//        // build lucene query
//        Set<String> selectorGroup = null;
//        if (queryModelQuery.getSource() != null)
//        {
//            List<Set<String>> selectorGroups = queryModelQuery.getSource().getSelectorGroups(functionContext);
//            if (selectorGroups.size() == 0)
//            {
//                throw new UnsupportedOperationException("No selectors");
//            }
//            if (selectorGroups.size() > 1)
//            {
//                throw new UnsupportedOperationException("Advanced join is not supported");
//            }
//            selectorGroup = selectorGroups.get(0);
//        }
//
        QueryEngineResults results = queryEngine.executeQuery(queryModelQuery, options, functionContext);
        ResultSet resultSet = results.getResults().values().iterator().next();
        return resultSet;
    }
 
Example 3
private Pair<Query, QueryEngineResults> executeQueryUsingEngine(QueryEngine queryEngine, CMISQueryOptions options)
{
    CapabilityJoin joinSupport = getJoinSupport();
    if (options.getQueryMode() == CMISQueryOptions.CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS)
    {
        joinSupport = CapabilityJoin.INNERANDOUTER;
    }

    // TODO: Refactor to avoid duplication of valid scopes here and in
    // CMISQueryParser

    BaseTypeId[] validScopes = (options.getQueryMode() == CMISQueryMode.CMS_STRICT) ? CmisFunctionEvaluationContext.STRICT_SCOPES
            : CmisFunctionEvaluationContext.ALFRESCO_SCOPES;
    CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext();
    functionContext.setCmisDictionaryService(cmisDictionaryService);
    functionContext.setNodeService(nodeService);
    functionContext.setValidScopes(validScopes);

    CMISQueryParser parser = new CMISQueryParser(options, cmisDictionaryService, joinSupport);
    QueryConsistency queryConsistency = options.getQueryConsistency();
    if (queryConsistency == QueryConsistency.DEFAULT)
    {
    	options.setQueryConsistency(QueryConsistency.EVENTUAL);
    }
    
    Query query = parser.parse(queryEngine.getQueryModelFactory(), functionContext);
    QueryEngineResults queryEngineResults = queryEngine.executeQuery(query, options, functionContext);
    
    return new Pair<Query, QueryEngineResults>(query, queryEngineResults);
}
 
Example 4
public CMISQueryParser(CMISQueryOptions options, CMISDictionaryService cmisDictionaryService,
        CapabilityJoin joinSupport)
{
    this.options = options;
    this.cmisDictionaryService = cmisDictionaryService;
    this.joinSupport = joinSupport;
    this.validScopes = (options.getQueryMode() == CMISQueryMode.CMS_STRICT) ? CmisFunctionEvaluationContext.STRICT_SCOPES
            : CmisFunctionEvaluationContext.ALFRESCO_SCOPES;
}
 
Example 5
public org.alfresco.repo.search.impl.querymodel.Query parseCMISQueryToAlfrescoAbstractQuery(CMISQueryMode mode, SearchParameters searchParameters,
                                                                                            SolrQueryRequest req, String alternativeDictionary, CmisVersion cmisVersion)
{
    // convert search parameters to cmis query options
    // TODO: how to handle store ref
    CMISQueryOptions options = new CMISQueryOptions(searchParameters.getQuery(), StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);
    options.setDefaultFieldName(searchParameters.getDefaultFieldName());
    // TODO: options.setDefaultFTSConnective()
    // TODO: options.setDefaultFTSFieldConnective()
    options.setIncludeInTransactionData(!searchParameters.excludeDataInTheCurrentTransaction());
    options.setLocales(searchParameters.getLocales());
    options.setMlAnalaysisMode(searchParameters.getMlAnalaysisMode());
    options.setQueryParameterDefinitions(searchParameters.getQueryParameterDefinitions());
    for(String name : searchParameters.getQueryTemplates().keySet())
    {
        String template = searchParameters.getQueryTemplates().get(name);
        options.addQueryTemplate(name, template);
    }

    // parse cmis syntax
    CapabilityJoin joinSupport = (mode == CMISQueryMode.CMS_STRICT) ? CapabilityJoin.NONE : CapabilityJoin.INNERANDOUTER;
    CmisFunctionEvaluationContext functionContext = getCMISFunctionEvaluationContext(mode, cmisVersion, alternativeDictionary);

    CMISDictionaryService cmisDictionary = getCMISDictionary(alternativeDictionary, cmisVersion);

    CMISQueryParser parser = new CMISQueryParser(options, cmisDictionary, joinSupport);
    org.alfresco.repo.search.impl.querymodel.Query queryModelQuery = parser.parse(new LuceneQueryModelFactory<Query, Sort, SyntaxError>(), functionContext);

    if (queryModelQuery.getSource() != null)
    {
        List<Set<String>> selectorGroups = queryModelQuery.getSource().getSelectorGroups(functionContext);
        if (selectorGroups.size() == 0)
        {
            throw new UnsupportedOperationException("No selectors");
        }
    }
    return queryModelQuery;
}
 
Example 6
public CapabilityJoin getJoinSupport()
{
    return CapabilityJoin.NONE;
}
 
Example 7
public CapabilityJoin getJoinSupport()
{
    return CapabilityJoin.NONE;
}
 
Example 8
/**
 * Creates the repository info object.
 */
private RepositoryInfo createRepositoryInfo(CmisVersion cmisVersion)
{
    Descriptor currentDescriptor = descriptorService.getCurrentRepositoryDescriptor();

    // get change token
    boolean auditEnabled = auditService.isAuditEnabled(CMIS_CHANGELOG_AUDIT_APPLICATION, "/"
            + CMIS_CHANGELOG_AUDIT_APPLICATION);
    String latestChangeLogToken = null;

    if (auditEnabled)
    {
        EntryIdCallback auditQueryCallback = new EntryIdCallback(false);
        AuditQueryParameters params = new AuditQueryParameters();
        params.setApplicationName(CMIS_CHANGELOG_AUDIT_APPLICATION);
        params.setForward(false);
        auditService.auditQuery(auditQueryCallback, params, 1);
        String entryId = auditQueryCallback.getEntryId();
        // MNT-13529
        // add initial change log token
        latestChangeLogToken = entryId == null ? "0" : entryId;
    }

    // compile repository info
    RepositoryInfoImpl ri = new RepositoryInfoImpl();

    ri.setId(currentDescriptor.getId());
    ri.setName(currentDescriptor.getName());
    ri.setDescription(currentDescriptor.getName());
    ri.setVendorName("Alfresco");
    ri.setProductName("Alfresco " + descriptorService.getServerDescriptor().getEdition());
    ri.setProductVersion(currentDescriptor.getVersion());
    NodeRef rootNodeRef = getRootNodeRef();
    ri.setRootFolder(constructObjectId(rootNodeRef, null));
    ri.setCmisVersion(cmisVersion);

    ri.setChangesIncomplete(true);
    ri.setChangesOnType(Arrays.asList(new BaseTypeId[] { BaseTypeId.CMIS_DOCUMENT, BaseTypeId.CMIS_FOLDER }));
    ri.setLatestChangeLogToken(latestChangeLogToken);
    ri.setPrincipalAnonymous(AuthenticationUtil.getGuestUserName());
    ri.setPrincipalAnyone(PermissionService.ALL_AUTHORITIES);

    RepositoryCapabilitiesImpl repCap = new RepositoryCapabilitiesImpl();
    ri.setCapabilities(repCap);

    repCap.setAllVersionsSearchable(false);
    repCap.setCapabilityAcl(CapabilityAcl.MANAGE);
    repCap.setCapabilityChanges(auditEnabled ? CapabilityChanges.OBJECTIDSONLY : CapabilityChanges.NONE);
    repCap.setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates.ANYTIME);
    repCap.setCapabilityJoin(CapabilityJoin.NONE);
    repCap.setCapabilityQuery(CapabilityQuery.BOTHCOMBINED);
    repCap.setCapabilityRendition(CapabilityRenditions.READ);
    repCap.setIsPwcSearchable(false);
    repCap.setIsPwcUpdatable(true);
    repCap.setSupportsGetDescendants(true);
    repCap.setSupportsGetFolderTree(true);
    repCap.setSupportsMultifiling(true);
    repCap.setSupportsUnfiling(false);
    repCap.setSupportsVersionSpecificFiling(false);

    AclCapabilitiesDataImpl aclCap = new AclCapabilitiesDataImpl();
    ri.setAclCapabilities(aclCap);

    aclCap.setAclPropagation(AclPropagation.PROPAGATE);
    aclCap.setSupportedPermissions(SupportedPermissions.BOTH);
    aclCap.setPermissionDefinitionData(repositoryPermissions);
    aclCap.setPermissionMappingData(permissionMappings);

    return ri;
}
 
Example 9
CapabilityJoin getJoinSupport();