Class: ResourceMapState

ResourceMapState()

new ResourceMapState()

Cache plain lookups and summaries derived from a Resource Map's RDF graph. This class never changes the graph. ResourceMap clears the cache after each graph edit, and the next read rebuilds it. Keeping these derived values avoids repeating the same graph scans during reads and validation.
Since:
  • 2.39.0
Source:

Methods

buildGraphIndex() → {object}

Build all cached lookups used by ResourceMap reads and validation.
Source:
Returns:
Derived graph index
Type
object

cloneRecords(field) → {Array.<object>}

Clone an indexed record list so callers can mutate the result safely.
Parameters:
Name Type Description
field string Graph index field holding plain record objects
Source:
Returns:
Shallow cloned records
Type
Array.<object>

createValidationContext() → {ResourceMapValidationContext}

Source:
Returns:
Shared validation inputs.
Type
ResourceMapValidationContext

findNodeUriForPid(pid) → {string|null}

Return the preferred existing RDF URI for a PID.
Parameters:
Name Type Description
pid string PID to resolve.
Source:
Returns:
Preferred URI.
Type
string | null

findNodesByIdentifier(identifier) → {Array.<(NamedNode|BlankNode)>}

Find RDF resources that declare a given identifier.
Parameters:
Name Type Description
identifier string Identifier to resolve.
Source:
Returns:
Matching RDF resource nodes.
Type
Array.<(NamedNode|BlankNode)>
Source:
Returns:
Cloned documentation links.
Type
Array.<ResMapDocLink>

getExecutionNodes() → {Array.<(NamedNode|BlankNode)>}

Source:
Returns:
RDF nodes representing program runs.
Type
Array.<(NamedNode|BlankNode)>

getExecutionNodesForProgram(programPid) → {Array.<(NamedNode|BlankNode)>}

Find the recorded runs of one program.
Parameters:
Name Type Description
programPid string Program PID.
Source:
Returns:
Matching executions.
Type
Array.<(NamedNode|BlankNode)>

getExecutionSummary(executionNode) → {object|null}

Return a safe copy of one program run summary.
Parameters:
Name Type Description
executionNode NamedNode | BlankNode Execution node.
Source:
Returns:
Execution summary.
Type
object | null

getGeneratedByPrograms() → {Array.<ExecutionProgramRelationship>}

Source:
Returns:
Links from programs to data they produced.
Type
Array.<ExecutionProgramRelationship>

getIndex() → {object}

Source:
Returns:
Lazily built graph index.
Type
object

getMember(pid) → {ResourceMapMember|null}

Return one member summary from indexed graph state.
Parameters:
Name Type Description
pid string Member PID.
Source:
Returns:
Member summary when present.
Type
ResourceMapMember | null

getMemberDescriptors() → {Array.<{pid: string, uri: string}>}

Source:
Returns:
Exact membership nodes.
Type
Array.<{pid: string, uri: string}>

getMemberPids() → {Array.<string>}

Source:
Returns:
Aggregated member PIDs.
Type
Array.<string>

getMemberUris(pid) → {Array.<string>}

Return every exact RDF URI used by package members that claim one PID.
Parameters:
Name Type Description
pid string Member PID
Source:
Returns:
Sorted package member URIs
Type
Array.<string>

getRolePidSet(className) → {Set.<string>}

Return PIDs classified as one PROVONE type, such as `Data` or `Program`.
Parameters:
Name Type Description
className string PROVONE class name.
Source:
Returns:
Matching PIDs.
Type
Set.<string>

getSummary() → {ResourceMapSummary}

Return a cached plain package summary, building it on the first read.
Source:
Returns:
Cloned package summary.
Type
ResourceMapSummary

getTypeAssertions() → {Array.<TypeAssertion>}

Source:
Returns:
Data and Program classifications.
Type
Array.<TypeAssertion>

getUsedByPrograms() → {Array.<ExecutionProgramRelationship>}

Source:
Returns:
Links from programs to data they consumed.
Type
Array.<ExecutionProgramRelationship>
Source:
Returns:
Data source relationships.
Type
Array.<WasDerivedFromRelationship>

getWasInformedByPrograms() → {Array.<ProgramLineageRelationship>}

Source:
Returns:
Current/previous program links.
Type
Array.<ProgramLineageRelationship>

hasMember(pid) → {boolean}

Test whether a PID belongs to the package.
Parameters:
Name Type Description
pid string Candidate PID.
Source:
Returns:
Whether the PID is a member.
Type
boolean

invalidate()

Clear all derived state after a graph mutation.
Source:

nodeHasIdentifier(node, pid) → {boolean}

Test whether a node has an expected identifier.
Parameters:
Name Type Description
node NamedNode | BlankNode | Literal RDF node.
pid string Expected PID.
Source:
Returns:
Whether the identifier matches.
Type
boolean

pidFromNode(node) → {string|null}

Resolve a node's PID from the current graph, including identifiers added earlier in a grouped edit. Cached summaries remain snapshots of the edit's starting state.
Parameters:
Name Type Description
node NamedNode | BlankNode | Literal RDF node
Source:
Returns:
PID when resolvable
Type
string | null

ResourceMapState(options)

new ResourceMapState(options)

Create derived state for one ResourceMap.
Parameters:
Name Type Description
options object State options
Properties
Name Type Description
resourceMap ResourceMap Resource Map to index
Source:

Methods

buildGraphIndex() → {object}

Build all cached lookups used by ResourceMap reads and validation.
Source:
Returns:
Derived graph index
Type
object

cloneRecords(field) → {Array.<object>}

Clone an indexed record list so callers can mutate the result safely.
Parameters:
Name Type Description
field string Graph index field holding plain record objects
Source:
Returns:
Shallow cloned records
Type
Array.<object>

createValidationContext() → {ResourceMapValidationContext}

Source:
Returns:
Shared validation inputs.
Type
ResourceMapValidationContext

findNodeUriForPid(pid) → {string|null}

Return the preferred existing RDF URI for a PID.
Parameters:
Name Type Description
pid string PID to resolve.
Source:
Returns:
Preferred URI.
Type
string | null

findNodesByIdentifier(identifier) → {Array.<(NamedNode|BlankNode)>}

Find RDF resources that declare a given identifier.
Parameters:
Name Type Description
identifier string Identifier to resolve.
Source:
Returns:
Matching RDF resource nodes.
Type
Array.<(NamedNode|BlankNode)>
Source:
Returns:
Cloned documentation links.
Type
Array.<ResMapDocLink>

getExecutionNodes() → {Array.<(NamedNode|BlankNode)>}

Source:
Returns:
RDF nodes representing program runs.
Type
Array.<(NamedNode|BlankNode)>

getExecutionNodesForProgram(programPid) → {Array.<(NamedNode|BlankNode)>}

Find the recorded runs of one program.
Parameters:
Name Type Description
programPid string Program PID.
Source:
Returns:
Matching executions.
Type
Array.<(NamedNode|BlankNode)>

getExecutionSummary(executionNode) → {object|null}

Return a safe copy of one program run summary.
Parameters:
Name Type Description
executionNode NamedNode | BlankNode Execution node.
Source:
Returns:
Execution summary.
Type
object | null

getGeneratedByPrograms() → {Array.<ExecutionProgramRelationship>}

Source:
Returns:
Links from programs to data they produced.
Type
Array.<ExecutionProgramRelationship>

getIndex() → {object}

Source:
Returns:
Lazily built graph index.
Type
object

getMember(pid) → {ResourceMapMember|null}

Return one member summary from indexed graph state.
Parameters:
Name Type Description
pid string Member PID.
Source:
Returns:
Member summary when present.
Type
ResourceMapMember | null

getMemberDescriptors() → {Array.<{pid: string, uri: string}>}

Source:
Returns:
Exact membership nodes.
Type
Array.<{pid: string, uri: string}>

getMemberPids() → {Array.<string>}

Source:
Returns:
Aggregated member PIDs.
Type
Array.<string>

getMemberUris(pid) → {Array.<string>}

Return every exact RDF URI used by package members that claim one PID.
Parameters:
Name Type Description
pid string Member PID
Source:
Returns:
Sorted package member URIs
Type
Array.<string>

getRolePidSet(className) → {Set.<string>}

Return PIDs classified as one PROVONE type, such as `Data` or `Program`.
Parameters:
Name Type Description
className string PROVONE class name.
Source:
Returns:
Matching PIDs.
Type
Set.<string>

getSummary() → {ResourceMapSummary}

Return a cached plain package summary, building it on the first read.
Source:
Returns:
Cloned package summary.
Type
ResourceMapSummary

getTypeAssertions() → {Array.<TypeAssertion>}

Source:
Returns:
Data and Program classifications.
Type
Array.<TypeAssertion>

getUsedByPrograms() → {Array.<ExecutionProgramRelationship>}

Source:
Returns:
Links from programs to data they consumed.
Type
Array.<ExecutionProgramRelationship>
Source:
Returns:
Data source relationships.
Type
Array.<WasDerivedFromRelationship>

getWasInformedByPrograms() → {Array.<ProgramLineageRelationship>}

Source:
Returns:
Current/previous program links.
Type
Array.<ProgramLineageRelationship>

hasMember(pid) → {boolean}

Test whether a PID belongs to the package.
Parameters:
Name Type Description
pid string Candidate PID.
Source:
Returns:
Whether the PID is a member.
Type
boolean

invalidate()

Clear all derived state after a graph mutation.
Source:

nodeHasIdentifier(node, pid) → {boolean}

Test whether a node has an expected identifier.
Parameters:
Name Type Description
node NamedNode | BlankNode | Literal RDF node.
pid string Expected PID.
Source:
Returns:
Whether the identifier matches.
Type
boolean

pidFromNode(node) → {string|null}

Resolve a node's PID from the current graph, including identifiers added earlier in a grouped edit. Cached summaries remain snapshots of the edit's starting state.
Parameters:
Name Type Description
node NamedNode | BlankNode | Literal RDF node
Source:
Returns:
PID when resolvable
Type
string | null