wt.clients.prodmgmt
Class PartHelper

java.lang.Object
  extended bywt.clients.prodmgmt.PartHelper
Direct Known Subclasses:
ConfiguredPartHelper

public class PartHelper
extends Object

PartHelper is a facade class that contains static methods for manipulating Parts. It encapsulates some of the persistence and navigation operations for Parts.

Supported API: true

Extendable: false

See Also:
wt.part.WTPart

Field Summary
private static ResourceBundle resource
           
private static String RESOURCE
           
 
Constructor Summary
PartHelper()
           
 
Method Summary
static BuildRule deleteBuildRule(BuildRule rule)
          Uses the PersistenceHelper to delete the given BuildRule.
static WTPart deletePart(WTPart part)
          Uses the PersistenceHelper to delete the given part.
static WTPartReferenceLink deletePartReferenceLink(WTPartReferenceLink link)
          Uses the PersistenceHelper to delete the given WTPartReferenceLink.
static WTPartUsageLink deletePartUsageLink(WTPartUsageLink usagelink)
          Uses the PersistenceHelper to delete the given WTPartUsageLink.
static WTPartUsageLink deleteUsageLink(WTPartUsageLink usagelink)
          Uses the PersistenceHelper to delete the given WTPartUsageLink.
static WTPart[] getAllPartVersions(WTPartMaster[] masters, ConfigSpec config_spec)
           
static WTPart[] getAllPartVersions(WTPartMaster master, ConfigSpec config_spec)
           
static WTPart[] getAllVersions(WTPartMaster[] masters, WTPartConfigSpec configSpec)
          Return all the versions of the specified PartMaster using the specified WTPartConfigSpec.
static WTPart[] getAllVersions(WTPartMaster master, WTPartConfigSpec configSpec)
          Return all the versions of the specified PartMaster using the specified ConfigSpecItem.
static BuildRule[] getBuildRule(WTPart part)
          Returns an array of BuildRule objects containing all BuildRules for the given part.
static WTPartConfigSpec getConfigSpec()
          Returns the WTPartConfigSpec which is stored for the current user.
static String getLifeCycle(WTPart part)
          Returns the String name of the life cycle that the given part is currently assigned to.
static String getLifeCycleState(WTPart part)
          Get the lifecycle state of the specified part
static int getMaxLength(Class a_class, String attribute_constant)
          Get the maximum length for the specified attribute in the specified class.
static Part getPartForOID(String part_id)
          Returns a Part which is retrieved using the given object id.
static WTPartReferenceLink[] getReferences(WTPart part)
          Returns an array of WTPartReferenceLink objects containing the reference relationships for the given part.
protected  ResourceBundle getResource()
           
static State[] getStates()
          Returns all available valid life cycle State objects.
static String getTeamTemplate(WTPart part)
          Get the name of the teamTmeplate the part is assigned to
static WTPartUsageLink[] getUsedBy(WTPart part)
          Returns an array of WTPartUsageLink objects containing the WTPartUsageLinks that represent the relationship describing which parts use the given part.
static Explorable[] getUses(WTPart part)
          Returns an array of Explorable objects retrieved in finding the parts that are used by the given part.
static Explorable[] getUses(WTPart part, PartExplorer explorer, ConfigSpec config_spec)
          Returns an array of Explorable objects retrieved by getting the children of given part using the given ConfigSpec.
static Explorable[] getUses(WTPart part, WTPartConfigSpec config_spec, PartExplorer explorer)
          Returns an array of Explorable objects retrieved in finding the parts that are used by the given part.
static WTPartUsageLink[] getUsesInterface(WTPart part)
          Returns an array of WTPartUsageLinks containing the relationships to the child parts used by the given part.
static View[] getViews()
          Returns an array of all defined View objects.
protected  void initResources()
           
static void main(String[] args)
          A short main to allow for testing and demonstrate usage.
static WTPartConfigSpec newConfigSpec(boolean checkedOut, State newState, View newView)
          Create a ConfigSpec based on the specified state, new, and checkout qualification.
static Object refresh(Persistable obj)
          Refreshes the given persistable object by re-retrieving it from the database.
static WTPart refresh(WTPart part)
          Refreshes the given WTPart object by re-retrieving it from the database.
static WTPart revisePart(WTPart part)
          Uses the VersionControlService to create a new version of the given part.
static BuildRule saveBuildRule(BuildRule rule)
          Uses the PersistenceHelper to save the given BuildRule.
static WTPart savePart(WTPart part)
          Uses the PersistentHelper to save the given part.
static WTPartReferenceLink savePartReferenceLink(WTPartReferenceLink link)
          Uses the PersistenceHelper to save the given WTPartReferenceLink.
static WTPartUsageLink savePartUsageLink(WTPartUsageLink usagelink)
          Uses the PersistenceHelper to save the given WTPartUsageLink.
static WTPartUsageLink saveUsageLink(WTPartUsageLink usagelink)
          Uses the PersistenceHelper to save the given WTPartUsageLink.
static WTPartConfigSpec setConfigSpec(WTPartConfigSpec spec)
          Sets the given WTPartConfigSpec as the WTPartConfigSpec to be associated with the current user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resource

private static ResourceBundle resource

RESOURCE

private static String RESOURCE
Constructor Detail

PartHelper

public PartHelper()
Method Detail

initResources

protected void initResources()

getResource

protected ResourceBundle getResource()

getPartForOID

public static Part getPartForOID(String part_id)
Returns a Part which is retrieved using the given object id. The given String is interpretted as an object identifier and used to retrieve the corresponding Part object.

Parameters:
part_id - the String id of the part to be returned
Returns:
the Part found using the given string id

refresh

public static Object refresh(Persistable obj)
                      throws WTException
Refreshes the given persistable object by re-retrieving it from the database. This method invokes the PersistenceHelper.manager.refresh method to refresh the given object.

Parameters:
obj - the Persistable object to be refreshed
Returns:
the refreshed object.
Throws:
WTException
See Also:
Persistable, PersistenceHelper

refresh

public static WTPart refresh(WTPart part)
                      throws WTException
Refreshes the given WTPart object by re-retrieving it from the database. This method invokes the PersistenceHelper.manager.refresh method to refresh the given WTPart.

Parameters:
part - the WTPart object to be refreshed
Returns:
the refreshed part.
Throws:
WTException
See Also:
Persistable, PersistenceHelper

getConfigSpec

public static WTPartConfigSpec getConfigSpec()
                                      throws WTException
Returns the WTPartConfigSpec which is stored for the current user.

Returns:
the WTPartConfigSpec stored for the current user.
Throws:
WTException
See Also:
WTPartConfigSpec

setConfigSpec

public static WTPartConfigSpec setConfigSpec(WTPartConfigSpec spec)
                                      throws WTException
Sets the given WTPartConfigSpec as the WTPartConfigSpec to be associated with the current user. The given WTPartConfigSpec is stored as the default config spec for the current user. The WTPartConfigSpec is saved as the user's default config spec and then returned.

Parameters:
spec - the WTPartConfigSpec to be associated as the default config spec for the current user
Returns:
the given WTPartConfigSpec after it has been stored as the default config spec for the current user.
Throws:
WTException

getStates

public static State[] getStates()
                         throws WTException
Returns all available valid life cycle State objects.

Returns:
an Array of all available State objects
Throws:
WTException
See Also:
State

getViews

public static View[] getViews()
                       throws WTException
Returns an array of all defined View objects.

Returns:
an array of all defined View objects
Throws:
WTException - if an error occurs attempting to retrieve the views.

getReferences

public static WTPartReferenceLink[] getReferences(WTPart part)
                                           throws WTException
Returns an array of WTPartReferenceLink objects containing the reference relationships for the given part. This method navigates the references role for the given part and returns all corresponding WTPartReferenceLinks.

Parameters:
part - the WTPart for which the references relationships are returned
Returns:
an array of WTPartReferenceLinks containing the reference relationships
Throws:
WTException - if an error occurs navigation the reference relationship

getBuildRule

public static BuildRule[] getBuildRule(WTPart part)
                                throws WTException
Returns an array of BuildRule objects containing all BuildRules for the given part. This method navigations the build source role for the given parts and returns the corresponding BuildRule objects retrieved.

Parameters:
part - the WTPart for which build rules will be returned
Returns:
an Array of BuildRule objects for the given part
Throws:
WTException - if an error occurs navigation the build rule relationship
See Also:
BuildRule

getUsedBy

public static WTPartUsageLink[] getUsedBy(WTPart part)
                                   throws WTException
Returns an array of WTPartUsageLink objects containing the WTPartUsageLinks that represent the relationship describing which parts use the given part. This method navigates the used by role for the given part and returns the WTPartUsageLinks found.

Parameters:
part - the part for which the used by relationships are returned
Returns:
an array of WTPartUsageLink representing the parts that use the given part
Throws:
WTException - if an error occurs navigation the used by role for the given part

getUses

public static Explorable[] getUses(WTPart part)
                            throws WTException
Returns an array of Explorable objects retrieved in finding the parts that are used by the given part. The array of Explorable objects could contain either PartItems, PartMasterItems, UsageItems, or UsageMasterItems depending on what was retrieved navigating the uses relationship for the given part.

Parameters:
part - the WTPart for which the uses parts are returned
Returns:
an array of Explorable objects containing objects that represent the parts used by the given WTPart
Throws:
WTException - if an error occurs navigating the uses relationship

newConfigSpec

public static WTPartConfigSpec newConfigSpec(boolean checkedOut,
                                             State newState,
                                             View newView)
                                      throws WTException
Create a ConfigSpec based on the specified state, new, and checkout qualification.

Parameters:
newState - the value for the LifeCycleQualification
newView - the value for the ViewQualification
Returns:
a new ConfigSpec with the specified qualifications
Throws:
WTException

getUses

public static Explorable[] getUses(WTPart part,
                                   WTPartConfigSpec config_spec,
                                   PartExplorer explorer)
                            throws WTException
Returns an array of Explorable objects retrieved in finding the parts that are used by the given part. This method navigates the uses relationship for the given part using the given WTPartConfigSpec to select the versions of the parts used to return. The array of Explorable objects could contain either PartItems, PartMasterItems, UsageItems, or UsageMasterItems depending on what was retrieved navigating the uses relationship for the given part. The given PartExplorer object is used to initialize the 'explorer' attribute of any PartItem objects that are returned in the array.

Parameters:
part - the WTPart for which the uses parts are returned
config_spec - the WTPartConfigSpec used for selecting part versions found when navigating the uses role for the given part
explorer - the PartExplorer used to initialize the 'explorer' attribute of any PartItems returned in the array.
Returns:
an array of Explorable objects containing objects that represent the parts used by the given WTPart
Throws:
WTException - if an error occurs navigating the uses relationship

getUses

public static Explorable[] getUses(WTPart part,
                                   PartExplorer explorer,
                                   ConfigSpec config_spec)
                            throws WTException
Returns an array of Explorable objects retrieved by getting the children of given part using the given ConfigSpec. This method navigates the uses relationship for the given part using the given ConfigSpec to select the versions of the parts used to return. The array of Explorable objects could contain either PartItems, PartMasterItems, UsageItems, or UsageMasterItems depending on what was retrieved navigating the uses relationship for the given part. The given PartExplorer object is used to initialize the 'explorer' attribute of any PartItem objects that are returned in the array.

Parameters:
part - the WTPart for which the uses parts are returned
config_spec - the ConfigSpec used for selecting part versions found when navigating the uses role for the given part
explorer - the PartExplorer used to initialize the 'explorer' attribute of any PartItems returned in the array.
Returns:
an array of Explorable objects containing objects that represent the parts used by the given WTPart
Throws:
WTException - if an error occurs navigating the uses relationship

getUsesInterface

public static WTPartUsageLink[] getUsesInterface(WTPart part)
                                          throws WTException
Returns an array of WTPartUsageLinks containing the relationships to the child parts used by the given part. This method navigates the uses role for the given part and returns an array containing the WTPartUsageLinks retrieved.

Parameters:
part - the part for which the usage relationships between the part and its children are returned
Returns:
an array of WTPartUsageLink containing the uses links between the given part and its children
Throws:
WTException - if an error occurs navigating the uses relationship

savePart

public static WTPart savePart(WTPart part)
                       throws WTException
Uses the PersistentHelper to save the given part. The given part can be either an already persisted part whose updates need to be saved or a new part that needs to be persisted for the first time.

Parameters:
part - the WTPart to be saved
Returns:
the part after it has been saved
Throws:
WTException - if an error occurs saving the part.

deletePart

public static WTPart deletePart(WTPart part)
                         throws WTException
Uses the PersistenceHelper to delete the given part.

Parameters:
part - the WTPart to be deleted
Returns:
the resulting WTPart after performing the delete
Throws:
WTException - if an error occurs deleting the part.

revisePart

public static WTPart revisePart(WTPart part)
                         throws WTException,
                                WTPropertyVetoException
Uses the VersionControlService to create a new version of the given part. The new version created is in the same view as the part being revise. The resulting version is returned.

Parameters:
part - the WTPart to be revised
Returns:
the new version of the WTPart
Throws:
WTException - if an error occurs attempting to revise the part
WTPropertyVetoException - if any of the properties of the given part prevent it from being revised.

deletePartReferenceLink

public static WTPartReferenceLink deletePartReferenceLink(WTPartReferenceLink link)
                                                   throws WTException
Uses the PersistenceHelper to delete the given WTPartReferenceLink.

Parameters:
link - the WTPartReferenceLink to be deleted
Returns:
the WTPartReferenceLink after the delete has been performed
Throws:
WTException - if an error occurs attempting to delete the link

deleteBuildRule

public static BuildRule deleteBuildRule(BuildRule rule)
                                 throws WTException
Uses the PersistenceHelper to delete the given BuildRule.

Returns:
the BuildRule after the delete has been performed
Throws:
WTException - if an error occurs attempting to delete the rule

savePartReferenceLink

public static WTPartReferenceLink savePartReferenceLink(WTPartReferenceLink link)
                                                 throws WTException
Uses the PersistenceHelper to save the given WTPartReferenceLink.

Parameters:
link - the WTPartReferenceLink to be saved
Returns:
the WTPartReferenceLink after performing the save
Throws:
WTException - if an error occurs saving the link

saveBuildRule

public static BuildRule saveBuildRule(BuildRule rule)
                               throws WTException
Uses the PersistenceHelper to save the given BuildRule.

Parameters:
rule - the BuildRule to be saved
Returns:
the BuildRule after performing the save
Throws:
WTException - if an error occurs saving the rule

saveUsageLink

public static WTPartUsageLink saveUsageLink(WTPartUsageLink usagelink)
                                     throws WTException
Uses the PersistenceHelper to save the given WTPartUsageLink.

Parameters:
usagelink - the WTPartUsageLink to be saved
Returns:
the WTPartUsageLink after performing the save
Throws:
WTException - if an error occurs saving the link

deleteUsageLink

public static WTPartUsageLink deleteUsageLink(WTPartUsageLink usagelink)
                                       throws WTException
Uses the PersistenceHelper to delete the given WTPartUsageLink.

Parameters:
usagelink - the WTPartUsageLink to be deleted
Returns:
the WTPartUsageLink after the delete has been performed
Throws:
WTException - if an error occurs attempting to delete the link

savePartUsageLink

public static WTPartUsageLink savePartUsageLink(WTPartUsageLink usagelink)
                                         throws WTException
Uses the PersistenceHelper to save the given WTPartUsageLink.

Parameters:
usagelink - the WTPartUsageLink to be saved
Returns:
the WTPartUsageLink after performing the save
Throws:
WTException - if an error occurs saving the link

deletePartUsageLink

public static WTPartUsageLink deletePartUsageLink(WTPartUsageLink usagelink)
                                           throws WTException
Uses the PersistenceHelper to delete the given WTPartUsageLink. This method and method deleteUsageLink can be used interchangeably.

Parameters:
usagelink - the WTPartUsageLink to be deleted
Returns:
the WTPartUsageLink after the delete has been performed
Throws:
WTException - if an error occurs attempting to delete the link

getLifeCycle

public static String getLifeCycle(WTPart part)
                           throws WTException
Returns the String name of the life cycle that the given part is currently assigned to.

Parameters:
part - the WTPart whose life cycle name is returned
Returns:
the String name of the life cycle of the given part
Throws:
WTException - if an error occurs retrieving the name of the life cycle for the given part

getTeamTemplate

public static String getTeamTemplate(WTPart part)
                              throws WTException
Get the name of the teamTmeplate the part is assigned to

Parameters:
part - the part to find the lifecycle name for
Returns:
the teamTemplate name for the specified part
Throws:
WTException

getLifeCycleState

public static String getLifeCycleState(WTPart part)
                                throws WTException
Get the lifecycle state of the specified part

Parameters:
part - the part whose name is requested
Returns:
the lifecycle state name for the part
Throws:
WTException

getAllVersions

public static WTPart[] getAllVersions(WTPartMaster[] masters,
                                      WTPartConfigSpec configSpec)
                               throws WTException
Return all the versions of the specified PartMaster using the specified WTPartConfigSpec.

Parameters:
masters - the PartMasters whose versions are requested
configSpec - the configuration specification qualifications
Returns:
an array of qualified versions
Throws:
WTException

getAllPartVersions

public static WTPart[] getAllPartVersions(WTPartMaster master,
                                          ConfigSpec config_spec)
                                   throws WTException
Throws:
WTException

getAllPartVersions

public static WTPart[] getAllPartVersions(WTPartMaster[] masters,
                                          ConfigSpec config_spec)
                                   throws WTException
Throws:
WTException

getAllVersions

public static WTPart[] getAllVersions(WTPartMaster master,
                                      WTPartConfigSpec configSpec)
                               throws WTException
Return all the versions of the specified PartMaster using the specified ConfigSpecItem.

Parameters:
master - the PartMaster whose versions are requested
Returns:
an array of qualified versions
Throws:
WTException

main

public static void main(String[] args)
A short main to allow for testing and demonstrate usage.


getMaxLength

public static int getMaxLength(Class a_class,
                               String attribute_constant)
                        throws WTIntrospectionException
Get the maximum length for the specified attribute in the specified class.

Parameters:
a_class - the class
attribute_constant - the string constant for the attribute
Returns:
the maximum length of the attribute
Throws:
WTIntrospectionException