Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

An asset is metadata plus content (content is the file) and namespaces are a virtual hierarchy of for assets.


Asset metadata

Standard metadata

...

Here is how to set the metadata value within of location to a value of "Perth" using pshell:

Code Block
asset.set :id 25480 :meta < :mytype < :location "Perth" > >

...

where myfile.jpg.meta contained the following:

Code Block
[asset]
geoshape/point]
/latitude = "10.0"
geoshape/point/longitude = "20.0"
geoshape/point/elevation = "100.0"

[mytype]
name = "the name"
details = "some more information"


Note

The asset section contains built-in "first class" asset metadata entries, whereas the mytype section contains the custom metadata.


We can then import the file using pshell, eg:

...

To restrict the search to look only in /projects/Data Teammyproject, use:

Code Block
asset.query :where "namespace='/projects/Data Teammyproject' and name='*.PNG'"


To If you wish to search in /projects/Data Team myproject and all folders underneath it, use:

Code Block
asset.query :wherenamespace "namespace>='/projects/Data Team' and myproject" :where "name='*.PNG'"


Searching for all assets that were created after a certain date would be done as follows:

Code Block
asset.query :wherenamespace "namespace>='/projects/Data Team' and myproject" :where "ctime>='01-Jan-2017'"

Similar searches could be done using a geometric bounding box if your data has geospatial information attached.

...

If one of the elements in mytype was location (which is of type string), then here is how to search for a particular value:

Code Block
asset.query :namespace "/projects/myproject" :where "xpath(mytype/location) = 'Perth' and namespace>='/projects/myproject'"


Getting more information from the results

...

To get the name of the asset as well, use:

Code Block
asset.query :wherenamespace "namespace>='/projects/Data Team' and myproject" :where "name='*.PNG'" :action get-name

To get arbitrary pieces of metadata, for example the name and checksum, use:

Code Block
asset.query :wherenamespace "namespace>='/projects/Data Team' and myproject" :where "name='*.PNG'" :action get-value :xpath name :xpath content/csum

...

To associate a better name with the returned metadata item, use something like:

Code Block
asset.query :wherenamespace "namespace>='/projects/Data Team' and myproject" :where "name='*.PNG'" :action get-value :xpath -ename checksum content/csum

...

For example, to count all PNG files stored in the entire Data Team project or and then to sum their sizes you would run, respectively:

Code Block
asset.query :wherenamespace "namespace>='/projects/Data Team' and myproject" :where "name='*.PNG'" :action count
asset.query :wherenamespace "namespace>='/projects/Data Team' and myproject" :where "name='*.PNG'" :action sum :xpath content/size

...

For example, suppose we wanted to move all PNG files to a new location /projects/Data Teammyproject/png-files we would use:

Code Block
asset.query :wherenamespace "namespace>='/projects/Data Team' and myproject" :where "name='*.PNG'" :action pipe :service -name asset.move < :namespace /projects/Data Teammyproject/png-files >

Here our action is to pipe the results to another service call, in this case an asset.move, which is a service call that takes the required destination namespace argument in a shorthand XML document.

Naturally, similar constructions could be used to simply delete these files instead:

Code Block
asset.query :wherenamespace "namespace>='/projects/Data Team' and myproject" :where "name='*.PNG'" :action pipe :service -name asset.destroy

...

To change the name of the sean folder1 namespace to sean2 folder2 use:

Code Block
asset.namespace.rename :namespace /projects/Data Teammyproject/seanfolder1 :name sean2folder2


To move the namespace sean to folder1 to a new parent location use:

Code Block
asset.namespace.move :namespace /projects/Data Teammyproject/seanfolder1 :to /projects/Data Teammyproject/adminsnewparent


To delete a namespace entirely, use:

Code Block
asset.namespace.destroy :namespace /projects/Data Teammyproject/seanfolder1