org.gcube.portlets.admin.irbootstrapperportlet.gwt.server.types.data
Class DataType<T extends Resource>

java.lang.Object
  extended by org.gcube.portlets.admin.irbootstrapperportlet.gwt.server.types.data.DataType<T>
All Implemented Interfaces:
Cloneable, Evaluable
Direct Known Subclasses:
ForwardIndexDataType, FullTextIndexDataType, FullTextIndexNodeDataType, GCUBECollectionDataType, GeoIndexDataType, IncrementalFTIndexUpdaterDataType, IncrementalFWIndexUpdaterDataType, IncrementalGeoIndexUpdaterDataType, MetadataCollectionDataType, OpenSearchDataType, TreeManagerCollectionDataType

public abstract class DataType<T extends Resource>
extends Object
implements Cloneable, Evaluable

Author:
Spyros Boutsis, NKUA

Field Summary
protected  String typeName
          The name of this dataType
protected  Document xml
          The XML definition of the dataType
 
Method Summary
 Object clone()
           
 void copyDataFromResource()
          Updates all the attributes of this data types with the values of the corresponding attributes defined in the associated resource.
 void copyDataToResource()
          Updates all the attributes of the associated resource with the values of the corresponding attributes defined in this data type.
abstract  boolean doesIdentifyUniqueResource()
          Returns true if the currently defined attributes of this DataType are adequate in order to uniquely identify a resource in the infrastructure.
 EvaluationResult evaluate(String expression)
          Returns the Node object representing a node in the XML definition of this data type.
 List<DataType<T>> findMatchesInScope(org.gcube.common.core.scope.GCUBEScope scope)
          Returns a list of DataTypeInstances representing all the resources that match the properties defined in this DataType in the given scope
 T getAssociatedResource()
           
 String getAttributeValue(String expression)
          Gets the value of an attribute defined in the XML definition of this data type.
abstract  Map<String,String> getDataTypeAttrToResourceAttrMappings()
          Returns (dataTypeAttrValue, resourceAttrValue) pairs, which describe the mappings between attributes defined in this data types and attributes defined in the wrapped type of resource.
 org.gcube.common.core.scope.GCUBEScope getScope()
           
 Node getTypeDefinition()
          Returns the XML definition of this data type
 String getTypeName()
           
abstract  String getUID()
          Returns an identifier that uniquely identifies the specific DataType instance.
abstract  String getUIDescription()
          Returns a string which will be displayed as the description of this DataType in the UI.
abstract  String getUIName()
          Returns a string which will be displayed as the name of this DataType in the UI.
abstract  Document getXMLTypeDefinitionDocument()
          Returns a Document object defining the XML structure of this DataType's contents.
 void initialize(String typeName)
          Initializes this DataType instance
 void setAttributeValue(String expression, String value)
          Sets the value of an attribute defined in the XML definition of this data type.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

typeName

protected String typeName
The name of this dataType


xml

protected Document xml
The XML definition of the dataType

Method Detail

initialize

public void initialize(String typeName)
                throws Exception
Initializes this DataType instance

Parameters:
typeName - the name of the data type
xml - the XML definition of the data type
Throws:
Exception

getTypeDefinition

public Node getTypeDefinition()
Returns the XML definition of this data type

Returns:

getScope

public org.gcube.common.core.scope.GCUBEScope getScope()

getTypeName

public String getTypeName()

evaluate

public EvaluationResult evaluate(String expression)
                          throws Exception
Returns the Node object representing a node in the XML definition of this data type.

Specified by:
evaluate in interface Evaluable
Parameters:
expression - the expression to evaluate, in "a.b.c..." notation
Returns:
the Node object that represents the requested node
Throws:
Exception

setAttributeValue

public void setAttributeValue(String expression,
                              String value)
                       throws Exception
Sets the value of an attribute defined in the XML definition of this data type. Works only for attributes represented by "leaf" nodes in the XML definition, whose value is only a string and not a node tree.

Parameters:
expression - the expression to evaluate, in "a.b.c..." notation
value - the value to set to the attribute identified by the given expression
Throws:
Exception

getAttributeValue

public String getAttributeValue(String expression)
                         throws Exception
Gets the value of an attribute defined in the XML definition of this data type. Works only for attributes represented by "leaf" nodes in the XML definition, whose value is only a string and not a node tree. If the requested attribute is not currently set, returns null.

Parameters:
expression - the expression to evaluate, in "a.b.c..." notation
Returns:
the value of the attribute identified by the given expression
Throws:
Exception

findMatchesInScope

public List<DataType<T>> findMatchesInScope(org.gcube.common.core.scope.GCUBEScope scope)
                                                      throws Exception
Returns a list of DataTypeInstances representing all the resources that match the properties defined in this DataType in the given scope

Parameters:
scope - the scope to search in
Returns:
the list of DataType instances
Throws:
Exception

getAssociatedResource

public T getAssociatedResource()

copyDataFromResource

public void copyDataFromResource()
                          throws Exception
Updates all the attributes of this data types with the values of the corresponding attributes defined in the associated resource.

Throws:
Exception

copyDataToResource

public void copyDataToResource()
                        throws Exception
Updates all the attributes of the associated resource with the values of the corresponding attributes defined in this data type.

Parameters:
resource -
Throws:
Exception

getDataTypeAttrToResourceAttrMappings

public abstract Map<String,String> getDataTypeAttrToResourceAttrMappings()
Returns (dataTypeAttrValue, resourceAttrValue) pairs, which describe the mappings between attributes defined in this data types and attributes defined in the wrapped type of resource.

Returns:

doesIdentifyUniqueResource

public abstract boolean doesIdentifyUniqueResource()
Returns true if the currently defined attributes of this DataType are adequate in order to uniquely identify a resource in the infrastructure. If the DataType attributes could possibly describe more than one resources, this method should return false;

Returns:

getUID

public abstract String getUID()
Returns an identifier that uniquely identifies the specific DataType instance. It is guaranteed that when this method is called, the DataType will be fully defined, meaning that none of its attributes will be empty. This guarantee is given so that subclasses implementing this method can freely depend on any attribute required in order to construct the unique ID.

Returns:
the DataType's UID

getUIName

public abstract String getUIName()
                          throws Exception
Returns a string which will be displayed as the name of this DataType in the UI.

Returns:
the DataType's name
Throws:
Exception

getUIDescription

public abstract String getUIDescription()
                                 throws Exception
Returns a string which will be displayed as the description of this DataType in the UI.

Returns:
the DataType's description
Throws:
Exception

getXMLTypeDefinitionDocument

public abstract Document getXMLTypeDefinitionDocument()
                                               throws Exception
Returns a Document object defining the XML structure of this DataType's contents.

Returns:
the XML type definition document
Throws:
Exception

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException


Copyright © 2013. All Rights Reserved.