org.deegree_impl.services.wfs
Class InsertTree

java.lang.Object
  extended byorg.deegree_impl.services.wfs.InsertTree

public class InsertTree
extends java.lang.Object

This recursive structure is used to hold all necessary data for an INSERT-Transaction of one instance of an GMLFeature.

Author:
Markus Schneider, Andreas Poth

Field Summary
private  java.util.HashMap fields
          fieldNames/value pairs for this table (for flat fields)
private  FeatureType ft
          associated FeatureType
private  boolean isJoinTable
          true, if associated table is a jointable
private  java.util.HashMap jSonNames
          lookup table for jointable-sons (values are RelatedTables)
private  java.util.HashMap sonNames
          lookup table for non-jointable-sons (values are InsertTrees)
private  java.util.ArrayList sons
          connected InsertTrees (Jointables and Non-Jointables)
private  TableDescription table
          associated DB-Table
 
Constructor Summary
private InsertTree(TableDescription table, FeatureType ft)
          Constructs a new InsertTree-object (only for class-internal use).
 
Method Summary
private  InsertTree addChild(RelatedTable targetTable, boolean childIsJT)
          Adds a table as a child.
private  boolean addField(java.lang.String value, java.lang.String mappedTable, java.lang.String mappedField)
          Adds a field to the structure.
private  InsertTree buildFromGMLFeature(GMLFeature gmlFeature)
          Builds a new InsertTree object recursively.
static InsertTree buildFromGMLFeature(GMLFeature gmlFeature, FeatureType ft)
           
 FeatureType getFeatureType()
          returns the feature type that is mapped to the tree
 java.util.Iterator getFieldsKeys()
           
 java.lang.Object getFieldValue(java.lang.String key)
          returns fieldNames/value pair for this table (for flat fields)
 java.util.ArrayList getSons()
          returns a list of InsertTrees that are connected to this one
 TableDescription getTableDescription()
          returns the associated DB-Table
 boolean isFieldsEmpty()
           
 boolean isJoinTable()
          returns true if the current table is a join table
 java.lang.Object putFieldValue(java.lang.String key, java.lang.Object value)
          set fieldNames/value pair for this table (for flat fields)
private  java.lang.String[] splitString(java.lang.String name)
          Extracts the two parts of a concatenated String of the form [a.]b (part a is optional).
 java.lang.String toString()
          Returns a String representation of this object.
private  java.lang.StringBuffer toStringRecurse(java.lang.String indent)
          Builds a StringBuffer recursively that describes this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ft

private FeatureType ft
associated FeatureType


table

private TableDescription table
associated DB-Table


isJoinTable

private boolean isJoinTable
true, if associated table is a jointable


sons

private java.util.ArrayList sons
connected InsertTrees (Jointables and Non-Jointables)


sonNames

private java.util.HashMap sonNames
lookup table for non-jointable-sons (values are InsertTrees)


jSonNames

private java.util.HashMap jSonNames
lookup table for jointable-sons (values are RelatedTables)


fields

private java.util.HashMap fields
fieldNames/value pairs for this table (for flat fields)

Constructor Detail

InsertTree

private InsertTree(TableDescription table,
                   FeatureType ft)
            throws InsertException
Constructs a new InsertTree-object (only for class-internal use). Iterates on the tables referenced by the given (constructed) table:

Parameters:
table - the table associated to the new InsertTree
ft - the FeatureType this InsertTree corresponds to
Method Detail

buildFromGMLFeature

public static InsertTree buildFromGMLFeature(GMLFeature gmlFeature,
                                             FeatureType ft)
                                      throws InsertException
Throws:
InsertException

addChild

private InsertTree addChild(RelatedTable targetTable,
                            boolean childIsJT)
                     throws InsertException
Adds a table as a child. (resulting in a new InsertTree connected to the object) If the table to add is a jointable, several children with the same name are possible, non-jointable sons have to have unique names.

Parameters:
targetTable - the table to add
childIsJT - true, if child table is a jointable
Returns:
the child's InsertTree-object
Throws:
InsertException

addField

private boolean addField(java.lang.String value,
                         java.lang.String mappedTable,
                         java.lang.String mappedField)
Adds a field to the structure. The field slips recursively through the tree until a InsertTree with a matching name is found. The recursion does not descend to subtrees that are connected via jointables, only "normally" connected subtrees are searched.

Parameters:
value - the data of the field
mappedTable - the name of the db-table
mappedField - the name of the db-field
Returns:
true, if a matching table was found, else false

buildFromGMLFeature

private InsertTree buildFromGMLFeature(GMLFeature gmlFeature)
                                throws InsertException
Builds a new InsertTree object recursively. Recurses on both the GMLFeature-parameter and the InsertTree-instance. Flat properties are simply added by calling addField (). Complex properties require that a new child-InsertTree to be added, recursion descends into the new child and the property.

Parameters:
gmlFeature - the GMLFeature the InsertTree shall represent
Returns:
the constructed and filled InsertTree
Throws:
InsertException

splitString

private java.lang.String[] splitString(java.lang.String name)
Extracts the two parts of a concatenated String of the form [a.]b (part a is optional). Method is null-save.

Returns:
array of Strings, [0] = a, [1] = b

toString

public java.lang.String toString()
Returns a String representation of this object.


toStringRecurse

private java.lang.StringBuffer toStringRecurse(java.lang.String indent)
Builds a StringBuffer recursively that describes this object.

Parameters:
indent - String to put in front of every line
Returns:
StringBuffer describing the object (and it's sons)

getFeatureType

public FeatureType getFeatureType()
returns the feature type that is mapped to the tree


getTableDescription

public TableDescription getTableDescription()
returns the associated DB-Table


isJoinTable

public boolean isJoinTable()
returns true if the current table is a join table


getSons

public java.util.ArrayList getSons()
returns a list of InsertTrees that are connected to this one


getFieldValue

public java.lang.Object getFieldValue(java.lang.String key)
returns fieldNames/value pair for this table (for flat fields)


putFieldValue

public java.lang.Object putFieldValue(java.lang.String key,
                                      java.lang.Object value)
set fieldNames/value pair for this table (for flat fields)


isFieldsEmpty

public boolean isFieldsEmpty()

getFieldsKeys

public java.util.Iterator getFieldsKeys()