Module Simantics/Misc

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

bundleFile :: String -> String -> File
bundleFile bundleId path

Returns the file at path inside the OSGi bundle bundleId, extracting it into the file system first if the bundle is not installed as a plain directory. The result is null if the bundle is not installed or has nothing at that path.

canDelete :: Resource -> <ReadGraph> Boolean

Returns True if the remover of the given resource has no objection to removing it, and also when the resource has no remover at all. Needs a read transaction.

canRename :: Resource -> <ReadGraph> Boolean

Always returns True. Kept for the actions that ask before renaming. Needs a read transaction.

createDependencyChangeListener :: <Proc> Boolean -> (MetadataI -> DependencyChanges -> <ReadGraph,Proc> ()) -> ChangeListener
createDependencyChangeListener veto onChange

Creates a database change listener that reports the dependency changes of each completed write transaction. Before the changes are computed, veto is called; returning False from it skips the event entirely, and so does having dependency indexing disabled. Otherwise onChange is called with the metadata of the write and the dependency changes, inside a read transaction. Creating the listener does not register it anywhere.

currentDate :: String -> String

Formats the current date and time with the given SimpleDateFormat pattern, for example "yyyy-MM-dd HH:mm". Fails if the pattern is not a valid one.

currentTimeMillis :: <Proc> Long

Returns the current time as the number of milliseconds since the start of 1 January 1970 UTC.

deleteMBNode :: [Resource] -> Boolean

Removes the given resources in a write transaction of its own, using the remover each resource adapts to and skipping the ones that have none. Marks an undo point and records the removals in the change metadata. Returns True when the removal went through and False when it failed, for instance because one of the removers refused.

getSystemProperty :: String -> Maybe String

Returns the value of the Java system property with the given name, or Nothing if the property is not set.

hasNext :: Scanner -> Boolean

Returns True if the scanner still has a token to read. Whitespace alone is not a token, so this is False once only whitespace is left.

hasSomethingToPaste :: Resource -> <ReadGraph> Boolean

Returns True if the Simantics clipboard holds anything at all. The resource argument is ignored, so this does not tell whether the content could be pasted into that resource. Needs a read transaction.

javaRandom :: () -> Double

Returns a pseudorandom number that is at least 0.0 and less than 1.0, from the random generator shared by the whole Java virtual machine.

killPlatform :: () -> ()

Shuts the Simantics platform down. Does the same as shutdownPlatform.

killPlatformRead :: () -> <ReadGraph> ()

Does nothing. Breaking the platform out of a running read transaction is not implemented.

killPlatformWrite :: () -> <WriteGraph> ()

Does nothing. Breaking the platform out of a running write transaction is not implemented.

loop :: Scanner -> String -> Pattern -> [String] -> <Proc> [String]
loop scanner name pattern list

Reads the rest of the scanner one line at a time and, for every line that matches pattern as a whole, appends the token that follows the line to list. Returns the list once the scanner runs out. The name argument is overwritten by the first line read and has no effect on the result.

An ad hoc helper for picking values out of a text file, not a general purpose function.

loop1 :: Scanner -> [String] -> <Proc> [String]
loop1 scanner list

Reads the rest of the scanner one line at a time, trims each line and appends it to list, and returns the list. Reading stops as soon as only whitespace is left, because the loop asks for a remaining token rather than a remaining line.

loop2 :: Scanner -> [String] -> Boolean -> <Proc> [String]
loop2 scanner list found

Reads the rest of the scanner one line at a time and appends a line to list whenever the line before it contained omposition, with every occurrence of M7: and _CM1 removed from the appended line. found tells whether the line preceding the first one read already contained omposition. Returns the list once the scanner runs out.

An ad hoc helper for picking values out of one kind of text file, not a general purpose function.

loop3 :: Scanner -> [String] -> <Proc> [String]
loop3 scanner list

Reads the rest of the scanner one whitespace separated token at a time and appends every token containing _NO1 to list, with every occurrence of M6: and _NO1 removed from the appended token. Returns the list once the scanner runs out.

An ad hoc helper for picking values out of one kind of text file, not a general purpose function.

loop4 :: Scanner -> [String] -> Boolean -> <Proc> [String]
loop4 scanner list found

Reads the rest of the scanner one whitespace separated token at a time, appends every token to list and returns the list. The found argument is carried along unchanged and does not affect the result.

nextLine :: Scanner -> String

Reads the rest of the current line, moves the scanner past the end of that line and returns the text read without the line separator. Fails if the scanner has no line left.

queryPreference :: String -> String -> <ReadGraph> String
queryPreference pluginId preferenceKey

Returns the value of the Eclipse preference preferenceKey of the plug-in pluginId, falling back to the default scope and then to the empty string when the preference is not set. The value is read as a database request, so queries that use it are recomputed when the preference changes. Needs a read transaction.

reconnectPlatform :: () -> ()

Reconnects the platform to its database using the default database driver.

scanNext :: Scanner -> String

Reads the next whitespace separated token and moves the scanner past it. Fails if the scanner has no token left.

scanNextLine :: Scanner -> String

Another name for nextLine; the two read the same thing.

scanner :: File -> <Proc> Scanner

Opens the given file for scanning, using the default character encoding of the platform. Fails if the file cannot be opened. There is no function here for closing the scanner again.

setSystemProperty :: String -> String -> <Proc> String
setSystemProperty name value

Sets the Java system property name to value and returns the value it had before, or null if it had none.

shutdownPlatform :: () -> ()

Shuts the Simantics platform down.

sleep :: Integer -> <Proc> ()

Suspends the calling thread for the given number of milliseconds. If the wait is interrupted it ends early and the interruption is only written to the log.

syncGraph :: () -> <Proc> ()

Waits until the database has no activity left and every running database job has finished, and then runs an empty write transaction to make sure that earlier writes have gone through. Fails if called while a transaction is already in progress.

synchronizeOntologies :: () -> <Proc> ()

Brings the ontologies stored in the database up to date with the ones installed in the platform, merging in what has changed, and flushes the query cache afterwards. This writes to the database.

trackDependencies :: <Proc> ()

Starts tracking the dependency relation of the whole database and indexes it once from the root library, so that dependency queries and the search index keep up with later writes. Runs a read transaction of its own and walks everything, so it is expensive on a large database.

trackOntologicalRequirements :: <Proc> ()

Starts listening to completed writes and enforcing after each one what the ontologies require of the data: creation and modification information is recorded for the components that changed, and resources whose type calls for an identifier are given one. Does nothing while dependency indexing is disabled.

untrackDependencies :: <Proc> ()

Stops tracking the dependency relation of the whole database. Does nothing if no session is open. Runs a read transaction of its own.

untrackOntologicalRequirements :: <Proc> ()

Stops the listener started by trackOntologicalRequirements.

workspaceDirectory :: () -> File

Returns the workspace directory the platform is running against.