it.unimo.dbgroup.momis.odli3
Class Schema

java.lang.Object
  extended byit.unimo.dbgroup.momis.odli3.MomisObject
      extended byit.unimo.dbgroup.momis.odli3.TypeContainer
          extended byit.unimo.dbgroup.momis.odli3.Schema
All Implemented Interfaces:
java.io.Serializable

public class Schema
extends TypeContainer
implements java.io.Serializable

ODL_i3 schema description data strucure entry point. All the entities, interfaces, rules etc, defined in a odl_i3 are accessible through an istance of this class.
Each istance of this class describes a ODL_I3 schema.

See Also:
Serialized Form

Field Summary
private  GlobalSource _globalSource
          The global class
private  java.lang.String _name
          The schema name
private  ThesaurusByObject _thesarusIndex
          Indexing structure for the Thesaurus Relations.
private  TranslationMap _tm
          Mapping structure for translation in OLCD.
private  TypeContainer _tmpTypeContainer
          This variable is used to take trace of the highest level types definition returned by a OdlSpecification statement.
private  java.util.TreeMap globalClasses
          Collection of global classes related to local schemata.
 
Fields inherited from class it.unimo.dbgroup.momis.odli3.TypeContainer
_constants, _interfaces, _sources, _structs, _thesRelations
 
Fields inherited from class it.unimo.dbgroup.momis.odli3.MomisObject
mod_GenericODLParser, mod_GlobalSchema, mod_QueryManger, mod_SIDes_ARM, mod_SIDes_ARTEMIS, mod_SIDes_EXTM, mod_SIDes_JoinMap, mod_SIDes_main, mod_SIDes_SAM, mod_SIDes_SIM, mod_SIDes_SIM2, mod_SIDes_SLIM, mod_SIDes_TREdit, mod_SIDes_TUNIM
 
Constructor Summary
Schema()
          basic constructor
Schema(java.io.PrintStream logPrintStream, org.xml.sax.InputSource inputSource, boolean fgValidate, SchemaParserXml schemaParserXml)
          Create a schema from an XML file, where the "parser" is given by the user.
Schema(java.io.PrintStream logPrintStream, java.io.InputStream xmlStream, boolean fgValidate)
          Initialize a schema from an XML input stream
Schema(java.io.PrintStream logPrintStream, java.io.Reader xmlReader, boolean fgValidate)
          Initialize a schema from an XML input Reader
Schema(java.io.PrintStream logPrintStream, java.lang.String xmlUri, boolean fgValidate)
          Initialize a schema from an URI addressing and XML file
Example
 
Method Summary
 void alignTypesFromTmpTypeContainer()
          At the end of parsing I add the highest level types definition returned by a OdlSpecification statement into the defined types in this schema.
 void closeWrapperConnection()
          closing the connection
 void comupteThesarusIndex()
          Re-indexes all thesaurus relations in a indexing data strucutre accessible by the method getThesarusIndex
 java.util.Vector getAllInterfaces()
          Returns all the interfaces defined in this schema.
 java.util.TreeMap getGlobalClasses()
          Return a Map object where keys are the global class names and values are GlobalClass objects.
 GlobalSource getGlobalSource()
          Get the _globalSource value.
 MomisCodeVersion getMomisCodeVersion()
           
 java.lang.String getName()
          Returns the name of "this" type container.
 java.lang.Object getObject(java.lang.String name)
          Given an schema element dotted name Returns the object or null if such object does not exist.
 ThesaurusByObject getThesarusIndex()
          Returns a indexing data structure that indexes all thesaurus relations.
 TranslationMap getTranslationMap()
          Gets the translation map;
private  void initialize(java.io.PrintStream logPrintStream, org.xml.sax.InputSource inputSource, boolean fgValidate)
          Initialize a schema from an XML file
 void initialize(java.io.PrintStream logPrintStream, org.xml.sax.InputSource inputSource, boolean fgValidate, SchemaParserXml schemaParserXml)
          Initialize a schema from an XML file
 void loadFromXML(org.xml.sax.Attributes attrib)
          Load the object from an xml tag.
 void mergeSchema(TypeContainer t)
          Insert a new schema into this Schema.
 java.lang.String parseVelocityTemplate(java.lang.String velocityMacroTemplateFileName)
          Processes a VelocityMacro template with information in this object
 void setGlobalClasses(java.util.TreeMap gcs)
          Sets the global classes with the ones stored in the TreeMap object where keys are the global class names and values are GlobalClass objects.
 void setGlobalSource(GlobalSource newGlobalSource)
          Set the _globalSource value.
 void setName(java.lang.String name)
          Returns the name of "this" type container.
 void setTmpTypeContainer(TypeContainer tmpTypeContainer)
          I Use the variable _tmpTypeContainer to take trace of the highest level types definition returned by a OdlSpecification statement.
 void setTranslationMap(TranslationMap tm)
          Set the translation map;
 void solveGlobalSource()
          Tries to solve unsolved references and for each interfaces builds the attribute list.
 void solveUnsolved()
          Tries to solve unsolved references and for each interfaces builds the attribute list.
 java.lang.String toArtemis()
          Generates a list of thesaurus relations for the ARTEMIS module.
 java.lang.String toOdl()
          Returns the ODLi3 description for this TypeContainer.
 java.lang.String toOlcd()
          Generates the OLCD representation.
 java.lang.String toOlcdOnMap(TranslationMap tm)
          Generates the OLCD representation using as translation map the map passed as parameter.
 java.lang.String toOlcdSimBOnMap(TranslationMap tm, java.util.Map attributeMap)
          Generates the OLCD representation for the SIM Module using as translation map the map passed as parameter.
private  void toOlcdThesRelationsToBeValidated_addUnique(java.util.Map attributes, java.util.Vector listOfAttributes)
          Private method used by toOlcdThesRelationsToBeValidated to add to a Map the object listed in a vector.
 java.lang.String toOlcdThesRelationsToBeValidated(TranslationMap tm)
          Returns the OLCD representation for VALIDATION of the Thes Relations of this schema, using as translation map the map passed as parameter.
 java.lang.String toXml()
          Generates the XML through the "vmtemplates/schemaXml.vm" VelocityMacro template
 java.lang.String toXml(java.lang.String templateFileName)
          Where is the Velocity XML output template
 
Methods inherited from class it.unimo.dbgroup.momis.odli3.TypeContainer
addConstant, addConstants, addDefined, addDefineds, addEnum, addEnums, addExtRule, addIntBodies, addIntBody, addIntBodyForceNewName, addInterface, addInterfaces, addModule, addModules, addRule, addRules, addSource, addSources, addStruct, addStructs, addThesRelation, addThesRelations, addThesRelationWithControl, addThesRelationWithControlIgnoreWeaker, addThesRelationWithControlIgnoreWeaker, addTypes, addTypesToSolve, addTypeToSolve, addUnion, addUnions, cloneAllThesRelations, delAllThesRelations, delRule, delRuleByName, delThesRelation, delThesRelationsForProducer, getConstant, getConstants, getDefined, getDefineds, getEnum, getEnums, getExtRule, getIntBodies, getIntBodiesAsCollection, getIntBodiesOrderByName, getIntBody, getInterface, getInterface, getInterfaces, getInterfacesAsCollection, getInterfacesOrderByName, getModule, getModules, getParent, getRule, getRuleByName, getRules, getSchema, getSource, getSources, getSourcesAsCollection, getSourcesOrderByName, getStruct, getStructs, getThesRelations, getTopParent, getTypesToSolve, getUnion, getUnions, retrieveAttribute, retrieveInterface, retrieveSource, setParent, setSource, solveUnsolvedForeignKeys, toOlcd, toOlcdSimB, toString
 
Methods inherited from class it.unimo.dbgroup.momis.odli3.MomisObject
getAdditionalInfo, getAdditionalInfos, getGenericProducerDescription, getProducerDescription, getProducerId, putAdditionalInfo, setProducerId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_tmpTypeContainer

private TypeContainer _tmpTypeContainer
This variable is used to take trace of the highest level types definition returned by a OdlSpecification statement.


_tm

private TranslationMap _tm
Mapping structure for translation in OLCD.
kew:name value:Object
Kinds of objects in this map:


globalClasses

private java.util.TreeMap globalClasses
Collection of global classes related to local schemata.


_name

private java.lang.String _name
The schema name


_thesarusIndex

private ThesaurusByObject _thesarusIndex
Indexing structure for the Thesaurus Relations.


_globalSource

private GlobalSource _globalSource
The global class

Constructor Detail

Schema

public Schema()
basic constructor


Schema

public Schema(java.io.PrintStream logPrintStream,
              java.io.InputStream xmlStream,
              boolean fgValidate)
       throws java.lang.Exception
Initialize a schema from an XML input stream

Parameters:
xmlStream -

Schema

public Schema(java.io.PrintStream logPrintStream,
              java.io.Reader xmlReader,
              boolean fgValidate)
       throws java.lang.Exception
Initialize a schema from an XML input Reader


Schema

public Schema(java.io.PrintStream logPrintStream,
              org.xml.sax.InputSource inputSource,
              boolean fgValidate,
              SchemaParserXml schemaParserXml)
       throws java.lang.Exception
Create a schema from an XML file, where the "parser" is given by the user. -

Parameters:
logPrintStream - where write log and error output
inputSource - the xml data input
fgValidate - true if we want the parser be validating

Schema

public Schema(java.io.PrintStream logPrintStream,
              java.lang.String xmlUri,
              boolean fgValidate)
       throws java.lang.Exception
Initialize a schema from an URI addressing and XML file
Example
file:/full/path/to/the/xml/file.xml

Method Detail

initialize

private void initialize(java.io.PrintStream logPrintStream,
                        org.xml.sax.InputSource inputSource,
                        boolean fgValidate)
                 throws java.lang.Exception
Initialize a schema from an XML file

Parameters:
logPrintStream - where write log and error output
inputSource - the xml data input
fgValidate - true if we want the parser be validating
Throws:
java.lang.Exception

initialize

public void initialize(java.io.PrintStream logPrintStream,
                       org.xml.sax.InputSource inputSource,
                       boolean fgValidate,
                       SchemaParserXml schemaParserXml)
                throws java.lang.Exception
Initialize a schema from an XML file

Parameters:
logPrintStream - where write log and error output
inputSource - the xml data input
fgValidate - true if we want the parser be validating
Throws:
java.lang.Exception

mergeSchema

public void mergeSchema(TypeContainer t)
                 throws OdlException
Insert a new schema into this Schema.
This method has been created to guarantee separation between Schemas during the MOMIS source acquisition.
Each schema is added as a module of the current schema while sources, rules and thesRelations are merged.
Nota Bene
We suppose tho have already solved every kind of object references!!! (the parser do it for us). So we don't need things like typeToSolve

Parameters:
t - the schema to be merged.
Throws:
OdlException

closeWrapperConnection

public void closeWrapperConnection()
                            throws java.lang.Exception
closing the connection

Throws:
java.lang.Exception

getAllInterfaces

public java.util.Vector getAllInterfaces()
Returns all the interfaces defined in this schema.
This method get the list of sources and retuns the union of all the interfaces defined in such sources.


toArtemis

public java.lang.String toArtemis()
Generates a list of thesaurus relations for the ARTEMIS module. Returns a string in the follwing format:
 S1.Class.Att1a  ,bt   ,S2.Class.Att2b            ,0;
 S2.Class.Att2b  ,nt   ,S1.Class.Att1b            ,1;
 S1.Class.Att1b  ,syn  , S3.Class3.Att3b            ,0 ;
 S3.Class3.Att3b  ,rt   ,S2.Class.Att2b            ,1 ;
 S3.Class3.Att3b  ,syn   ,S2.Class.Att2a            ,1 ;
 S1.Class  ,bt   ,S3.Class3            , ;
 S2.Class  ,rt   ,S3.Class3            , ;
 
Where an attribute is identified as:
SOURCEname.INTERFACEname.ATTRIBUTEname
the last number, null, 0 or 1, means
null: relation between interfaces
0: attribute relation not validated
1: attribute relation validated


toOdl

public java.lang.String toOdl()
Returns the ODLi3 description for this TypeContainer.

Overrides:
toOdl in class TypeContainer

toXml

public java.lang.String toXml(java.lang.String templateFileName)
                       throws java.lang.Exception
Where is the Velocity XML output template

Throws:
java.lang.Exception

toXml

public java.lang.String toXml()
                       throws java.lang.Exception
Generates the XML through the "vmtemplates/schemaXml.vm" VelocityMacro template

Throws:
java.lang.Exception

parseVelocityTemplate

public java.lang.String parseVelocityTemplate(java.lang.String velocityMacroTemplateFileName)
                                       throws java.lang.Exception
Processes a VelocityMacro template with information in this object

Throws:
java.lang.Exception

toOlcd

public java.lang.String toOlcd()
Generates the OLCD representation.


setTranslationMap

public void setTranslationMap(TranslationMap tm)
Set the translation map;


getTranslationMap

public TranslationMap getTranslationMap()
Gets the translation map;


toOlcdOnMap

public java.lang.String toOlcdOnMap(TranslationMap tm)
Generates the OLCD representation using as translation map the map passed as parameter.


toOlcdSimBOnMap

public java.lang.String toOlcdSimBOnMap(TranslationMap tm,
                                        java.util.Map attributeMap)
Generates the OLCD representation for the SIM Module using as translation map the map passed as parameter.

Parameters:
tm - Translation Map
attributeMap - Attribute Map, describes how to sobstitute attribute definition according to thesaurus relations. This method will return a virtual schema described in OLCD to be passed to ODB-Tools for Thesaurus Relationships validation and inference.

Main feature of this routine is that Thesaurus Relationships contribute in Interface definition.
NT relationships cause the Interface to inherit from the Broader Interface
RT interface cause the definition of dummy attributes that links to the related interface.
SYN relationships cause the Interface to be grouped in a set of Synonym Interface. Such interface share the same definition in terms of Parent Interfaces and attributes. The parent Interfaces of each of the synonym Interfaces is given by the union of the Interface each Interface inherits from or take part of a NT or BT relation. The set of attribute is given by the union of the attributes each interface inherits from. RT relationship that give rise to the RT dummy attributes is given by the union of the RT relationship that involves at least one Interface in the SYN group.

toOlcdThesRelationsToBeValidated_addUnique

private void toOlcdThesRelationsToBeValidated_addUnique(java.util.Map attributes,
                                                        java.util.Vector listOfAttributes)
Private method used by toOlcdThesRelationsToBeValidated to add to a Map the object listed in a vector.

Parameters:
attributes - the map to be filled.
listOfAttributes - vector of attributes to evenutually add.

toOlcdThesRelationsToBeValidated

public java.lang.String toOlcdThesRelationsToBeValidated(TranslationMap tm)
Returns the OLCD representation for VALIDATION of the Thes Relations of this schema, using as translation map the map passed as parameter.


setTmpTypeContainer

public void setTmpTypeContainer(TypeContainer tmpTypeContainer)
I Use the variable _tmpTypeContainer to take trace of the highest level types definition returned by a OdlSpecification statement.


alignTypesFromTmpTypeContainer

public void alignTypesFromTmpTypeContainer()
                                    throws OdlException
At the end of parsing I add the highest level types definition returned by a OdlSpecification statement into the defined types in this schema.

Throws:
OdlException

getGlobalClasses

public java.util.TreeMap getGlobalClasses()
Return a Map object where keys are the global class names and values are GlobalClass objects.

Returns:
A Map object.

setGlobalClasses

public void setGlobalClasses(java.util.TreeMap gcs)
Sets the global classes with the ones stored in the TreeMap object where keys are the global class names and values are GlobalClass objects.


comupteThesarusIndex

public void comupteThesarusIndex()
Re-indexes all thesaurus relations in a indexing data strucutre accessible by the method getThesarusIndex


getThesarusIndex

public ThesaurusByObject getThesarusIndex()
Returns a indexing data structure that indexes all thesaurus relations. This data structure is initialized by the method comupteThesarusIndex;


getObject

public java.lang.Object getObject(java.lang.String name)
Given an schema element dotted name Returns the object or null if such object does not exist.
Global interface is identified by the defaultName "globalSource"

Parameters:
name - Name of the object in dot notation.
Returns:
The object identified by the dotted name: Source, Interface or a Vector (attribute).

solveUnsolved

public void solveUnsolved()
                   throws OdlException
Tries to solve unsolved references and for each interfaces builds the attribute list.

Overrides:
solveUnsolved in class TypeContainer
Throws:
OdlException

solveGlobalSource

public void solveGlobalSource()
                       throws OdlException
Tries to solve unsolved references and for each interfaces builds the attribute list.

Throws:
OdlException

getName

public java.lang.String getName()
Returns the name of "this" type container.

Overrides:
getName in class TypeContainer

setName

public void setName(java.lang.String name)
Returns the name of "this" type container.


loadFromXML

public void loadFromXML(org.xml.sax.Attributes attrib)
                 throws java.lang.Exception
Load the object from an xml tag.

Throws:
java.lang.Exception

getGlobalSource

public GlobalSource getGlobalSource()
Get the _globalSource value.

Returns:
the _globalSource value.

setGlobalSource

public void setGlobalSource(GlobalSource newGlobalSource)
Set the _globalSource value.

Parameters:
newGlobalSource - The new _globalSource value.

getMomisCodeVersion

public MomisCodeVersion getMomisCodeVersion()


Universita' di Modena e Reggio Emilia