treebolic.provider.sql
Class Provider

java.lang.Object
  extended by treebolic.provider.sql.Provider
All Implemented Interfaces:
IProvider

public class Provider
extends java.lang.Object
implements IProvider

Provider for SQL

Author:
Bernard Bou

Field Summary
private  IProviderContext theContext
          Provider context
private static java.lang.String theDefaultEdgesSql
          Get edges SQL statement
private static java.lang.String theDefaultMenuSql
          Get menu item SQL statement
private static java.lang.String theDefaultNodesSql
          Get nodes SQL statement
private static java.lang.String theDefaultSettingsSql
          Get settings SQL statement
private static java.lang.String theDefaultTreeEdgesSql
          Get tree edges SQL statement
private  java.util.Hashtable<java.lang.String,TreeMutableNode> theIdToNodeMap
          Node map by id
protected  java.util.Properties theProperties
          Properties
private static java.lang.String thePropertyFile
          Property files
 
Constructor Summary
Provider()
          Constructor
 
Method Summary
 void connect(IProviderContext thisContext)
          Called by framework to pass context reference (may default to void action if provider does not need it)
private  java.lang.String getName(java.lang.String thisKey)
          Get name
private  boolean initialize(java.lang.String thisSource)
          Initialize
private  java.lang.String macroExpand(java.lang.String thisString)
          Expand macros
 Model makeModel(java.lang.String thisSource)
          Make model
 Tree makeTree(java.lang.String thisSource, boolean checkRecursion)
          Make tree.
private  java.lang.String makeUrl(java.util.Properties theseProperties)
          Make URL
private  java.util.List<IEdge> queryEdges(java.sql.Connection thisConnection)
          Query edges
private  Model queryModel()
          Query model
private  MutableNode queryNodes(java.sql.Connection thisConnection)
          Query nodes
private  Settings querySettings(java.sql.Connection thisConnection)
          Query settings
private  Tree queryTree()
          Query tree
private  Tree queryTree(java.sql.Connection thisConnection)
          Query tree
private  java.lang.Boolean readBoolean(java.sql.ResultSet thisRecordSet, java.lang.String thisName)
          Read boolean
private  java.awt.Color readColor(java.sql.ResultSet thisRecordSet, java.lang.String thisName)
          Read color
private  java.lang.Double readDouble(java.sql.ResultSet thisRecordSet, java.lang.String thisName)
          Read double
private  java.lang.Integer readInteger(java.sql.ResultSet thisRecordSet, java.lang.String thisName)
          Read integer
private  java.lang.String readString(java.sql.ResultSet thisRecordSet, java.lang.String thisName)
          Read string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

thePropertyFile

private static java.lang.String thePropertyFile
Property files


theDefaultNodesSql

private static java.lang.String theDefaultNodesSql
Get nodes SQL statement


theDefaultTreeEdgesSql

private static java.lang.String theDefaultTreeEdgesSql
Get tree edges SQL statement


theDefaultEdgesSql

private static java.lang.String theDefaultEdgesSql
Get edges SQL statement


theDefaultSettingsSql

private static java.lang.String theDefaultSettingsSql
Get settings SQL statement


theDefaultMenuSql

private static java.lang.String theDefaultMenuSql
Get menu item SQL statement


theContext

private IProviderContext theContext
Provider context


theIdToNodeMap

private java.util.Hashtable<java.lang.String,TreeMutableNode> theIdToNodeMap
Node map by id


theProperties

protected java.util.Properties theProperties
Properties

Constructor Detail

Provider

public Provider()
Constructor

Method Detail

initialize

private boolean initialize(java.lang.String thisSource)
Initialize

Parameters:
thisSource - source
Returns:
true if successful

connect

public void connect(IProviderContext thisContext)
Description copied from interface: IProvider
Called by framework to pass context reference (may default to void action if provider does not need it)

Specified by:
connect in interface IProvider
Parameters:
thisContext - context

makeModel

public Model makeModel(java.lang.String thisSource)
Description copied from interface: IProvider
Make model

Specified by:
makeModel in interface IProvider
Parameters:
thisSource - source (a string that refers to the data in a was that the provider implementation will understand)
Returns:
model

makeTree

public Tree makeTree(java.lang.String thisSource,
                     boolean checkRecursion)
Description copied from interface: IProvider
Make tree. Settings are not parsed. This is used in mounting.

Specified by:
makeTree in interface IProvider
Parameters:
thisSource - source (a string that refers to the data in a was that the provider implementation will understand)
checkRecursion - whether immediate recursion is checked (avoid mount-now infinite recursion)
Returns:
tree

makeUrl

private java.lang.String makeUrl(java.util.Properties theseProperties)
Make URL

Parameters:
theseProperties - properties
Returns:
url string

queryModel

private Model queryModel()
Query model

Returns:
model

queryTree

private Tree queryTree()
Query tree

Returns:
tree

queryTree

private Tree queryTree(java.sql.Connection thisConnection)
                throws java.sql.SQLException
Query tree

Parameters:
thisConnection - connection
Returns:
tree
Throws:
java.sql.SQLException

queryNodes

private MutableNode queryNodes(java.sql.Connection thisConnection)
                        throws java.sql.SQLException
Query nodes

Parameters:
thisConnection - connection
Returns:
tree root node
Throws:
java.sql.SQLException

queryEdges

private java.util.List<IEdge> queryEdges(java.sql.Connection thisConnection)
                                  throws java.sql.SQLException
Query edges

Parameters:
thisConnection - connection
Returns:
edge list
Throws:
java.sql.SQLException

querySettings

private Settings querySettings(java.sql.Connection thisConnection)
Query settings

Parameters:
thisConnection - connection
Returns:
settings

readString

private java.lang.String readString(java.sql.ResultSet thisRecordSet,
                                    java.lang.String thisName)
Read string

Parameters:
thisRecordSet - record set
thisName - field name
Returns:
String value

readInteger

private java.lang.Integer readInteger(java.sql.ResultSet thisRecordSet,
                                      java.lang.String thisName)
Read integer

Parameters:
thisRecordSet - record set
thisName - field name
Returns:
Integer value

readDouble

private java.lang.Double readDouble(java.sql.ResultSet thisRecordSet,
                                    java.lang.String thisName)
Read double

Parameters:
thisRecordSet - record set
thisName - field name
Returns:
Double value

readBoolean

private java.lang.Boolean readBoolean(java.sql.ResultSet thisRecordSet,
                                      java.lang.String thisName)
Read boolean

Parameters:
thisRecordSet - record set
thisName - field name
Returns:
Boolean value

readColor

private java.awt.Color readColor(java.sql.ResultSet thisRecordSet,
                                 java.lang.String thisName)
Read color

Parameters:
thisRecordSet - record set
thisName - field name
Returns:
Color value

getName

private java.lang.String getName(java.lang.String thisKey)
Get name

Parameters:
thisKey - key
Returns:
value if not null or key after last '.'

macroExpand

private java.lang.String macroExpand(java.lang.String thisString)
Expand macros

Parameters:
thisString - string to expand macro in
Returns:
string with expanded macros