use of org.alfresco.service.cmr.repository.ChildAssociationRef in project acs-community-packaging by Alfresco.
the class BrowseBean method deleteSpace.
/**
* Handles the deleteSpace action by deciding which delete dialog to display
*/
public void deleteSpace(ActionEvent event) {
setupDeleteAction(event);
boolean hasMultipleParents = false;
boolean showDeleteAssocDialog = false;
// determine if the node being delete has multiple parents
Node node = this.getActionSpace();
List<ChildAssociationRef> parents = this.nodeService.getParentAssocs(node.getNodeRef(), ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
if (parents != null && parents.size() > 1) {
hasMultipleParents = true;
}
// determine which delete dialog to display
if (this.navigator.getSearchContext() == null && hasMultipleParents) {
// if we are not in a search and the node has multiple parents
// see if the current node has the primary parent association
NodeRef parentSpace = this.navigator.getCurrentNode().getNodeRef();
ChildAssociationRef assoc = this.nodeService.getPrimaryParent(node.getNodeRef());
// show delete assoc dialog if the current space is not the primary parent for the node
showDeleteAssocDialog = !parentSpace.equals(assoc.getParentRef());
}
// show the appropriate dialog
FacesContext fc = FacesContext.getCurrentInstance();
if (showDeleteAssocDialog) {
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:deleteSpaceAssoc");
} else {
final Map<String, String> dialogParams = new HashMap<String, String>(1);
dialogParams.put("hasMultipleParents", Boolean.toString(hasMultipleParents));
Application.getDialogManager().setupParameters(dialogParams);
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:deleteSpace");
}
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project acs-community-packaging by Alfresco.
the class AdminNodeBrowseBean method selectResultNode.
/**
* Action to select search result node
*
* @return next action
*/
public String selectResultNode() {
ChildAssociationRef assocRef = (ChildAssociationRef) searchResults.getRows().getRowData();
NodeRef childRef = assocRef.getChildRef();
setNodeRef(childRef);
return "success";
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project acs-community-packaging by Alfresco.
the class AdminNodeBrowseBean method getChildren.
/**
* Gets the current node children
*
* @return node children
*/
public DataModel getChildren() {
if (children == null) {
List<ChildAssociationRef> assocRefs = getNodeService().getChildAssocs(getNodeRef());
children = new ListDataModel(assocRefs);
}
return children;
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project acs-community-packaging by Alfresco.
the class CategoryBrowserPluginBean method retrieveChildren.
/**
* Retrieves the child folders for the noderef given in the 'noderef' parameter and caches the nodes against the area
* in the 'area' parameter.
*/
public void retrieveChildren() throws IOException {
FacesContext context = FacesContext.getCurrentInstance();
ResponseWriter out = context.getResponseWriter();
UserTransaction tx = null;
try {
tx = Repository.getUserTransaction(context, true);
tx.begin();
Map params = context.getExternalContext().getRequestParameterMap();
String nodeRefStr = (String) params.get("nodeRef");
// work out which list to cache the nodes in
Map<String, TreeNode> currentNodes = getNodesMap();
if (nodeRefStr != null && currentNodes != null) {
// get the given node's details
NodeRef parentNodeRef = new NodeRef(nodeRefStr);
TreeNode parentNode = currentNodes.get(parentNodeRef.toString());
parentNode.setExpanded(true);
if (logger.isDebugEnabled())
logger.debug("retrieving children for noderef: " + parentNodeRef);
// remove any existing children as the latest ones will be added
// below
parentNode.removeChildren();
// get all the child folder objects for the parent
List<ChildAssociationRef> childRefs = this.getNodeService().getChildAssocs(parentNodeRef, ContentModel.ASSOC_SUBCATEGORIES, RegexQNamePattern.MATCH_ALL);
List<TreeNode> sortedNodes = new ArrayList<TreeNode>();
for (ChildAssociationRef ref : childRefs) {
NodeRef nodeRef = ref.getChildRef();
logger.debug("retrieving child : " + nodeRef);
// build the XML representation of the child node
TreeNode childNode = createTreeNode(nodeRef);
parentNode.addChild(childNode);
currentNodes.put(childNode.getNodeRef(), childNode);
sortedNodes.add(childNode);
}
// order the tree nodes by the tree label
if (sortedNodes.size() > 1) {
QuickSort sorter = new QuickSort(sortedNodes, "name", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
// generate the XML representation
StringBuilder xml = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><nodes>");
for (TreeNode childNode : sortedNodes) {
xml.append(childNode.toXML());
}
xml.append("</nodes>");
// send the generated XML back to the tree
out.write(xml.toString());
if (logger.isDebugEnabled())
logger.debug("returning XML: " + xml.toString());
}
// commit the transaction
tx.commit();
} catch (Throwable err) {
try {
if (tx != null) {
tx.rollback();
}
} catch (Exception tex) {
}
}
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project acs-community-packaging by Alfresco.
the class CategoryBrowserPluginBean method getCategoryRootNodes.
public List<TreeNode> getCategoryRootNodes() {
if (this.categoryRootNodes == null) {
this.categoryRootNodes = new ArrayList<TreeNode>();
this.categoryNodes = new HashMap<String, TreeNode>();
UserTransaction tx = null;
try {
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance(), true);
tx.begin();
Collection<ChildAssociationRef> childRefs = this.getCategoryService().getRootCategories(Repository.getStoreRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE);
for (ChildAssociationRef ref : childRefs) {
NodeRef child = ref.getChildRef();
TreeNode node = createTreeNode(child);
this.categoryRootNodes.add(node);
this.categoryNodes.put(node.getNodeRef(), node);
}
tx.commit();
} catch (Throwable err) {
Utils.addErrorMessage("NavigatorPluginBean exception in getCompanyHomeRootNodes()", err);
try {
if (tx != null) {
tx.rollback();
}
} catch (Exception tex) {
}
}
}
return this.categoryRootNodes;
}
Aggregations