Constructor
new PortalModel()
- Source:
Extends
Members
newSectionLabel :string
The default text to use for a new section label added by the user
Type:
- Source:
type :string
The name of this type of model
Type:
- Overrides:
- Source:
Methods
addIsPartOfFilter(seriesIdopt) → {Filter|undefined}
Creates a FilterModel with isPartOf as the field and this collection's
seriesId as the value, then adds it to the definitionFilters
collection. (which will also add it to the searchFilters collection)
Parameters:
| Name |
Type |
Attributes |
Description |
seriesId |
string
|
<optional>
|
the seriesId of the collection or portal |
- Inherited From:
- Source:
Returns:
The new isPartOf filter, if created
-
Type
-
Filter
|
undefined
Adds the given section to this Portal
Parameters:
| Name |
Type |
Description |
section |
PortalSectionModel
|
string
|
Either the
PortalSectionModel to add, or the name of the section to add. Some
sections in the portals are not tied to PortalSectionModels, because
they are created from other parts of the Portal document. For example,
the Data, Metrics, and Members sections. |
- Source:
Returns:
The section that was added if it
was a markdown or cesium section, or null if it was a data, metrics, or
members section.
-
Type
-
PortalSectionModel
|
null
addToUploadQueue()
Updates the upload status attribute on this model and marks the collection as changed
- Inherited From:
- Source:
cachePortal()
Saves a reference to this Portal on the MetacatUI global object
- Source:
cacheSearchResults(searchResults)
Creates a copy of the SolrResults collection and saves it in this model
so that there is always access to the unfiltered list of datasets
Parameters:
| Name |
Type |
Description |
searchResults |
SolrResults
|
The SolrResults collection to
cache |
- Inherited From:
- Source:
calculateChecksum(algorithmopt) → {string}
Calculate a checksum for the object
Parameters:
| Name |
Type |
Attributes |
Description |
algorithm |
string
|
<optional>
|
The algorithm to use, defaults to MD5 |
- Inherited From:
- Source:
Returns:
A checksum plain JS object with value and algorithm attributes
-
Type
-
string
checkAuthority(actionopt, optionsopt) → {boolean}
Check if the current user is authorized to perform an action on this object. This function doesn't return
the result of the check, but it sends an XHR, updates this model, and triggers a change event.
Parameters:
| Name |
Type |
Attributes |
Description |
action |
string
|
<optional>
|
The action (read, write, or changePermission) to check
if the current user has authorization to perform. By default checks for the highest level of permission. |
options |
object
|
<optional>
|
Additional options for this function. See the properties below. |
Properties:
| Name |
Type |
Description |
options.onSuccess |
function
|
A function to execute when the checkAuthority API is successfully completed |
options.onError |
function
|
A function to execute when the checkAuthority API returns an error, or when no PID or SID can be found for this object. |
- Inherited From:
- Source:
Returns:
-
Type
-
boolean
checkLabelAvailability(l)
Queries the Solr discovery index for other Portal objects with this
same label. Also, checks for the existing block list for repository
labels If at least one other Portal has the same label, then it is not
available.
Parameters:
| Name |
Type |
Description |
l |
string
|
The label to query for |
- Source:
cleanXMLText(textString) → {string|undefined}
Cleans up the given text so that it is XML-valid by escaping reserved
characters, trimming white space, etc.
Parameters:
| Name |
Type |
Description |
textString |
string
|
The string to clean up |
- Source:
Returns:
The cleaned string, or undefined for a
non-string value.
-
Type
-
string
|
undefined
createAccessPolicy(accessPolicyXMLopt) → {AccessPolicy}
Create an access policy for this DataONEObject using the default access
policy set in the AppModel.
Parameters:
| Name |
Type |
Attributes |
Description |
accessPolicyXML |
Element
|
<optional>
|
An XML node
that contains a list of access rules. |
- Inherited From:
- Source:
Returns:
- an AccessPolicy collection that represents the
given XML or the default policy set in the AppModel.
-
Type
-
AccessPolicy
createNodeAttributes(nodeInfoObject)
Sets attributes on this Portal using the given Member Node data
Parameters:
| Name |
Type |
Description |
nodeInfoObject |
object
|
A literal object taken from the
NodeModel 'members' array |
- Source:
createSearchModel() → {Search}
Creates a new instance of a Search model with a Filters collection. The
Search model is created and returned and NOT set directly on the model
in this function, because this function is called during parse(), when
we're not ready to set attributes directly on the model yet.
- Inherited From:
- Source:
Returns:
A search model with an empty Filters collection
-
Type
-
Search
Build a fresh system metadata document for this object when it is new
Return it as a DOM object
- Inherited From:
- Source:
createViewURL() → {string}
Creates a URL for viewing more information about this object
- Overrides:
- Source:
Returns:
The URL for viewing this portal.
-
Type
-
string
createXML() → {XMLDocument}
Initialize the object XML for a brand spankin' new collection
- Overrides:
- Source:
Returns:
The new collection document
-
Type
-
XMLDocument
defaults() → {object}
Overrides the default Backbone.Model.defaults() function to specify
default attributes for the portal model
- Overrides:
- Source:
Returns:
The default portal attributes
-
Type
-
object
downloadWithCredentials()
This method will download this object while
sending the user's auth token in the request.
- Inherited From:
- Source:
Returns:
None
errorValidatingLabel(eopt)
Reports a failure while checking portal label availability.
Parameters:
| Name |
Type |
Attributes |
Description |
e |
Error
|
string
|
<optional>
|
The error to log |
- Source:
fetch(optionsopt) → {jqXHR|undefined}
Overrides the default Backbone.Model.fetch() function to provide some
custom fetch options
Parameters:
| Name |
Type |
Attributes |
Description |
options |
object
|
<optional>
|
Options for this fetch.
Properties
| Name |
Type |
Attributes |
Description |
objectOnly |
boolean
|
<optional>
|
If true, only the object
will be retrieved and not the system metadata |
systemMetadataOnly |
boolean
|
<optional>
|
If true, only the
system metadata will be retrieved |
|
- Overrides:
- Source:
Returns:
The fetch request, or undefined when the
request is deferred or only system metadata is fetched.
-
Type
-
jqXHR
|
undefined
Sends an AJAX request to fetch the system metadata for this object.
Will not trigger a sync event since it does not use
Backbone.Model.fetch
Parameters:
| Name |
Type |
Attributes |
Description |
options |
object
|
<optional>
|
AJAX settings to use for the request |
- Inherited From:
- Source:
fileDoesNotExist() → {boolean}
Checks for a 404 error in the error status or message
- Since:
- Inherited From:
- Source:
Returns:
True if a 404 error is found
-
Type
-
boolean
findLatestVersion(latestVersionopt, possiblyNeweropt)
Finds the latest version of this object by travesing the obsolescence chain
Parameters:
| Name |
Type |
Attributes |
Description |
latestVersion |
string
|
<optional>
|
The identifier of the latest known object in the version chain.
If not supplied, this model's `id` will be used. |
possiblyNewer |
string
|
<optional>
|
The identifier of the object that obsoletes the latestVersion. It's "possibly" newer, because it may be private/inaccessible |
- Inherited From:
- Source:
A utility function that will format an XML string or XML nodes by camel-casing the node names, as necessary
Parameters:
| Name |
Type |
Description |
xml |
string
|
Element
|
The XML to format |
- Inherited From:
- Source:
Returns:
The formatted XML string
-
Type
-
string
generateId() → {string}
Generate a unique identifier to be used as an XML id attribute
- Inherited From:
- Source:
Returns:
The identifier string that was generated
-
Type
-
string
getCanonicalDOIIRI() → {string|null}
Check if the seriesID or PID matches a DOI regex, and if so, return
a canonical IRI for the DOI.
- Since:
- Inherited From:
- Source:
Returns:
- The canonical IRI for the DOI, or null if
neither the seriesId nor the PID match a DOI regex.
-
Type
-
string
|
null
Looks up human readable format of the DataONE Object
- Since:
- Inherited From:
- Source:
Returns:
format String
Get the object format identifier for this object
- Inherited From:
- Source:
getPackageURL()
Create the URL string that is used to download this package
- Since:
- Inherited From:
- Source:
Returns:
PackageURL string for this DataONE Object
getQuery() → {string}
This is a shortcut function that returns the query for the datasets in
this portal, using the Search model for this portal. This is the full
query that includes the filters not serialized to the portal XML, such
as the filters used for the DataCatalogView.
- Inherited From:
- Source:
Returns:
The collection's search query
-
Type
-
string
getRandomSectionImage() → {PortalImage|string|undefined}
getRandomSectionImage - Using the list of image identifiers set in the
app config, select an image to use for a portal section. The function
will not return the same image until all the images have been returned
at least once. If an image would return a 404 error, it is skipped. If
all images give 404s, an empty string is returned.
- Source:
Returns:
A portal image model, an
empty string when configured images are unavailable, or undefined when
no images are configured.
-
Type
-
PortalImage
|
string
|
undefined
getSeriesIdByLabel()
Get the portal seriesId by searching for the portal by its label in
Solr
- Source:
getSeriesIdByName()
This function has been renamed `getSeriesIdByLabel` and may be removed
in future releases.
- Deprecated:
- This function has been renamed `getSeriesIdByLabel` and may
be removed in future releases.
- Source:
- See:
-
getType()
Returns a plain-english version of the general format - either image, program, metadata, PDF, annotation or data
- Inherited From:
- Source:
getXMLPosition(portalNode, nodeName) → {jQuery|boolean}
Finds the node in the given portal XML document afterwhich the given
node type should be inserted
Parameters:
| Name |
Type |
Description |
portalNode |
Element
|
The portal element of an XML document |
nodeName |
string
|
The name of the node to be inserted into xml |
- Source:
Returns:
A jQuery object indicating a position, or
false when nodeName is not in the portal
schema
-
Type
-
jQuery
|
boolean
getXMLSafeID(idopt) → {string}
Converts the identifier string to a string safe to use in an XML id attribute
Parameters:
| Name |
Type |
Attributes |
Description |
id |
string
|
<optional>
|
The ID string |
- Inherited From:
- Source:
Returns:
- The XML-safe string
-
Type
-
string
handleChange(modelopt, options)
Set the changed flag on any system metadata or content attribute changes,
and set the hasContentChanges flag on content changes only
Parameters:
| Name |
Type |
Attributes |
Description |
model |
DataONEObject
|
<optional>
|
|
options |
object
|
|
Furhter options for this function |
Properties:
| Name |
Type |
Description |
options.force |
boolean
|
If true, a change will be handled regardless if the attribute actually changed |
- Inherited From:
- Source:
hasUpdates() → {boolean}
Checks if this system metadata XML has updates that need to be synced with the server.
- Inherited From:
- Source:
Returns:
-
Type
-
boolean
Converts hex color values to RGB
Parameters:
| Name |
Type |
Description |
hex |
string
|
a color in hexadecimal format |
- Source:
Returns:
The RGB color, or null if the hex
value is invalid
-
Type
-
PortalModel#rgb
|
null
initialize(attrs)
Overrides the default Backbone.Model.initialize() function to provide
some custom initialize options
Parameters:
| Name |
Type |
Description |
attrs |
object
|
Initial model attributes. |
- Overrides:
- Source:
isDOI(customString) → {boolean}
Checks if the pid or sid or given string is a DOI
Parameters:
| Name |
Type |
Description |
customString |
string
|
Optional. An identifier string to check instead of the id and seriesId attributes on the model |
- Inherited From:
- Source:
Returns:
True if it is a DOI
-
Type
-
boolean
isData() → {boolean}
Checks the formatId of this model and determines if it is a data file.
This determination is mostly used for display and the provenance editor. In the
DataONE API, many formatIds are considered `DATA` formatTypes, but they are categorized
as images
DataONEObject#isImage or software
DataONEObject#isSoftware.
- Inherited From:
- Source:
Returns:
true if this data object is a data file, false if it is other
-
Type
-
boolean
isDerivationField(field) → {boolean}
Returns true if this provenance field points to a derivation of this data or metadata object
Parameters:
| Name |
Type |
Description |
field |
string
|
|
- Inherited From:
- Source:
Returns:
-
Type
-
boolean
isImage() → {boolean}
Checks the formatId of this model and determines if it is an image.
- Inherited From:
- Source:
Returns:
true if this data object is an image, false if it is other
-
Type
-
boolean
isNew() → {boolean}
Returns true if this DataONE object is new. A DataONE object is new
if there is no upload date and it's been synced (i.e. been fetched)
- Inherited From:
- Source:
Returns:
-
Type
-
boolean
isPDF() → {boolean}
Checks the formatId of this model and determines if it a PDF.
- Inherited From:
- Source:
Returns:
true if this data object is a pdf, false if it is other
-
Type
-
boolean
isSoftware() → {boolean}
Checks the formatId of this model and determines if it is a software file.
This determination is mostly used for display and the provenance editor. In the
DataONE API, many formatIds are considered `DATA` formatTypes, but they are categorized
as images
DataONEObject#isImage for display purposes.
- Inherited From:
- Source:
Returns:
true if this data object is a software file, false if it is other
-
Type
-
boolean
isSourceField(field) → {boolean}
Returns true if this provenance field points to a source of this data or metadata object
Parameters:
| Name |
Type |
Description |
field |
string
|
|
- Inherited From:
- Source:
Returns:
-
Type
-
boolean
labelAvailable()
Reports that the current portal label is available
- Source:
labelTaken(label)
Adds a label to the local block list and reports that it is taken.
Parameters:
| Name |
Type |
Description |
label |
string
|
The unavailable portal label |
- Source:
nodeNameMap()
Maps the lower-case sys meta node names (valid in HTML DOM) to the
camel-cased sys meta node names (valid in DataONE).
Used during parse() and serialize()
- Inherited From:
- Source:
onSuccessfulSave(modelopt, responseopt, xhropt)
This function is executed when the XHR that saves this DataONEObject has
successfully completed. It can be called directly if a DataONEObject is saved
without directly using the DataONEObject.save() function.
Parameters:
| Name |
Type |
Attributes |
Description |
model |
DataONEObject
|
<optional>
|
A reference to this DataONEObject model |
response |
XMLHttpRequest.response
|
<optional>
|
The XHR response object |
xhr |
XMLHttpRequest
|
<optional>
|
The XHR that was just completed successfully |
- Inherited From:
- Source:
parse(response) → {object}
Overrides the default Backbone.Model.parse() function to parse the
custom portal XML document
Parameters:
| Name |
Type |
Description |
response |
XMLDocument
|
The XMLDocument returned from the
fetch() AJAX call |
- Overrides:
- Source:
Returns:
The parsed portal attributes, to be set
directly on the model.
-
Type
-
object
parseCollectionXML(rootNode) → {JSON}
Parses the collection XML into a JSON object
Parameters:
| Name |
Type |
Description |
rootNode |
Element
|
The XML Element that contains all the
collection nodes |
- Inherited From:
- Source:
Returns:
The result of the parsed XML, in JSON. To be set
directly on the model.
-
Type
-
JSON
parseEMLTextNode(parentNode, nodeName, isMultiple) → {EMLText|Array.<EMLText>|null}
Parses the XML nodes that are of type EMLText
Parameters:
| Name |
Type |
Description |
parentNode |
Element
|
The XML Element that contains all the
EMLText nodes |
nodeName |
string
|
The name of the XML node to parse |
isMultiple |
boolean
|
If true, parses the nodes into an array |
- Source:
Returns:
The parsed EMLText model or models,
or null when a single matching node is not found
-
Type
-
EMLText
|
Array.<EMLText>
|
null
parseTextNode(parentNode, nodeName, isMultiple) → {string|Array}
Gets the text content of the XML node matching the given node name
Parameters:
| Name |
Type |
Description |
parentNode |
Element
|
The parent node to select from |
nodeName |
string
|
The name of the XML node to parse |
isMultiple |
boolean
|
If true, parses the nodes into an array |
- Inherited From:
- Source:
Returns:
- Returns a string or array of strings of the
text content
-
Type
-
string
|
Array
pushSectionToSectionsArray(newSection)
Adds the given section to the sections array on the model and triggers
an "addSection" event with the new section as an argument. Necessary
because Backbone doesn't trigger a "change" event when an array is
updated. Sections should be a collection instead of an array, but this
is a workaround for now.
Parameters:
| Name |
Type |
Description |
newSection |
PortalSectionModel
|
The section to add to the
sections array on the model. |
- Since:
- Source:
queryForLabel(label, urlBaseopt, tryAltRepoopt)
Queries a repository for an existing portal label and reports whether
it is available.
Parameters:
| Name |
Type |
Attributes |
Description |
label |
string
|
|
The portal label to query for |
urlBase |
string
|
<optional>
|
The query service URL |
tryAltRepo |
boolean
|
<optional>
|
Whether to query an alternate
repository when the label is not found. Defaults to true. |
- Source:
Removes nodes from the XML that do not have an accompanying model (i.e.
nodes which were probably removed by the user during editing)
Parameters:
| Name |
Type |
Description |
nodes |
jQuery
|
The nodes to potentially remove |
models |
Array.<Model>
|
The model to compare to |
- Source:
removePortalImage(portalImage)
removePortalImage - remove a PortalImage model from either the logo,
sections, or acknowledgmentsLogos node of the portal model.
Parameters:
| Name |
Type |
Description |
portalImage |
PortalImage
|
The portal image model to remove |
- Source:
removeSection(section)
Removes or hides the given section from this Portal
Parameters:
| Name |
Type |
Description |
section |
PortalSectionModel
|
string
|
Either the
PortalSectionModel to remove, or the name of the section to remove.
Some sections in the portals are not tied to PortalSectionModels,
because they are created from other parts of the Portal document. For
example, the Data, Metrics, and Members sections. |
- Source:
reportSectionChange(modelopt)
Reports which portal section is active to every section model.
Parameters:
| Name |
Type |
Attributes |
Description |
model |
PortalSectionModel
|
<optional>
|
The active section model |
- Source:
reserveSeriesId() → {Promise.<void>}
Generate a UUID, reserve it using the DataOne API, and set it on the
model
- Inherited From:
- Source:
Returns:
Resolves when reservation finishes
-
Type
-
Promise.<void>
resetID()
Resets the identifier for this model. This undos all of the changes made in {DataONEObject#updateID}
- Inherited From:
- Source:
save() → {false|undefined}
Saves the portal XML document to the server using the DataONE API.
- Overrides:
- Source:
Returns:
False when validation fails; otherwise
undefined.
-
Type
-
false
|
undefined
saveNodeBlockList(xml)
Parses the retrieved XML document and saves the node information to the
BlockList
Parameters:
| Name |
Type |
Description |
xml |
XMLDocument
|
The XMLDocument returned from the fetch()
AJAX call. |
- Source:
sectionIsDefault(sectionModel) → {boolean}
Checks whether the given sectionModel has been updated by the user, or
whether all attributes match their default values. For a section's
markdown, the default value is either an empty string or null. For a
section's label, the default value is either an empty string or a
string that begins with the value set to PortalModel.newSectionLabel.
For all other attributes, the defaults are set in
PortalSectionModel.defaults.
Parameters:
| Name |
Type |
Description |
sectionModel |
PortalSectionModel
|
The model to check against a
default model |
- Source:
Returns:
returns true if the sectionModel matches a default
model, and false when at least one attribute differs
-
Type
-
boolean
serialize() → {string|undefined}
Retrieves the model attributes and serializes into portal XML, to
produce the new or modified portal document.
- Source:
Returns:
The portal XML, or undefined when
serialization fails.
-
Type
-
string
|
undefined
Using the attributes set on this DataONEObject model, serializes the system metadata XML
- Inherited From:
- Source:
Returns:
-
Type
-
string
setMissingFileName()
Sets the fileName attribute on this model using the portal label
- Overrides:
- Source:
setNotFound(e)
Set the notFound attribute to true and trigger a notFound event
Parameters:
| Name |
Type |
Description |
e |
Error
|
An optional error object from a failed fetch |
- Inherited From:
- Source:
setPossibleAuthMNs()
Creates an array of objects that represent Member Nodes that could possibly be this
object's authoritative MN. This function updates the `possibleAuthMNs` attribute on this model.
- Inherited From:
- Source:
setProvClass(className)
Set the DataONE ProvONE provenance class
param className - the shortened form of the actual classname value. The
shortname will be appened to the ProvONE namespace, for example,
the className "program" will result in the final class name
"http://purl.dataone.org/provone/2015/01/15/ontology#Program"
see https://github.com/DataONEorg/sem-prov-ontologies/blob/master/provenance/ProvONE/v1/provone.html
Parameters:
| Name |
Type |
Description |
className |
string
|
|
- Inherited From:
- Source:
Copy stable member fields to the linked EML entity.
- Since:
- Inherited From:
- Source:
toJson(xml)
A utility function for converting XML to JSON
Parameters:
| Name |
Type |
Description |
xml |
|
|
- Inherited From:
- Source:
toXML(json, containerNode) → {Element}
Serialize the DataONE object JSON to XML
Parameters:
| Name |
Type |
Description |
json |
object
|
the JSON object to convert to XML |
containerNode |
Element
|
an HTML element to insertt the resulting XML into |
- Inherited From:
- Source:
Returns:
The updated HTML Element
-
Type
-
Element
updateCollectionDOM(objectDOM) → {XMLElement}
Updates collection XML with values in the collection model
Parameters:
| Name |
Type |
Description |
objectDOM |
XMLDocument
|
the XML element to be updated |
- Inherited From:
- Source:
Returns:
An updated XML element
-
Type
-
XMLElement
updateID(id)
Update identifiers for this object
Parameters:
| Name |
Type |
Description |
id |
string
|
Optional identifier to update with. Generated
automatically when not given.
Note that this method caches the objects attributes prior to
updating so this.resetID() can be called in case of a failure
state.
Also note that this method won't run if theh oldPid attribute is
set. This enables knowing before this.save is called what the next
PID will be such as the case where we want to update a matching
EML entity when replacing files. |
- Inherited From:
- Source:
updateNodeBlockList()
Queries the CN Solr to retrieve the updated BlockList
- Source:
updateProgress(e)
Updates the progress percentage when the model is getting uploaded
Parameters:
| Name |
Type |
Description |
e |
ProgressEvent
|
The ProgressEvent when this file is being uploaded |
- Inherited From:
- Source:
updateRelationships()
Updates the relationships with other models when this model has been updated
- Inherited From:
- Source:
updateSearchModel()
updateSearchModel - This function is called when any changes are made
to the definition filters. The function adds, removes, or updates
models in the Search Model filters when models are changed in the
collection Definition Filters.
- Inherited From:
- Source:
Updates the DataONEObject System Metadata to the server
- Inherited From:
- Source:
updateTo110(modelJSON) → {JSON}
Takes parsed Collections 1.0.0 XML in JSON format and makes any changes
required so that collections are still represented in MetacatUI as they
were before MetacatUI was updated to support 1.1.0 Collections.
Parameters:
| Name |
Type |
Description |
modelJSON |
JSON
|
Parsed 1.0.0 Collections XML, in JSON |
- Inherited From:
- Source:
Returns:
The updated JSON, compatible with 1.1.0 changes
-
Type
-
JSON
url() → {string}
Returns the portal URL
- Overrides:
- Source:
Returns:
The portal URL
-
Type
-
string
validate(_attrsopt, _optionsopt) → {object|undefined}
Overrides the default Backbone.Model.validate.function() to check if
this portal model has all the required values necessary to save to the
server.
Parameters:
| Name |
Type |
Attributes |
Description |
_attrs |
object
|
<optional>
|
A literal object of model attributes to
validate. |
_options |
object
|
<optional>
|
A literal object of options for this
validation process |
- Overrides:
- Source:
Returns:
An object of error messages, or undefined
when there are no errors.
-
Type
-
object
|
undefined
validateLabel(label) → {string|undefined}
Checks that a label does not equal a restricted value (e.g. new
temporary name), and that it's encoded properly for use as part of a
url
Parameters:
| Name |
Type |
Description |
label |
string
|
The label to be validated |
- Inherited From:
- Source:
Returns:
An error message if the label is invalid
-
Type
-
string
|
undefined
Type Definitions
rgb
An RGB color value
Type:
Properties:
| Name |
Type |
Description |
r |
number
|
A value between 0 and 255 defining the intensity
of red |
g |
number
|
A value between 0 and 255 defining the intensity
of green |
b |
number
|
A value between 0 and 255 defining the intensity
of blue |
- Source: