]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.document.linking.ui/src/org/simantics/document/linking/ge/SourceReferenceOldTest.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.document.linking.ui / src / org / simantics / document / linking / ge / SourceReferenceOldTest.java
1 package org.simantics.document.linking.ge;
2
3 import org.simantics.browsing.ui.model.tests.Test;
4 import org.simantics.db.ReadGraph;
5 import org.simantics.db.Resource;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.db.layer0.variable.Variable;
8 import org.simantics.document.DocumentResource;
9 import org.simantics.document.linking.ontology.DocumentLink;
10 import org.simantics.document.linking.utils.SourceLinkUtil;
11
12 public class SourceReferenceOldTest  implements Test  {
13         
14         public SourceReferenceOldTest() {
15         }
16         
17         
18         @Override
19         public boolean isCompatible(Class<?> contentType) {
20                 return contentType == Variable.class;
21         }
22         
23         @Override
24         public boolean test(ReadGraph graph, Object content)
25                         throws DatabaseException {
26                 Variable variable = (Variable)content;
27                 Resource res = variable.getPossibleRepresents(graph);
28                 if (res == null)
29                         return false;
30                 DocumentLink sl = DocumentLink.getInstance(graph);
31                 DocumentResource doc = DocumentResource.getInstance(graph);
32                 if (graph.isInstanceOf(res, sl.Source)) {
33                         Resource ref = SourceLinkUtil.getReferredDocument(graph, res);
34                         if (ref != null)
35                                 return graph.hasStatement(ref, doc.HasNewerVersion);
36                 }
37                 return false;
38         }
39         
40
41 }