org.archiviststoolkit.plugin
Class ATPluginUtils

java.lang.Object
  extended by org.archiviststoolkit.plugin.ATPluginUtils

public class ATPluginUtils
extends java.lang.Object

Archivists' Toolkit(TM) Copyright 2005-2009 Regents of the University of California, New York University, & Five Colleges, Inc. All rights reserved. This software is free. You can redistribute it and / or modify it under the terms of the Educational Community License (ECL) version 1.0 (http://www.opensource.org/licenses/ecl1.php) This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ECL license for more details about permissions and limitations. Archivists' Toolkit(TM) http://www.archiviststoolkit.org info@archiviststoolkit.org Created by IntelliJ IDEA. This is a utility class to make it easier for plugin developers to save data to the AT database and perform validation on AT records.


Constructor Summary
ATPluginUtils()
           
 
Method Summary
static void deletePluginData(ATPluginData pluginData)
          Method to delete plugin data in the database
static java.util.Collection getData(java.lang.String pluginName)
          Method to get all the saved data for a certain plugin
static java.util.Collection getData(java.lang.String pluginName, java.lang.String dataType)
          Method to get all the saved data for a particular plugin and data type
static java.lang.Object getDataByName(java.lang.String pluginName, java.lang.String dataName)
          Method to return a string object or xml encoded object found in the database.
static java.lang.Object getObjectFromPluginData(ATPluginData pluginData)
          Method to return an object from plugin data using xstream to convert the saved xml to an object
static void saveData(java.lang.String pluginName, int dataVersion, java.lang.String dataName, java.lang.String dataType, java.lang.Object dataObject)
          Method that first converts a java object to an xml string then save it to the database
static void saveData(java.lang.String pluginName, int dataVersion, java.lang.String dataName, java.lang.String dataType, java.lang.String dataString)
          Method to save text data to the database
static void saveRecordToDatabase(DomainObject record)
          Method to save an AT record to the database.
static void saveToDatabase(ATPluginData pluginData)
          Saves plugin data object to the database
static boolean validateRecord(java.awt.Component component, DomainObject record)
          Method to valid a AT record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ATPluginUtils

public ATPluginUtils()
Method Detail

saveData

public static void saveData(java.lang.String pluginName,
                            int dataVersion,
                            java.lang.String dataName,
                            java.lang.String dataType,
                            java.lang.String dataString)
                     throws java.lang.Exception
Method to save text data to the database

Parameters:
pluginName - The name of the plugin
dataVersion - The dataVersion
dataName - The name of the data
dataType - The type of data
dataString - The text data to save
Throws:
java.lang.Exception - is thrown if there was a problem saving the data

saveData

public static void saveData(java.lang.String pluginName,
                            int dataVersion,
                            java.lang.String dataName,
                            java.lang.String dataType,
                            java.lang.Object dataObject)
                     throws java.lang.Exception
Method that first converts a java object to an xml string then save it to the database

Parameters:
pluginName - The name of the plugin
dataVersion - The dataVersion
dataName - The name of the data
dataType - The type of data
dataObject - The object that contains the data or is the data
Throws:
java.lang.Exception - is thrown if there was a problem saving the data

saveToDatabase

public static void saveToDatabase(ATPluginData pluginData)
                           throws java.lang.Exception
Saves plugin data object to the database

Parameters:
pluginData - The plugin data object
Throws:
java.lang.Exception - If there is any problems saving to the database

deletePluginData

public static void deletePluginData(ATPluginData pluginData)
                             throws java.lang.Exception
Method to delete plugin data in the database

Parameters:
pluginData - The plugin data
Throws:
java.lang.Exception - if there was a problem deleting that data

getData

public static java.util.Collection getData(java.lang.String pluginName)
                                    throws java.lang.Exception
Method to get all the saved data for a certain plugin

Parameters:
pluginName - The name of the plugin
Returns:
Collection containing any data they found
Throws:
java.lang.Exception

getData

public static java.util.Collection getData(java.lang.String pluginName,
                                           java.lang.String dataType)
                                    throws java.lang.Exception
Method to get all the saved data for a particular plugin and data type

Parameters:
pluginName - The name of the plugin
dataType - The data type of the plugin
Returns:
A collection containing any data that was found
Throws:
java.lang.Exception - is thrown of there is a problem find the data

getDataByName

public static java.lang.Object getDataByName(java.lang.String pluginName,
                                             java.lang.String dataName)
                                      throws java.lang.Exception
Method to return a string object or xml encoded object found in the database. If more than one data object with the same name is found then the first one is return.

Parameters:
pluginName - The name of the plugin
dataName - The name of the data
Returns:
The data object
Throws:
java.lang.Exception - If there is a problem finding the data from the database

getObjectFromPluginData

public static java.lang.Object getObjectFromPluginData(ATPluginData pluginData)
Method to return an object from plugin data using xstream to convert the saved xml to an object

Parameters:
pluginData - The ATPluginDataContaining the xml encoded object
Returns:
The converted object or null if conversion can't be done

saveRecordToDatabase

public static void saveRecordToDatabase(DomainObject record)
                                 throws java.lang.Exception
Method to save an AT record to the database.

Parameters:
record - The AT record to save to the database.
Throws:
java.lang.Exception - if there is a problem saving the record to the database

validateRecord

public static boolean validateRecord(java.awt.Component component,
                                     DomainObject record)
Method to valid a AT record. Calling this ensures that no invalid records are saved to the database

Parameters:
component - UI component that is requesting validation of the record
record - The AT record to validate
Returns:
true if the record valide, false otherwise