use of org.alfresco.service.cmr.repository.AssociationRef in project acs-community-packaging by Alfresco.
the class AdminNodeBrowseBean method selectToNode.
/**
* Action to select association To node
*
* @return next action
*/
public String selectToNode() {
AssociationRef assocRef = (AssociationRef) getAssocs().getRowData();
NodeRef targetRef = assocRef.getTargetRef();
setNodeRef(targetRef);
return "success";
}
use of org.alfresco.service.cmr.repository.AssociationRef in project acs-community-packaging by Alfresco.
the class AdminNodeBrowseBean method getSourceAssocs.
/**
* Gets the current source associations
*
* @return associations
*/
public DataModel getSourceAssocs() {
if (sourceAssocs == null) {
try {
List<AssociationRef> assocRefs = getNodeService().getSourceAssocs(getNodeRef(), RegexQNamePattern.MATCH_ALL);
sourceAssocs = new ListDataModel(assocRefs);
} catch (UnsupportedOperationException err) {
// some stores do not support associations
}
}
return sourceAssocs;
}
use of org.alfresco.service.cmr.repository.AssociationRef in project acs-community-packaging by Alfresco.
the class AdminNodeBrowseBean method getAssocs.
/**
* Gets the current node associations
*
* @return associations
*/
public DataModel getAssocs() {
if (assocs == null) {
try {
List<AssociationRef> assocRefs = getNodeService().getTargetAssocs(getNodeRef(), RegexQNamePattern.MATCH_ALL);
assocs = new ListDataModel(assocRefs);
} catch (UnsupportedOperationException err) {
// some stores do not support associations
}
}
return assocs;
}
use of org.alfresco.service.cmr.repository.AssociationRef in project acs-community-packaging by Alfresco.
the class UIAssociationEditor method renderReadOnlyAssociations.
/**
* @see org.alfresco.web.ui.repo.component.property.BaseAssociationEditor#renderReadOnlyAssociations(javax.faces.context.FacesContext, javax.faces.context.ResponseWriter, org.alfresco.service.cmr.repository.NodeService)
*/
protected void renderReadOnlyAssociations(FacesContext context, ResponseWriter out, NodeService nodeService) throws IOException {
if (this.originalAssocs.size() > 0) {
out.write("<table cellspacing='0' cellpadding='2' border='0'>");
Iterator iter = this.originalAssocs.values().iterator();
while (iter.hasNext()) {
out.write("<tr><td>");
AssociationRef assoc = (AssociationRef) iter.next();
NodeRef targetNode = assoc.getTargetRef();
if (nodeService.exists(targetNode)) {
if (ContentModel.TYPE_PERSON.equals(nodeService.getType(targetNode))) {
// if the node represents a person, show the username instead of the name
out.write(Utils.encode(User.getFullNameAndUserId(nodeService, targetNode)));
} else if (ContentModel.TYPE_AUTHORITY_CONTAINER.equals(nodeService.getType(targetNode))) {
// if the node represents a group, show the group display name instead of the name
String groupDisplayName = (String) nodeService.getProperty(targetNode, ContentModel.PROP_AUTHORITY_DISPLAY_NAME);
if (groupDisplayName == null || groupDisplayName.length() == 0) {
String group = (String) nodeService.getProperty(targetNode, ContentModel.PROP_AUTHORITY_NAME);
groupDisplayName = group.substring(PermissionService.GROUP_PREFIX.length());
}
out.write(Utils.encode(groupDisplayName));
} else {
// use the standard cm:name property
// Fix AWC-1301
String displayString = null;
try {
displayString = Repository.getDisplayPath(nodeService.getPath(targetNode)) + "/" + Repository.getNameForNode(nodeService, targetNode);
} catch (AccessDeniedException ade) {
displayString = Application.getMessage(context, MSG_WARN_CANNOT_VIEW_TARGET_DETAILS);
}
out.write(Utils.encode(displayString));
}
} else {
String message = Application.getMessage(context, MSG_WARN_USER_WAS_DELETED);
out.write(message);
}
out.write("</td></tr>");
}
out.write("</table>");
}
}
use of org.alfresco.service.cmr.repository.AssociationRef in project acs-community-packaging by Alfresco.
the class UIAssociationEditor method addTarget.
/**
* Updates the component and node state to reflect an association being added
*
* @param node The node we are dealing with
* @param toAdd The noderefs of the children to add
*/
protected void addTarget(Node node, String[] toAdd) {
if (node != null && toAdd != null && toAdd.length > 0) {
for (int x = 0; x < toAdd.length; x++) {
String targetRef = toAdd[x];
// update the node so it knows to add the association (if it wasn't there originally)
if (this.originalAssocs.containsKey(targetRef) == false) {
QName assocQName = Repository.resolveToQName(this.associationName);
AssociationRef newAssoc = new AssociationRef(null, node.getNodeRef(), assocQName, new NodeRef(targetRef));
Map<String, AssociationRef> added = node.getAddedAssociations().get(this.associationName);
added.put(targetRef, newAssoc);
if (logger.isDebugEnabled())
logger.debug("Added association to " + targetRef + " to the added list");
}
// if the association was previously removed and has now been re-added it
// will still be in the "to be removed" list so remove it if it is
Map<String, AssociationRef> removed = node.getRemovedAssociations().get(this.associationName);
if (removed.containsKey(targetRef)) {
removed.remove(targetRef);
if (logger.isDebugEnabled())
logger.debug("Removed association to " + targetRef + " from the removed list");
}
}
}
}
Aggregations