0

Here it is told how to get a list of children of a NodeRef. Here is the code:

 List<ChildAssociationRef> children = nodeService.getChildAssocs(c);
       for (ChildAssociationRef childAssoc : children) {
           NodeRef childNodeRef = childAssoc.getChildRef();
           // Use childNodeRef here.
       }

What is the parameter companyHome, what type is it and the most important is how to get it from the process?

Nikitin Mikhail
  • 2,983
  • 9
  • 42
  • 67
  • @Krutik Jayswal of course I will but I didn't deal yet, maybe I'll have some questions. For example: I've found out that companyhome must be of ActivitiScriptNode type but I don't see anything about this in the links you gave(by the way they all are the same). Some things are not obvious for me so I need some time to think – Nikitin Mikhail Dec 24 '14 at 15:08
  • 1
    are you facing this kind of error. --> http://forums.activiti.org/content/convert-alfresco-scripnode-activitiscriptnode – Krutik Jayswal Dec 24 '14 at 16:11
  • @Krutik Jayswa it shed some light on my problem, but how to try to call the constructor of public 'ActivitiScriptNode(NodeRef nodeRef, ServiceRegistry services)' if I need this activiti script node to get that 'NodeRef nodeRef' for 'List children = nodeService.getChildAssocs(packageNode.getNodeRef(), WorkflowModel.ASSOC_PACKAGE_CONTAINS, RegexQNamePattern.MATCH_ALL);' only after which i'll have a noderef – Nikitin Mikhail Dec 24 '14 at 16:27
  • I mean I can't get a node ref before creating activitiscriptnode – Nikitin Mikhail Dec 24 '14 at 16:28
  • can you please explain little more. – Krutik Jayswal Dec 24 '14 at 17:39
  • @Krutik Jayswal ok. I need to get all available nodes(i.e. files) from the task. The example I provided 'List children = nodeService.getChildAssocs(companyHome)' needs an ActivitiScriptNode as a companyHome. BUT to create a new ActivitiScripNode I need a 'NodeRef nodeRef'. SO I need a node ref to create ActivitiScriptNode and at the same time I need an ActivitiScriptNode to get a nodeRef. It turns out that I can't get one of them withot another. – Nikitin Mikhail Dec 24 '14 at 19:01

1 Answers1

2

companyHome is a root node in alfresco of files which we are creating or uploading.

Below code sample which you have given is for iterating childrens of node c, where c can be folder(space) or file in alfresco file system.In alfresco files are called content and folders are called space.

 List<ChildAssociationRef> children = nodeService.getChildAssocs(c);
       for (ChildAssociationRef childAssoc : children) {
           NodeRef childNodeRef = childAssoc.getChildRef();
           // Use childNodeRef here.
       }

For retrieving company home node you can use search service and use lucene search for that. Below is link for lucene search.

https://wiki.alfresco.com/wiki/Search

For understanding search service you can use any of below link.

https://wiki.alfresco.com/wiki/Search

https://wiki.alfresco.com/wiki/Search

Krutik Jayswal
  • 3,165
  • 1
  • 15
  • 38