org.ceryle.ui
Class DatabaseUtils

java.lang.Object
  extended by org.ceryle.ui.DatabaseUtils

public class DatabaseUtils
extends Object

A class that provices database utility functions designed for use by the DocumentView, to which it is rather tightly associated. An instance of this class is accessible from the ViewManager (rather than Services).

Since:
JDK1.4
Version:
$Id$
Author:
Murray Altheim

Field Summary
static boolean autoIndex
          Variable controlling whether an index should be created upon changes to the collection or node lists.
 
Constructor Summary
DatabaseUtils(ViewManager viewmanager)
          Default constructor, supplied with the application's ViewManager.
 
Method Summary
 boolean changeID(EditorPanel m_editor)
          Change the ID of the current document.
 void checkRevisionLimits(String cid, XNode xnode)
          If revision control limits are active, alerts the user if either the revision count or space limit of the provided XNode has been exceeded.
 String createCollection(CollectionList list, String cid, String title)
          Create a new Collection whose identifier is the String cid.
protected  boolean createNode(EditorPanel m_editor)
          Add the current view content as a new Node, using the current Collection and Node ID fields as its identifiers.
protected  boolean createNode(EditorPanel m_editor, String cid, String nid)
          Add the current view content as a new Node.
protected  void deleteCollection(DocumentView dv)
          Delete the Collection at the selected index of the provided DocumentView's CollectionList.
 boolean duplicateNode(EditorPanel m_editor, boolean canSelectCID)
          Duplicate the currently-loaded Node in the current collection, querying for the Collection and Node IDs, returning true if successful.
protected  Document getContentAsDocument(EditorPanel m_editor, String content)
          Turns the String content into an XML Document, either as valid or well-formed XML, or as a CDATA section.
 Document getContentAsDocument(int method, String content, boolean validating)
          Turns the String content into an XML Document, either as valid or well-formed XML, or as a CDATA section.
 String getDefaultCollection(EditorPanel m_editor)
          Returns a String containing the name of the default Collection, via a circuitous route from EditorPanel back to its DocumentView.
 boolean modifyNode(EditorPanel m_editor)
          Modify an existing Node whose ID matches the current collection and node ID fields, returning true if successful.
 boolean modifyNode(EditorPanel m_editor, String cid, String nid)
          Modify an existing Node whose ID matches the String nid, in Collection ID cid, returning true if successful.
protected  String openCollection(CollectionList list, String cid)
          Opens the Collection cid as the default Collection.
protected  void savePresentation(EditorPanel m_editor)
          If this is a Note, save its location as metadata to its stored XNode.
protected  void savePresentation(EditorPanel m_editor, String cid, String nid, XNode xnode, boolean writeNode)
          Saves the current background color, font, and bounds of the window to the XNode's metadata.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

autoIndex

public static boolean autoIndex
Variable controlling whether an index should be created upon changes to the collection or node lists.

Constructor Detail

DatabaseUtils

public DatabaseUtils(ViewManager viewmanager)
Default constructor, supplied with the application's ViewManager. All other essentials are provided by Services.

Method Detail

createCollection

public String createCollection(CollectionList list,
                               String cid,
                               String title)
Create a new Collection whose identifier is the String cid. If this is null, it will be requested via a dialog box.

Parameters:
list - the optional CollectionList to update
cid - the Collection ID
title - the optional Collection title
Returns:
the new Collection ID, or null if cancelled or otherwise failed.

openCollection

protected String openCollection(CollectionList list,
                                String cid)
Opens the Collection cid as the default Collection. Returns a String containing the CID of the default Collection, null is unavailable.


deleteCollection

protected void deleteCollection(DocumentView dv)
Delete the Collection at the selected index of the provided DocumentView's CollectionList.


createNode

protected boolean createNode(EditorPanel m_editor)
Add the current view content as a new Node, using the current Collection and Node ID fields as its identifiers.

Returns:
true if the node was created

getDefaultCollection

public String getDefaultCollection(EditorPanel m_editor)
                            throws ProcessException
Returns a String containing the name of the default Collection, via a circuitous route from EditorPanel back to its DocumentView.

Throws:
ProcessException

createNode

protected boolean createNode(EditorPanel m_editor,
                             String cid,
                             String nid)
                      throws ProcessException
Add the current view content as a new Node. This queries for a title, and populates the node ID field with an ID-converted form of the title.

Returns:
true if the node was created.
Throws:
ProcessException

getContentAsDocument

protected Document getContentAsDocument(EditorPanel m_editor,
                                        String content)
Turns the String content into an XML Document, either as valid or well-formed XML, or as a CDATA section. If unable, returns null.


getContentAsDocument

public Document getContentAsDocument(int method,
                                     String content,
                                     boolean validating)
                              throws XMLParseException,
                                     ProcessException
Turns the String content into an XML Document, either as valid or well-formed XML, or as a CDATA section. If unable, returns null. If validating is true, only valid content will be acceptable.

Throws:
XMLParseException
ProcessException

modifyNode

public boolean modifyNode(EditorPanel m_editor)
Modify an existing Node whose ID matches the current collection and node ID fields, returning true if successful. If the node doesn't exist, this is identical in functionality to createNode(EditorPanel). If the node already exists, its content will be changed and its metadata updated accordingly.


modifyNode

public boolean modifyNode(EditorPanel m_editor,
                          String cid,
                          String nid)
Modify an existing Node whose ID matches the String nid, in Collection ID cid, returning true if successful. If the node doesn't exist, this is identical in functionality to createNode(EditorPanel,String,String). If the node already exists, its content will be changed and its metadata updated accordingly.


checkRevisionLimits

public void checkRevisionLimits(String cid,
                                XNode xnode)
If revision control limits are active, alerts the user if either the revision count or space limit of the provided XNode has been exceeded. If limits are inactive, this method does nothing.


savePresentation

protected void savePresentation(EditorPanel m_editor)
If this is a Note, save its location as metadata to its stored XNode.


savePresentation

protected void savePresentation(EditorPanel m_editor,
                                String cid,
                                String nid,
                                XNode xnode,
                                boolean writeNode)
                         throws XNodeException
Saves the current background color, font, and bounds of the window to the XNode's metadata. If writeNode is true, writes the data to the XNodeStore, otherwise this just modifies the XNode but doesn't store it.

Throws:
XNodeException

duplicateNode

public boolean duplicateNode(EditorPanel m_editor,
                             boolean canSelectCID)
Duplicate the currently-loaded Node in the current collection, querying for the Collection and Node IDs, returning true if successful. If canSelectCID is true, the collection ID is selectable.


changeID

public boolean changeID(EditorPanel m_editor)
Change the ID of the current document.

Returns:
true if changed


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.