1 17 24 package org.alfresco.repo.search.results; 25 26 import java.util.ArrayList ; 27 import java.util.Iterator ; 28 import java.util.List ; 29 30 import org.alfresco.repo.search.AbstractResultSet; 31 import org.alfresco.repo.search.SimpleResultSetMetaData; 32 import org.alfresco.service.cmr.repository.ChildAssociationRef; 33 import org.alfresco.service.cmr.repository.NodeRef; 34 import org.alfresco.service.cmr.repository.NodeService; 35 import org.alfresco.service.cmr.repository.Path; 36 import org.alfresco.service.cmr.search.LimitBy; 37 import org.alfresco.service.cmr.search.PermissionEvaluationMode; 38 import org.alfresco.service.cmr.search.ResultSetMetaData; 39 import org.alfresco.service.cmr.search.ResultSetRow; 40 import org.alfresco.service.cmr.search.SearchParameters; 41 42 public class ChildAssocRefResultSet extends AbstractResultSet 43 { 44 private List <ChildAssociationRef> cars; 45 NodeService nodeService; 46 47 public ChildAssocRefResultSet(NodeService nodeService, List <ChildAssociationRef> cars, Path[] propertyPaths) 48 { 49 super(propertyPaths); 50 this.nodeService = nodeService; 51 this.cars = cars; 52 } 53 54 public ChildAssocRefResultSet(NodeService nodeService, List <NodeRef> nodeRefs, Path[] propertyPaths, boolean resolveAllParents) 55 { 56 super(propertyPaths); 57 this.nodeService = nodeService; 58 List <ChildAssociationRef> cars = new ArrayList <ChildAssociationRef>(nodeRefs.size()); 59 for(NodeRef nodeRef : nodeRefs) 60 { 61 if(resolveAllParents) 62 { 63 cars.addAll(nodeService.getParentAssocs(nodeRef)); 64 } 65 else 66 { 67 cars.add(nodeService.getPrimaryParent(nodeRef)); 68 } 69 } 70 this.cars = cars; 71 } 72 73 public int length() 74 { 75 return cars.size(); 76 } 77 78 public NodeRef getNodeRef(int n) 79 { 80 return cars.get(n).getChildRef(); 81 } 82 83 public ChildAssociationRef getChildAssocRef(int n) 84 { 85 return cars.get(n); 86 } 87 88 public ResultSetRow getRow(int i) 89 { 90 return new ChildAssocRefResultSetRow(this, i); 91 } 92 93 public Iterator <ResultSetRow> iterator() 94 { 95 return new ChildAssocRefResultSetRowIterator(this); 96 } 97 98 public NodeService getNodeService() 99 { 100 return nodeService; 101 } 102 103 public ResultSetMetaData getResultSetMetaData() 104 { 105 return new SimpleResultSetMetaData(LimitBy.UNLIMITED, PermissionEvaluationMode.EAGER, new SearchParameters()); 106 } 107 } 108 | Popular Tags |