Constructor
new EMLAttributes()
- Since:
- Source:
Extends
Members
model
- Source:
Methods
addAttribute(attributesopt, options) → {EMLAttribute}
Add an attribute to the collection. Will try to set the parentModel if
it is not already set.
Parameters:
Name |
Type |
Attributes |
Description |
attributes |
object
|
EMLAttribute
|
<optional>
|
The model attributes of the
new EML attribute. Should include the parentModel. Or an instance of
EMLAttribute. |
options |
object
|
|
Options to pass to the add method |
- Source:
Returns:
The newly added attribute
-
Type
-
EMLAttribute
addNewAttribute(parentModel, allowMultiple) → {EMLAttribute}
Add a new attribute to the collection. Only allows one new attribute to
be added at a time (unless allowMultiple is true). Returns the existing
new attribute if one is already present.
Parameters:
Name |
Type |
Description |
parentModel |
EMLEntity
|
The model that contains this collection,
optional |
allowMultiple |
boolean
|
If true, allows multiple new
attributes to be added. If false, only one new attribute can be added
at a time. Defaults to false. |
- Source:
Returns:
The newly added attribute model
-
Type
-
EMLAttribute
comparator(model) → {number}
Ensure new models are always at the end of the collection.
Parameters:
Name |
Type |
Description |
model |
EMLAttribute
|
The model to compare |
- Source:
Returns:
A value greater than 0 if the model is new, 0
otherwise
-
Type
-
number
Find the first attribute in the collection that is marked as new
- Source:
Returns:
The new attribute model or null if none found
-
Type
-
EMLAttribute
getParentModel() → {EMLEntity}
Get the model that contains this collection. Searches through all of
the attributes in the collection to find the one that has the
parentModel set.
- Source:
Returns:
The model that contains this collection or null if
no parent model is found
-
Type
-
EMLEntity
hasNonEmptyAttributes() → {boolean}
Check that the collection has at least one attribute that has data.
- Source:
Returns:
True if the collection has at least one attribute
that is not empty, false otherwise
-
Type
-
boolean
isValid() → {boolean}
Check if the collection is valid. If not, set the validationError
property to the validation errors.
- Source:
Returns:
True if the collection is valid, false otherwise
-
Type
-
boolean
parse()
- Source:
removeEmptyAttributes() → {Array.<EMLAttribute>}
Remove all attributes that are empty
- Source:
Returns:
The removed attributes
-
Type
-
Array.<EMLAttribute>
serialize() → {string}
Serialize the collection of attributes to an XML string
- Source:
Returns:
The XML string representing the collection of
attributes
-
Type
-
string
updateNames(names, parentModel, options)
Given an array of strings, update the names of the attributes in the
collection to match the array. If the number of names in the array
exceeds the number of attributes in the collection, new attributes will
be added to the collection. If the number of names is less than the
number of attributes in the collection, the extra attributes will be
removed.
Parameters:
Name |
Type |
Description |
names |
Array.<string>
|
An array of new attribute names |
parentModel |
EMLAttributeList
|
The model that contains this
collection |
options |
object
|
Options to pass to the add, remove, and set
methods |
- Source:
validate()
- Source: