com.senn.magic.dctm
Class TypeConverter

java.lang.Object
  extended by com.senn.magic.dctm.TypeConverter

public class TypeConverter
extends Object

Converts an object in Documentum into another type (including older versions). Currently only for dm_document subtypes.
NOTES:
This creates a new object with data from the first one in Documentum so

Author:
Bart Thierens
Last modification: 06/06/2010

Nested Class Summary
protected  class TypeConverter.InvalidMappingException
          Internal Exception for when the mapping is invalid
protected  class TypeConverter.TempSysObject
          Internal class that represents a sysobject with its versionlabels/
 
Field Summary
protected  Map<String,String> attributeMapping
           
protected static String FIRST_VERSION_LABEL
           
protected  com.documentum.fc.client.IDfSysObject sourceObject
           
protected  String targetObjectType
           
 
Constructor Summary
TypeConverter(com.documentum.fc.client.IDfSysObject sourceObject, String targetObjectType, Map<String,String> attributeMapping)
          Builds a TypeConverter object
 
Method Summary
 void addAttributeMapping(String sourceAttr, String targetAttr)
          Adds an entry to the attribute mapping
 com.documentum.fc.client.IDfSysObject convert(com.documentum.fc.client.IDfSession session, boolean deleteSource)
          Converts the object to another type.
 Map<String,String> getAttributeMapping()
           
 com.documentum.fc.client.IDfSysObject getSourceObject()
           
 String getTargetObjectType()
           
protected  void setAttributeMapping(Map<String,String> attributeMapping)
           
protected  void setAttributes(com.documentum.fc.client.IDfSysObject newObject, com.documentum.fc.client.IDfSession session)
          Internal method that sets the attributes of the new sysobject.
protected  void setSourceObject(com.documentum.fc.client.IDfSysObject sourceObject)
           
protected  void setTargetObjectType(String targetObjectType)
           
protected  boolean validateMapping()
          Internal method that validates the
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIRST_VERSION_LABEL

protected static final String FIRST_VERSION_LABEL
See Also:
Constant Field Values

attributeMapping

protected Map<String,String> attributeMapping

sourceObject

protected com.documentum.fc.client.IDfSysObject sourceObject

targetObjectType

protected String targetObjectType
Constructor Detail

TypeConverter

public TypeConverter(com.documentum.fc.client.IDfSysObject sourceObject,
                     String targetObjectType,
                     Map<String,String> attributeMapping)
Builds a TypeConverter object

Parameters:
sourceObject - the source object in Documentum
targetObjectType - the target object type
attributeMapping - the mapping of attribute values to allow porting of (custom) metadata, for example:
"source_custom_string" => "target_custom_string"
"source_custom_string2" => "title"

It is suggested to map attribute of the same type (STRING=>STRING, INT=>INT,...) but some types can be mapped to other types.
Method Detail

convert

public com.documentum.fc.client.IDfSysObject convert(com.documentum.fc.client.IDfSession session,
                                                     boolean deleteSource)
                                              throws com.documentum.fc.common.DfException
Converts the object to another type.

Parameters:
session - a valid Documentum session. The user must have enough privileges to perform the actions!
deleteSource - whether or not to delete the source object after the conversion.
Deletion might not be possible if the object has relations.
Returns:
IDfSysObject - the newly created object
Throws:
com.documentum.fc.common.DfException

setAttributes

protected void setAttributes(com.documentum.fc.client.IDfSysObject newObject,
                             com.documentum.fc.client.IDfSession session)
                      throws com.documentum.fc.common.DfException
Internal method that sets the attributes of the new sysobject.

Parameters:
newObject - the new sysobject
session - a valid Documentum session
Throws:
com.documentum.fc.common.DfException

validateMapping

protected boolean validateMapping()
                           throws TypeConverter.InvalidMappingException
Internal method that validates the

Returns:
Throws:
TypeConverter.InvalidMappingException

getSourceObject

public com.documentum.fc.client.IDfSysObject getSourceObject()
Returns:
IDfSysObject - the source object

setSourceObject

protected void setSourceObject(com.documentum.fc.client.IDfSysObject sourceObject)

getAttributeMapping

public Map<String,String> getAttributeMapping()
Returns:
Map - the attribute mapping

setAttributeMapping

protected void setAttributeMapping(Map<String,String> attributeMapping)

addAttributeMapping

public void addAttributeMapping(String sourceAttr,
                                String targetAttr)
Adds an entry to the attribute mapping

Parameters:
sourceAttr - attribute of the source object
targetAttr - attribute of the target object

getTargetObjectType

public String getTargetObjectType()
Returns:
String - the target object type

setTargetObjectType

protected void setTargetObjectType(String targetObjectType)