Constructor
new DataPackage()
- Source:
Extends
Members
comparator :string
Used to keep the collection sorted by model "sortOrder". The three
model types are ordered as: Metadata: 1; Data: 2; DataPackage: 3. See
getMember(). We do this so that Metadata get rendered first, and Data
are rendered as DOM siblings of the Metadata rows of the DataPackage
table.
Type:
- Source:
dataPackageGraph :RDFGraph
The RDF graph representing this data package
Type:
- Source:
Package members that are derivations in provenance relationships.
Type:
- Source:
editable :boolean
A flag used for the package's edit status. Can be set to false to
'lock' the package
Type:
- Source:
filterModel :Filter
A Filter model that should filter the Solr index for only the objects
aggregated by this package.
Type:
- Source:
id :string
The package identifier
Type:
- Source:
namespaces :object
Namespaces used in the RDF XML. The key is the prefix and the value is
the namespace URI.
Type:
- Source:
nodeLevel :number
The nesting level in a data package hierarchy
Type:
- Source:
numSaves :number
The number of models that have been updated during the current save().
This is reset to zero after the current save() is complete.
Type:
- Source:
originalIsDocBy :object
The science data identifiers associated with this data package (from
cito:documents), mapped to the science metadata identifier that
documents it. Not to be changed after initial fetch - this is to keep
track of the relationships in their original state
Type:
- Source:
originalMembers :Array.<string>
An array of ids that are aggregated in the resource map on the server.
Taken from the original RDF XML that was fetched from the server. Used
for comparing the original aggregation with the aggregation of this
collection.
Type:
- Source:
A DataONEObject representing the resource map itself
Type:
- Source:
provEdits :Array.<Array.<string>>
Contains provenance relationships added or deleted to this
DataONEObject. Each entry is [operation ('add' or 'delete'), prov field
name, object id], i.e. ['add', 'prov_used', 'urn:uuid:5678']
Type:
- Source:
provenanceFlag :string|null
Set to "complete" to signal that all prov queries have finished
Type:
- Source:
The SolrResults collection associated with this DataPackage. This can
be used to fetch the package from Solr by passing the 'fromIndex'
option to fetch().
Type:
- Source:
Package members that are sources in provenance relationships.
Type:
- Source:
transferQueue :DataPackage|Metadata|Array.<Data>
The type of the object (DataPackage, Metadata, Data) Simple queue to
enqueue file transfers. Use push() and shift() to add and remove items.
If this gets to large/slow, possibly switch to
http://code.stephenmorley.org/javascript/queues/
Type:
- Source:
type :string
The name of this type of collection
Type:
- Source:
Methods
addNewModel(model)
Adds a DataONEObject model to this DataPackage collection
Parameters:
Name |
Type |
Description |
model |
DataONEObject
|
The DataONEObject model to add |
- Source:
addProgramToGraph(programId) → {string}
Add a program identifier to the RDF graph and create an execution node
Parameters:
Name |
Type |
Description |
programId |
string
|
The program identifier |
- Source:
Returns:
The execution identifier
-
Type
-
string
addToAggregation(id)
Adds a new object to the resource map RDF graph
Parameters:
Name |
Type |
Description |
id |
string
|
The identifier of the object to add |
- Source:
addToGraph(subject, predicate, object)
Add the specified relationship to the RDF graph only if it has not
already been added.
Parameters:
Name |
Type |
Description |
subject |
object
|
The subject of the statement to add |
predicate |
object
|
The predicate of the statement to add |
object |
object
|
The object of the statement to add |
- Source:
broadcastAccessPolicy(accessPolicy)
Broadcast an accessPolicy across members of this package
Note: Currently just sets the incoming accessPolicy on this object and
doesn't broadcast to other members (such as data). How this works is
likely to change in the future.
Closely tied to the AccessPolicyView.broadcast property.
Parameters:
Name |
Type |
Description |
accessPolicy |
AccessPolicy
|
The accessPolicy to broadcast |
- Source:
cloneNode(nodeToClone) → {Node}
Clone an rdflib.js Node by creaing a new node based on the original
node RDF term type and data type.
Parameters:
Name |
Type |
Description |
nodeToClone |
Node
|
The node to clone |
- Source:
Returns:
- The cloned node
-
Type
-
Node
fetch(sourceOptionsopt) → {Promise}
Overload fetch calls for a DataPackage
This fetch function will fetch the resource map RDF XML for this
package
+ Example 1: `this.fetch();`
+ Example 2: `this.fetch({fetchModels: false});`
+ Example 3: `this.fetch({fromIndex: true});`
+ Example 4:
```
this.fetch()
.then(function() {
console.log("Fetch complete!");
})
.catch(function() {
console.log("Fetch failed!");
});
```
Parameters:
Name |
Type |
Attributes |
Description |
sourceOptions |
object
|
<optional>
|
Optional options for this fetch that get
sent with the XHR request |
Properties:
Name |
Type |
Description |
fetchModels |
boolean
|
If false, this fetch will not fetch
each model in the collection. It will only get the resource map
object. |
fromIndex |
boolean
|
If true, the collection will be
fetched from Solr rather than fetching the system metadata of each
model. Useful when you only need to retrieve limited information about
each package member. Set query-specific parameters on the
`solrResults` SolrResults set on this collection. |
- Source:
Returns:
A promise that resolves when the fetch is complete
-
Type
-
Promise
fetchFromIndex()
Fetches this DataPackage from the Solr index by using a SolrResults
collection and merging the models in.
- Source:
fetchMemberModels(models, batchSizeopt, timeoutopt, maxRetriesopt) → {Promise}
Fetches member models in batches to avoid fetching all members
simultaneously.
Parameters:
Name |
Type |
Attributes |
Description |
models |
Array.<Backbone.Model>
|
|
The array of member models to fetch. |
batchSize |
number
|
<optional>
|
The number of models to fetch in each
batch. |
timeout |
number
|
<optional>
|
The timeout for each fetch request in
milliseconds. If set to anything other than a positive number greater
than 0, the fetch will never timeout. |
maxRetries |
number
|
<optional>
|
The maximum number of retries for each
fetch request. |
- Since:
- Source:
Returns:
A promise that resolves when all models have been
fetched.
-
Type
-
Promise
fetchPromise(model) → {object}
Fetch a model using Backbone's fetch method but return a promise that
resolves when the fetch is complete, along with the XHR object
Parameters:
- Since:
- Source:
Returns:
An object with a promise and an XHR reference
-
Type
-
object
fetchWithRetryAndTimeout(memberModel, maxRetries, timeout, attemptopt) → {DataONEObject}
Fetch a model with a timeout and a maximum number of retries. Fetch a
model with a timeout, aborting the fetch if it takes too long.
Parameters:
Name |
Type |
Attributes |
Description |
memberModel |
DataONEObject
|
|
The model to fetch |
maxRetries |
number
|
|
The maximum number of retries |
timeout |
number
|
|
The timeout in milliseconds. If set to
anything other than a positive number greater than 0, the fetch will
not have a timeout (i.e., will wait indefinitely) |
attempt |
number
|
<optional>
|
The current attempt number |
- Since:
- Source:
Returns:
The fetched model
-
Type
-
DataONEObject
getAbsolutePath(relativePath) → {string}
Get the absolute path from a relative path, handling '~', '..', and
'.'.
Parameters:
Name |
Type |
Description |
relativePath |
string
|
The relative path to be converted to an
absolute path. |
- Since:
- Source:
Returns:
The absolute path after processing '~', '..', and
'.'. If the result is empty, returns '/'.
-
Type
-
string
getAtLocation() → {object}
Returns atLocation information found in this resourceMap for all the
PIDs in this resourceMap
- Since:
- Source:
Returns:
- object with PIDs as key and atLocation paths as
values
-
Type
-
object
getCnURI() → {string}
Parses out the CN Resolve URL from the existing statements in the RDF
or if not found in the RDF, from the app configuration.
- Source:
Returns:
- The CN resolve URL
-
Type
-
string
getExecutionId(programId) → {string}
Get the execution identifier that is associated with a program id. This
will either be in the 'prov_wasExecutedByExecution' of the package
member for the program script, or available by tracing backward in the
RDF graph from the program node, through the assocation to the related
execution.
Parameters:
Name |
Type |
Description |
programId |
string
|
The program identifier |
- Source:
Returns:
The execution identifier
-
Type
-
string
getExecutionNode(executionId) → {object}
Get the RDF node for an execution that is associated with the execution
identifier. The execution may have been created in the resource map as
a 'bare' urn:uuid (no resolveURI), or as a resolve URL, so check for
both until the id is found.
Parameters:
Name |
Type |
Description |
executionId |
string
|
The execution identifier |
- Source:
Returns:
The RDF node for the execution
-
Type
-
object
getMember(context) → {Backbone.Model}
When a data package member updates, we evaluate it for its formatid,
and update it appropriately if it is not a data object only
Parameters:
Name |
Type |
Description |
context |
Backbone.Model
|
The model that was updated |
- Source:
Returns:
The updated model
-
Type
-
Backbone.Model
getQueue() → {Array}
Gets objects not yet uploaded to the DataONE server
- Source:
Returns:
An array of models that are in the queue or in
progress of uploading
-
Type
-
Array
getURIFromRDF(id) → {string}
Finds the given identifier in the RDF graph and returns the subject URI
of that statement. This is useful when adding additional statements to
the RDF graph for an object that already exists in that graph.
Parameters:
Name |
Type |
Description |
id |
string
|
The identifier to search for |
- Source:
Returns:
- The full URI for the given id as it exists in the
RDF.
-
Type
-
string
getValue(result, name) → {string}
The return values have to be extracted from the result.
Parameters:
Name |
Type |
Description |
result |
object
|
The result of the SPARQL query |
name |
string
|
The name of the field to extract |
- Source:
Returns:
- The value of the result
-
Type
-
string
handleAdd(dataONEObject)
Actions ot perform when a DataONEObject model is added to this
collection
Parameters:
Name |
Type |
Description |
dataONEObject |
DataONEObject
|
The DataONEObject model that was
added |
- Source:
handleMemberFetchError(failedModels, errors)
Handle errors that occur when fetching member models
Parameters:
Name |
Type |
Description |
failedModels |
Array.<DataONEObject>
|
The models that were being
fetched |
errors |
Array.<Error>
|
The errors that occurred |
- Since:
- Source:
initialize()
- Source:
mergeModels(otherModels, fieldsToMergeopt)
Merge the attributes of other models into the corresponding models in
this collection. This should be used when merging models of other types
(e.g. SolrResult) that represent the same object that the DataONEObject
models in the collection represent.
Parameters:
Name |
Type |
Attributes |
Description |
otherModels |
Array.<Backbone.Model>
|
|
the other models to merge with
the models in this collection |
fieldsToMerge |
Array.<string>
|
<optional>
|
If specified, only these fields
will be extracted from the otherModels |
- Source:
The DataPackage collection stores DataPackages and DataONEObjects,
including Metadata and Data objects. Return the correct model based on
the type
Parameters:
Name |
Type |
Description |
attrs |
object
|
The attributes of the model |
options |
object
|
Options to pass to the instantiated model |
- Source:
Returns:
The model
-
Type
-
DataONEObject
|
ScienceMetadata
|
EML211
|
DataPackage
needsUpdate() → {boolean}
Checks if this resource map has had any changes that requires an update
- Source:
Returns:
- True if the resource map needs to be updated
-
Type
-
boolean
onDone()
This callback is called when all queries have finished.
- Source:
onResult(result)
This callback is called for every query solution of the SPARQL queries.
One query may result in multple queries solutions and calls to this
function. Each query result returns two pids, i.e. pid: 1234
prov_generated: 5678, which corresponds to the RDF triple '5678
wasGeneratedBy 1234', or the DataONE solr document for pid '1234', with
the field prov_generated: 5678.
Parameters:
Name |
Type |
Description |
result |
object
|
The result of the SPARQL query |
- Source:
Example
// The result can look like this:
[?pid: t, ?prov_wasDerivedFrom: t, ?primary_data: t, ?derived_data: t]
?derived_data : t {termType: "NamedNode", value: "https://cn-stage.test.dataone.org/cn/v2/resolve/urn%3Auuid%3Adbbb9a2e-af64-452a-b7b9-122861a5dbb2"}
?pid : t {termType: "Literal", value: "urn:uuid:dbbb9a2e-af64-452a-b7b9-122861a5dbb2", datatype: t}
?primary_data : t {termType: "NamedNode", value: "https://cn-stage.test.dataone.org/cn/v2/resolve/urn%3Auuid%3Aaae9d025-a331-4c3a-b399-a8ca0a2826ef"}
?prov_wasDerivedFrom : t {termType: "Literal", value: "urn:uuid:aae9d025-a331-4c3a-b399-a8ca0a2826ef", datatype: t}]
parse(response, _options) → {Array.<DataPackage>}
Deserialize a Package from OAI-ORE RDF XML
Parameters:
Name |
Type |
Description |
response |
string
|
The RDF/XML string to parse |
_options |
object
|
Options for parsing the RDF/XML |
- Source:
Returns:
- An array of models that were parsed from the
RDF/XML
-
Type
-
Array.<DataPackage>
parseProv()
Parse the provenance relationships from the RDF graph, after all
DataPackage members have been fetched, as the prov info will be stored
in them.
- Source:
Use the DataONEObject parseSysMeta() function
Parameters:
Name |
Type |
Description |
sysMeta |
object
|
The system metadata object to parse |
- Source:
Returns:
The parsed system metadata object
-
Type
-
object
provEditsPending() → {boolean}
Check if there are any provenance edits pending
- Source:
Returns:
Returns true if the prov edits list is not empty,
otherwise false.
-
Type
-
boolean
recordProvEdit(operation, subject, predicate, object)
Accumulate edits that are made to the provenance relationships via the
ProvChartView. these edits are accumulated here so that they are
available to any package member or view.
Parameters:
Name |
Type |
Description |
operation |
string
|
The operation performed on the relationship
(add or delete) |
subject |
string
|
The subject of the relationship |
predicate |
string
|
The predicate of the relationship |
object |
string
|
The object of the relationship |
- Source:
removeFromAggregation(id)
Removes an object from the aggregation in the RDF graph
Parameters:
Name |
Type |
Description |
id |
string
|
The identifier of the object to remove |
- Source:
removeIfLastProvRef(subjectNode, predicateNode, objectNode)
Remove the statement fromn the RDF graph only if the subject of this
relationship is not referenced by any other provenance relationship,
i.e. for example, the prov relationship "id rdf:type provone:data" is
only needed if the subject ('id') is referenced in another
relationship. Also don't remove it if the subject is in any other prov
statement, meaning it still references another prov object.
Parameters:
Name |
Type |
Description |
subjectNode |
object
|
The subject of the statement to remove |
predicateNode |
object
|
The predicate of the statement to
remove |
objectNode |
object
|
The object of the statement to remove |
- Source:
removeOrphanedBlankNodes()
Remove orphaned blank nodes from the model's current graph
This was put in to support replacing package members who are referenced
by provenance statements, specifically members typed as Programs.
rdflib.js will throw an error when serializing if any statements in the
graph have objects that are blank nodes when no other statements in the
graph have subjects for the same blank node. i.e., blank nodes
references that aren't defined.
Should be called during a call to serialize() and mutates
this.dataPackageGraph directly as a side-effect.
- Source:
removeProgramFromGraph(programId) → {boolean}
Remove a program identifier from the RDF graph and remove associated
linkage between the program id and the exection, if the execution is
not being used by any other statements.
Parameters:
Name |
Type |
Description |
programId |
string
|
The program identifier |
- Source:
Returns:
Returns true if the program was removed, otherwise
false.
-
Type
-
boolean
save(optionsopt)
Overwrite the Backbone.Collection.sync() function to set custom options
Parameters:
Name |
Type |
Attributes |
Description |
options |
object
|
<optional>
|
Options for this DataPackage save
Properties
Name |
Type |
Attributes |
Description |
sysMetaOnly |
boolean
|
<optional>
|
If true, only the system
metadata of this Package will be saved. |
resourceMapOnly |
boolean
|
<optional>
|
If true, only the Resource
Map/Package object will be saved. Metadata and Data objects aggregated
by the package will be skipped. |
|
- Source:
saveProv()
If provenance relationships have been modified by the provenance editor
(in ProvChartView), then update the ORE Resource Map and save it to the
server.
- Source:
saveReference(model)
Save a reference to this collection in the model
Parameters:
Name |
Type |
Description |
model |
DataONEObject
|
The model to save a reference to |
- Source:
serialize() → {string}
Serialize the DataPackage to OAI-ORE RDF XML
- Source:
Returns:
The serialized RDF/XML
-
Type
-
string
setLoadingFiles(dataONEObjectopt)
Tracks the upload status of DataONEObject models in this collection. If
they are `loading` into the DOM or `in progress` of an upload to the
server, they will be considered as "loading" files.
Parameters:
Name |
Type |
Attributes |
Description |
dataONEObject |
DataONEObject
|
<optional>
|
A model to begin tracking.
Optional. If no DataONEObject is given, then only the number of loading
files will be calcualted and set on the packageModel. |
- Since:
- Source:
triggerComplete(model)
Trigger the complete event if all models have been fetched
Parameters:
Name |
Type |
Description |
model |
Backbone.Model
|
The model that was fetched |
- Source:
updateLoadingCount(num)
Sets the numLoadingFileMetadata attribute on the package model
Parameters:
Name |
Type |
Description |
num |
number
|
The number of models that are currently being
fetched |
- Since:
- Source:
updateMemberModelType(memberModel, maxRetries, timeout) → {DataONEObject}
After a member model is fetched, determine whether it needs to:
1) be merged into the collection (the type did NOT change)
2) replace the old model (the type changed to DataPackage)
3) be fetched again, waited for, and then replaced in the collection
(the type from the server is different from the type in the
collection) Then resolve the promise when the model is fully
handled.
Parameters:
Name |
Type |
Description |
memberModel |
DataONEObject
|
The model to potentially replace |
maxRetries |
number
|
The maximum number of retries for each
fetch request |
timeout |
number
|
The timeout for each fetch request in
milliseconds. If set to anything other than a positive number greater
than 0, the fetch will never timeout |
- Since:
- Source:
Returns:
The updated model
-
Type
-
DataONEObject
updateRelationships()
Update the relationships in this resource map when its been udpated
- Source:
url(optionsopt) → {string}
Build the DataPackage URL based on the
MetacatUI.appModel.objectServiceUrl and id or seriesid
Parameters:
Name |
Type |
Attributes |
Description |
options |
object
|
<optional>
|
Optional options for this URL
Properties
Name |
Type |
Attributes |
Description |
update |
boolean
|
<optional>
|
If true, this URL will be for
updating the package |
|
- Source:
Returns:
The URL for this DataPackage
-
Type
-
string