Search in sources :

Example 1 with QNamePattern

use of org.alfresco.service.namespace.QNamePattern in project alfresco-remote-api by Alfresco.

the class AbstractNodeRelation method getAssocTypeFromWhereElseAll.

protected QNamePattern getAssocTypeFromWhereElseAll(Parameters parameters) {
    QNamePattern assocTypeQNamePattern = RegexQNamePattern.MATCH_ALL;
    Query q = parameters.getQuery();
    if (q != null) {
        MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(WHERE_PARAMS_ASSOC_TYPE, null);
        QueryHelper.walk(q, propertyWalker);
        String assocTypeQNameStr = propertyWalker.getProperty(Nodes.PARAM_ASSOC_TYPE, WhereClauseParser.EQUALS, String.class);
        if (assocTypeQNameStr != null) {
            assocTypeQNamePattern = nodes.getAssocType(assocTypeQNameStr);
        }
    }
    return assocTypeQNamePattern;
}
Also used : Query(org.alfresco.rest.framework.resource.parameters.where.Query) MapBasedQueryWalker(org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker) RegexQNamePattern(org.alfresco.service.namespace.RegexQNamePattern) QNamePattern(org.alfresco.service.namespace.QNamePattern)

Example 2 with QNamePattern

use of org.alfresco.service.namespace.QNamePattern in project alfresco-remote-api by Alfresco.

the class NodeTargetsRelation method delete.

@Override
@WebApiDescription(title = "Remove node assoc(s)")
public void delete(String sourceNodeId, String targetNodeId, Parameters parameters) {
    NodeRef srcNodeRef = nodes.validateNode(sourceNodeId);
    NodeRef tgtNodeRef = nodes.validateNode(targetNodeId);
    String assocTypeStr = parameters.getParameter(Nodes.PARAM_ASSOC_TYPE);
    QNamePattern assocTypeQName = nodes.getAssocType(assocTypeStr, false);
    if (assocTypeQName == null) {
        assocTypeQName = RegexQNamePattern.MATCH_ALL;
    }
    boolean found = false;
    List<AssociationRef> assocRefs = nodeService.getTargetAssocs(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, sourceNodeId), assocTypeQName);
    for (AssociationRef assocRef : assocRefs) {
        if (assocRef.getTargetRef().equals(tgtNodeRef)) {
            nodeService.removeAssociation(srcNodeRef, tgtNodeRef, assocRef.getTypeQName());
            found = true;
        }
    }
    if (!found) {
        throw new EntityNotFoundException(sourceNodeId + "," + assocTypeStr + "," + targetNodeId);
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) RegexQNamePattern(org.alfresco.service.namespace.RegexQNamePattern) QNamePattern(org.alfresco.service.namespace.QNamePattern) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) AssociationRef(org.alfresco.service.cmr.repository.AssociationRef) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 3 with QNamePattern

use of org.alfresco.service.namespace.QNamePattern in project alfresco-remote-api by Alfresco.

the class NodeParentsRelation method readAll.

/**
 * List child node's parent(s) based on (parent ->) child associations.
 * Returns primary parent & also secondary parents, if any.
 *
 * @param childNodeId String id of child node
 */
@Override
@WebApiDescription(title = "Return a list of parent nodes based on child assocs")
public CollectionWithPagingInfo<Node> readAll(String childNodeId, Parameters parameters) {
    NodeRef childNodeRef = nodes.validateOrLookupNode(childNodeId, null);
    QNamePattern assocTypeQNameParam = RegexQNamePattern.MATCH_ALL;
    Boolean isPrimary = null;
    Query q = parameters.getQuery();
    if (q != null) {
        MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(WHERE_PARAMS_PARENTS, null);
        QueryHelper.walk(q, propertyWalker);
        isPrimary = propertyWalker.getProperty(Nodes.PARAM_ISPRIMARY, WhereClauseParser.EQUALS, Boolean.class);
        String assocTypeQNameStr = propertyWalker.getProperty(Nodes.PARAM_ASSOC_TYPE, WhereClauseParser.EQUALS, String.class);
        if (assocTypeQNameStr != null) {
            assocTypeQNameParam = nodes.getAssocType(assocTypeQNameStr);
        }
    }
    List<ChildAssociationRef> childAssocRefs = null;
    if (assocTypeQNameParam.equals(RegexQNamePattern.MATCH_ALL)) {
        childAssocRefs = nodeService.getParentAssocs(childNodeRef);
    } else {
        childAssocRefs = nodeService.getParentAssocs(childNodeRef, assocTypeQNameParam, RegexQNamePattern.MATCH_ALL);
    }
    return listNodeChildAssocs(childAssocRefs, parameters, isPrimary, false);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Query(org.alfresco.rest.framework.resource.parameters.where.Query) MapBasedQueryWalker(org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker) RegexQNamePattern(org.alfresco.service.namespace.RegexQNamePattern) QNamePattern(org.alfresco.service.namespace.QNamePattern) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 4 with QNamePattern

use of org.alfresco.service.namespace.QNamePattern in project alfresco-repository by Alfresco.

the class VirtualNodeServiceExtension method revertVirtualAssociation.

private List<ChildAssociationRef> revertVirtualAssociation(ChildAssociationRef childAssocRef, NodeServiceTrait theTrait, NodeRef childRef) {
    childRef = smartStore.materialize(Reference.fromNodeRef(childRef));
    ChildAssociationRef parent = theTrait.getPrimaryParent(childRef);
    final QName assocName = childAssocRef.getQName();
    List<ChildAssociationRef> assocsToRemove = theTrait.getChildAssocs(parent.getParentRef(), childAssocRef.getTypeQName(), new QNamePattern() {

        @Override
        public boolean isMatch(QName qname) {
            return assocName.getLocalName().equals(qname.getLocalName());
        }
    });
    return assocsToRemove;
}
Also used : QName(org.alfresco.service.namespace.QName) RegexQNamePattern(org.alfresco.service.namespace.RegexQNamePattern) QNamePattern(org.alfresco.service.namespace.QNamePattern) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 5 with QNamePattern

use of org.alfresco.service.namespace.QNamePattern in project alfresco-repository by Alfresco.

the class RatingServiceImpl method getRatingNodeChildren.

/**
 * This method gets all the cm:rating child nodes of the specified targetNode that
 * have been applied by the specified user in the specified rating scheme.
 *
 * @param targetNode the target node under which the cm:rating nodes reside.
 * @param user the user name of the user whose ratings are sought, <code>null</code>
 *             for all users.
 * @param ratingSchemeName the name of the rating scheme, <code>null</code> for all schemes.
 * @return List<ChildAssociationRef>
 */
List<ChildAssociationRef> getRatingNodeChildren(NodeRef targetNode, String ratingSchemeName, String user) {
    QNamePattern qnamePattern = ratingNamingConventions.getRatingAssocPatternForUser(user, ratingSchemeName);
    List<ChildAssociationRef> results = nodeService.getChildAssocs(targetNode, ContentModel.ASSOC_RATINGS, qnamePattern);
    return results;
}
Also used : QNamePattern(org.alfresco.service.namespace.QNamePattern) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Aggregations

QNamePattern (org.alfresco.service.namespace.QNamePattern)12 RegexQNamePattern (org.alfresco.service.namespace.RegexQNamePattern)10 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)7 NodeRef (org.alfresco.service.cmr.repository.NodeRef)6 WebApiDescription (org.alfresco.rest.framework.WebApiDescription)5 AssociationRef (org.alfresco.service.cmr.repository.AssociationRef)3 QName (org.alfresco.service.namespace.QName)3 Query (org.alfresco.rest.framework.resource.parameters.where.Query)2 MapBasedQueryWalker (org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker)2 ArrayList (java.util.ArrayList)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 VirtualizationIntegrationTest (org.alfresco.repo.virtual.VirtualizationIntegrationTest)1 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)1 NamespaceException (org.alfresco.service.namespace.NamespaceException)1 Test (org.junit.Test)1