--- /dev/null
+import "Simantics/DB"\r
+import "Simantics/Variables"\r
+import "Simantics/Model"\r
+import "Simantics/Diagram"\r
+import "Simantics/Library"\r
+import "Simantics/Misc"\r
+import "Simantics/DB" as DB\r
+\r
+import "http://www.simantics.org/Layer0-1.1" as L0\r
+import "http://www.simantics.org/Layer0-1.1/HasRange" as HasRange\r
+import "http://www.simantics.org/Annotation-1.0" as ANNO\r
+\r
+type Annotation = Resource\r
+type AnnotationPropertyRelation = Resource\r
+type AnnotationType = Resource\r
+type AnnotationValue = Resource\r
+type AnnotationProperty = Resource\r
+\r
+importJava "org.simantics.annotation.ui.SCLAnnotation" where\r
+ @JavaName newAnnotationType\r
+ """\r
+ Creates new AnnotationType under the given Library instance and returns it without PropertyRelation\r
+ """\r
+ newAnnotationType :: Library -> <WriteGraph> AnnotationType\r
+ \r
+ @JavaName newAnnotationValue\r
+ """\r
+ Creates new AnnotationValue under the given Library instance with the AnnotationType reference. Returns the created AnnotationValue.\r
+ """\r
+ newAnnotationValue :: Library -> AnnotationType -> <WriteGraph> AnnotationValue\r
+ newAnnotationValueWithName :: Library -> String -> AnnotationType -> <WriteGraph> AnnotationValue\r
+ \r
+ @JavaName newAnnotationType1\r
+ """\r
+ Creates new AnnotationType under the given Library instance. Returns a Tuple2 consisting the AnnotationPropertyRelation and AnnotationType instances.\r
+ """\r
+ newAnnotationType1 :: Library -> <WriteGraph> (AnnotationPropertyRelation, AnnotationType)\r
+ \r
+ @JavaName newAnnotationProperty\r
+ """\r
+ Creates new AnnotationProperty under the given AnnotatoinType instance. Returns the created AnnotationProperty.\r
+ """\r
+ newAnnotationProperty :: AnnotationType -> <WriteGraph> AnnotationProperty\r
+ \r
+ @JavaName advancedAnnotationProperty\r
+ """\r
+ Creates new AnnotationProperty under the given AnnotationType instance with advanced options for user to define non-default parameters for the following values\r
+ \r
+ * name\r
+ * type\r
+ * unit\r
+ * range\r
+ * label\r
+ * description\r
+ """\r
+ advancedAnnotationProperty :: AnnotationType -> String -> String -> String -> String -> String -> String -> <WriteGraph> AnnotationProperty\r
+ \r
+ @JavaName removeAnnotationProperty\r
+ """\r
+ Removes the given AnnotationProperty instance.\r
+ """\r
+ removeAnnotationProperty :: AnnotationProperty -> <WriteGraph> ()\r
+ \r
+ @JavaName attachAnnotation\r
+ """\r
+ Attaches the given AnnotationType to the given Resource which can be for example a Diagram or a Symbol.\r
+ """\r
+ attachAnnotationType :: Resource -> AnnotationType -> <WriteGraph> Annotation\r
+ \r
+ @JavaName setPropertyLabel\r
+ setPropertyLabel :: AnnotationProperty -> String -> <WriteGraph> ()\r
+ \r
+ @JavaName setPropertyUnit\r
+ setPropertyUnit :: AnnotationProperty -> String -> <WriteGraph> ()\r
+ \r
+ @JavaName setPropertyRange\r
+ setPropertyRange :: AnnotationProperty -> String -> <WriteGraph> ()\r
+ \r
+ @JavaName setPropertyDescription\r
+ setPropertyDescription :: AnnotationProperty -> String -> <WriteGraph> ()\r
+ \r
+ @JavaName setPropertyType\r
+ setPropertyType :: AnnotationProperty -> String -> <WriteGraph> ()\r
+ \r
+ @JavaName saveAnnotation\r
+ saveAnnotation :: Annotation -> Library -> String -> <WriteGraph> Resource\r
+ \r
+ @JavaName importAnnotationFromFile\r
+ importAnnotation :: File -> Library -> <Proc> ()\r
+ \r
+ @JavaName exportAnnotationToFile\r
+ exportAnnotationType :: File -> AnnotationType -> <Proc> ()\r
+ \r
+ @JavaName copyAnnotationData\r
+ copyAnnotationData :: Resource -> Resource -> <WriteGraph> ()\r
+\r
+getAnnotationNameFromType :: Resource -> <ReadGraph> String\r
+getAnnotationNameFromType annotationType = do\r
+ relation = singleObject annotationType HasRange.Inverse\r
+ untypedRelatedValue relation L0.HasName\r
+\r
+getPossibleAnnotationType :: Resource -> String -> <ReadGraph> Maybe AnnotationType\r
+getPossibleAnnotationType model name = do\r
+ all = searchByType model ANNO.AnnotationType\r
+ named = filter (\x -> (getAnnotationNameFromType x) == name) all \r
+ if ((length named) == 1)\r
+ then Just (fromResource $ named!0) \r
+ else Nothing\r
+ \r
+setAnnotationPropertyValue :: AnnotationPropertyRelation -> Resource -> String -> String -> <WriteGraph> ()\r
+setAnnotationPropertyValue annotation resource property newValue = do\r
+ resourceUri = uriOf resource\r
+ annotationName = DB.nameOf (toResource annotation)\r
+ completeUri = resourceUri + "#" + annotationName + "#" + property + "#HasDisplayValue"\r
+ propertyVariable = variable completeUri\r
+ setValue propertyVariable newValue\r
+ \r
+/* \r
+findAnnotationType :: Model -> [AnnotationType]\r
+findAnnotationType m = do\r
+ fromResource $ searchByQuery m "Types: AnnotationType"\r
+*/\r