DB module documentation

data Resource

A resource is a node in a semantic graph.

Reading

URIs

resource :: String -> <ReadGraph> Resource

Converts an absolute URI to a resource

possibleResource :: String -> <ReadGraph> Maybe Resource

Converts an absolute URI to a resource or returns Nothing if there is no such resource.

relativeResource :: Resource -> String -> <ReadGraph> Resource

Converts a relative URI to a resource starting from the given resource

Graph hierarchy

class Browsable a

Things that are addressed by URI and browsed as a tree of named children. Both Resource and Variable are browsable: a resource is browsed through the resources it consists of, a variable through its own child structure.

fromUri :: Browsable a => String -> <ReadGraph> a

Returns the value at the given absolute URI. Fails if there is nothing at that URI.

uriOf :: Browsable a => a -> <ReadGraph> String

Returns the URI of the given value.

possibleUriOf :: Browsable a => a -> <ReadGraph> Maybe String

Returns the URI of the given value if it exists or Nothing.

nameOf :: Browsable a => a -> <ReadGraph> String

Reads the name of the value.

possibleNameOf :: Browsable a => a -> <ReadGraph> Maybe String

Reads the name of the value or Nothing if it has no name.

valueOf :: Browsable a => Serializable b => a -> <ReadGraph> b

Reads the value the given entity holds, deserialized with the binding of the expected type. Fails if the entity holds no value.

genericRelatedValue :: Browsable a => a -> Resource -> <ReadGraph> b

Reads the value related to the given entity with the given relation. For a resource this is the value of the object of that relation, for a variable the value of the property named after the relation. Fails if there is no such value.

genericPossibleRelatedValue :: Browsable a => a -> Resource -> <ReadGraph> Maybe b

As genericRelatedValue but returns Nothing when there is no such value.

variantValueOf :: Browsable a => a -> <ReadGraph> Variant

Reads the value the given entity holds as a Variant, packaged together with its data type.

children :: Browsable a => a -> <ReadGraph> [a]

Returns the children of the given entity. For a resource these are the resources it consists of.

parent :: Browsable a => a -> <ReadGraph> a

Returns the parent of the given entity. Fails if there is no unique parent.

possibleParent :: Browsable a => a -> <ReadGraph> Maybe a

As parent but returns Nothing when there is no unique parent.

child :: Browsable a => a -> String -> <ReadGraph> a

child entity name returns the child of entity with the given name. Fails if there is no such child.

possibleChild :: Browsable a => a -> String -> <ReadGraph> Maybe a

As child but returns Nothing when there is no child with the given name.

childWithPath :: Browsable a => a -> [String] -> <ReadGraph> a

Returns a child Browsable of the specified parent that has that is the child of the specified parent with the specified name path.

possibleChildWithPath :: Browsable a => a -> [String] -> <ReadGraph> Maybe a

Like childWithPath but returns Maybe a which will be Nothing if no child was found.

Objects

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

subject # predicate returns all objects with the given subject and predicate.

singleObject :: Resource -> Resource -> <ReadGraph> Resource

Assumes that there is exactly one object with the given subject and predicate and returns it.

possibleObject :: Resource -> Resource -> <ReadGraph> Maybe Resource

If there is exactly one object with the given subject and predicate, possibleObject subject predicate returns it. Otherwise, it returns Nothing.

possibleObjectWithType :: Resource -> Resource -> Resource -> <ReadGraph> Maybe Resource

possibleObjectWithType subject predicate type returns the single object with the given subject and predicate that is an instance of type, or Nothing if there is no such object or more than one.

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

objectsWithType subject predicate type returns those objects with the given subject and predicate that are instances of type. Duplicates are removed and the order of the result is unspecified.

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

assertedObjects subject predicate` returns all asserted objects defined in the specified subjects with the given predicate.

Statements

data Statement

A statement is an edge in a semantic graph.

subjectOf :: Statement -> Resource

Returns the subject of the statement, the resource the edge starts from.

predicateOf :: Statement -> Resource

Returns the predicate of the statement, the relation the edge stands for.

objectOf :: Statement -> Resource

Returns the object of the statement, the resource the edge points to.

statements :: Resource -> Resource -> <ReadGraph> [Statement]

statements subject predicate` returns all statements with the given subject and predicate.

singleStatement :: Resource -> Resource -> <ReadGraph> Statement

Assumes that there is exactly one statement with the given subject and predicate and returns it.

assertedStatements :: Resource -> Resource -> <ReadGraph> [Statement]

assertedStatements subject predicate` returns all asserted statements defined in the specified subjects with the given predicate.

isAsserted :: Statement -> Resource -> <ReadGraph> Boolean

isAsserted statement subject tells whether the statement was inherited by subject from an assertion made by one of its types instead of being stated on subject itself. It compares subject with the subject recorded in the statement, so it is meaningful only for a statement that was read using subject as the query subject.

Special objects

singleTypeOf :: Resource -> Resource -> <ReadGraph> Resource

singleTypeOf resource baseType returns the principal type of resource that is baseType or inherits from it. Fails if there is not exactly one such type.

possibleTypeOf :: Resource -> Resource -> <ReadGraph> Maybe Resource

As singleTypeOf but returns Nothing when the resource has no principal type inheriting from the given base type, or more than one.

inverseOf :: Resource -> <ReadGraph> Resource

Returns the inverse relation of the given relation. Fails if the relation has no inverse.

possibleInverseOf :: Resource -> <ReadGraph> Maybe Resource

As inverseOf but returns Nothing when the relation has no inverse or more than one.

superTypesOf :: Resource -> <ReadGraph> Set.T Resource

Returns all types the given type inherits from, transitively. The type itself is not included in the result.

superRelationsOf :: Resource -> <ReadGraph> Set.T Resource

Returns all relations the given relation is a subrelation of, transitively. The relation itself is not included in the result.

Literals

relatedValue :: Serializable a => Resource -> Resource -> <ReadGraph> a

Reads the value of a literal that is an object with the given subject and predicate

possibleRelatedValue :: Serializable a => Resource -> Resource -> <ReadGraph> Maybe a

Reads the value of the literal that is an object with the given subject and predicate, or Nothing if there is no such object, if there is more than one, or if the object holds no value.

relatedValue2 :: Resource -> Resource -> <ReadGraph> a

Reads the value related to the given subject with the given predicate using the general value mechanism: the object may be a literal, an external value, or a resource that computes its value with the converter declared for it. Fails if there is not exactly one such object or if no value can be produced for it.

untypedValueOf :: Resource -> <ReadGraph> Dynamic

Reads the value stored in the given literal as a Dynamic, using the binding implied by the data type recorded in the database. Fails if the resource holds no value. possibleFromDynamic converts the result to a known type.

untypedRelatedValue :: Resource -> Resource -> <ReadGraph> a

As relatedValue but the binding comes from the data type recorded in the database instead of from the expected type. The result is not checked against the type the caller expects.

untypedPossibleRelatedValue :: Resource -> Resource -> <ReadGraph> Maybe a

As untypedRelatedValue but returns Nothing when there is no object with the given subject and predicate, when there is more than one, or when the object holds no value.

Predicates

isInstanceOf :: Resource -> Resource -> <ReadGraph> Boolean

isInstanceOf r t returns true, if r is an instance of t

isSubrelationOf :: Resource -> Resource -> <ReadGraph> Boolean

isSubrelationOf r s returns true, if r is s or a subrelation of s, directly or transitively

isInheritedFrom :: Resource -> Resource -> <ReadGraph> Boolean

isInheritedFrom r t returns true, if r is t or inherits from t, directly or transitively

isParent :: Resource -> Resource -> <ReadGraph> Boolean

isParent a b returns True if a is b or contains b, directly or transitively.

existsStatement :: Resource -> Resource -> <ReadGraph> Boolean

existsStatement subject predicate returns True if there is at least one statement with the given subject whose predicate is the given predicate or one of its subrelations.

existsStatement3 :: Resource -> Resource -> Resource -> <ReadGraph> Boolean

existsStatement3 subject predicate object returns True if that statement exists, assertions included.

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

Returns the predicates of all statements that have the given resource as subject, assertions included.

possiblePredicateByName :: Resource -> String -> <ReadGraph> Maybe Resource

possiblePredicateByName resource name returns the property relation named name in the domain of one of the principal types of resource, or Nothing if no type of the resource defines a property with that name.

possiblePredicateByNameFromType :: Resource -> String -> <ReadGraph> Maybe Resource

possiblePredicateByNameFromType type name returns the property relation named name in the domain of type or of one of its supertypes, or Nothing if there is no such property.

isAsserted :: Statement -> Resource -> <ReadGraph> Boolean

isAsserted statement subject tells whether the statement was inherited by subject from an assertion made by one of its types instead of being stated on subject itself. It compares subject with the subject recorded in the statement, so it is meaningful only for a statement that was read using subject as the query subject.

Special resources

currentModel :: <ReadGraph> Resource

Gives the current active model.

currentProject :: () -> Resource

Returns the project resource of the current session. Fails if there is no session or no current project.

getRootLibrary :: () -> <ReadGraph> Resource

Returns the root library of the database, the resource at the root of the URI hierarchy.

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

Returns the ontologies found under the root library.

possibleCurrentModel :: <ReadGraph> Maybe Resource

Gives the current active model if it exists or Nothing otherwise.

Resource id

resourceId :: Resource -> Long

Returns the 64-bit unique identifier of the resource.

resourceFromId :: Long -> <ReadGraph> Resource

Returns the resource with the given 64-bit identifier, the inverse of resourceId. Fails if the identifier does not refer to a resource.

Queries

subquery :: <ReadGraph,Proc> a -> <ReadGraph,Proc> a

Makes a new read request with given procedure for calculating the result. The request is cached only if the current request is listened.

subqueryA :: <ReadGraph,AsyncReadGraph,Proc> a -> <ReadGraph,Proc> a

Performs synchronously a new AsyncRead request.

subqueryC :: <ReadGraph,Proc> a -> <ReadGraph,Proc> a

Makes a new read request with given procedure for calculating the result. The request is always cached.

subqueryL :: <ReadGraph,Proc> a -> (a -> <ReadGraph,b> ()) -> (Throwable -> <ReadGraph,b> ()) -> <b> Boolean -> <ReadGraph,Proc,b> ()

Makes a new read asynchronous request with function to handle the request result. The last isDisposed function parameter is used to determine if the listener is still alive or not.

subqueryP :: <ReadGraph,Proc> a -> (a -> <ReadGraph,b> ()) -> (Throwable -> <ReadGraph,b> ()) -> <AsyncReadGraph,Proc> ()

Performs asynchronously a new Read request with given result and exception handlers.

unaryQuery :: (a -> <ReadGraph,c> b) -> a -> <ReadGraph> b

unaryQuery f x evaluates f x as a separate read request so that the result can be reused. The request is cached only if the current request is listened.

unaryQueryCached :: (a -> <ReadGraph,c> b) -> a -> <ReadGraph> b

As unaryQuery but the request is always cached.

Writing

Adding statements

newResource :: () -> <WriteGraph> Resource

Creates a new resource.

claim :: Resource -> Resource -> Resource -> <WriteGraph> ()

Adds a statement to the semantic graph.

claimWithInverse :: Resource -> Resource -> Maybe Resource -> Resource -> <WriteGraph> ()

claimWithInverse subject predicate inverse object adds the statement (subject, predicate, object) and, when inverse is Just i, also the statement (object, i, subject). Nothing checks that i really is the inverse of predicate, that is the caller's responsibility. Needs a write transaction.

deny :: Resource -> Resource -> Resource -> <WriteGraph> ()

Removes a statement with the given subject, predicate and object

denyByPredicate :: Resource -> Resource -> <WriteGraph> ()

denyByPredicate subject predicate removes every statement that has the given subject and the given predicate or any of its subrelations, together with the inverses of those statements. Needs a write transaction.

denyAllStatements :: Resource -> <WriteGraph> ()

Removes every statement that has the given resource as subject, together with the inverses of those statements. Needs a write transaction.

claimAssertion :: Resource -> Resource -> Resource -> <WriteGraph> ()

claimAssertion type predicate object adds an assertion to type so that every instance of type gets the statement (instance, predicate, object) without it being stated on the instance itself. Needs a write transaction.

Writing literals

claimRelatedValue :: Serializable a => Resource -> Resource -> a -> <WriteGraph> ()

Sets the value of the literal that is an object with the given subject and predicate.

claimRelatedValueWithType :: Serializable a => Resource -> Resource -> Resource -> a -> <WriteGraph> ()

claimRelatedValueWithType subject predicate type value sets the value of the literal that is the object of subject with predicate and gives the literal the type type. Needs a write transaction.

untypedClaimRelatedValue :: Resource -> Resource -> a -> <WriteGraph> ()

As claimRelatedValue but the binding is chosen from the runtime class of the value instead of from the expected type. Needs a write transaction.

denyValue :: Resource -> <WriteGraph> ()

Removes the literal value of the given resource, if it has one. Needs a write transaction.

Ordered sets

addToOrderedSet :: Resource -> Resource -> <WriteGraph> Boolean

addToOrderedSet s e adds element e to ordered set s

addFirstToOrderedSet :: Resource -> Resource -> <WriteGraph> Boolean

addFirstToOrderedSet s e adds element e to ordered set s as the first element

addAfterToOrderedSet :: Resource -> Resource -> Resource -> <WriteGraph> Boolean

addAfterToOrderedSet s p e adds element e to ordered set s after element p

addBeforeToOrderedSet :: Resource -> Resource -> Resource -> <WriteGraph> Boolean

addBeforeToOrderedSet s p e adds element e to ordered set s before element p

removeFromOrderedSet :: Resource -> Resource -> <WriteGraph> Boolean

removeFromOrderedSet s e removes element e from ordered set s

setOrderedSet :: Resource -> [Resource] -> <WriteGraph> Boolean

setOrderedSet s [e] makes ordered set s contain exactly the elements [e] in that order, adding and removing links as needed. Returns True if the set changed.

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

elementsOfOrderedSet s returns the elements of ordered set s in order

parentOrderedSet :: Resource -> <ReadGraph> Resource

Returns the ordered set the given element belongs to. Fails if the element belongs to no ordered set or to more than one.

Linked List

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

elementsOfList l returns elements of list l

createList :: [Resource] -> <WriteGraph> Resource

createList [e] creates a new list containing elements [e]

createListWithType :: Resource -> [Resource] -> <WriteGraph> Resource

createListWithType t [e] creates a new list with type t containing elements [e]

insertListBack :: Resource -> [Resource] -> <WriteGraph> ()

insertListBack l [e] inserts elements [e] back to the list l

insertListFront :: Resource -> [Resource] -> <WriteGraph> ()

insertListFront l [e] inserts elements [e] front of the list l

removeListElement :: Resource -> Resource -> <WriteGraph> Boolean

removeListElement l e removes a element e from the list l

swapListElementWithPrevious :: Resource -> Resource -> <WriteGraph> Boolean

swapListElementWithPrevious l e exchanges element e with the element before it in list l. Returns False and changes nothing if e is not in the list or is already its first element.

swapListElementWithNext :: Resource -> Resource -> <WriteGraph> Boolean

swapListElementWithNext l e exchanges element e with the element after it in list l. Returns False and changes nothing if e is not in the list or is already its last element.

Transactions

syncRead :: (() -> <Proc,ReadGraph> a) -> <Proc> a

Executes a read transaction and waits that it completes.

asyncRead :: (() -> <Proc,ReadGraph> a) -> <Proc> ()

Begins a read transaction and immediately returns.

syncWrite :: (() -> <Proc,ReadGraph,WriteGraph> a) -> <Proc> a

Executes a write transaction and waits that it completes.

delayedSyncWrite :: (() -> <Proc,WriteGraph> a) -> <Proc> a

Executes a delayed write transaction and waits that it completes.

asyncWrite :: (() -> <Proc,ReadGraph,WriteGraph> a) -> <Proc> ()

Begins a write transaction and immediately returns.

virtualSyncWriteMem :: String -> (() -> <b,WriteGraph> a) -> <b,WriteGraph> a

virtualSyncWriteMem id f executes f as a write into the memory-persistent virtual graph with the given identifier and waits that it completes. The virtual graph is created if it does not exist yet, and its contents are lost when the session ends. Needs a write transaction.

virtualSyncWriteWS :: String -> (() -> <b,WriteGraph> a) -> <b,WriteGraph> a

As virtualSyncWriteMem but writes into the workspace-persistent virtual graph with the given identifier. Such a graph is stored on disk and restored when the workspace is opened again.

lift1Read :: (a -> <ReadGraph,Proc> b) -> a -> <Proc> b

Turns a one-argument function that needs a read transaction into one that can be called without a transaction, by executing it in a read transaction of its own and waiting that it completes.

lift2Read :: (a -> b -> <ReadGraph,Proc> c) -> a -> b -> <Proc> c

As lift1Read but for a function of two arguments.

lift3Read :: (a -> b -> c -> <ReadGraph,Proc> d) -> a -> b -> c -> <Proc> d

As lift1Read but for a function of three arguments.

lift1Write :: (a -> <WriteGraph,Proc> b) -> a -> <Proc> b

Turns a one-argument function that needs a write transaction into one that can be called without a transaction, by executing it in a write transaction of its own and waiting that it completes.

lift2Write :: (a -> b -> <WriteGraph,Proc> c) -> a -> b -> <Proc> c

As lift1Write but for a function of two arguments.

lift3Write :: (a -> b -> c -> <WriteGraph,Proc> d) -> a -> b -> c -> <Proc> d

As lift1Write but for a function of three arguments.

addCommentMetadata :: String -> <WriteGraph> ()

Attaches a comment to the ongoing write transaction. The comment is stored in the metadata of the change set and is what the undo history shows for the operation. Needs a write transaction.

makeSynchronous :: Boolean -> <ReadGraph> ()

Sets the GRAPH_HINT_SYNCHRONOUS hint of the current graph handle. Use withGraphHintBoolean to set the hint for the duration of one function only.

enableDependencies :: () -> <WriteGraph> ()

Turns maintenance of the dependency index back on for the ongoing write transaction. Needs a write transaction.

disableDependencies :: () -> <WriteGraph> ()

Stops maintaining the dependency index for the ongoing write transaction. The setting is reset when the transaction ends. Needs a write transaction.

Undo

markUndoPoint :: () -> <WriteGraph> ()

Marks the beginning of the ongoing write transaction as an undo point. Needs a write transaction. Calling it more than once during the same transaction has no further effect. startUndoPoint also attaches a comment that the undo history can show.

startUndoPoint :: String -> <WriteGraph> ()

Marks the beginning of the ongoing write transaction as an undo point and attaches the given comment to it, which is what the undo history shows for the operation. Needs a write transaction.

undo :: () -> <Proc> String

Undoes the last write operation and returns a description of what was reverted. If the undo history is empty, nothing is changed and the description says so.

redo :: () -> <Proc> String

Redoes the last undone write operation and returns a description of what was redone. If the redo history is empty, nothing is changed and the description says so.

undoOperations :: Integer -> <Proc> String

As undo but undoes the given number of operations.

Generation of resource names

findFreshName :: String -> Resource -> <ReadGraph> String

findFreshName proposition container returns proposition if no child of container has that name, and otherwise proposition followed by a space and a running number that makes it unique.

findFreshEscapedName :: String -> Resource -> <ReadGraph> String

As findFreshName but separates the running number from the name with an underscore instead of a space.

Helper functions for handling URIs

escapeURI :: String -> String

Escapes a string so that it can be used as one segment of a URI, replacing the characters that are not allowed there, the path separator included, with %NN escapes.

unescapeURI :: String -> String

Turns the %NN escapes of a URI segment back into the characters they stand for.

splitURI :: String -> [String]

Splits an absolute URI at its last path separator and returns the namespace and the local name as a two element list. Fails if the URI has no path separator.

Structured graph writing

newEntity :: [Resource -> <ReadGraph,WriteGraph> ()] -> <ReadGraph,WriteGraph> Resource

Creates a new resource, applies each of the given specifications to it and returns it. The specifications are functions such as hasName, hasType, hasParent and hasProperty. Needs a write transaction.

hasStatement :: Resource -> Resource -> Resource -> <WriteGraph> ()
hasName :: String -> Resource -> <WriteGraph> ()
hasType :: Resource -> Resource -> <WriteGraph> ()
hasLabel :: String -> Resource -> <WriteGraph> ()
hasProperty :: Serializable a => Resource -> a -> Resource -> <WriteGraph> ()
hasTypedProperty :: Serializable a => Resource -> a -> Resource -> Resource -> <WriteGraph> ()
hasPossibleProperty :: Serializable a => Resource -> Maybe a -> Resource -> <WriteGraph> ()
hasParent :: Resource -> Resource -> <WriteGraph> ()

Clusters

newClusterSet :: Resource -> <WriteGraph> ()

Creates a new cluster set identified by the given resource. Clusters are the units in which the database stores resources. Fails if a cluster set with that identifier already exists. Needs a write transaction.

selectClusterSet :: Resource -> <WriteGraph> ()

Chooses the cluster set that resources created later in this transaction go into, based on the cluster set of the given resource. Falls back to the cluster set of the root library if the resource does not determine one. Needs a write transaction.

sortByCluster :: [a] -> (a -> Resource) -> <ReadGraph> [a]

sortByCluster xs f orders the elements of xs by the cluster of the resource that f gives for each of them.

Debugging

queryDebugSupport :: String -> <Proc> String

Runs the given command through the database debug support and returns its output. The command is passed on as exec command.

queryListSupport :: String -> <Proc> String

As queryDebugSupport but the command is passed on as list command.

Domain/Namespace Migration

data MigrationConfig
dryRun

If dryRun is True, migrations will not perform any database changes during their execution but can report what changes would be made. When false, changes will be done immediately by the migration.

collectDetailedReportData

Defines whether the migration should collect data for performed and failed migrations in the collections included in this class. If the client only wants to know whether migration succeeded or failed somehow, this can be set to false by the constructor.

collectApplicableChanges

If dryRun is True and collectApplicableChanges is True the migration will collect the statement changes that would be made into the returned MigrationReport. The changes can then be applied later with applyMigrationChanges. If dryRun is False this option has no effect.

MigrationConfig :: Boolean -> Boolean -> Boolean -> MigrationConfig
data MigrationReport

The result of a domain migration: what was processed, what was migrated and what failed. Read it as text with dumpMigrationReport or dumpMigrationReport2, and apply the changes a dry run collected with applyMigrationChanges. How much detail the report holds is decided by the MigrationConfig the migration was run with.

migrateDomainWithSpecs :: MigrationConfig -> Resource -> [(Resource, [Resource])] -> <WriteGraph> MigrationReport
migrateDomainWithSpecs config migratedResource migrationSpecifications

Executes graph domain based migration for the specified migratedResource based on the provided migration specifications.

The function produces a MigrationReport that can be dumped to text or used to apply the pre-computed migration steps after resolving the migration with a dry-run.

Migration specifications are provided as a list of (sourceNamespace, [targetNamespace]) specifications. A single migration specification consists of:

  • a single source namespace (such as a shared library version)
  • one or more target namespaces (such as a new version of the same shared library)

Multiple specifications can be provided to the function.

The migration will process all database statements of the computed graph domain for migrationResource and attempt to migrate any statement predicate and object resources that are not internal to the computed graph domain. If the encountered resources reference a resource in any of the provided source namespaces, the system will try to look for a matching resource in any of the target namespaces provided for the matched source namespace.

If a match is found in a target namespace, the statement containing the migrated resources will first be denied and then reclaimed using the migrated predicate and/or object.

If no match can be found in any of the provided target namespaces, migration for that specific resource is considered failed and will be included in the produced MigrationReport according to what is specified in the provided MigrationConfig.

migrateDomain :: MigrationConfig -> Resource -> Resource -> Resource -> <WriteGraph> MigrationReport
migrateDomain config migratedResource sourceContainer targetContainer

Equal to migrateDomainWithSpecs config migratedResource [(sourceContainer, [targetContainer])].

applyMigrationChanges :: MigrationReport -> <WriteGraph> ()

If MigrationConfig collectApplicableChanges was set to True and MigrationConfig dryRun set to True, this function can be used to apply the collected migration operations in one go after first resolving them with migrateDomainWithSpecs or migrateDomain.

dumpMigrationReport :: MigrationReport -> <ReadGraph> String

Formats a migration report as text: a summary followed by one section for each kind of change, listing the subjects whose statements, predicates or objects were changed and the ones whose migration failed.

dumpMigrationReport2 :: MigrationReport -> <ReadGraph> String

Formats a migration report as text like dumpMigrationReport but lists the changes grouped by subject, marking the changed predicates and objects with an asterisk. The detailed part is present only if the migration was run with collectDetailedReportData set to True.

Miscellaneous functions

GRAPH_HINT_SYNCHRONOUS :: String

The key of the graph hint that controls synchronous reading. While the hint is True, a read of external data that would otherwise yield a cached pending placeholder waits until the real value has been computed. Set it with withGraphHintBoolean or makeSynchronous.

activateOnce :: Resource -> <Proc> ()

Runs the triggers attached to the given resource once and then deactivates them.

addMetadataListener :: ChangeListener -> <Proc> ()

Registers a listener that is called after every completed write transaction of the current session.

assertedObjects_ :: Resource -> Resource -> <ReadGraph> Collection Resource

Returns all asserted objects with the given subject and predicate as a Java collection. assertedObjects is the same query with the result converted to a list.

assertedStatements_ :: Resource -> Resource -> <ReadGraph> Collection Statement

Returns all asserted statements with the given subject and predicate as a Java collection. assertedStatements is the same query with the result converted to a list.

claimRelatedValueWithType_ :: Resource -> Resource -> Resource -> a -> Binding a -> <WriteGraph> ()

claimRelatedValueWithType_ subject predicate type value binding sets the value of the literal that is the object of subject with predicate, gives the literal the type type and serializes the value with the given binding. Needs a write transaction.

claimRelatedValue_ :: Resource -> Resource -> a -> Binding a -> <WriteGraph> ()

claimRelatedValue_ subject predicate value binding sets the value of the literal that is the object of subject with predicate, serializing it with the given binding. Any previous value is replaced and the literal is created if it does not exist yet. Needs a write transaction. claimRelatedValue is the same function with the binding taken from the type of the value.

collectionToList :: Collection a -> [a]

Copies the elements of a Java collection into a list.

copyTo :: Resource -> Resource -> <WriteGraph> Resource

copyTo targetContainer source copies source into targetContainer and returns the copy. How the copy is attached to the container is decided by the paste handler adapted from the container. Fails if the copy produced no resource. Needs a write transaction.

denyRelatedValue :: Resource -> Resource -> <WriteGraph> ()

denyRelatedValue subject predicate removes every statement with the given subject and predicate together with the literals those statements point to. Needs a write transaction.

emptyTrashBin :: () -> <Proc> ()

Deletes the contents of the trash bin of the current project and then purges the database. The deletion cannot be undone.

flushCluster :: () -> <WriteGraph> ()

Ends writing into the current cluster and starts a new one, so that resources created after this call go into the new cluster. Needs a write transaction.

getDataType :: Resource -> <ReadGraph> Datatype

Returns the data type of the value stored in the given literal. Fails if the resource has no data type.

isImmutable :: Resource -> <ReadGraph> Boolean

Returns True if the given resource is immutable. Immutability is a property of the cluster the resource belongs to.

isPersistent :: Resource -> Boolean

Returns True if the resource is stored in the persistent database and False if it exists only in a virtual graph.

objects_ :: Resource -> Resource -> <ReadGraph> Collection Resource

Returns all objects with the given subject and predicate as a Java collection. subject # predicate is the same query with the result converted to a list.

possibleFromDynamic :: Typeable a => String -> Dynamic -> Maybe a

Tries to convert the given Dynamic value to a value with the inferred type

possibleRelatedInteger :: Resource -> Resource -> <ReadGraph> Maybe Integer

Reads the value of the literal that is an object with the given subject and predicate as an integer, or Nothing if there is no such value.

possibleRelatedString :: Resource -> Resource -> <ReadGraph> Maybe String

Reads the value of the literal that is an object with the given subject and predicate as a string, or Nothing if there is no such value.

possibleRelatedValue2 :: Resource -> Resource -> <ReadGraph> Maybe a

As relatedValue2 but returns Nothing instead of failing when there is no single object or no value can be produced for it.

possibleRelatedValue_ :: Resource -> Resource -> Binding a -> <ReadGraph> Maybe a

As relatedValue_ but returns Nothing when there is no object with the given subject and predicate, when there is more than one, or when the object holds no value.

possibleResourceChild :: Resource -> String -> <ReadGraph> Maybe Resource

possibleResourceChild resource name returns the child of resource that has the given name, or Nothing if it has no such child. Only named children are considered, that is, the resources resource consists of that carry a name property.

possibleStatement :: Resource -> Resource -> <ReadGraph> Maybe Statement

If there is exactly one statement with the given subject and predicate, possibleStatement subject predicate returns it. Otherwise, it returns Nothing.

prettyPrintResource :: Resource -> Boolean -> <ReadGraph> String

prettyPrintResource resource ignoreIdentifiers exports the given resource and everything it contains as a transferable graph and returns it in readable text form. When ignoreIdentifiers is True, the identifier properties of the exported resources are left out of the output.

printChanges :: Long -> Long -> <ReadGraph> String

Simple change / metadata debugging report.

purgeDatabase :: () -> <Proc> ()

Asks the server to purge the database. If the system property db.purge.discardVirtualGraphs is set to true, all virtual graphs are discarded first.

relatedValue_ :: Resource -> Resource -> Binding a -> <ReadGraph> a

Reads the value of the single literal that is the object of the given subject and predicate, deserializing it with the given binding. Fails if there is not exactly one such object or if the object holds no value. relatedValue is the same function with the binding taken from the expected type.

relatedVariantValue :: Resource -> Resource -> <ReadGraph> Variant

Reads the value of the single literal that is the object of the given subject and predicate and returns it as a Variant, a value packaged together with its data type. Fails if there is not exactly one such object or if the object holds no value.

relatedVariantValue2 :: Resource -> Resource -> <ReadGraph> Variant

As relatedValue2 but returns the value as a Variant, that is, packaged together with its data type.

removeMetadataListener :: ChangeListener -> <Proc> ()

Removes a listener registered with addMetadataListener.

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

Returns the resources the given resource consists of.

resourceToCollection :: a -> Collection a

Reinterprets a value as a Java collection without converting or checking anything. The result is usable only if the value already is a Java collection.

safeExec :: (() -> <Proc> a) -> <Proc> a

Executes the given function and returns its result. If the function throws, the exception is logged and null is returned in its place, so the failure only shows up where the result is used.

setDependenciesIndexingDisabled :: Boolean -> <WriteGraph> ()

Turns maintenance of the dependency index off or on for the ongoing write transaction. The setting is reset when the transaction ends. Needs a write transaction.

statements_ :: Resource -> Resource -> <ReadGraph> Collection Statement

Returns all statements with the given subject and predicate as a Java collection. statements is the same query with the result converted to a list.

syncActivateOnce :: Resource -> <WriteGraph,Proc> ()

As activateOnce but runs the triggers inside the ongoing write transaction. Needs a write transaction.

untypedClaimValue :: Resource -> a -> <WriteGraph> ()

Stores the given value into the given resource as its literal value, replacing any previous value. Needs a write transaction.

untypedPossibleValueOf :: Resource -> <ReadGraph> Maybe Dynamic

As untypedValueOf but returns Nothing when the resource holds no value.

updateEntity :: Resource -> [Resource -> <ReadGraph,WriteGraph> ()] -> <ReadGraph,WriteGraph> Resource

Applies each of the given specifications to an existing resource and returns the resource. See newEntity. Needs a write transaction.

withGraphHintBoolean :: String -> Boolean -> (() -> <b,ReadGraph> a) -> <ReadGraph> a

withGraphHintBoolean key value f executes f with the given boolean graph hint in effect and restores the previous hints afterwards, also when f fails. See GRAPH_HINT_SYNCHRONOUS.