1 package org.simantics.document.linking.report.templates;
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import java.util.Collections;
8 import org.simantics.db.ReadGraph;
9 import org.simantics.db.Resource;
10 import org.simantics.db.layer0.adapter.Instances;
11 import org.simantics.document.linking.utils.SourceLinkUtil;
12 import org.simantics.utils.datastructures.MapList;
15 public class DiagramStructureWithDependenciesWriter extends DiagramStructureWriter{
18 public String getName() {
19 return "Diagram structure with dependencies";
23 public List<Resource> getReportItems(ReadGraph graph) throws Exception {
24 Instances instancesQuery = graph.adapt(sl.Source, Instances.class);
25 Collection<Resource> found = instancesQuery.find(graph, model);
26 List<Resource> list = new ArrayList<Resource>();
27 MapList<Resource, Resource> diagramToReference = new MapList<Resource, Resource>();
28 for (Resource source : found) {
29 Resource parent = graph.getSingleObject(source, sl.hasSource_Inverse);
30 List<Resource> path = SourceLinkUtil.getPath(graph, model, parent);
31 for (Resource r : path) {
32 if (graph.hasStatement(r, mod.CompositeToDiagram)){
33 Resource doc = SourceLinkUtil.getReferredDocument(graph, source);
34 if (doc != null && !diagramToReference.contains(r, doc)) {
35 diagramToReference.add(r,doc);
41 Collections.sort(list, diagramDocumentComparator);