com.ibm.websphere.wim.util
Class SDOHelper

java.lang.Object
  extended by com.ibm.websphere.wim.util.SDOHelper

public class SDOHelper
extends java.lang.Object

A helper class for construt virtual member manager SDO data graph and data object.


Constructor Summary
SDOHelper()
           
 
Method Summary
static commonj.sdo.DataObject cloneDataObject(commonj.sdo.DataObject dataObject)
          Clones the input DataObject.
static org.eclipse.emf.ecore.EObject cloneEObject(org.eclipse.emf.ecore.EObject obj)
          Clones an EObject.
static commonj.sdo.DataObject cloneRootDataObject(commonj.sdo.DataObject root)
          Clones the input root DataObject.
static commonj.sdo.DataObject createConfigDataObject(commonj.sdo.DataObject parentDO, java.lang.String uri, java.lang.String configType)
          Creates a config type data object under the specified parent data ojbect, with specified virtual member manager configuration uri.
static commonj.sdo.DataObject createConfigProviderDataObject()
          Creates an empty data object that contains virtual member manager configuration name space URI in the document root.
static commonj.sdo.DataObject createConfigRepositoryDataObject(commonj.sdo.DataObject configProvider, java.lang.String repositoryTypeName)
          Creates an entity data object under the specified root data object with specified eitity type URI.
static commonj.sdo.DataObject createContextDataObject(commonj.sdo.DataGraph dataGraph, java.lang.String uri, java.lang.String contextTypeName)
          Creates a context data object under the specified data graph with specified context type uri.
static commonj.sdo.DataObject createContextDataObject(commonj.sdo.DataObject root, java.lang.String uri, java.lang.String contextTypeName)
          Creates a context data object under the specified root data object with specified context type URI.
static commonj.sdo.DataObject createControlDataObject(commonj.sdo.DataGraph dataGraph, java.lang.String uri, java.lang.String controlTypeName)
          Creates a control data object under the specified data graph with specified control type URI.
static commonj.sdo.DataObject createControlDataObject(commonj.sdo.DataObject root, java.lang.String uri, java.lang.String controlTypeName)
          Creates a control data object under the specified root data object with specified control type URI.
static commonj.sdo.DataGraph createDataGraph(java.lang.String uri)
          Creates an empty data graph that has the document root under the specified URI.
static commonj.sdo.DataObject createDataObject(java.lang.String uri, java.lang.String typeName)
          Creates a type data object with specified uri.
static commonj.sdo.DataObject createEntityDataObject(commonj.sdo.DataGraph dataGraph, java.lang.String uri, java.lang.String entityTypeName)
          Creates an entity data object under the specified data graph with specified entity type URI.
static commonj.sdo.DataObject createEntityDataObject(commonj.sdo.DataObject root, java.lang.String uri, java.lang.String entityTypeName)
          Creates an entity data object under the specified root data object with specified eitity type URI.
static commonj.sdo.DataObject createRootDataObject()
          Creates an empty data object that contains virtual member manager name space URI in the document root.
static commonj.sdo.DataObject deepCloneRootDataObject(commonj.sdo.DataObject root)
          Returns a deep clone of root DataObject once ChangeSummary is not null, otherwise, normal cloneRootDataObject will be returned.
static java.lang.Object deepCopyObject(java.lang.Object root)
          Returns a deep copy of an object, return null if the object to be cloned is null.
static java.util.Date getDateFromString(java.lang.String dateStr)
          Returns a Date from the specified String.
static java.lang.String getDateString(java.util.Date date)
          Returns a date String from the specified Date object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SDOHelper

public SDOHelper()
Method Detail

createRootDataObject

public static commonj.sdo.DataObject createRootDataObject()
                                                   throws WIMException
Creates an empty data object that contains virtual member manager name space URI in the document root.

Throws:
WIMException
Return:
An empty data object that contains virtual member manager name space URI in the document root.

createConfigDataObject

public static commonj.sdo.DataObject createConfigDataObject(commonj.sdo.DataObject parentDO,
                                                            java.lang.String uri,
                                                            java.lang.String configType)
                                                     throws WIMException
Creates a config type data object under the specified parent data ojbect, with specified virtual member manager configuration uri.

Parameters:
parentDO - The parent data object to create the new data object under.
uri - The virtual member manager configuration namespace uri.
configType - The configuration type.
Throws:
WIMException
Return:
A data object under the specified parent data ojbect, with specified virtual member manager configuration uri using specified configuration type.

createConfigProviderDataObject

public static commonj.sdo.DataObject createConfigProviderDataObject()
Creates an empty data object that contains virtual member manager configuration name space URI in the document root.

Throws:
WIMException
Return:
An empty data object that contains virtual member manager configuration name space URI in the document root.

createConfigRepositoryDataObject

public static commonj.sdo.DataObject createConfigRepositoryDataObject(commonj.sdo.DataObject configProvider,
                                                                      java.lang.String repositoryTypeName)
Creates an entity data object under the specified root data object with specified eitity type URI. For example: SDOHelper.createConfigRepositoryDataObject(configProvider, ConfigConstants.CONFIG_DO_LDAP_REPOSITORY_TYPE);

Parameters:
configProvider - The configuration provider data object that the repository data object to create under.
repositoryTypeName - A repository type name.
Return:
A data object.

createDataGraph

public static commonj.sdo.DataGraph createDataGraph(java.lang.String uri)
Creates an empty data graph that has the document root under the specified URI.

Parameters:
uri - The document root URI.
Return:
An empty data graph containing the specified document root data object.

createEntityDataObject

public static commonj.sdo.DataObject createEntityDataObject(commonj.sdo.DataGraph dataGraph,
                                                            java.lang.String uri,
                                                            java.lang.String entityTypeName)
Creates an entity data object under the specified data graph with specified entity type URI. For example: SDOHelper.createEntityDataObject(datagraph, null, SchemaConstants.DO_PERSON_ACCOUNT);

Parameters:
dataGraph - A data graph that the entity data object to create under.
uri - The name space URI of the entity. If not specified, virtual member manager name space URI will be used ("http://www.ibm.com/websphere/wim").
entityTypeName - An entity type name.
Return:
A data object.

createEntityDataObject

public static commonj.sdo.DataObject createEntityDataObject(commonj.sdo.DataObject root,
                                                            java.lang.String uri,
                                                            java.lang.String entityTypeName)
Creates an entity data object under the specified root data object with specified eitity type URI. For example: SDOHelper.createEntityDataObject(root, null, SchemaConstants.DO_PERSON_ACCOUNT);

Parameters:
root - The root data object that the entity data object to create under.
uri - The name space URI of the entity. If not specified, virtual member manager name space URI will be used ("http://www.ibm.com/websphere/wim").
entityTypeName - An entity type name.
Return:
A data object.

createControlDataObject

public static commonj.sdo.DataObject createControlDataObject(commonj.sdo.DataGraph dataGraph,
                                                             java.lang.String uri,
                                                             java.lang.String controlTypeName)
Creates a control data object under the specified data graph with specified control type URI. * For example: SDOHelper.createControlDataObject(datagraph, null, SchemaConstants.DO_PROPERTY_CONTROL);

Parameters:
dataGraph - The data graph that the control data object to create under.
uri - The name space URI of the control. If not specified, virtual member manager name space URI will be used ("http://www.ibm.com/websphere/wim").
controlTypeName - A control type name.
Return:
A data object.

createControlDataObject

public static commonj.sdo.DataObject createControlDataObject(commonj.sdo.DataObject root,
                                                             java.lang.String uri,
                                                             java.lang.String controlTypeName)
Creates a control data object under the specified root data object with specified control type URI. For example: SDOHelper.createControlDataObject(root, null, SchemaConstants.DO_PROPERTY_CONTROL);

Parameters:
root - The root data object that the control data object to create under.
uri - The name space URI of the control. If not specified, virtual member manager name space URI will be used ("http://www.ibm.com/websphere/wim").
controlTypeName - A control type name.
Return:
A data object.

createContextDataObject

public static commonj.sdo.DataObject createContextDataObject(commonj.sdo.DataGraph dataGraph,
                                                             java.lang.String uri,
                                                             java.lang.String contextTypeName)
Creates a context data object under the specified data graph with specified context type uri. For example: SDOHelper.createContextDataObject(datagraph, null, SchemaConstants.TYPE_CONTEXT)

Parameters:
dataGraph - The data graph that the context data object to create under.
uri - The name space URI of the context. If not specified, virtual member manager name space URI will be used ("http://www.ibm.com/websphere/wim").
contextTypeName - A context type name.
Return:
A data object.

createContextDataObject

public static commonj.sdo.DataObject createContextDataObject(commonj.sdo.DataObject root,
                                                             java.lang.String uri,
                                                             java.lang.String contextTypeName)
Creates a context data object under the specified root data object with specified context type URI. For example: SDOHelper.createContextDataObject(root, null, SchemaConstants.TYPE_CONTEXT)

Parameters:
root - The root data object that the context data object to create under.
uri - The name space URI of the context. If not specified, virtual member manager name space URI will be used ("http://www.ibm.com/websphere/wim").
contextTypeName - A context type name.
Return:
A data object.

createDataObject

public static commonj.sdo.DataObject createDataObject(java.lang.String uri,
                                                      java.lang.String typeName)
Creates a type data object with specified uri. For example: To create a Group data object SDOHelper.createDataObject(SchemaContants.WIM_NS_URI, SchemaConstants.DO_GROUP)

Parameters:
uri - the name space URI of the type. If it is null or empty, default is virtual member manager name space URI ("http://www.ibm.com/websphere/wim").
typeName - The name of the type.
Return:
A type data object with specified URI.

getDateString

public static java.lang.String getDateString(java.util.Date date)
Returns a date String from the specified Date object. It is expected to be called before passing the date to SDO set method. For example: date = new Date(); entity.set("registerDate", SDOHelper.getDateString(date)); Input: 2005-05-04T09:34:18.444-0400 Output: 2005-05-04T09:34:18.444-04:00

Parameters:
date - The Date object.
Return:
A date String that converted from Date object.

getDateFromString

public static java.util.Date getDateFromString(java.lang.String dateStr)
                                        throws WIMException
Returns a Date from the specified String. It is expected to be called on the date string returned in the datagraph. For example: String dateStr = entity.get("registerDate").toString(); Date date = SDOHelper.getDateFromString(dateStr); Input: 2005-05-04T09:34:18.444Z OR 2005-05-04T09:34:18Z

Parameters:
date - Date string.
Throws:
WIMException - if a parsing error occurs.
Return:
Date object.

cloneDataObject

public static commonj.sdo.DataObject cloneDataObject(commonj.sdo.DataObject dataObject)
Clones the input DataObject.

Parameters:
dataObject - the DataObject to be cloned.
Return:
the cloned DataObject

cloneRootDataObject

public static commonj.sdo.DataObject cloneRootDataObject(commonj.sdo.DataObject root)
Clones the input root DataObject.

Parameters:
root - root DataObject to be cloned.
Return:
the cloned DataObject

cloneEObject

public static org.eclipse.emf.ecore.EObject cloneEObject(org.eclipse.emf.ecore.EObject obj)
Clones an EObject.

Parameters:
obj - EOObject to be cloned.
Return:
the cloned EObject

deepCloneRootDataObject

public static final commonj.sdo.DataObject deepCloneRootDataObject(commonj.sdo.DataObject root)
Returns a deep clone of root DataObject once ChangeSummary is not null, otherwise, normal cloneRootDataObject will be returned.

Parameters:
root - DataObject to be copied
Return:
new copy of original root DataObject.

deepCopyObject

public static final java.lang.Object deepCopyObject(java.lang.Object root)
Returns a deep copy of an object, return null if the object to be cloned is null. If serialization fails, this will return null.

Parameters:
source - Object to be copied (must be Serializable)
Return:
new copy of original source parameter.