]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.datatypes/scl/Simantics/GUID.scl
Merge remote-tracking branch 'origin/svn'
[simantics/platform.git] / bundles / org.simantics.datatypes / scl / Simantics / GUID.scl
1 import "Simantics/DB"\r
2 import "Simantics/Ontologies"\r
3 \r
4 importJava "org.simantics.datatypes.literal.GUID" where\r
5     \r
6     data GUID\r
7 \r
8 instance Show GUID where\r
9     show guid = guidIndexString guid\r
10 \r
11 importJava "org.simantics.datatypes.literal.GUID" where\r
12     @JavaName "BINDING"\r
13     guidBinding :: Binding a\r
14     @JavaName random\r
15     randomGUID :: <Proc> GUID\r
16     @JavaName indexString\r
17     guidIndexString :: GUID -> String\r
18     \r
19 guidOf :: Resource -> <ReadGraph> GUID\r
20 guidOf res = relatedValue_ res L0.identifier guidBinding\r
21     \r
22 possibleGUIDOf :: Resource -> <ReadGraph> Maybe GUID\r
23 possibleGUIDOf res = possibleRelatedValue_ res L0.identifier guidBinding\r
24 \r
25 claimGUID :: Resource -> <WriteGraph, Proc> ()\r
26 claimGUID res = do\r
27     match possibleGUIDOf res with\r
28       Nothing -> claimRelatedValueWithType_ res L0.identifier L0.GUID randomGUID guidBinding\r
29       _ -> ()