wt.csm
Class ReclassifyTool

java.lang.Object
  extended bywt.csm.ReclassifyTool
All Implemented Interfaces:
RemoteAccess

public class ReclassifyTool
extends Object
implements RemoteAccess

What this class provides: // Given a node, returns the whole path from root node to selected node public static String getWholePath(wt.iba.value.litevalue.LiteIBAReferenceable ref) throws WTException, java.rmi.RemoteException // Returns the classification node of a given iba holder public static String getClassificationNode(IBAHolder ibaHolder) // Given a node it returns all its ancestors public static Vector getParentNodes(ClassificationNode classificationnode) ... file taken from SASIB G.S. (luca) basically, the functionality of this class has been used but presented to the user in a slightly different way. now, this will be called from a command line "power user" application that allows the user to type in the source node and its new destination. it will then <> 1: delete the constraints the source node inherited from its parents. 2: find the new set of attributes (the union of the ones it and its new parent) 3: add the constraints of the new parent node 4: move the node <> 1: search for WTObject objects of the affected classification (these should implement the IBAHolder interface) 2: determine which attributes need to be added (NO attributes will be removed; no information will be lost) 2b: for any added attributes, give an appropriate default value 3: reclassify the WTObject object. any errors occurring during this process will be logged in a file that the user should (must?) look at after the operation. typical errors would include "part checked out", "current attribute value breaks constraint", "DB connection error" if the case of invalid values regarding a constraint, the user will have to open up the part and manually save it after entering a valid value. in the case of checked out parts, the user will have to rerun the program after checking in all affected parts.


Field Summary
private static String classStructure
           
private static boolean DEBUG
           
private static int DEBUG_PRIORITY
           
private static int debugLevel
           
private static int HIGH_PRIORITY
           
private static int indentLevel
           
private static PrintWriter log
           
private static int LOW_PRIORITY
           
private static int MEDIUM_PRIORITY
           
private static boolean reclassifyOnly
           
private static boolean removeExtraAttributes
           
private static int spaceCount
           
private static int TOP_PRIORITY
           
 
Fields inherited from interface wt.method.RemoteAccess
versionID
 
Constructor Summary
ReclassifyTool()
           
 
Method Summary
static AbstractValueView attributeAlreadyExist(AbstractValueView[] abstractValuesView, AbstractValueView abstractvalueview)
          check if an Attribute is already into an AbstractValueView set
static AbstractValueView attributeAlreadyExist(DefaultAttributeContainer defaultattributecontainer, AbstractValueView abstractvalueview)
          check if an Attribute is already into the DefaultAttributeContainer
static DefaultAttributeContainer compareAttributeContainers(DefaultAttributeContainer objAttributeContainer, DefaultAttributeContainer movedNodeAttributeContainer)
          Compare the Classification Node Attribute Container and the obj Attribute Container return a "merged" Attribute Container
static boolean constraintAlreadyExists(String constraintDescriptor, ClassificationNodeDefaultView classificationnodedefaultview)
          Check if a constraint already exists on a given Classification Node
static AbstractValueView copyAttributeValue(AbstractValueView newAbstractValueView, AbstractValueView oldAbstractValueView)
          Copy Attribute values from two Attributes
static void copyCSMConstraints(ClassificationNode classificationnode, CSMContainerConstraint[] acsmcontainerconstraint, CSMSingleDefConstraint[] acsmsingledefconstraint)
          Copy constraints to a given Classification Node
static void copyParentsCSMConstraints(ClassificationNode classificationnode, Vector parents)
          Copy constraints to a given Classification Node from all its Parents
static ClassificationNodeDefaultView deleteConstraints(AbstractCSMAttributeConstraintView[] aabstractcsmattributeconstraintview, ClassificationNodeDefaultView classificationnodedefaultview)
          Remove constraints from a Classification Node
static String getClassificationAttribute(String structName)
          Get the classification attribute label from the passed in structural name.
static ClassificationNode[] getClassificationNodeChildren(ClassificationNode classificationnode)
          Get all childrens of a given Classification Node
static ClassificationNodeDefaultView getClassificationNodeDefaultView(ClassificationNode node)
          return the ClassificationNodeDefaultView from a Classification Node
static ClassificationNodeNodeView getClassificationNodeNodeView(ClassificationNode node)
          return the ClassificationNodeNodeView from a Classification Node
protected static String getClassStructName()
          Get the classification structure root label.
static AbstractCSMAttributeConstraintView getConstraintFromDescriptor(String constraintDescriptor, ClassificationNodeDefaultView classificationnodedefaultview)
          Return a Classification Node constraint given a its Constraint Descriptor
static CSMContainerConstraint[] getCSMContainerConstraints(ObjectIdentifier objectidentifier)
          Get Container Constraints of a given Classification Node
static CSMSingleDefConstraint[] getCSMSingleDefConstraints(ObjectIdentifier objectidentifier)
          Get SingleDef Constraints of a given Classification Node
static String getIBAObjectID(String IBAName)
          return the Object ID of a given IBA
static String getIBAObjectID(WTObject obj, String IBAName)
          return the Object ID of a given IBA in a given obj
static QueryResultsIBAHolder[] getobjFromIBAvalue(ClassificationNodeNodeView classificationnodenodeview, String ibaName, String ibaValue)
          Search IBAHolder objects on IBA values
static Vector getParentNodes(ClassificationNode classificationnode)
          Given a node it returns all its Parents
static void getParentsAttributeDefinitionsAndValues(ClassificationNode currentNode, Vector parents, Hashtable parentsAttributeDefinitions, Hashtable values)
          return all the attribute definitions of all the classification node Parents
static AbstractValueView initializeAttributeValue(AbstractValueView abstractValueView)
          initialize the value on a given IBA
static boolean isConstraintExisting(CSMSingleDefConstraint[] csmsingledefconstraint, CSMSingleDefConstraint parentCSMSingleDefConstraint)
          Check if a constraint is already defined on the Classification Node
static void main(String[] args)
          main method for program to move classification node which indirectly reclassifies all affected objs.
static void message(Object msg)
           
static void message(Object msg, int severity)
          prints out message to console and log file if severity is above threshold
static void messageBegin(Object msg, int severity)
           
static void messageEnd(Object msg, int severity)
           
static ClassificationNodeNodeView moveNode(ClassificationNode source, ClassificationNode dest)
          moves the "source" node to the specified "dest" position.
static void reclassifyObjs(ClassificationNodeNodeView node)
          given a node, this method will find all the objs classified as the associated type then 1: add any required attributes that it is missing 2: assign default values to any newly added attributes 3: check out the obj 4: reclassify the obj 5: check in the obj
static DefaultAttributeContainer removeAttributeConstraint(DefaultAttributeContainer defaultattributecontainer, AttributeDefDefaultView attrDefDefaultView)
          removes constraint from given container
static ClassificationNodeDefaultView removeParentsInheritedCSMConstraints(ClassificationNode classificationnode, Vector parents)
          Copy constraints to a given Classification Node from all its Parents
static ClassificationNodeDefaultView setClassificationNodeAttributeContainer(ClassificationNodeDefaultView node, AttributeDefDefaultView[] newAttributeDefDefaultView, Hashtable parentValues)
          update the Attributes of a Classification Node return the updated Classification Node
protected static void setClassStructName(String classStructName)
          Set the classification structure root label.
static String stripQuotes(String s)
           
static ClassificationNodeNodeView updateMovedClassificationNode(ClassificationNodeNodeView sourceNode, ClassificationNodeNodeView destNode, Vector oldParents, Vector newParents, String doItOnlyOnce)
          Update Attributes and Constraints on a "moved" Classification Node and all of its childrens
static void updateObjContainer(IBAHolder holder, WTObject obj, DefaultAttributeContainer movedNodeAttributeContainer)
          updates the objs attribute container so it contains the proper attributes and their default values.
static Boolean updateObjsOnMovedClassificationNode(ClassificationNodeNodeView classificationNodeNodeView)
          Update objs classified on a Classification Node
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

private static boolean DEBUG

debugLevel

private static int debugLevel

reclassifyOnly

private static boolean reclassifyOnly

removeExtraAttributes

private static boolean removeExtraAttributes

log

private static PrintWriter log

TOP_PRIORITY

private static final int TOP_PRIORITY
See Also:
Constant Field Values

HIGH_PRIORITY

private static final int HIGH_PRIORITY
See Also:
Constant Field Values

MEDIUM_PRIORITY

private static final int MEDIUM_PRIORITY
See Also:
Constant Field Values

LOW_PRIORITY

private static final int LOW_PRIORITY
See Also:
Constant Field Values

DEBUG_PRIORITY

private static final int DEBUG_PRIORITY
See Also:
Constant Field Values

indentLevel

private static int indentLevel

spaceCount

private static int spaceCount

classStructure

private static String classStructure
Constructor Detail

ReclassifyTool

public ReclassifyTool()
Method Detail

getClassStructName

protected static String getClassStructName()
Get the classification structure root label. For example, for WTPart the default is "wt.part.WTPart".

Returns:
String classification structure root label

setClassStructName

protected static void setClassStructName(String classStructName)
Set the classification structure root label. For example, for WTPart the default is "wt.part.WTPart".

Parameters:
classStructName - classification structure root label

attributeAlreadyExist

public static AbstractValueView attributeAlreadyExist(DefaultAttributeContainer defaultattributecontainer,
                                                      AbstractValueView abstractvalueview)
check if an Attribute is already into the DefaultAttributeContainer

Parameters:
abstractvalueview -
defaultattributecontainer -
Returns:
AbstractValueView

attributeAlreadyExist

public static AbstractValueView attributeAlreadyExist(AbstractValueView[] abstractValuesView,
                                                      AbstractValueView abstractvalueview)
check if an Attribute is already into an AbstractValueView set

Parameters:
abstractValuesView - set of views to search in
abstractvalueview - the view to search for
Returns:
AbstractValueView the view or null if it doesn't exist in the set

compareAttributeContainers

public static DefaultAttributeContainer compareAttributeContainers(DefaultAttributeContainer objAttributeContainer,
                                                                   DefaultAttributeContainer movedNodeAttributeContainer)
                                                            throws WTPropertyVetoException,
                                                                   IBAConstraintException
Compare the Classification Node Attribute Container and the obj Attribute Container return a "merged" Attribute Container

Parameters:
objAttributeContainer -
movedNodeAttributeContainer -
Returns:
DefaultAttributeContainer
Throws:
WTPropertyVetoException
IBAConstraintException

copyAttributeValue

public static AbstractValueView copyAttributeValue(AbstractValueView newAbstractValueView,
                                                   AbstractValueView oldAbstractValueView)
                                            throws WTPropertyVetoException
Copy Attribute values from two Attributes

Parameters:
oldAbstractValueView -
Returns:
AbstractValueView
Throws:
WTPropertyVetoException

copyCSMConstraints

public static void copyCSMConstraints(ClassificationNode classificationnode,
                                      CSMContainerConstraint[] acsmcontainerconstraint,
                                      CSMSingleDefConstraint[] acsmsingledefconstraint)
                               throws CSMClassificationNavigationException,
                                      NotAuthorizedException,
                                      WTException,
                                      RemoteException
Copy constraints to a given Classification Node

Parameters:
classificationnode -
acsmcontainerconstraint -
Returns:
void
Throws:
CSMClassificationNavigationException
NotAuthorizedException
WTException
RemoteException

constraintAlreadyExists

public static boolean constraintAlreadyExists(String constraintDescriptor,
                                              ClassificationNodeDefaultView classificationnodedefaultview)
Check if a constraint already exists on a given Classification Node

Parameters:
constraintDescriptor -
Returns:
boolean true if constraint exists in given node

copyParentsCSMConstraints

public static void copyParentsCSMConstraints(ClassificationNode classificationnode,
                                             Vector parents)
                                      throws WTException,
                                             RemoteException
Copy constraints to a given Classification Node from all its Parents

Parameters:
classificationnode -
Returns:
void
Throws:
WTException
RemoteException

getParentNodes

public static Vector getParentNodes(ClassificationNode classificationnode)
Given a node it returns all its Parents

Parameters:
classificationnode -
Returns:
Vector all of the Parent nodes (may NOT be null)

getParentsAttributeDefinitionsAndValues

public static void getParentsAttributeDefinitionsAndValues(ClassificationNode currentNode,
                                                           Vector parents,
                                                           Hashtable parentsAttributeDefinitions,
                                                           Hashtable values)
                                                    throws WTException,
                                                           RemoteException
return all the attribute definitions of all the classification node Parents

Parameters:
currentNode -
Returns:
void
Throws:
WTException
RemoteException

getClassificationNodeNodeView

public static ClassificationNodeNodeView getClassificationNodeNodeView(ClassificationNode node)
                                                                throws CSMClassificationNavigationException
return the ClassificationNodeNodeView from a Classification Node

Parameters:
node -
Returns:
ClassificationNodeNodeView
Throws:
CSMClassificationNavigationException

getClassificationNodeDefaultView

public static ClassificationNodeDefaultView getClassificationNodeDefaultView(ClassificationNode node)
                                                                      throws CSMClassificationNavigationException,
                                                                             WTException,
                                                                             RemoteException
return the ClassificationNodeDefaultView from a Classification Node

Parameters:
node -
Returns:
ClassificationNodeDefaultView
Throws:
CSMClassificationNavigationException
WTException
RemoteException

deleteConstraints

public static ClassificationNodeDefaultView deleteConstraints(AbstractCSMAttributeConstraintView[] aabstractcsmattributeconstraintview,
                                                              ClassificationNodeDefaultView classificationnodedefaultview)
                                                       throws WTException
Remove constraints from a Classification Node

Parameters:
aabstractcsmattributeconstraintview -
classificationnodedefaultview -
Returns:
ClassificationNodeDefaultView
Throws:
WTException

getCSMContainerConstraints

public static CSMContainerConstraint[] getCSMContainerConstraints(ObjectIdentifier objectidentifier)
                                                           throws CSMClassificationNavigationException,
                                                                  WTException
Get Container Constraints of a given Classification Node

Parameters:
objectidentifier -
Returns:
CSMContainerConstraint[] an array of constraints in associated object or null if none found.
Throws:
CSMClassificationNavigationException
WTException

getCSMSingleDefConstraints

public static CSMSingleDefConstraint[] getCSMSingleDefConstraints(ObjectIdentifier objectidentifier)
                                                           throws CSMClassificationNavigationException,
                                                                  WTException
Get SingleDef Constraints of a given Classification Node

Parameters:
objectidentifier -
Returns:
CSMSingleDefConstraint[] array of constraints in associated object or null if none found
Throws:
CSMClassificationNavigationException
WTException

getConstraintFromDescriptor

public static AbstractCSMAttributeConstraintView getConstraintFromDescriptor(String constraintDescriptor,
                                                                             ClassificationNodeDefaultView classificationnodedefaultview)
Return a Classification Node constraint given a its Constraint Descriptor

Parameters:
constraintDescriptor -
classificationnodedefaultview -
Returns:
AbstractCSMAttributeConstraintView

getClassificationNodeChildren

public static ClassificationNode[] getClassificationNodeChildren(ClassificationNode classificationnode)
                                                          throws CSMClassificationNavigationException,
                                                                 WTException
Get all childrens of a given Classification Node

Parameters:
classificationnode -
Returns:
ClassificationNode
Throws:
CSMClassificationNavigationException
WTException

getIBAObjectID

public static String getIBAObjectID(String IBAName)
return the Object ID of a given IBA

Parameters:
IBAName -
Returns:
the object id of the IBA with the given name

getIBAObjectID

public static String getIBAObjectID(WTObject obj,
                                    String IBAName)
return the Object ID of a given IBA in a given obj

Parameters:
obj -
IBAName -
Returns:
void

getobjFromIBAvalue

public static QueryResultsIBAHolder[] getobjFromIBAvalue(ClassificationNodeNodeView classificationnodenodeview,
                                                         String ibaName,
                                                         String ibaValue)
Search IBAHolder objects on IBA values

Parameters:
classificationnodenodeview -
ibaName -
ibaValue -
Returns:
QueryResultsIBAHolder

initializeAttributeValue

public static AbstractValueView initializeAttributeValue(AbstractValueView abstractValueView)
                                                  throws WTPropertyVetoException
initialize the value on a given IBA

Parameters:
abstractValueView -
Returns:
AbstractValueView
Throws:
WTPropertyVetoException

isConstraintExisting

public static boolean isConstraintExisting(CSMSingleDefConstraint[] csmsingledefconstraint,
                                           CSMSingleDefConstraint parentCSMSingleDefConstraint)
Check if a constraint is already defined on the Classification Node

Parameters:
csmsingledefconstraint -
Returns:
void

main

public static final void main(String[] args)
main method for program to move classification node which indirectly reclassifies all affected objs.

Parameters:
args -
Returns:
void

message

public static final void message(Object msg,
                                 int severity)
prints out message to console and log file if severity is above threshold

Parameters:
msg -
severity -
Returns:
void

message

public static final void message(Object msg)
Parameters:
msg -
Returns:
void

messageBegin

public static final void messageBegin(Object msg,
                                      int severity)
Parameters:
msg -
severity -
Returns:
void

messageEnd

public static final void messageEnd(Object msg,
                                    int severity)
Parameters:
msg -
severity -

moveNode

public static final ClassificationNodeNodeView moveNode(ClassificationNode source,
                                                        ClassificationNode dest)
                                                 throws WTException
moves the "source" node to the specified "dest" position. errors may occur if the source and/or dest are invalid node specs.

Parameters:
source - source node
dest - destination node
Returns:
ClassificationNodeNodeView the newly moved node
Throws:
WTException

reclassifyObjs

public static final void reclassifyObjs(ClassificationNodeNodeView node)
                                 throws WTException
given a node, this method will find all the objs classified as the associated type then 1: add any required attributes that it is missing 2: assign default values to any newly added attributes 3: check out the obj 4: reclassify the obj 5: check in the obj

Parameters:
node - the node whose associated objs are to be reclassified.
Returns:
void
Throws:
WTException

removeAttributeConstraint

public static DefaultAttributeContainer removeAttributeConstraint(DefaultAttributeContainer defaultattributecontainer,
                                                                  AttributeDefDefaultView attrDefDefaultView)
removes constraint from given container

Parameters:
defaultattributecontainer -
attrDefDefaultView -
Returns:
void

removeParentsInheritedCSMConstraints

public static ClassificationNodeDefaultView removeParentsInheritedCSMConstraints(ClassificationNode classificationnode,
                                                                                 Vector parents)
                                                                          throws WTException,
                                                                                 RemoteException
Copy constraints to a given Classification Node from all its Parents

Parameters:
classificationnode -
Returns:
ClassificationNodeDefaultView the updated node (after constraints have been removed)
Throws:
WTException
RemoteException

setClassificationNodeAttributeContainer

public static ClassificationNodeDefaultView setClassificationNodeAttributeContainer(ClassificationNodeDefaultView node,
                                                                                    AttributeDefDefaultView[] newAttributeDefDefaultView,
                                                                                    Hashtable parentValues)
                                                                             throws WTException
update the Attributes of a Classification Node return the updated Classification Node

Parameters:
node -
newAttributeDefDefaultView -
Returns:
ClassificationNodeDefaultView
Throws:
WTException

stripQuotes

public static final String stripQuotes(String s)
Parameters:
s - string to have quotes stripped (may not have quotes).
Returns:
void

updateMovedClassificationNode

public static ClassificationNodeNodeView updateMovedClassificationNode(ClassificationNodeNodeView sourceNode,
                                                                       ClassificationNodeNodeView destNode,
                                                                       Vector oldParents,
                                                                       Vector newParents,
                                                                       String doItOnlyOnce)
                                                                throws RemoteException,
                                                                       WTException
Update Attributes and Constraints on a "moved" Classification Node and all of its childrens

Parameters:
destNode - the destination parent node (source to be placed underneath this node)
doItOnlyOnce - if "YES" then persistence code will be called
Throws:
RemoteException
WTException

updateObjContainer

public static final void updateObjContainer(IBAHolder holder,
                                            WTObject obj,
                                            DefaultAttributeContainer movedNodeAttributeContainer)
updates the objs attribute container so it contains the proper attributes and their default values.

Parameters:
obj -
holder -
movedNodeAttributeContainer -
Returns:
void

updateObjsOnMovedClassificationNode

public static Boolean updateObjsOnMovedClassificationNode(ClassificationNodeNodeView classificationNodeNodeView)
                                                   throws WTException,
                                                          RemoteException
Update objs classified on a Classification Node

Returns:
Boolean true if parts reclassified successfully
Throws:
WTException
RemoteException

getClassificationAttribute

public static String getClassificationAttribute(String structName)
Get the classification attribute label from the passed in structural name.

Parameters:
structName -
Returns:
String classification attribute label