Module Simantics/SharedOntologies

This module is undocumented. This is a list of its definitions.

allSharedOntologies :: () -> <ReadGraph> [Resource]

Returns every shared ontology of the database, including the ones flagged to be treated as system ontologies, which getSharedOntologies may leave out. Walks the whole library tree. Needs a read transaction.

availableSharedOntologies :: Resource -> <ReadGraph> [Resource]

Returns the visible shared ontologies that the given resource could still be linked to: the ones it is not linked to already, minus the ones that are themselves linked to it directly or indirectly, since linking those would create a cycle. Walks the whole library tree to find the candidates. Needs a read transaction.

createClusterSet :: Resource -> <WriteGraph> ()

Creates a new cluster set identified by the given resource and makes it the cluster set that resources created later in this transaction go into. Fails if a cluster set with that identifier already exists. Needs a write transaction.

createLibrary :: Resource -> Resource -> String -> Boolean -> <WriteGraph> Resource
createLibrary parentLibrary libraryType name clusterSet

Creates a new resource of type libraryType, names it name and attaches it under parentLibrary with L0.ConsistsOf, and returns it. When clusterSet is True the new library gets a cluster set of its own, so that the resources created below it are stored separately; otherwise it goes into the cluster set of parentLibrary. Needs a write transaction.

createNewVersionWithUI :: Resource -> <ReadGraph> ()

Opens the dialog for creating a new version of the given resource, filled in from its current version information. The dialog is opened asynchronously on the user interface thread and does the copying itself, so this returns before the new version exists. Needs a read transaction.

createNewVersionWithoutUI :: Resource -> <WriteGraph> ()

Creates the next version of the given resource by copying it next to itself with the version number increased by one. The copy is left unpublished. Marks an undo point and records a comment in the change metadata. Needs a write transaction.

createSharedOntology :: String -> Resource -> <WriteGraph> Resource
createSharedOntology uri ontologyType

Creates a shared ontology at the given URI and returns it. The path segments of the URI are followed down from the root library, creating the intermediate L0.Library resources that are missing on the way. The last segment is created as an instance of ontologyType with a cluster set of its own, and an SCLMain module is created in it. An existing resource is reused for any segment that already exists. Needs a write transaction.

createSharedOntologyWithUI :: Resource -> <ReadGraph> ()

Opens the dialog for creating a new shared library, offering the concrete index root types inheriting from the given base type. The dialog is opened asynchronously on the user interface thread and does the writing itself, so this returns before anything has been created. Needs a read transaction.

exportSharedOntology :: Resource -> String -> String -> Integer -> <ReadGraph> ()
exportSharedOntology library fileName format version

Writes the given shared library into the file fileName as a transferable graph. format and version identify the container format written into the file; the shared library wizard uses "sharedLibrary" and 1. The export carries a draft status when the library is not published. Copies the whole library into memory first. Fails if the library has nothing to export or the file cannot be written. Needs a read transaction.

getOrCreateLibrary :: Resource -> Resource -> String -> Boolean -> <WriteGraph> Resource
getOrCreateLibrary parentLibrary libraryType name clusterSet

Returns the child of parentLibrary named name if there is one, whatever its type, and otherwise creates it with createLibrary. Needs a write transaction.

getSharedOntologies :: () -> <ReadGraph> [Resource]

Returns the visible shared ontologies of the database, that is, traverseSharedOntologies applied to the root library. Walks the whole library tree. Needs a read transaction.

getSystemOntologies :: () -> <ReadGraph> [Resource]

Returns the system ontologies of the database, that is, traverseSystemOntologies applied to the root library. Walks the whole library tree. Needs a read transaction.

getVisibleSystemOntologies :: () -> <ReadGraph> [Resource]

Returns the system ontologies that the user is meant to see: all of them when the ontology.visibility preference of org.simantics is all, and none otherwise. Needs a read transaction.

importSharedOntology :: String -> <Proc> ()

Imports a shared ontology from the transferable graph file with the given name, writing it into the database. Fails if the file cannot be read or the import fails.

importSharedOntology2 :: String -> <Proc> [Resource]

As importSharedOntology, but returns the roots that were created by the import.

importSharedOntologyWithUI :: Variable -> <ReadGraph> ()

Opens the shared library import wizard for the given variable. The wizard is opened asynchronously on the user interface thread, so this returns before anything has been imported. Needs a read transaction.

isContainerNotPublished :: Resource -> <ReadGraph> Boolean

Returns True if the index root containing the given resource is not published, and also when the resource has no index root. Needs a read transaction.

isLinkedToDeep :: Resource -> Resource -> <ReadGraph> Boolean
isLinkedToDeep r1 r2

Returns True if r1 is r2 or reaches r2 by following L0.IsLinkedTo statements any number of steps. Needs a read transaction.

isLocked :: Resource -> <ReadGraph> Boolean

Returns True if the given component type carries the Locked property of STR.ComponentType. Needs a read transaction.

isNotLocked :: Resource -> <ReadGraph> Boolean
isNotPublished :: Resource -> <ReadGraph> Boolean
isPublished :: Resource -> <ReadGraph> Boolean

Returns the value of the published property of L0.Entity on the given resource, and False when the resource does not have that property. A value that is not a boolean counts as published. Needs a read transaction.

linkSharedOntology :: Resource -> Resource -> <WriteGraph> ()
linkSharedOntology model ontology

Makes model use the shared ontology by claiming the statement model L0.IsLinkedTo ontology. Marks an undo point before the change and records a comment in the change metadata. Needs a write transaction.

newVersionAction :: Resource -> <Proc> ()

Runs createNewVersionWithUI for the given resource in a read transaction of its own and waits for it to finish. That only opens the dialog; the new version is created later by the dialog itself.

publish :: Resource -> <WriteGraph> ()

Marks the given resource as published by claiming the published property of L0.Entity to True, and records a comment in the change metadata. Publishes without any of the checks the WithUI variants make. Needs a write transaction.

publishAction :: Resource -> <Proc> ()

Runs publish for the given resource in a write transaction of its own and waits for it to finish.

publishComponentTypeAction :: Resource -> <Proc> ()

Runs publishComponentTypeWithUI for the given component type in a write transaction of its own and waits for it to finish.

publishComponentTypeWithUI :: Resource -> <WriteGraph> ()

Publishes the given user component type, but only if all the user components used in the composite that defines it are published themselves. Otherwise nothing is published and the unpublished components are shown in a dialog. The publishing happens in a write transaction of its own, so it is not part of the caller's transaction. Needs a write transaction.

publishSharedOntologyAction :: Resource -> <Proc> ()

Runs publishSharedOntologyWithUI for the given shared ontology in a write transaction of its own and waits for it to finish.

publishSharedOntologyWithUI :: Resource -> <WriteGraph> ()

Publishes the given shared ontology. If it contains unpublished component types or is linked to unpublished shared ontologies, those are shown in a dialog first and the user decides whether to publish anyway. The publishing happens in a write transaction of its own, so it is not part of the caller's transaction. Needs a write transaction.

querySharedOntologyType :: () -> <ReadGraph> Resource

Returns one index root type that a new shared ontology can be created as: the first concrete index root type found in the installed ontologies that is not a model type. Fails if there is none. Needs a read transaction.

traverseOntologies :: Resource -> (Resource -> <ReadGraph> Boolean) -> <ReadGraph> [Resource]
traverseOntologies library filterFn

Walks the library tree below library and returns the ontologies in it that filterFn accepts. A resource that is an ontology ends the descent and is tested with filterFn; a model ends the descent and contributes nothing; a library is descended into through L0.ConsistsOf; anything else contributes nothing. Reads the whole library subtree, so this is expensive on a large database. Needs a read transaction.

traverseSharedOntologies :: Resource -> <ReadGraph> [Resource]

Returns the shared ontologies in the library tree below the given library, leaving out the ones flagged to be treated as system ontologies unless the ontology.visibility preference of org.simantics is all-shared or all. Walks the whole subtree. Needs a read transaction.

traverseSystemOntologies :: Resource -> <ReadGraph> [Resource]

Returns the system ontologies in the library tree below the given library, that is, the ontologies that are not shared ontologies together with the shared ontologies flagged to be treated as system ontologies. Walks the whole subtree. Needs a read transaction.

treatAsSystemOntology :: Resource -> Boolean -> <WriteGraph> ()
treatAsSystemOntology sharedOntology setting

Sets whether the given shared ontology is treated as a system ontology. System ontologies are left out of getSharedOntologies and counted in getSystemOntologies instead. Needs a write transaction.

unlinkSharedOntology :: Resource -> Resource -> <WriteGraph> ()
unlinkSharedOntology model ontology

Stops model from using the shared ontology by denying the statement model L0.IsLinkedTo ontology. Marks an undo point before the change and records a comment in the change metadata. Does not check whether anything in the model still refers to the ontology. Needs a write transaction.

unlinkSharedOntologyWithUI :: Variable -> [Resource] -> <ReadGraph> Boolean
unlinkSharedOntologyWithUI variable libraries

Unlinks the given shared libraries from the index root that variable represents, but only if nothing in that index root instantiates a component type defined by them. Returns True and schedules the write when that is the case, and otherwise returns False and shows the offending instances in a dialog. Returns False if variable does not represent a resource. Needs a read transaction.

uriParts :: String -> [String]

Splits an absolute http:// URI into its path segments, outermost first, so that uriParts "http://www.example.org/Lib/Sub" gives ["www.example.org", "Lib", "Sub"]. The segments are returned as they appear in the URI, still escaped. Fails for a URI that does not start with http://.

usedSharedOntologies :: Resource -> <ReadGraph> [Resource]

Returns the visible shared ontologies that the given model is directly linked to with L0.IsLinkedTo. Walks the whole library tree to find the candidates. Needs a read transaction.