uk.ac.ic.doc.automed.templates
Class CompositeTransformation

java.lang.Object
  extended by uk.ac.ic.doc.automed.templates.CompositeTransformation

public class CompositeTransformation
extends java.lang.Object

The CompositeTransformation class.
How to create a composite transformation representing a statement:
//create partially the statement's arguments
TemplateArgumentSequence foreachArgs = new TemplateArgumentSequence();
//initilize argument sequence
foreachArgs.createArgument(1, value1);

//create the arguments for the statements that are going to
//be executed inside the foreach statement
...

//create the composite transformation
CompositeTransformation foreachBlock = new CompositeTransformation(name, null, false);

//built this composite transformation's program
...

//finish the foreach statement's arguments
foreachArgs.createArgument(2, String.valueOf(foreachBlock.getTransIf()));


Field Summary
static int ARG_ACTION_IN_PRIMITIVE
          Position in the PRIMITIVE_TRANSFORMATION_STATEMENT for action
static int ARG_ARGSEQUENCES_IN_FOREACH
          Position in the FOREACH_STATEMENT for argument sequence ID of the lists to iterate
static int ARG_ARGSINGLETONS_IN_FOREACH
          Position in the FOREACH_STATEMENT for argument sequence ID of singleton arguments
static int ARG_ARGUMENTS_IN_INVOCATION
          Position in the INVOCATION_STATEMENT for the argument sequnce ID
static int ARG_CID_IN_NEWOBJECT
          Position in the NEW_OBJECT_STATEMENT for CID(Construct ID)
static int ARG_CONCATENATIONOP_IN_DEFINE_STRING
          Position int the DEFINE_STRING statement for concatenation operator of the list of string fragments.
static int ARG_CONSTRAINTS_IN_PRIMITIVE
          Position in the PRIMITIVE_TRANSFORMATION_STATEMENT for constraints
static int ARG_FROMOBJ_IN_PRIMITIVE
          Position in the PRIMITIVE_TRANSFORMATION_STATEMENT for FromObject OBID
static int ARG_FROMSCHEMA_IN_CONTRACT
          Position in the CONTRACT_STATEMENT for the initial schema ID
static int ARG_FROMSCHEMA_IN_PRIMITIVE
          Position in the PRIMITIVE_TRANSFORMATION_STATEMENT for FromSchema SID
static int ARG_FUNCTION_IN_PRIMITIVE
          Position in the PRIMITIVE_TRANSFORMATION_STATEMENT for function
static int ARG_INDEX_IN_INDEX_LIST
           
static int ARG_ISTEMP_IN_NEWOBJECT
          Position in the NEW_OBJECT_STATEMENT for IsTemp
static int ARG_LIST_IN_INDEX_LIST
           
static int ARG_LISTPOINTER_IN_CREATE_LIST
           
static int ARG_LISTPOINTER_IN_DEFINE_STRING
          Position in the DEFINE_STRING statement for the (pointer to the) list of string fragments that will make up the resulting string when concatenated
static int ARG_OBID_IN_NEWOBJECT
          Position in the NEW_OBJECT_STATEMENT for OBID(Object ID)
static int ARG_OBID_IN_SCHEMELIST
           
static int ARG_OBJECT_IN_CONTRACT
          Position in the CONTRACT_STATEMENT for object ID
static int ARG_RESULT_IN_DEFINE_STRING
          Position in the DEFINE_STRING statement for the resulting string
static int ARG_RESULT_IN_INDEX_LIST
           
static int ARG_RESULT_IN_SCHEMELIST
           
static int ARG_RETURNED_ARGS_START_IN_FOREACH
          Position in the FOREACH_STATEMENT where the returned argument sequences start
static int ARG_SCHEMA_IN_CREATE_LIST
           
static int ARG_SCHEMA_IN_DEFINE_STRING
          Position int the DEFINE_STRING statement for the initial and final schema.
static int ARG_SCHEMA_IN_FOREACH
          Position in the FOREACH_STATEMENT for current schema SID
static int ARG_SCHEMA_IN_INDEX_LIST
           
static int ARG_SCHEMA_IN_SCHEMELIST
           
static int ARG_SCHEME_IN_NEWOBJECT
          Position in the NEW_OBJECT_STATEMENT for the argument sequence ID of the object's scheme
static int ARG_SCHEMEID_IN_EXTGENSCHEME
          Position in the EXTGENSCHEME_STATEMENT for the argument sequence ID of the generalisation's scheme
static int ARG_SCHEMEPOS_IN_EXTGENSCHEME
          Position in the EXTGENSCHEME_STATEMENT for the position in the scheme where to start extending
static int ARG_SID_IN_NEWOBJECT
          Position in the NEW_OBJECT_STATEMENT for SID(Schema ID)
static int ARG_SUBENTITIES_IN_EXTGENSCHEME
          Position in the EXTGENSCHEME_STATEMENT for the argument sequence ID of the sub-entities
static int ARG_TOOBJ_IN_PRIMITIVE
          Position in the PRIMITIVE_TRANSFORMATION_STATEMENT for ToObject OBID
static int ARG_TOSCHEMA_IN_CONTRACT
          Position in the CONTRACT_STATEMENT for the final schema ID
static int ARG_TOSCHEMA_IN_PRIMITIVE
          Position in the PRIMITIVE_TRANSFORMATION_STATEMENT for ToSchema SID
static int ARG_TRANS_IN_FOREACH
          Position in the FOREACH_STATEMENT for template transformation ID
static int ARG_TRANSFORMATION_IN_INVOCATION
          Position in the INVOCATION_STATEMENT for the template transformation's ID
static int ARG_VALUE_IN_NEWOBJECT
          Position in the NEW_OBJECT_STATEMENT for the object's value
static java.lang.String CONTRACT_STATEMENT
          Statement to contract an object
static java.lang.String CREATE_LIST_STATEMENT
           
static java.lang.String DEFINE_STRING_STATEMENT
          Statement to defined dynamic strings, used for functions, constraints definitions and more
static java.lang.String EXTGENSCHEME_STATEMENT
          Statement to extend an ER generalization's scheme
static java.lang.String FOREACH_STATEMENT
          Statement to iterate on lists
static java.lang.String INDEX_LIST_STATEMENT
           
static java.lang.String INVOCATION_STATEMENT
          Statement to inve other template transformations
static char METHOD_PREFIX
          A character that prefixes the method calls in the DEFINE_STRING statement.
static java.lang.String NEW_OBJECT_STATEMENT
          Statement to create new objects
static java.lang.String PRIMITIVE_TRANSFORMATION_STATEMENT
          Statement to execute primitive transformations
static java.lang.String SCHEMELIST_STATEMENT
           
 
Constructor Summary
CompositeTransformation(java.lang.String name, java.lang.String description, boolean preservesEq)
          Constructs a new CompositeTransformation without any argument definitions nor program.
 
Method Summary
 TransformationArgumentDefinition createArgumentDefinition(int position, java.lang.String description, boolean isReturnedValue)
          Defines an argument for this CompositeTransformation.
 TransformationArgumentDefinition createArgumentDefinition(int position, java.lang.String description, boolean isReturnedValue, int elementNR, int type, int typeInstance, int ref_pos)
          Defines an argument for this CompositeTransformation.
 TransformationArgumentDefinition createArgumentDefinition(int position, java.lang.String tablename, java.lang.String fieldname, java.lang.String description, boolean isReturnedValue)
          Defines an argument for this CompositeTransformation.
protected  int createFirstArgument(int arg_pos, java.lang.String value, java.util.Vector createdArgIds)
          Creates a new sequence of arguments and adds a new argument to the sequence
protected  void createPrimitiveTransformation(int argId, java.lang.String[] resultingSID, java.lang.String[] createdOBID, java.util.Vector transformationSequence)
          Creates a primitive transformation and appends it in the STR.
 void createReturnedArgumentsDefinition(TemplateArgumentSequence args)
          Defines the values of the arguments that store returned values after the transformation's invocation.
 StatementExecution createStatementExecution(int pc, Statement stmnt, TemplateArgumentSequence args)
          Defines the statement to be invoked at a particular program counter.
 java.lang.String describeTransformations(java.util.Vector transformationSequence)
          Returns a String describing the transformations executed in the Vector given as a parameter
protected  void executeCreateListStatement(int stmntId, int stmntTemplateArgId, int transIdToUse, java.lang.String[] transArgs, java.util.HashMap argMap, int runTimePc, java.lang.String[] resultingSID, java.lang.String[] createdOBID, java.util.Vector createdArgIds, java.util.Vector transformationSequence)
          Executes a CREATE_LIST statement.
protected  void executeDefineStringStatement(int stmntId, int stmntTemplateArgId, int transIdToUse, java.lang.String[] transArgs, java.util.HashMap argMap, int runTimePc, java.lang.String[] resultingSID, java.lang.String[] createdOBID, java.util.Vector createdArgIds, java.util.Vector transformationSequence)
          Executes a DEFINE_STRING statement.
protected  int executeForEachStatement(int stmntId, int stmntTemplateArgId, int transIdToUse, java.lang.String[] transArgs, java.util.HashMap argMap, int startRunTimePc, java.lang.String[] resultingSID, java.lang.String[] createdOBID, java.util.Vector createdArgIds, java.util.Vector transformationSequence)
          Executes a foreach statement.
protected  void executeIndexListStatement(int stmntId, int stmntTemplateArgId, int transIdToUse, java.lang.String[] transArgs, java.util.HashMap argMap, int runTimePc, java.lang.String[] resultingSID, java.lang.String[] createdOBID, java.util.Vector createdArgIds, java.util.Vector transformationSequence)
           
protected  int executeInvocationStatement(int stmntId, int stmntTemplateArgId, int transIdToUse, java.lang.String[] transArgs, java.util.HashMap argMap, int runTimePc, java.lang.String[] resultingSID, java.lang.String[] createdOBID, java.util.Vector createdArgIds, java.util.Vector transformationSequence)
          Executes a transformation_invocation statement.
protected  void executeNewObjectStatement(int stmntId, int stmntTemplateArgId, int transIdToUse, java.lang.String[] transArgs, java.util.HashMap argMap, int runTimePc, java.lang.String[] resultingSID, java.lang.String[] createdOBID, java.util.Vector createdArgIds, java.util.Vector transformationSequence)
          Executes a new_object statement.
protected  void executePrimitiveTransformationStatement(int stmntId, int stmntTemplateArgId, int transIdToUse, java.lang.String[] transArgs, java.util.HashMap argMap, int runTimePc, java.lang.String[] resultingSID, java.lang.String[] createdOBID, java.util.Vector createdArgIds, java.util.Vector transformationSequence)
          Executes a primitive_transformation statement.
protected  void executeSchemeListStatement(int stmntId, int stmntTemplateArgId, int transIdToUse, java.lang.String[] transArgs, java.util.HashMap argMap, int runTimePc, java.lang.String[] resultingSID, java.lang.String[] createdOBID, java.util.Vector createdArgIds, java.util.Vector transformationSequence)
           
protected  int executeTransformation(int transIdToExecute, int transIdToUse, java.lang.String[] transArgs, java.util.HashMap argMap, int startRunTimePc, java.lang.String[] resultingSID, java.lang.String[] createdOBID, java.util.Vector createdArgIds, java.util.Vector transformationSequence)
          Main method which executes a composite transformation.
static CompositeTransformation[] getAllCompositeTransformations()
          Returns an array of all CompositeTransformation objects.
 TransformationArgumentDefinition getArgumentDefinitionAt(int position)
          Returns a particular TransformationArgumentDefinition in the CompositeTransformations's argument definition list.
 TransformationArgumentDefinition[] getArgumentDefinitions()
          Returns an array of all the TransformationArgumentDefinition objects in this CompositeTransformation.
 TransformationArgumentDefinition[] getArgumentDefinitions(boolean isReturnedValue)
          Returns an array of TransformationArgumentDefinition objects.
static CompositeTransformation getCompositeTransformation(int transId)
          Returns a reference to a CompositeTransformation.
static CompositeTransformation getCompositeTransformation(java.lang.String name)
          Returns a reference to a CompositeTransformation.
static CompositeTransformation[] getCompositeTransformations(boolean preservesEq)
          Returns an array of CompositeTransformation objects.
 java.lang.String getDescription()
          Returns the description of this CompositeTransformation.
 java.lang.String getName()
          Returns the name of this CompositeTransformation.
 TemplateArgumentSequence getReturnedArgumentsDefinition()
          Returns the arguments that store returned values after the transformation's invocation.
protected  java.lang.Object[] getSchemeArray(Construct objectConstruct, java.lang.String[] objectScheme)
          This method is used to retrieve the Object [] which defines the schema of a newly added object.
 StatementExecution getStatementExecutionAt(int pc)
          Returns a particular StatementExecution in the CompositeTransformations's template program.
 StatementExecution[] getStatementExecutions()
          Returns an array of all the StatementExecution objects in this CompositeTransformation.
 int getTransId()
          Returns the ID of this CompositeTransformation.
protected  java.lang.String getValueForTemplateArgument(int templateArgIdRef, int templateArgPosRef, java.lang.String templateValue, java.lang.String[] transArgs, java.util.HashMap argMap)
          Returns the value for a template argument.
protected  java.lang.String getValueForTemplateArgumentPointingToArgId(int templateArgIdRef, int templateArgPosRef, java.lang.String templateValue, java.lang.String[] transArgs, java.util.HashMap argMap, java.util.Vector createdArgIds, boolean nestedPointersToSequences)
          .
protected  int handleNonStatementArgument(int templateArgId, java.lang.String[] transArgs, java.util.HashMap argMap, java.util.Vector createdArgIds, boolean pointingToArgumentSequences)
          Creates an execution argument sequence according to a template argument sequence.
 CompositeTransformationRecord invoke(RuntimeArgumentSequence tas)
          Invokes this CompositeTransformation with the specified RuntimeArgumentSequence as arguments.
 boolean isExecuted()
          Returns false if the specified transformation is not currently being executed, true otherwise.
 boolean preservesEquivalence()
          Returns whether this CompositeTransformation preserves schema equivalence.
 void remove()
          Removes this CompositeTransformation
 void removeArgumentDefinition(int position)
          Removes a particular argument definition from this CompositeTransformation's argument definition list.
static void removeCompositeTransformation(java.lang.String name)
          Removes a CompositeTransformation
protected  void removeExecutionTrace(int transId, java.util.Vector createdArgIds)
          Removes the trace of a composite transformation's executionfrom the TER.
 void removeReturnedArgumentsDefinition()
          Removes the definitions of this transformation's returned arguments.
 void removeStatementExecution(int pc)
          Removes a particular statement execution from this CompositeTransformations's template program
protected static void rollbackSTR(java.util.Vector transformationSequence)
          Removes the trace of a composite transformation's execution for the STR.
 void setDescription(java.lang.String description)
          Sets this CompositeTransformation's description.
 void setName(java.lang.String name)
          Sets this CompositeTransformation's name.
 void setPreservesEquivalence(boolean preservesEq)
          Sets whether this CompositeTransformation preserves schema equivalence.
 void setReturnedArgumentsDefinition(TemplateArgumentSequence args)
          Sets the arguments that store returned values after the transformation's invocation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFINE_STRING_STATEMENT

public static final java.lang.String DEFINE_STRING_STATEMENT
Statement to defined dynamic strings, used for functions, constraints definitions and more

See Also:
Constant Field Values

ARG_RESULT_IN_DEFINE_STRING

public static final int ARG_RESULT_IN_DEFINE_STRING
Position in the DEFINE_STRING statement for the resulting string

See Also:
Constant Field Values

ARG_LISTPOINTER_IN_DEFINE_STRING

public static final int ARG_LISTPOINTER_IN_DEFINE_STRING
Position in the DEFINE_STRING statement for the (pointer to the) list of string fragments that will make up the resulting string when concatenated

See Also:
Constant Field Values

ARG_SCHEMA_IN_DEFINE_STRING

public static final int ARG_SCHEMA_IN_DEFINE_STRING
Position int the DEFINE_STRING statement for the initial and final schema. The schema does not change during the execution of this statement

See Also:
Constant Field Values

ARG_CONCATENATIONOP_IN_DEFINE_STRING

public static final int ARG_CONCATENATIONOP_IN_DEFINE_STRING
Position int the DEFINE_STRING statement for concatenation operator of the list of string fragments.

See Also:
Constant Field Values

METHOD_PREFIX

public static final char METHOD_PREFIX
A character that prefixes the method calls in the DEFINE_STRING statement. Note that a method call is made on an object. For example object?schema defines the schema of object

See Also:
Constant Field Values

SCHEMELIST_STATEMENT

public static final java.lang.String SCHEMELIST_STATEMENT
See Also:
Constant Field Values

ARG_RESULT_IN_SCHEMELIST

public static final int ARG_RESULT_IN_SCHEMELIST
See Also:
Constant Field Values

ARG_OBID_IN_SCHEMELIST

public static final int ARG_OBID_IN_SCHEMELIST
See Also:
Constant Field Values

ARG_SCHEMA_IN_SCHEMELIST

public static final int ARG_SCHEMA_IN_SCHEMELIST
See Also:
Constant Field Values

INDEX_LIST_STATEMENT

public static final java.lang.String INDEX_LIST_STATEMENT
See Also:
Constant Field Values

ARG_RESULT_IN_INDEX_LIST

public static final int ARG_RESULT_IN_INDEX_LIST
See Also:
Constant Field Values

ARG_LIST_IN_INDEX_LIST

public static final int ARG_LIST_IN_INDEX_LIST
See Also:
Constant Field Values

ARG_INDEX_IN_INDEX_LIST

public static final int ARG_INDEX_IN_INDEX_LIST
See Also:
Constant Field Values

ARG_SCHEMA_IN_INDEX_LIST

public static final int ARG_SCHEMA_IN_INDEX_LIST
See Also:
Constant Field Values

CREATE_LIST_STATEMENT

public static final java.lang.String CREATE_LIST_STATEMENT
See Also:
Constant Field Values

ARG_LISTPOINTER_IN_CREATE_LIST

public static final int ARG_LISTPOINTER_IN_CREATE_LIST
See Also:
Constant Field Values

ARG_SCHEMA_IN_CREATE_LIST

public static final int ARG_SCHEMA_IN_CREATE_LIST
See Also:
Constant Field Values

NEW_OBJECT_STATEMENT

public static final java.lang.String NEW_OBJECT_STATEMENT
Statement to create new objects

See Also:
Constant Field Values

PRIMITIVE_TRANSFORMATION_STATEMENT

public static final java.lang.String PRIMITIVE_TRANSFORMATION_STATEMENT
Statement to execute primitive transformations

See Also:
Constant Field Values

FOREACH_STATEMENT

public static final java.lang.String FOREACH_STATEMENT
Statement to iterate on lists

See Also:
Constant Field Values

EXTGENSCHEME_STATEMENT

public static final java.lang.String EXTGENSCHEME_STATEMENT
Statement to extend an ER generalization's scheme

See Also:
Constant Field Values

INVOCATION_STATEMENT

public static final java.lang.String INVOCATION_STATEMENT
Statement to inve other template transformations

See Also:
Constant Field Values

CONTRACT_STATEMENT

public static final java.lang.String CONTRACT_STATEMENT
Statement to contract an object

See Also:
Constant Field Values

ARG_SID_IN_NEWOBJECT

public static final int ARG_SID_IN_NEWOBJECT
Position in the NEW_OBJECT_STATEMENT for SID(Schema ID)

See Also:
Constant Field Values

ARG_CID_IN_NEWOBJECT

public static final int ARG_CID_IN_NEWOBJECT
Position in the NEW_OBJECT_STATEMENT for CID(Construct ID)

See Also:
Constant Field Values

ARG_OBID_IN_NEWOBJECT

public static final int ARG_OBID_IN_NEWOBJECT
Position in the NEW_OBJECT_STATEMENT for OBID(Object ID)

See Also:
Constant Field Values

ARG_VALUE_IN_NEWOBJECT

public static final int ARG_VALUE_IN_NEWOBJECT
Position in the NEW_OBJECT_STATEMENT for the object's value

See Also:
Constant Field Values

ARG_ISTEMP_IN_NEWOBJECT

public static final int ARG_ISTEMP_IN_NEWOBJECT
Position in the NEW_OBJECT_STATEMENT for IsTemp

See Also:
Constant Field Values

ARG_SCHEME_IN_NEWOBJECT

public static final int ARG_SCHEME_IN_NEWOBJECT
Position in the NEW_OBJECT_STATEMENT for the argument sequence ID of the object's scheme

See Also:
Constant Field Values

ARG_ACTION_IN_PRIMITIVE

public static final int ARG_ACTION_IN_PRIMITIVE
Position in the PRIMITIVE_TRANSFORMATION_STATEMENT for action

See Also:
Constant Field Values

ARG_FROMOBJ_IN_PRIMITIVE

public static final int ARG_FROMOBJ_IN_PRIMITIVE
Position in the PRIMITIVE_TRANSFORMATION_STATEMENT for FromObject OBID

See Also:
Constant Field Values

ARG_TOOBJ_IN_PRIMITIVE

public static final int ARG_TOOBJ_IN_PRIMITIVE
Position in the PRIMITIVE_TRANSFORMATION_STATEMENT for ToObject OBID

See Also:
Constant Field Values

ARG_FROMSCHEMA_IN_PRIMITIVE

public static final int ARG_FROMSCHEMA_IN_PRIMITIVE
Position in the PRIMITIVE_TRANSFORMATION_STATEMENT for FromSchema SID

See Also:
Constant Field Values

ARG_TOSCHEMA_IN_PRIMITIVE

public static final int ARG_TOSCHEMA_IN_PRIMITIVE
Position in the PRIMITIVE_TRANSFORMATION_STATEMENT for ToSchema SID

See Also:
Constant Field Values

ARG_FUNCTION_IN_PRIMITIVE

public static final int ARG_FUNCTION_IN_PRIMITIVE
Position in the PRIMITIVE_TRANSFORMATION_STATEMENT for function

See Also:
Constant Field Values

ARG_CONSTRAINTS_IN_PRIMITIVE

public static final int ARG_CONSTRAINTS_IN_PRIMITIVE
Position in the PRIMITIVE_TRANSFORMATION_STATEMENT for constraints

See Also:
Constant Field Values

ARG_SCHEMA_IN_FOREACH

public static final int ARG_SCHEMA_IN_FOREACH
Position in the FOREACH_STATEMENT for current schema SID

See Also:
Constant Field Values

ARG_ARGSEQUENCES_IN_FOREACH

public static final int ARG_ARGSEQUENCES_IN_FOREACH
Position in the FOREACH_STATEMENT for argument sequence ID of the lists to iterate

See Also:
Constant Field Values

ARG_ARGSINGLETONS_IN_FOREACH

public static final int ARG_ARGSINGLETONS_IN_FOREACH
Position in the FOREACH_STATEMENT for argument sequence ID of singleton arguments

See Also:
Constant Field Values

ARG_TRANS_IN_FOREACH

public static final int ARG_TRANS_IN_FOREACH
Position in the FOREACH_STATEMENT for template transformation ID

See Also:
Constant Field Values

ARG_RETURNED_ARGS_START_IN_FOREACH

public static final int ARG_RETURNED_ARGS_START_IN_FOREACH
Position in the FOREACH_STATEMENT where the returned argument sequences start

See Also:
Constant Field Values

ARG_SUBENTITIES_IN_EXTGENSCHEME

public static final int ARG_SUBENTITIES_IN_EXTGENSCHEME
Position in the EXTGENSCHEME_STATEMENT for the argument sequence ID of the sub-entities

See Also:
Constant Field Values

ARG_SCHEMEID_IN_EXTGENSCHEME

public static final int ARG_SCHEMEID_IN_EXTGENSCHEME
Position in the EXTGENSCHEME_STATEMENT for the argument sequence ID of the generalisation's scheme

See Also:
Constant Field Values

ARG_SCHEMEPOS_IN_EXTGENSCHEME

public static final int ARG_SCHEMEPOS_IN_EXTGENSCHEME
Position in the EXTGENSCHEME_STATEMENT for the position in the scheme where to start extending

See Also:
Constant Field Values

ARG_TRANSFORMATION_IN_INVOCATION

public static final int ARG_TRANSFORMATION_IN_INVOCATION
Position in the INVOCATION_STATEMENT for the template transformation's ID

See Also:
Constant Field Values

ARG_ARGUMENTS_IN_INVOCATION

public static final int ARG_ARGUMENTS_IN_INVOCATION
Position in the INVOCATION_STATEMENT for the argument sequnce ID

See Also:
Constant Field Values

ARG_FROMSCHEMA_IN_CONTRACT

public static final int ARG_FROMSCHEMA_IN_CONTRACT
Position in the CONTRACT_STATEMENT for the initial schema ID

See Also:
Constant Field Values

ARG_OBJECT_IN_CONTRACT

public static final int ARG_OBJECT_IN_CONTRACT
Position in the CONTRACT_STATEMENT for object ID

See Also:
Constant Field Values

ARG_TOSCHEMA_IN_CONTRACT

public static final int ARG_TOSCHEMA_IN_CONTRACT
Position in the CONTRACT_STATEMENT for the final schema ID

See Also:
Constant Field Values
Constructor Detail

CompositeTransformation

public CompositeTransformation(java.lang.String name,
                               java.lang.String description,
                               boolean preservesEq)
                        throws TemplateTransformationRepositoryException,
                               RepositoryAccessException
Constructs a new CompositeTransformation without any argument definitions nor program.

Parameters:
name - name of the transformation.
description - description of the transformation
preservesEq - true if transformation can be invoked independently on a schema, false otherwise
Throws:
TemplateTransformationRepositoryException - see TemplateTransformationRepository.createCompositeTransformation(String, String, boolean)
RepositoryAccessException - if the repositories cannot be accessed
Method Detail

removeCompositeTransformation

public static void removeCompositeTransformation(java.lang.String name)
                                          throws TemplateTransformationRepositoryException,
                                                 RepositoryAccessException
Removes a CompositeTransformation

Parameters:
name - name of transformation to remove.
Throws:
TemplateTransformationRepositoryException - see TemplateTransformationRepository.getCompositeTransformationByName(String) and TemplateTransformationRepository.removeCompositeTransformation(int) and remove()
RepositoryAccessException - if the repositories cannot be accessed

remove

public void remove()
            throws TemplateTransformationRepositoryException,
                   RepositoryAccessException
Removes this CompositeTransformation

Throws:
TemplateTransformationRepositoryException - see TransformationArgumentDefinition.remove() and StatementExecution.remove() and TemplateTransformationRepository.removeCompositeTransformation(int)
RepositoryAccessException - if the repositories cannot be accessed

getAllCompositeTransformations

public static CompositeTransformation[] getAllCompositeTransformations()
                                                                throws RepositoryAccessException
Returns an array of all CompositeTransformation objects. Returns null if no records of compoiste transformations exist in the TTR.

Returns:
an array of all CompositeTransformation objects.
Throws:
RepositoryAccessException - if the repositories cannot be accessed

getCompositeTransformations

public static CompositeTransformation[] getCompositeTransformations(boolean preservesEq)
                                                             throws RepositoryAccessException
Returns an array of CompositeTransformation objects. The returned transformation preserve schema equivalence (if preservesEq is true), or they don't preserve equivalence(if preservesEq is false). Method returns null if there aren't any appropriate transformations.

Parameters:
preservesEq - whether the CompositeTransformation objects preserve schema equivalence
Returns:
an array of CompositeTransformations.
Throws:
RepositoryAccessException - if the repositories cannot be accessed

getCompositeTransformation

public static CompositeTransformation getCompositeTransformation(java.lang.String name)
                                                          throws TemplateTransformationRepositoryException,
                                                                 RepositoryAccessException
Returns a reference to a CompositeTransformation.

Parameters:
name - name of the CompositeTransformation to return.
Returns:
the reference to the transformation with the given name.
Throws:
TemplateTransformationRepositoryException - if no transformation with the specified name exists. See TemplateTransformationRepository.getCompositeTransformationByName(String)
RepositoryAccessException - if the repositories cannot be accessed

getCompositeTransformation

public static CompositeTransformation getCompositeTransformation(int transId)
                                                          throws TemplateTransformationRepositoryException,
                                                                 RepositoryAccessException
Returns a reference to a CompositeTransformation.

Parameters:
transId - identifier of the CompositeTransformation to return.
Returns:
the reference to the transformation with the given identifier.
Throws:
TemplateTransformationRepositoryException - if no transformation with the specified ID exists. See TemplateTransformationRepository.getCompositeTransformationName(int)
RepositoryAccessException - if the repositories cannot be accessed

getName

public java.lang.String getName()
                         throws TemplateTransformationRepositoryException,
                                RepositoryAccessException
Returns the name of this CompositeTransformation.

Returns:
name of CompositeTransformation.
Throws:
TemplateTransformationRepositoryException - see TemplateTransformationRepository.getCompositeTransformationName(int)
RepositoryAccessException - if the repositories cannot be accessed

getDescription

public java.lang.String getDescription()
                                throws TemplateTransformationRepositoryException,
                                       RepositoryAccessException
Returns the description of this CompositeTransformation.

Returns:
description of CompositeTransformation.
Throws:
TemplateTransformationRepositoryException - see TemplateTransformationRepository.getCompositeTransformationDescription(int)
RepositoryAccessException - if the repositories cannot be accessed

preservesEquivalence

public boolean preservesEquivalence()
                             throws TemplateTransformationRepositoryException,
                                    RepositoryAccessException
Returns whether this CompositeTransformation preserves schema equivalence.

Returns:
whether this CompositeTransformation preserves schema equivalence.
Throws:
TemplateTransformationRepositoryException - see TemplateTransformationRepository.getCompositeTransformationPreservesEquivalence(int)
RepositoryAccessException - if the repositories cannot be accessed

getTransId

public int getTransId()
Returns the ID of this CompositeTransformation.

Returns:
ID of CompositeTransformation

setName

public void setName(java.lang.String name)
             throws TemplateTransformationRepositoryException,
                    RepositoryAccessException
Sets this CompositeTransformation's name.

Parameters:
name - new name of CompositeTransformation.
Throws:
TemplateTransformationRepositoryException - see TemplateTransformationRepository.setCompositeTransformationName(int, String)
RepositoryAccessException - if the repositories cannot be accessed

setDescription

public void setDescription(java.lang.String description)
                    throws TemplateTransformationRepositoryException,
                           RepositoryAccessException
Sets this CompositeTransformation's description.

Parameters:
description - new description of CompositeTransformation.
Throws:
TemplateTransformationRepositoryException - see TemplateTransformationRepository.setCompositeTransformationDescription(int, String)
RepositoryAccessException - if the repositories cannot be accessed

setPreservesEquivalence

public void setPreservesEquivalence(boolean preservesEq)
                             throws TemplateTransformationRepositoryException,
                                    RepositoryAccessException
Sets whether this CompositeTransformation preserves schema equivalence.

Parameters:
preservesEq - true if this CompositeTransformation preserves equivalence, false otherwise.
Throws:
TemplateTransformationRepositoryException - see TemplateTransformationRepository.setCompositeTransformationPreservesEquivalence(int, boolean)
RepositoryAccessException - if the repositories cannot be accessed

getArgumentDefinitions

public TransformationArgumentDefinition[] getArgumentDefinitions()
Returns an array of all the TransformationArgumentDefinition objects in this CompositeTransformation. If no arguments have been defined for this CompositeTransformation, an empty array is returned.

Returns:
an array of all the ransformationArgumentDefinition objects in this CompositeTransformation.

getArgumentDefinitions

public TransformationArgumentDefinition[] getArgumentDefinitions(boolean isReturnedValue)
                                                          throws RepositoryAccessException
Returns an array of TransformationArgumentDefinition objects. If no arguments have been defined for this CompositeTransformation, an empty array is returned.

Parameters:
isReturnedValue -
Returns:
an array of the TransformationArgumentDefinition objects that define arguments for the invocation of this CompositeTransformation if isReturnedValue is false, or an array of TransformationArgumentDefinition objects defining the arguments storing the transformation's returned values
Throws:
RepositoryAccessException - if the repositories cannot be accessed

createArgumentDefinition

public TransformationArgumentDefinition createArgumentDefinition(int position,
                                                                 java.lang.String tablename,
                                                                 java.lang.String fieldname,
                                                                 java.lang.String description,
                                                                 boolean isReturnedValue)
                                                          throws TemplateTransformationRepositoryException,
                                                                 RepositoryAccessException
Defines an argument for this CompositeTransformation. Method constructs a new TransformationArgumentDefinition and adds it to this CompositeTransformation's argument definitions. The defined argument holds position position in this CompositeTransformation object's arguments. tablename, fieldname and description are used to describe the specific argument. Note that this method does not define the parameters elementNR, type, typeInstance, ref_pos, and is only used for backwards compatibility.

Parameters:
position - the position in the transformation's arguments
tablename - name of the table referenced by this argument.
fieldname - name of the table's field referenced by this argument.
description - description of this argument.
isReturnedValue - whether this argument stores a returned value or not.
Returns:
reference to the new CompositeTransformationArgumentDefinition.
Throws:
TemplateTransformationRepositoryException - see TransformationArgumentDefinition.TransformationArgumentDefinition(int, int, String, String, String, boolean)
RepositoryAccessException - if the repositories cannot be accessed

createArgumentDefinition

public TransformationArgumentDefinition createArgumentDefinition(int position,
                                                                 java.lang.String description,
                                                                 boolean isReturnedValue,
                                                                 int elementNR,
                                                                 int type,
                                                                 int typeInstance,
                                                                 int ref_pos)
                                                          throws TemplateTransformationRepositoryException,
                                                                 RepositoryAccessException
Defines an argument for this CompositeTransformation. Method constructs a new TransformationArgumentDefinition and adds it to this CompositeTransformation's argument definitions.

Parameters:
position - the position in the transformation's arguments
description - description of this argument.
isReturnedValue - whether this argument stores a returned value or not.
elementNR. - 1 means that the element is single, <1 means that it is an unbounded list and n, where n>1 means that it is a bounded list of exactly n elements
type - The type of this argument. Although a user can define his own types, in order to use the wrapper the type is defined by uk.ac.ic.doc.automed.templates.templates.wrapper.TConstants. Note that a list of type X, has type X
typeInstance - this is meant to define the construct ID when the type is object, but you could extend it to define other things. For example it can define weather a schema if initial or final.
ref_pos - this only has a meaning when elementNR is less. i.e. when it is an unbounded list. It has a value greater than zero, then its value's semantics is the position of an other list who should have the same value as this. For example if its value is 3 then this list should have the same length as list at position 3.
Returns:
reference to the new CompositeTransformationArgumentDefinition.
Throws:
TemplateTransformationRepositoryException - see TransformationArgumentDefinition.TransformationArgumentDefinition(int, int, String, String, String, boolean)
RepositoryAccessException - if the repositories cannot be accessed

createArgumentDefinition

public TransformationArgumentDefinition createArgumentDefinition(int position,
                                                                 java.lang.String description,
                                                                 boolean isReturnedValue)
                                                          throws TemplateTransformationRepositoryException,
                                                                 RepositoryAccessException
Defines an argument for this CompositeTransformation. Method constructs a new TransformationArgumentDefinition and adds it to this CompositeTransformation's argument definitions. The defined argument holds position position in this CompositeTransformation object's arguments. description is used to describe the specific argument.

Parameters:
position - the position in the transformation's arguments
description - description of this argument.
isReturnedValue - whether this argument stores a returned value or not.
Returns:
reference to the new CompositeTransformationArgumentDefinition.
Throws:
TemplateTransformationRepositoryException - see TransformationArgumentDefinition.TransformationArgumentDefinition(int, int, String, String, String, boolean)
RepositoryAccessException - if the repositories cannot be accessed

getArgumentDefinitionAt

public TransformationArgumentDefinition getArgumentDefinitionAt(int position)
                                                         throws AutoRepException
Returns a particular TransformationArgumentDefinition in the CompositeTransformations's argument definition list.

Parameters:
position - the position in the transformation's arguments.
Returns:
the TransformationArgumentDefinition specified by the given position
Throws:
AutoRepException - if the specified position doesn't exist in this CompositeTransformation's argument definition list

removeArgumentDefinition

public void removeArgumentDefinition(int position)
                              throws TemplateTransformationRepositoryException,
                                     AutoRepException,
                                     RepositoryAccessException
Removes a particular argument definition from this CompositeTransformation's argument definition list.

Parameters:
position - the position to be removed from the transformation's argument definitions.
Throws:
AutoRepException - see getArgumentDefinitionAt(int)
TemplateTransformationRepositoryException - see TransformationArgumentDefinition.remove()
RepositoryAccessException - if the repositories cannot be accessed

createReturnedArgumentsDefinition

public void createReturnedArgumentsDefinition(TemplateArgumentSequence args)
                                       throws TemplateTransformationRepositoryException,
                                              RepositoryAccessException
Defines the values of the arguments that store returned values after the transformation's invocation.

Parameters:
args - the TemplateArgumentSequence defining which positions store the returned values and how these values can be obtained
Throws:
TemplateTransformationRepositoryException - see TemplateTransformationRepository.createCompositeTransformationReturnedValuesDefinition(int, int)
RepositoryAccessException - if the repositories cannot be accessed

setReturnedArgumentsDefinition

public void setReturnedArgumentsDefinition(TemplateArgumentSequence args)
                                    throws TemplateTransformationRepositoryException,
                                           RepositoryAccessException
Sets the arguments that store returned values after the transformation's invocation.

Parameters:
args - the TemplateArgumentSequence defining which positions store the returned values and how these values can be obtained
Throws:
TemplateTransformationRepositoryException - see TemplateTransformationRepository.setCompositeTransformationReturnedValuesDefinitionArgId(int, int)
RepositoryAccessException - if the repositories cannot be accessed

getReturnedArgumentsDefinition

public TemplateArgumentSequence getReturnedArgumentsDefinition()
                                                        throws TemplateTransformationRepositoryException,
                                                               RepositoryAccessException,
                                                               AutoRepException
Returns the arguments that store returned values after the transformation's invocation.

Returns:
the TemplateArgumentSequence defining which positions store the returned values and how these values can be obtained
Throws:
TemplateTransformationRepositoryException - if no returned arguments have been defined for this transformation. See TemplateTransformationRepository.getCompositeTransformationReturnedValuesDefinitionArgId(int)
AutoRepException - see TemplateArgumentSequence.getTemplateArgumentSequence(int)
RepositoryAccessException - if the repositories cannot be accessed

removeReturnedArgumentsDefinition

public void removeReturnedArgumentsDefinition()
                                       throws RepositoryAccessException
Removes the definitions of this transformation's returned arguments. The transformation doesn't return any values after this method call.

Throws:
RepositoryAccessException - if the repositories cannot be accessed

getStatementExecutions

public StatementExecution[] getStatementExecutions()
Returns an array of all the StatementExecution objects in this CompositeTransformation. If no StatementExecution objects have been defined for this CompositeTransformation, an empty array is returned.

Returns:
an array of all the StatementExecution objects in this CompositeTransformation.

createStatementExecution

public StatementExecution createStatementExecution(int pc,
                                                   Statement stmnt,
                                                   TemplateArgumentSequence args)
                                            throws TemplateTransformationRepositoryException,
                                                   RepositoryAccessException
Defines the statement to be invoked at a particular program counter. Method defines the statement (stmnt) to be invoked when the program counter reaches pc, and the sequence of arguments(args) used for the statement invocation. Method constructs a new StatementExecution and adds it to the CompositeTransformation's template program.

Parameters:
pc - the program counter in the transformation's template program
stmnt - Statement that is going to be executed at the specific pc by this transformation
args - TemplateArgumentSequence that is going to be used as arguments to the Statement
Returns:
reference to the new StatementExecution.
Throws:
TemplateTransformationRepositoryException - see StatementExecution.StatementExecution(int, int, Statement, TemplateArgumentSequence)
RepositoryAccessException - if the repositories cannot be accessed

getStatementExecutionAt

public StatementExecution getStatementExecutionAt(int pc)
                                           throws AutoRepException
Returns a particular StatementExecution in the CompositeTransformations's template program.

Parameters:
pc - the program counter in the transformation's template program
Returns:
the StatementExecution specified by the given pc
Throws:
AutoRepException - if the specified pc doesn't exist in this CompositeTransformation's program

removeStatementExecution

public void removeStatementExecution(int pc)
                              throws TemplateTransformationRepositoryException,
                                     AutoRepException,
                                     RepositoryAccessException
Removes a particular statement execution from this CompositeTransformations's template program

Parameters:
pc - the program counter in the transformation's template program to remove
Throws:
AutoRepException - see getStatementExecutionAt(int)
TemplateTransformationRepositoryException - see StatementExecution.remove()
RepositoryAccessException - if the repositories cannot be accessed

isExecuted

public boolean isExecuted()
                   throws RepositoryAccessException
Returns false if the specified transformation is not currently being executed, true otherwise.

Returns:
whether this transformation is currently being executed or not
Throws:
RepositoryAccessException - if the repositories cannot be accessed

invoke

public CompositeTransformationRecord invoke(RuntimeArgumentSequence tas)
                                     throws TemplateTransformationSyntaxRepositoryException,
                                            TemplateExecutionRepositoryException,
                                            TemplateTransformationRepositoryException,
                                            AutoRepException,
                                            RepositoryAccessException
Invokes this CompositeTransformation with the specified RuntimeArgumentSequence as arguments. The CompositeTransformaion must preserve schema equivalence and the RuntimeArgumentSequence object must contain RuntimeArgument objects.

Parameters:
tas - the RuntimeArgumentSequence used in the invocation
Returns:
the resulting Schema
Throws:
AutoRepException
TemplateExecutionRepositoryException
TemplateTransformationRepositoryException
RepositoryAccessException - if the repositories cannot be accessed
TemplateTransformationSyntaxRepositoryException

executeTransformation

protected int executeTransformation(int transIdToExecute,
                                    int transIdToUse,
                                    java.lang.String[] transArgs,
                                    java.util.HashMap argMap,
                                    int startRunTimePc,
                                    java.lang.String[] resultingSID,
                                    java.lang.String[] createdOBID,
                                    java.util.Vector createdArgIds,
                                    java.util.Vector transformationSequence)
                             throws TemplateTransformationSyntaxRepositoryException,
                                    TemplateTransformationRepositoryException,
                                    TemplateExecutionRepositoryException,
                                    AutoRepException,
                                    RepositoryAccessException
Main method which executes a composite transformation. The method checks the current statement in the composite transformation's program, and calls the appropriate method. The initial composite transformation has ID transIdToUse. This transformation might call other composite transformations (in an transformation_invocation or in a for_each statement). The IDs of these invoked transformation are stored in transIdToExecute.

Parameters:
transIdToExecute - the ID of the composite transformation that is to be really executed
transIdToUse - the ID of the initial composite transformation
transArgs - the initial composite transformation's execution arguments' values
argMap - a mapping from template argument sequence IDs to execution argument sequence IDs
startRunTimePc - the starting program counter for the transformation that is going to be executed (transIdToExecute)
resultingSID - a single-element array storing the schema ID after the execution of the transformation
createdOBID - a single-element array storing the object ID of the object created by the execution of the transformation (meaningfull only in a new_object statement)
createdArgIds - vector of Integer objects storing the created execution argument sequence IDs
createdSchemas - vector of Integer objects storing the created schemas during the transformation's execution
createdObjects - vector of Integer objects storing the created objects during the transformation's execution
Returns:
the new run-time program counter that must be used after this execution
Throws:
AutoRepException
TemplateExecutionRepositoryException
TemplateTransformationRepositoryException
RepositoryAccessException - if the repositories cannot be accessed
TemplateTransformationSyntaxRepositoryException

executeNewObjectStatement

protected void executeNewObjectStatement(int stmntId,
                                         int stmntTemplateArgId,
                                         int transIdToUse,
                                         java.lang.String[] transArgs,
                                         java.util.HashMap argMap,
                                         int runTimePc,
                                         java.lang.String[] resultingSID,
                                         java.lang.String[] createdOBID,
                                         java.util.Vector createdArgIds,
                                         java.util.Vector transformationSequence)
                                  throws TemplateExecutionRepositoryException,
                                         RepositoryAccessException,
                                         AutoRepException
Executes a new_object statement.

Parameters:
stmntId - statement's ID
stmntTemplateArgId - template argument sequence ID
transIdToUse - composite transformation's ID to use in the comp_transformation_execution entries
transArgs - current composite transformation's execution argument sequence
argMap - map IDs of template argument sequences to IDs of execution argument sequences
runTimePc - current program counter
resultingSID - one element array storing the resulting schema ID after this statement's execution
createdOBID - one element array storing the created schema object ID after this statement's execution
createdArgIds - Vector storing the IDs of all the created sequences of arguments during a composite transformation execution
createdSchemas - Vector storing the IDs of all the created schemas during the composite transformation execution
createdObjects - Vector storing the IDs of all the created objects during the composite transformation execution
Throws:
AutoRepException
TemplateExecutionRepositoryException
RepositoryAccessException - if the repositories cannot be accessed

executePrimitiveTransformationStatement

protected void executePrimitiveTransformationStatement(int stmntId,
                                                       int stmntTemplateArgId,
                                                       int transIdToUse,
                                                       java.lang.String[] transArgs,
                                                       java.util.HashMap argMap,
                                                       int runTimePc,
                                                       java.lang.String[] resultingSID,
                                                       java.lang.String[] createdOBID,
                                                       java.util.Vector createdArgIds,
                                                       java.util.Vector transformationSequence)
                                                throws TemplateExecutionRepositoryException,
                                                       AutoRepException,
                                                       RepositoryAccessException
Executes a primitive_transformation statement.

Parameters:
stmntId - statement's ID
stmntTemplateArgId - template argument sequence ID
transIdToUse - composite transformation's ID to use in the comp_transformation_execution entries
transArgs - current composite transformation's execution argument sequence
argMap - map IDs of template argument sequences to IDs of execution argument sequences
runTimePc - current program counter
resultingSID - one element array storing the resulting schema ID after this statement's execution
createdOBID - one element array storing the created schema object ID after this statement's execution
createdArgIds - Vector storing the IDs of all the created sequences of arguments during a composite transformation execution
createdSchemas - Vector storing the IDs of all the created schemas during the composite transformation execution
createdObjects - Vector storing the IDs of all the created objects during the composite transformation execution
Throws:
AutoRepException
TemplateExecutionRepositoryException
TemplateTransformationRepositoryException
RepositoryAccessException - if the repositories cannot be accessed

executeInvocationStatement

protected int executeInvocationStatement(int stmntId,
                                         int stmntTemplateArgId,
                                         int transIdToUse,
                                         java.lang.String[] transArgs,
                                         java.util.HashMap argMap,
                                         int runTimePc,
                                         java.lang.String[] resultingSID,
                                         java.lang.String[] createdOBID,
                                         java.util.Vector createdArgIds,
                                         java.util.Vector transformationSequence)
                                  throws TemplateTransformationSyntaxRepositoryException,
                                         TemplateExecutionRepositoryException,
                                         TemplateTransformationRepositoryException,
                                         AutoRepException,
                                         RepositoryAccessException
Executes a transformation_invocation statement.

Parameters:
stmntId - statement's ID
stmntTemplateArgId - template argument sequence ID
transIdToUse - composite transformation's ID to use in the comp_transformation_execution entries
transArgs - current composite transformation's execution argument sequence
argMap - map IDs of template argument sequences to IDs of execution argument sequences
runTimePc - current program counter
resultingSID - one element array storing the resulting schema ID after this statement's execution
createdOBID - one element array storing the created schema object ID after this statement's execution
createdArgIds - Vector storing the IDs of all the created sequences of arguments during a composite transformation execution
createdSchemas - Vector storing the IDs of all the created schemas during the composite transformation execution
createdObjects - Vector storing the IDs of all the created objects during the composite transformation execution
Returns:
the new run-time program counter that must be used after this execution
Throws:
AutoRepException
TemplateExecutionRepositoryException
TemplateTransformationRepositoryException
RepositoryAccessException - if the repositories cannot be accessed
TemplateTransformationSyntaxRepositoryException

executeForEachStatement

protected int executeForEachStatement(int stmntId,
                                      int stmntTemplateArgId,
                                      int transIdToUse,
                                      java.lang.String[] transArgs,
                                      java.util.HashMap argMap,
                                      int startRunTimePc,
                                      java.lang.String[] resultingSID,
                                      java.lang.String[] createdOBID,
                                      java.util.Vector createdArgIds,
                                      java.util.Vector transformationSequence)
                               throws TemplateTransformationSyntaxRepositoryException,
                                      TemplateTransformationRepositoryException,
                                      TemplateExecutionRepositoryException,
                                      AutoRepException,
                                      RepositoryAccessException
Executes a foreach statement.

Parameters:
stmntId - statement's ID
stmntTemplateArgId - template argument sequence ID
transIdToUse - composite transformation's ID to use in the comp_transformation_execution entries
transArgs - current composite transformation's execution argument sequence
argMap - map IDs of template argument sequences to IDs of execution argument sequences
runTimePc - current program counter
resultingSID - one element array storing the resulting schema ID after this statement's execution
createdOBID - one element array storing the created schema object ID after this statement's execution
createdArgIds - Vector storing the IDs of all the created sequences of arguments during a composite transformation execution
createdSchemas - Vector storing the IDs of all the created schemas during the composite transformation execution
createdObjects - Vector storing the IDs of all the created objects during the composite transformation execution
Returns:
the new run-time program counter that must be used after this execution
Throws:
AutoRepException
TemplateExecutionRepositoryException
TemplateTransformationRepositoryException
RepositoryAccessException - if the repositories cannot be accessed
TemplateTransformationSyntaxRepositoryException

createFirstArgument

protected int createFirstArgument(int arg_pos,
                                  java.lang.String value,
                                  java.util.Vector createdArgIds)
                           throws TemplateExecutionRepositoryException,
                                  RepositoryAccessException
Creates a new sequence of arguments and adds a new argument to the sequence

Parameters:
arg_pos - position of argument in the new sequence of arguments
value - the value of the specific argument
createdArgIds - Vector storing the IDs of all the created sequences of arguments during a composite transformation execution
Returns:
ID of the new sequence of arguments
Throws:
TemplateExecutionRepositoryException - see TemplateExecutionRepository.createFirstArgument(int, String)
RepositoryAccessException - if the repositories cannot be accessed

getValueForTemplateArgument

protected java.lang.String getValueForTemplateArgument(int templateArgIdRef,
                                                       int templateArgPosRef,
                                                       java.lang.String templateValue,
                                                       java.lang.String[] transArgs,
                                                       java.util.HashMap argMap)
                                                throws TemplateExecutionRepositoryException,
                                                       RepositoryAccessException,
                                                       AutoRepException
Returns the value for a template argument. If the argument references another argument then it returns the other argument's value. Note: any referenced argument must be already mapped to an execution argument.

Parameters:
templateArgIdRef - ID of referenced argument sequence
templateArgPosRef - position in the referenced argument sequence
templateValue - value field of the template argument
transArgs - current composite transformation's execution argument sequence
argMap - map IDs of template argument sequences to IDs of execution argument sequences
Returns:
value of template argument
Throws:
AutoRepException - if the argument doesn't reference another argument and the templateValue is null, or if a run-time argument doesn't exist for templateArgIdRef.
TemplateExecutionRepositoryException - see TemplateExecutionRepository.getArgumentsValue(int,int)
RepositoryAccessException - if the repositories cannot be accessed

getValueForTemplateArgumentPointingToArgId

protected java.lang.String getValueForTemplateArgumentPointingToArgId(int templateArgIdRef,
                                                                      int templateArgPosRef,
                                                                      java.lang.String templateValue,
                                                                      java.lang.String[] transArgs,
                                                                      java.util.HashMap argMap,
                                                                      java.util.Vector createdArgIds,
                                                                      boolean nestedPointersToSequences)
                                                               throws TemplateExecutionRepositoryException,
                                                                      RepositoryAccessException,
                                                                      AutoRepException
. Returns the value for a template argument that points to another argument in the TTR. If the argument references another argument then it returns the other argument's value. If not, then the value of this argument is a template argument sequence ID, so it clones the sequence into the TER and returns the ID of the execution argument sequence. nestedPoinstersToSequence should be true if the pointed argument sequence has only references to other sequence and false if the pointerd argument sequence only refers to other arguments.

Parameters:
templateArgIdRef - ID of referenced argument sequence
templateArgPosRef - position in the referenced argument sequence
templateValue - value field of the template argument
transArgs - current composite transformation's execution argument sequence
argMap - map IDs of template argument sequences to IDs of execution argument sequences
createdArgIds - Vector storing the IDs of all the created sequences of arguments during a composite transformation execution
nestedPointersToSequence - whether the argument sequence the template argument points to has only references to other sequences or only refers to other arguments
Returns:
value of template argument. The value is an execution argument sequence ID.
Throws:
AutoRepException - see getValueForTemplateArgument(int,int, String, String[], HashMap) and handleNonStatementArgument(int,String[], HashMap, Vector, boolean)
TemplateExecutionRepositoryException - see uk.ac.ic.doc.automed.TemplateExecutionRepository#getValueForTemplateArgument(int,int, String, String[], HashMap) and uk.ac.ic.doc.automed.TemplateExecutionRepository#handleNonStatementArgument(int,String[], HashMap, Vector, boolean)
RepositoryAccessException - if the repositories cannot be accessed

handleNonStatementArgument

protected int handleNonStatementArgument(int templateArgId,
                                         java.lang.String[] transArgs,
                                         java.util.HashMap argMap,
                                         java.util.Vector createdArgIds,
                                         boolean pointingToArgumentSequences)
                                  throws AutoRepException,
                                         TemplateExecutionRepositoryException,
                                         RepositoryAccessException
Creates an execution argument sequence according to a template argument sequence. If template argument sequence has only references to other sequences then pointingToArgumentSequences must be true. If the sequence doesn't refer to other sequences then pointingToArgumentSequences must be false.

Parameters:
templateArgId - ID of template argument sequence
transArgs - current composite transformation's execution argument sequence
argMap - map IDs of template argument sequences to IDs of execution argument sequences
createdArgIds - Vector storing the IDs of all the created sequences of arguments during a composite transformation execution
pointingToArgumentSequences - whether this argument sequence points to other sequences or not
Returns:
ID of the new sequence of arguments
Throws:
AutoRepException - if no records for the specified templateArgId exist in TTR, or if there is no mapping for the templateArgId to an argument sequence in the TER. See also getValueForTemplateArgument(int,int, String, String[], HashMap) and uk.ac.ic.doc.automed.templates.CompositeTransformation#getValueForTemplateArgumentPointingToArgId(int,int, String, String[], HashMap, Vector)
TemplateExecutionRepositoryException - see TemplateExecutionRepository.createFirstArgument(int, String), getValueForTemplateArgument(int,int, String, String[], HashMap) and uk.ac.ic.doc.automed.templates.CompositeTransformation#getValueForTemplateArgumentPointingToArgId(int,int, String, String[], HashMap, Vector) and TemplateExecutionRepository.createArgument(int, int, String)
RepositoryAccessException - if the repositories cannot be accessed

removeExecutionTrace

protected void removeExecutionTrace(int transId,
                                    java.util.Vector createdArgIds)
Removes the trace of a composite transformation's executionfrom the TER.

Parameters:
transId - ID of composite transformation executed
createdArgIds - Vector storing the IDs of all the created sequences of arguments during the composite transformation execution

rollbackSTR

protected static void rollbackSTR(java.util.Vector transformationSequence)
Removes the trace of a composite transformation's execution for the STR. If there is a run-time error in the transformation's execution then this method rollbacks the STR in its state before the execution.

Parameters:
transformationSequence - Vector containing all the transformations executed so far

createPrimitiveTransformation

protected void createPrimitiveTransformation(int argId,
                                             java.lang.String[] resultingSID,
                                             java.lang.String[] createdOBID,
                                             java.util.Vector transformationSequence)
                                      throws RepositoryAccessException,
                                             AutoRepException
Creates a primitive transformation and appends it in the STR.

Parameters:
argId - execution argument sequence ID pointing to the primitive transformation's values (action, fromObj...)
Throws:
AutoRepException - if there are no arguments for argId in the TER, or if the primitive transformation couldn't be created due to error in the STR
RepositoryAccessException - if the repositories cannot be accessed

getSchemeArray

protected java.lang.Object[] getSchemeArray(Construct objectConstruct,
                                            java.lang.String[] objectScheme)
This method is used to retrieve the Object [] which defines the schema of a newly added object. The format of the array is as described in the REPS api, during addTransformations. Tbe format of the array depends on the construct of the newly created object and it is defined by the ConstructScheme. Once we retrieve the constructScheme [] of the construct then we know how to read the String [] that determines the object scheme, as defined in the template definition. For each scheme position there is a lower and an upper bound. The lower bound determines the least number of elements at that position and the upper bound the least. There are 3 cases: 1) min==max: The number of elements is fixed. So the next min (or max) elements in the scheme are of the type defined at that position. 2) minmax: The maximum is unbounded. It is like case 2, without the limitation on the number of iterations. The type of the scheme position is either 1 or 2. type 1: The object is passed by value.It means that the object has not been created first, but the new_object statement for that object must have been called. Consequently the entry for this object is in the form "temp21", which means that it is held temporarily in the tempObjects hash table. tempObjects.get("temp21"); will get the value of temporary variable 21 (ie it name). The entry in the Object [] should be that value. type 2: The object is passed by reference. It means that the object HAS been created already and added to the database. The scheme should hold the actual number (as held in the repository), which is used to create the ObjectSchema that will be added to the Object [].


describeTransformations

public java.lang.String describeTransformations(java.util.Vector transformationSequence)
Returns a String describing the transformations executed in the Vector given as a parameter


executeCreateListStatement

protected void executeCreateListStatement(int stmntId,
                                          int stmntTemplateArgId,
                                          int transIdToUse,
                                          java.lang.String[] transArgs,
                                          java.util.HashMap argMap,
                                          int runTimePc,
                                          java.lang.String[] resultingSID,
                                          java.lang.String[] createdOBID,
                                          java.util.Vector createdArgIds,
                                          java.util.Vector transformationSequence)
                                   throws TemplateExecutionRepositoryException,
                                          RepositoryAccessException,
                                          AutoRepException
Executes a CREATE_LIST statement. This statement is used to create a list of elements.

Throws:
TemplateExecutionRepositoryException
RepositoryAccessException
AutoRepException

executeDefineStringStatement

protected void executeDefineStringStatement(int stmntId,
                                            int stmntTemplateArgId,
                                            int transIdToUse,
                                            java.lang.String[] transArgs,
                                            java.util.HashMap argMap,
                                            int runTimePc,
                                            java.lang.String[] resultingSID,
                                            java.lang.String[] createdOBID,
                                            java.util.Vector createdArgIds,
                                            java.util.Vector transformationSequence)
                                     throws TemplateExecutionRepositoryException,
                                            RepositoryAccessException,
                                            AutoRepException
Executes a DEFINE_STRING statement. This statement is used to define dynamic strings used for functions constrains etc.

Throws:
TemplateExecutionRepositoryException
RepositoryAccessException
AutoRepException

executeSchemeListStatement

protected void executeSchemeListStatement(int stmntId,
                                          int stmntTemplateArgId,
                                          int transIdToUse,
                                          java.lang.String[] transArgs,
                                          java.util.HashMap argMap,
                                          int runTimePc,
                                          java.lang.String[] resultingSID,
                                          java.lang.String[] createdOBID,
                                          java.util.Vector createdArgIds,
                                          java.util.Vector transformationSequence)
                                   throws TemplateExecutionRepositoryException,
                                          RepositoryAccessException,
                                          AutoRepException
Throws:
TemplateExecutionRepositoryException
RepositoryAccessException
AutoRepException

executeIndexListStatement

protected void executeIndexListStatement(int stmntId,
                                         int stmntTemplateArgId,
                                         int transIdToUse,
                                         java.lang.String[] transArgs,
                                         java.util.HashMap argMap,
                                         int runTimePc,
                                         java.lang.String[] resultingSID,
                                         java.lang.String[] createdOBID,
                                         java.util.Vector createdArgIds,
                                         java.util.Vector transformationSequence)
                                  throws TemplateExecutionRepositoryException,
                                         RepositoryAccessException,
                                         AutoRepException
Throws:
TemplateExecutionRepositoryException
RepositoryAccessException
AutoRepException