Fork me on GitHub Fork me on GitHub

Collection


    <%
    var dataStore = new MetadataStore("admin", "admin");
    var collection = dataStore.newCollection();
    dataStore.put("wso2products", collection);
    //creating resource and adding it to collection
    var resource = dataStore.newResource();
    dataStore.put("wso2products/jaggery.xml", resource);
     
    //now we reading from collection
    var res = dataStore.get("wso2products");
    print(res.getChildren());
    %>

Overview

Collection can contain resources


Members

Member Type Description
authorString
collection.author;
Returns the author username on a collection
lastUpdatedUserStringget author username who did the last update on a collection
lastUpdatedTimeDateget lastUpdatedTime
createdTimeDateget createdTime
idStringget id of the collection.
pathStringget path of the collection
parentPathStringget parentPath
permanentPathStringget permanentPath
stateNumberget state
mediaTypeStringget/set mediaType
contentObjectget/set content
descriptionStringget/set description
getChildren Numberget resource count in collection

Operations

Operation Returns Description
addProperty("name", "value")None
var dataStore = new MetadataStore("admin", "admin");
var collection = dataStore.newCollection();
collection.addProperty("company", "WSO2");

adding property for collection

addProperty("name", "value")None
var dataStore = new MetadataStore("admin", "admin");
var collection = dataStore.newCollection();
collection.addProperty("company", "WSO2");

adding property for collection

getProperty(String collectionName);String
var value = collection.getProperty("company");
This method returns value of a collection

Above code returns last added value for a collection if there is a list of values.
getPropertyValues(String propertyName);String []
var value = collection.getPropertyValues("company");
This method returns list of values of a property in collection
getProperties();Object[]
var properties = collection.getProperties();
This method returns the list of properties with 'name' and 'value'. value is list of a vlaue for particular collection

editPropertyValue(String propertyName,String propertyValue,String propertyNewValue );None
 editPropertyValue("company","WSO2","WSO2 Inc"); 
This method will edit property value in to new value.
removePropertyValue(String propertyName,String propertyValue);None
 removePropertyValue("company","WSO2 Inc"); 
This method will remove property value in property.
removeProperty(String propertyName);None
 removeProperty("company"); 
This method will remove property from the resource.
setProperty(String propertyName, String propertyValue/Values);None
 setProperty("company","WSO2"); 
This method will set property values.