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;
}
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);
}
}
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);
}
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;
}
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;
}
Aggregations