StoreCollection
- A collection of stores and their name and parameters, including methods to convert to a from metadata representation.
use StoreCollection;
# instantiate
my $sc=StoreCollection->new();
# get metadata hash from hash
my $md=$sc->hash2Metadata($hash);
# get hash from metadata
my $md=$sc->metadata2Hash($metadata);
# merge/inherit values from several hashes
my $result=$sc->mergeHash($hash1,$hash2,$hash3...$hashn);
Class to manage a Store-collection in hash- and metadata version and conversions between the two, including merging/inheritance functionality. It also cleans and ensures compliance with the AURORA StoreCollection structural format.
A Store-collection when stored in the AURORA database are represented thus:
system.storecollection.name = SCALAR
system.storecollection.get.1.name = SCALAR
system.storecollection.get.1.store = ID (store-entity id)
system.storecollection.get.1.whatever = SCALAR
system.storecollection.get.1.classparam.p1 = SCALAR
system.storecollection.get.1.param.p1 = SCALAR
system.storecollection.get.1.param.p2 = SCALAR
system.storecollection.get.1.param.p3 = SCALAR
system.storecollection.get.1.param.p4 = SCALAR
system.storecollection.get.1.param.pN = SCALAR
system.storecollection.get.2.name = SCALAR
system.storecollection.get.2.store = ID
system.storecollection.get.2.param.p1 = SCALAR
system.storecollection.get.2.param.pN = SCALAR
.
.
system.storecollection.put.1.name = SCALAR
system.storecollection.put.1.store = ID
system.storecollection.put.1.whatever = SCALAR
system.storecollection.put.1.classparam.p1 = SCALAR
system.storecollection.put.1.param.p1 = SCALAR
system.storecollection.put.1.param.p2 = SCALAR
system.storecollection.put.1.param.pN = SCALAR
.
.
system.storecollection.put.N.name = SCALAR
.
.
system.storecollection.del.1.name = SCALAR
system.storecollection.del.1.store = ID
system.storecollection.del.1.classparam.p1 = SCALAR
system.storecollection.del.1.param.p1 = SCALAR
system.storecollection.del.1.param.pN = SCALAR
.
.
system.storecollection.del.2.name = SCALAR
.
.
etc..
This AURORA metadata namespace representation is converted to a normal HASH thus:
(
name => SCALAR,
get => { 1 => { name => SCALAR,
store => ID,
whatever => SCALAR,
classparam => { p1 => SCALAR,
},
param => { p1 => SCALAR,
p2 => SCALAR,
p3 => SCALAR,
p5 => SCALAR,
pN => SCALAR,
}
}
2 => { name => SCALAR,
store => ID,
param => { p1 => SCALAR, pN => SCALAR }
}
put => { 1 => { name => SCALAR,
store => ID,
whatever => SCALAR,
classparam => { p1 => SCALAR,
},
param => { p1 => SCALAR,
p2 => SCALAR,
pN => SCALAR,
}
}
N => { name => SCALAR,
}
}
del => { 1 => { name => SCALAR,
store => ID,
classparam => { p1 => SCALAR,
},
param => { p1 => SCALAR,
.
pN => SCALAR,
}
}
2 => { name => SCALAR,
}
}
)
Instantiates the StoreCollection-class.
It takes the following parameters
base Sets the namespace base for converting back- and forth from the AURORA metadata namespace. If none is given it defaults to "system.storecollection".
Returns the instantiated class.
This method turns the hash-format structure into a AURORA metadata structure (see DESCRIPTION).
Input is a hash reference to the structure to convert into a metadata structure.
Name- and store can be left non-existent in the hash reference that is given for conversion. It will then only convert potential param-values. But the hash-structure has to contain the starting keys of get and/or put and the subkeys has to be numbered to be accepted. The returned metadata hash might then only contain a parameter subkey setting, even an empty array if none is specified. This functionality is to allow for easy inheritance of param-values, where templates further down in the hierachy does not need to set any name or store entity id, only which parameters that are to be overridden/changed.
It returns a metadata hash reference upon success, undef upon failure. Please check the error()-method for more information on a potential error.
This method converts an AURORA metadata hash into a hash-format structure (see DESCRIPTION).
As with hash2Metadata, the name- and store settings can be non-existent. It will always return a param-setting for any existing, numbered get- or put setting. The param-setting may be non-existing as well.
It takes a AURORA metadata hash reference as input.
The method returns the hash-format reference upon success, undef upon failure. Please check the error()-method upon any failure.
This method merges two or more hash-format references into one hash.
It takes any number of hash-reference as input in the form of a hash reference LIST.
The hash-structures references will be iterated over in the order that they were input into the method. The last hash-structure to be checked will override any previous hash-structure setting, so that last in the list has precedence.
It returns a resulting hash-reference to a hash-format structure upon success, undef upon failure. Please check the error()-method for more information upon failure.
This method can also be used to a clean a hash that is of uncertain format and content. Since the method just iterates over the hash-references specified as input, by specifying just one hash reference to the method it will just clean that one and return the result (and valid keys and data).
This method converts a template as returned from AuroraDB into a hash-format structure of store-collection definitions (if any exists).
It takes the template hash-reference from AuroraDB as input.
The method works similarily to the metadata2Hash()-method. See that method for more information. Instead of that method it takes the "default"-setting of the template and sets it as values for name, store and/or param.
It returns the finished converted hash or undef upon failure. Please check the error()-method upon failure.
This method returns or sets the AURORA database metadata base namespace for the store-collections used by this module for conversion. See the "base" option in the new()-method for more information.
Upon set takes the base namespace as parameter (SCALAR). Upon get it takes no parameters.
Returns the base namespace as a SCALAR.
Returns the last error from the StoreCollection-class, if any.
No input taken.
Returns a SCALAR with the error message if any (blank if none).