org.makumba.providers.datadefinition.mdd
Class DataDefinitionImpl

java.lang.Object
  extended by org.makumba.providers.datadefinition.mdd.DataDefinitionImpl
All Implemented Interfaces:
Serializable, DataDefinition, ValidationDefinition

public class DataDefinitionImpl
extends Object
implements DataDefinition, ValidationDefinition, Serializable

Implementation of the DataDefinition interface.
This implementation gets its data from a MDDNode after parsing, and adds the necessary functionality to it.

Version:
$Id: DataDefinitionImpl.java,v 1.1 23.06.2009 11:52:36 gaym Exp $
Author:
Manuel Gay
See Also:
Serialized Form

Nested Class Summary
protected static class DataDefinitionImpl.TitleFieldType
          the type of the title expression
 
Nested classes/interfaces inherited from interface org.makumba.DataDefinition
DataDefinition.MultipleUniqueKeyDefinition, DataDefinition.QueryFragmentFunction
 
Field Summary
static String ENUM_FIELD_NAME
           
protected  String fieldNameInParent
          name of the parent field, for ptrOne and setComplex
protected  LinkedHashMap<String,FieldDefinition> fields
           
protected  QueryFragmentFunctions functions
           
protected  String indexName
          name of the index field
protected  boolean isFileSubfield
          indicator if this is MDD is a file subfield
protected  LinkedHashMap<Object,DataDefinition.MultipleUniqueKeyDefinition> multiFieldUniqueList
           
protected  String name
          name of the data definition
protected  URL origin
          origin of the data definition
protected  DataDefinition parent
          parent MDD of the subfield
protected  String ptrSubfield
          pointer to the subfield, for construction of subfield names dynamically
protected  String setMemberFieldName
          name of the enumerator field, for setIntEnum and charIntEnum
protected  String setOwnerFieldName
          name of the field that holds the relational pointer to the parent field
protected  String titleField
          the title field
protected  String titleFieldExpr
          the original title expression
protected  DataDefinitionImpl.TitleFieldType titleFieldType
           
protected  LinkedHashMap<String,ValidationRule> validationRules
           
 
Fields inherited from interface org.makumba.DataDefinition
createName, modifyName
 
Constructor Summary
DataDefinitionImpl(MDDNode mdd)
          constructor for data definitions during parsing
DataDefinitionImpl(String name)
          make a virtual data definition
DataDefinitionImpl(String name, DataDefinitionImpl parent)
          constructor for virtual subfield data definitions, like file
DataDefinitionImpl(String fieldName, MDDNode mdd, DataDefinition parent)
          constructor for subfield data definitions during parsing
 
Method Summary
 void addField(FieldDefinition fd)
          methods related to fields
 void addFunctions(HashMap<String,DataDefinition.QueryFragmentFunction> funcNames)
           
 void addMultiUniqueKey(DataDefinition.MultipleUniqueKeyDefinition definition)
          methods related to multiple uniqueness keys
 void addRule(String fieldName, Collection<ValidationRule> rules)
          Add several rules for the given field.
 void addRule(String fieldName, ValidationRule rule)
          Add a new rule for the given field.
protected  void build()
          Builds the DataDefinitionImpl based on the MDDNode.
 void checkFieldNames(Dictionary<String,Object> d)
          methods for checks
 void checkUpdate(String fieldName, Dictionary<String,Object> d)
          Checks whether a record can be updated *
 String getCreationDateFieldName()
          which is the name of the creation timestamp field, if any?
 DataDefinition getDataDefinition()
          Get the data definition associated with this validation definition.
 FieldDefinition getFieldDefinition(int n)
          the field with the respective index, null if such a field doesn't exist
 FieldDefinition getFieldDefinition(String name)
          the field with the respective name, null if such a field doesn't exist
 Vector<String> getFieldNames()
          the names of the fields declared in this data definition, in the order of declaration
 FieldDefinition getFieldOrPointedFieldDefinition(String nm)
          returns the field info associated with a name
 DataDefinition.QueryFragmentFunction getFunctionOrPointedFunction(String nm)
          returns the field info associated with a name
 QueryFragmentFunctions getFunctions()
          returns all functions in this data definition.
 String getIndexPointerFieldName()
          which is the name of the index field, if any?
 String getLastModificationDateFieldName()
          which is the name of the modification timestamp field, if any?
 DataDefinition.MultipleUniqueKeyDefinition[] getMultiFieldUniqueKeys()
          Get all multiple-feld uniqueness definition.
 String getName()
          base methods
 FieldDefinition getParentField()
          If this type is the data pointed by a 1-1 pointer or subset (ptrOne and setComplex), return the type of the main record, otherwise return null
 ArrayList<FieldDefinition> getReferenceFields()
          Gets all the fields that are references to other tables, i.e. pointers and some types of sets.
 String getSetMemberFieldName()
          The name of the set member (Pointer, Character or Integer), for set subtypes
 String getSetOwnerFieldName()
          The name of the pointer to the main table, for set and internal set subtypes
 String getStructure()
           
 String getTitleFieldName()
          The title field indicated, or the default one
 ArrayList<FieldDefinition> getUniqueFields()
          Gets all the fields that have the unique modifier.
 ValidationDefinition getValidationDefinition()
          methods for validation definitions
 ValidationRule getValidationRule(String ruleName)
          Get the validation rule with the given rule name.
 Collection<ValidationRule> getValidationRules(String fieldName)
          Get all validation rules for the given field name.
 boolean hasMultiUniqueKey(String[] fieldNames)
          Check whether this data definition has a multi-field uniqe key defined with the given fields.
 boolean hasValidationRules()
           
 boolean isTemporary()
          tells whether this data definition was generated temporarily to depict a query result as opposed to being read from an MDD file
 long lastModified()
          Indicates when the data definition was modified the last time
 String toString()
           
 String toString1()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ENUM_FIELD_NAME

public static final String ENUM_FIELD_NAME
See Also:
Constant Field Values

name

protected String name
name of the data definition


ptrSubfield

protected String ptrSubfield
pointer to the subfield, for construction of subfield names dynamically


indexName

protected String indexName
name of the index field


titleField

protected String titleField
the title field


titleFieldExpr

protected String titleFieldExpr
the original title expression


titleFieldType

protected DataDefinitionImpl.TitleFieldType titleFieldType

origin

protected URL origin
origin of the data definition


parent

protected DataDefinition parent
parent MDD of the subfield


fieldNameInParent

protected String fieldNameInParent
name of the parent field, for ptrOne and setComplex


isFileSubfield

protected boolean isFileSubfield
indicator if this is MDD is a file subfield


setMemberFieldName

protected String setMemberFieldName
name of the enumerator field, for setIntEnum and charIntEnum


setOwnerFieldName

protected String setOwnerFieldName
name of the field that holds the relational pointer to the parent field


fields

protected LinkedHashMap<String,FieldDefinition> fields

validationRules

protected LinkedHashMap<String,ValidationRule> validationRules

multiFieldUniqueList

protected LinkedHashMap<Object,DataDefinition.MultipleUniqueKeyDefinition> multiFieldUniqueList

functions

protected QueryFragmentFunctions functions
Constructor Detail

DataDefinitionImpl

public DataDefinitionImpl(String name)
make a virtual data definition


DataDefinitionImpl

public DataDefinitionImpl(String name,
                          DataDefinitionImpl parent)
constructor for virtual subfield data definitions, like file


DataDefinitionImpl

public DataDefinitionImpl(String fieldName,
                          MDDNode mdd,
                          DataDefinition parent)
constructor for subfield data definitions during parsing


DataDefinitionImpl

public DataDefinitionImpl(MDDNode mdd)
constructor for data definitions during parsing

Method Detail

build

protected void build()
Builds the DataDefinitionImpl based on the MDDNode. This step needs to be done separately, as a MDD may refer to itself (through ptr or set).


addFunctions

public void addFunctions(HashMap<String,DataDefinition.QueryFragmentFunction> funcNames)

getName

public String getName()
base methods

Specified by:
getName in interface DataDefinition
Specified by:
getName in interface ValidationDefinition

getTitleFieldName

public String getTitleFieldName()
Description copied from interface: DataDefinition
The title field indicated, or the default one

Specified by:
getTitleFieldName in interface DataDefinition

isTemporary

public boolean isTemporary()
Description copied from interface: DataDefinition
tells whether this data definition was generated temporarily to depict a query result as opposed to being read from an MDD file

Specified by:
isTemporary in interface DataDefinition

lastModified

public long lastModified()
Description copied from interface: DataDefinition
Indicates when the data definition was modified the last time

Specified by:
lastModified in interface DataDefinition

getDataDefinition

public DataDefinition getDataDefinition()
Description copied from interface: ValidationDefinition
Get the data definition associated with this validation definition.

Specified by:
getDataDefinition in interface ValidationDefinition

addField

public void addField(FieldDefinition fd)
methods related to fields

Specified by:
addField in interface DataDefinition

getFieldDefinition

public FieldDefinition getFieldDefinition(String name)
Description copied from interface: DataDefinition
the field with the respective name, null if such a field doesn't exist

Specified by:
getFieldDefinition in interface DataDefinition

getFieldDefinition

public FieldDefinition getFieldDefinition(int n)
Description copied from interface: DataDefinition
the field with the respective index, null if such a field doesn't exist

Specified by:
getFieldDefinition in interface DataDefinition

getFieldNames

public Vector<String> getFieldNames()
Description copied from interface: DataDefinition
the names of the fields declared in this data definition, in the order of declaration

Specified by:
getFieldNames in interface DataDefinition

getFieldOrPointedFieldDefinition

public FieldDefinition getFieldOrPointedFieldDefinition(String nm)
returns the field info associated with a name

Specified by:
getFieldOrPointedFieldDefinition in interface DataDefinition

getFunctionOrPointedFunction

public DataDefinition.QueryFragmentFunction getFunctionOrPointedFunction(String nm)
returns the field info associated with a name

Specified by:
getFunctionOrPointedFunction in interface DataDefinition

getIndexPointerFieldName

public String getIndexPointerFieldName()
which is the name of the index field, if any?

Specified by:
getIndexPointerFieldName in interface DataDefinition

getReferenceFields

public ArrayList<FieldDefinition> getReferenceFields()
Description copied from interface: DataDefinition
Gets all the fields that are references to other tables, i.e. pointers and some types of sets.

Specified by:
getReferenceFields in interface DataDefinition

getUniqueFields

public ArrayList<FieldDefinition> getUniqueFields()
Description copied from interface: DataDefinition
Gets all the fields that have the unique modifier.

Specified by:
getUniqueFields in interface DataDefinition

addMultiUniqueKey

public void addMultiUniqueKey(DataDefinition.MultipleUniqueKeyDefinition definition)
methods related to multiple uniqueness keys

Specified by:
addMultiUniqueKey in interface DataDefinition

hasMultiUniqueKey

public boolean hasMultiUniqueKey(String[] fieldNames)
Description copied from interface: DataDefinition
Check whether this data definition has a multi-field uniqe key defined with the given fields.

Specified by:
hasMultiUniqueKey in interface DataDefinition

getMultiFieldUniqueKeys

public DataDefinition.MultipleUniqueKeyDefinition[] getMultiFieldUniqueKeys()
Description copied from interface: DataDefinition
Get all multiple-feld uniqueness definition.

Specified by:
getMultiFieldUniqueKeys in interface DataDefinition

checkFieldNames

public void checkFieldNames(Dictionary<String,Object> d)
methods for checks

Specified by:
checkFieldNames in interface DataDefinition

checkUpdate

public void checkUpdate(String fieldName,
                        Dictionary<String,Object> d)
Description copied from interface: DataDefinition
Checks whether a record can be updated *

Specified by:
checkUpdate in interface DataDefinition

getFunctions

public QueryFragmentFunctions getFunctions()
Description copied from interface: DataDefinition
returns all functions in this data definition.

Specified by:
getFunctions in interface DataDefinition

getParentField

public FieldDefinition getParentField()
If this type is the data pointed by a 1-1 pointer or subset (ptrOne and setComplex), return the type of the main record, otherwise return null

Specified by:
getParentField in interface DataDefinition

getSetMemberFieldName

public String getSetMemberFieldName()
Description copied from interface: DataDefinition
The name of the set member (Pointer, Character or Integer), for set subtypes

Specified by:
getSetMemberFieldName in interface DataDefinition

getSetOwnerFieldName

public String getSetOwnerFieldName()
Description copied from interface: DataDefinition
The name of the pointer to the main table, for set and internal set subtypes

Specified by:
getSetOwnerFieldName in interface DataDefinition

getValidationDefinition

public ValidationDefinition getValidationDefinition()
methods for validation definitions

Specified by:
getValidationDefinition in interface DataDefinition

addRule

public void addRule(String fieldName,
                    Collection<ValidationRule> rules)
Description copied from interface: ValidationDefinition
Add several rules for the given field.

Specified by:
addRule in interface ValidationDefinition

addRule

public void addRule(String fieldName,
                    ValidationRule rule)
Description copied from interface: ValidationDefinition
Add a new rule for the given field.

Specified by:
addRule in interface ValidationDefinition

getValidationRules

public Collection<ValidationRule> getValidationRules(String fieldName)
Description copied from interface: ValidationDefinition
Get all validation rules for the given field name.

Specified by:
getValidationRules in interface ValidationDefinition

hasValidationRules

public boolean hasValidationRules()
Specified by:
hasValidationRules in interface ValidationDefinition

getValidationRule

public ValidationRule getValidationRule(String ruleName)
Description copied from interface: ValidationDefinition
Get the validation rule with the given rule name.

Specified by:
getValidationRule in interface ValidationDefinition

getCreationDateFieldName

public String getCreationDateFieldName()
which is the name of the creation timestamp field, if any?

Specified by:
getCreationDateFieldName in interface DataDefinition

getLastModificationDateFieldName

public String getLastModificationDateFieldName()
which is the name of the modification timestamp field, if any?

Specified by:
getLastModificationDateFieldName in interface DataDefinition

toString

public String toString()
Overrides:
toString in class Object

toString1

public String toString1()

getStructure

public String getStructure()