Dresden OCL Toolkit

tudresden.ocl.codegen.decl
Class ObjectView

java.lang.Object
  extended bytudresden.ocl.codegen.decl.ObjectView

public class ObjectView
extends Object

An ObjectView is a View on relational tables of a database containing all columns that are part of the relational mapping of a class that has been mapped to the database during an object-relational mapping very complex attributes as attributes containing muliple values or class references are excluded from the view

Author:
Andrea Kling

Nested Class Summary
private  class ObjectView.Column
           
private  class ObjectView.Connection
           
 
Field Summary
private  String className
           
private  Vector columns
           
private  Vector connections
           
private  String viewName
           
 
Constructor Summary
ObjectView(String viewName, String className)
          creates a new ObjectView named viewName for a classifier named className
 
Method Summary
 void addColumn(String attribute, String columnName, Table table)
          adds a Column to the view
 void addConnection(String column1, Table table1, String column2, Table table2)
          adds a restriction to the 'where'-clause of the view, the restriction is formed like:
table1Name.column1 = table2Name.column2
this is used to realize foreign key references
 ObjectView copy()
          a cind of cloneof the current ObjectView containing the same columns and connections
 Object[][] getAttributeColumns(String attribute)
          returns all columns the class attribute given was mapped to, null if the attribute isn't contained in the view
Object[x][0] = String column name (as used in addColumn())
Object[x][1] = Table original table of colum
 String getClassifier()
           
private  ObjectView.Column getColumn(String name, Table table)
           
 Object[][] getColumns()
          returns all Information about all defined columns the field is formed like:
Object[x][0] = String classAttribute
Object[x][1] = String columnName (in the original Table)
Object[x][2] = Table originalTable of the Column
 Object[][] getConnections()
          returns all foreign key connections for the where clause of this view contents of Object[][]:
Object[x][0] = String column1 name
Object[x][1] = Table table of column1
Object[x][2] = String column2 name
Object[x][3] = Table table of column2
the connection should be: table1name.column1 = table2name.column2
 String getName()
           
 String getPrimaryKeyRepresentation()
          returns a representation of this views 'primary key' meaning row identifying columns the String is formed '(pk1, pk2,..)'
 void removeColumn(String name, Table table)
          removes a certain column from View
 void removeColumnsFor(String attribute)
          removes all columns from view that are part of mapping of the given class attribute.
 void removePrimaryKey()
          resets the primary key flag of all column to false
protected  void setColumns(Vector columns)
          sets the columns of this view
protected  void setConnections(Vector connections)
          sets the connections of this View
 void setPrimaryKey(String column, Table table)
          defines a column of the view as being part of the 'primary key' of the view, meaning the 'primary key' will be referred for example by Guides to associationends of Associations between classifiers
 void setViewNames(String viewName, String className)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

viewName

private String viewName

className

private String className

columns

private Vector columns

connections

private Vector connections
Constructor Detail

ObjectView

public ObjectView(String viewName,
                  String className)
creates a new ObjectView named viewName for a classifier named className

Method Detail

addColumn

public void addColumn(String attribute,
                      String columnName,
                      Table table)
               throws IllegalArgumentException
adds a Column to the view

Parameters:
attribute - the name of the class attribute the new column is representing (partly) in the view
columnName - the name of the column (in its original table)
table - the original table the column is viewed from
Throws:
IllegalArgumentException

addConnection

public void addConnection(String column1,
                          Table table1,
                          String column2,
                          Table table2)
                   throws IllegalArgumentException
adds a restriction to the 'where'-clause of the view, the restriction is formed like:
table1Name.column1 = table2Name.column2
this is used to realize foreign key references

Throws:
IllegalArgumentException

setPrimaryKey

public void setPrimaryKey(String column,
                          Table table)
defines a column of the view as being part of the 'primary key' of the view, meaning the 'primary key' will be referred for example by Guides to associationends of Associations between classifiers

See Also:
Guide

getColumns

public Object[][] getColumns()
returns all Information about all defined columns the field is formed like:
Object[x][0] = String classAttribute
Object[x][1] = String columnName (in the original Table)
Object[x][2] = Table originalTable of the Column

See Also:
Table

removeColumnsFor

public void removeColumnsFor(String attribute)
removes all columns from view that are part of mapping of the given class attribute. May be used for attributes with collection types


removeColumn

public void removeColumn(String name,
                         Table table)
removes a certain column from View

Parameters:
name - the name of the Column as used in addColumn()
table - the original Table of the column as used in addColumn()

getAttributeColumns

public Object[][] getAttributeColumns(String attribute)
returns all columns the class attribute given was mapped to, null if the attribute isn't contained in the view
Object[x][0] = String column name (as used in addColumn())
Object[x][1] = Table original table of colum


removePrimaryKey

public void removePrimaryKey()
resets the primary key flag of all column to false


setViewNames

public void setViewNames(String viewName,
                         String className)
Parameters:
viewName - the name of the ObjectView
className - the name of the classifier the ObjectView represents

getName

public String getName()
Returns:
the name of the view

getClassifier

public String getClassifier()
Returns:
the name of the classifier this view represents

getConnections

public Object[][] getConnections()
returns all foreign key connections for the where clause of this view contents of Object[][]:
Object[x][0] = String column1 name
Object[x][1] = Table table of column1
Object[x][2] = String column2 name
Object[x][3] = Table table of column2
the connection should be: table1name.column1 = table2name.column2

See Also:
Table

getPrimaryKeyRepresentation

public String getPrimaryKeyRepresentation()
returns a representation of this views 'primary key' meaning row identifying columns the String is formed '(pk1, pk2,..)'


setColumns

protected void setColumns(Vector columns)
sets the columns of this view

Parameters:
columns - a Vector of Column

setConnections

protected void setConnections(Vector connections)
sets the connections of this View

Parameters:
connections - a Vector of Connection

copy

public ObjectView copy()
a cind of cloneof the current ObjectView containing the same columns and connections


getColumn

private ObjectView.Column getColumn(String name,
                                    Table table)

Dresden OCL Toolkit

Submit a bug
Developed at the Dresden University of Technology.
This software is published under the GNU Lesser General Public License.