wxtpages
Class unitDBContent

java.lang.Object
  extended byjavax.swing.tree.DefaultMutableTreeNode
      extended bywxtpages.unit
          extended bywxtpages.unitDBContent
All Implemented Interfaces:
java.lang.Cloneable, javax.swing.tree.MutableTreeNode, java.io.Serializable, javax.swing.tree.TreeNode

public class unitDBContent
extends unit

unitDBContent instances holds pieces of content that will be placed in templates to form a page. An instance of unitDBContent match a content element in the script.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class wxtpages.unit
CONTENT_TYPE, DBCONTENT_TYPE, GROUP_TYPE, m_absoluteUri, m_description, m_Doc, m_GroupMaster, m_lastTimeUsed, m_myElement, m_name, m_optionMap, m_originalUri, m_parameterMap, m_propertyMap, m_txtContent, m_type, PAGE_TYPE, TEMPLATE_TYPE, TEXTCONTENT_TYPE, TRANSFORMATION_TYPE, UNIT_TYPE
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
unitDBContent(unitGroup master, org.w3c.dom.Element elt, unit owner)
          Creates a new instance of unitDBContent, as it appears in the script
unitDBContent(unitGroup master, java.lang.String loc, unit owner)
          Creates a new instance of unitDBContent, as atemporary unit in respons to a PI
 
Method Summary
protected  void accessDatabase(command cmd)
           
protected  boolean establishDom()
          Attempt to establish the DOM for this unit.
protected  org.w3c.dom.Document establishInputDom(java.lang.String text)
          Attempt to establish the DOM for the input to the database.
 void execute(java.sql.Connection db, java.lang.String sqlquery)
           
 boolean exist(java.lang.String node)
           
 org.w3c.dom.NodeList getNodeList(command cmd)
          Get a list of nodes according to the xpath specifyed in cmd
 java.sql.Connection handleDBconn(java.lang.String passwd)
          Connects to the spesified database on host
 void nodeProsess(org.w3c.dom.Node node, java.lang.String tableName)
           
protected  java.lang.String parseToXml(java.lang.String inputString, java.sql.Connection dbConn)
          Creates valid and structured xml from input.
 boolean prepare(unit p, java.lang.String theCommonName, java.lang.String theCommonValue)
          Prepare this unitDBContent with imports from non-content files.
protected  java.lang.String putToDatabase(java.lang.String tablename, java.lang.String xmlfile, java.sql.Connection dbConn)
          The methode takes a tablename for table to be updated / inserted to, and a xml file to be parsed into INSERT or UPDATE sql statments.
static java.lang.String readFromFile(java.lang.String input)
          Reads a file and put the content into a string
 
Methods inherited from class wxtpages.unit
addTransformationParameters, browseUnit, build, calculateAbsoluteAddress, controlLinks, correctAllAddressingInDocument, correctAllAddressingInFragment, correctOneCommonLink, correctStyleAttributes, correctStyleElements, correctStyleString, displayProperties, editUnit, getAbsoluteUri, getAbsoluteUriAsString, getAsText, getDescription, getDoc, getDocCopy, getEncoding, getFileName, getName, getOption, getOptions, getOriginalAsString, getOriginalUri, getProperties, getReporter, getTransformation, getTransformationAsString, getTransformationID, getTransformationParameterMap, getType, getURItoAsString, isSameAs, isUpdatedAfterUse, killDocument, loadAsText, makeComment, makeImageRefToPage, makeRefToPage, saveFromDOM, setEncoding, setNowAsLastTimeUsed, setReporter, setTransformationFromString, setTransformationId, setUpPopMenu, toString
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

unitDBContent

public unitDBContent(unitGroup master,
                     org.w3c.dom.Element elt,
                     unit owner)
              throws java.lang.Exception
Creates a new instance of unitDBContent, as it appears in the script

Parameters:
master - The unitGroup object that owns this content object
elt - The element in the script that defines this unitContent object
owner - The unit that owns this unitContent, normally a unitPage-object
Throws:
java.lang.Exception - when the object cannot be established

unitDBContent

public unitDBContent(unitGroup master,
                     java.lang.String loc,
                     unit owner)
              throws java.lang.Exception
Creates a new instance of unitDBContent, as atemporary unit in respons to a PI

Parameters:
master - The unitGroup object that owns this content object
loc - Where the unitContent object is stored
owner - The unit that owns this unitContent, normally a unitPage-object
Throws:
java.lang.Exception - when the object cannot be established
Method Detail

prepare

public boolean prepare(unit p,
                       java.lang.String theCommonName,
                       java.lang.String theCommonValue)
Prepare this unitDBContent with imports from non-content files. Does necessary address calculations. Calls supers (unit) prepare

Overrides:
prepare in class unit
Parameters:
p - The unit that will use this unit as content, may not be null
theCommonName - The name used for common resources in the material
theCommonValue - The value that we will use
Returns:
false if a fatal error occurs during preparation, true otherwise

handleDBconn

public java.sql.Connection handleDBconn(java.lang.String passwd)
Connects to the spesified database on host

Parameters:
passwd - Password for username
Returns:
db Connection Object

parseToXml

protected java.lang.String parseToXml(java.lang.String inputString,
                                      java.sql.Connection dbConn)
Creates valid and structured xml from input. Adds xml encoding line, rootelement and information about how the data was retrived from the database. Adds a tablerow for each record from the result of connectionObject and puts the colums of each row into the tablerow element.

Parameters:
dbConn - Connection Object
inputString - String with result from handleDBconn
Returns:
output String with result as valid xml

putToDatabase

protected java.lang.String putToDatabase(java.lang.String tablename,
                                         java.lang.String xmlfile,
                                         java.sql.Connection dbConn)
The methode takes a tablename for table to be updated / inserted to, and a xml file to be parsed into INSERT or UPDATE sql statments. The sql statements are thereafter executed.

Parameters:
tablename - Name of table to be used for update / insertion
xmlfile - XML-content file with information to be updated / inserted
dbConn - Database connection object

nodeProsess

public void nodeProsess(org.w3c.dom.Node node,
                        java.lang.String tableName)
                 throws java.io.IOException
Throws:
java.io.IOException

exist

public boolean exist(java.lang.String node)

execute

public void execute(java.sql.Connection db,
                    java.lang.String sqlquery)

readFromFile

public static java.lang.String readFromFile(java.lang.String input)
Reads a file and put the content into a string

Parameters:
input - Location for file to be read
Returns:
outout String containing data from

accessDatabase

protected void accessDatabase(command cmd)

establishDom

protected boolean establishDom()
Attempt to establish the DOM for this unit. Take input transformation into account.

Overrides:
establishDom in class unit
Returns:
true if we can establish dom from actual absolute address, false otherwise

establishInputDom

protected org.w3c.dom.Document establishInputDom(java.lang.String text)
Attempt to establish the DOM for the input to the database. Take input transformation into account.

Returns:
true if we can establish dom from actual absolute address, false otherwise

getNodeList

public org.w3c.dom.NodeList getNodeList(command cmd)
Get a list of nodes according to the xpath specifyed in cmd

Overrides:
getNodeList in class unit
Parameters:
cmd - the command that controls the listproduction
Returns:
null, allways