--- /dev/null
+package org.simantics.document.linking.ge;\r
+\r
+import org.simantics.browsing.ui.model.tests.Test;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.document.DocumentResource;\r
+import org.simantics.document.linking.ontology.DocumentLink;\r
+import org.simantics.document.linking.utils.SourceLinkUtil;\r
+\r
+public class SourceReferenceOldTest implements Test {\r
+ \r
+ public SourceReferenceOldTest() {\r
+ }\r
+ \r
+ \r
+ @Override\r
+ public boolean isCompatible(Class<?> contentType) {\r
+ return contentType == Variable.class;\r
+ }\r
+ \r
+ @Override\r
+ public boolean test(ReadGraph graph, Object content)\r
+ throws DatabaseException {\r
+ Variable variable = (Variable)content;\r
+ Resource res = variable.getPossibleRepresents(graph);\r
+ if (res == null)\r
+ return false;\r
+ DocumentLink sl = DocumentLink.getInstance(graph);\r
+ DocumentResource doc = DocumentResource.getInstance(graph);\r
+ if (graph.isInstanceOf(res, sl.Source)) {\r
+ Resource ref = SourceLinkUtil.getReferredDocument(graph, res);\r
+ if (ref != null)\r
+ return graph.hasStatement(ref, doc.HasNewerVersion);\r
+ }\r
+ return false;\r
+ }\r
+ \r
+\r
+}\r