com.ptc.windchill.esi.tgt
Class ESITargetUtility

java.lang.Object
  extended bycom.ptc.windchill.esi.tgt.ESITargetUtility

public final class ESITargetUtility
extends Object



Supported API: true

Extendable: false


Nested Class Summary
private  class ESITargetUtility.TargetCounter
          A private class which determines the number of persistables associated with an ESITarget.
 
Field Summary
private static String CLASSNAME
           
private static String ESITARGET_MAPFILE
           
private static String NULL_STRING
           
private static String RESOURCE
           
private  TaskHelper taskHelper
           
private static String UFID_DELIMITER
           
private static String USED_RESOURCE
           
private static int VECTOR_SIZE_MULTIPLIER
           
 
Constructor Summary
ESITargetUtility()
           
 
Method Summary
 void adjustTargetAssignments(String ufids, Group targetInfo)
          Given a concatenated set of UFIDs (for WTParts) and a Collection of ESITarget UFIDs, make (or remove) any required assignments.
 void assignTargets(Collection targetAssociations)
          Given a collection of ESITargetAssociation objects, create an ESITargetAssignmentLink object for each entry in the collection that is not already persisted in the database.
 void assignTargets(Persistable object, Group targets)
          Given a Persistable object and an Infoengine group of ESITarget objects, create an ESITargetAssignmentLink for each unassigned ESITarget object in the group.
 void connectTargetToOrganization(ESITarget tgt, WTOrganization org)
          Creates an ESITargetAsssociationLink between an WTOrganization and an ESITarget.
 ESITarget createTarget(String name, String description, String system, WTContainerRef containerRef)
          Creates and persists an ESITarget based upon the following container hierarchy via looking up.
 void deleteESITarget(ESITarget tgt)
          Deletes an ESITarget from the database.
private  Collection deleteExistingAssignments(Collection coll)
           
 void deleteTargetAssociation(ESITargetAssignmentLink link)
          Deletes the argument from the database.
 void disconnectTargetFromOrganization(ESITarget tgt, WTOrganization org)
          Deletes all ESITargetOrganizationLink objects between the target and the WTOrganization.
 Collection getOrganizationLinksForOrganizations(Collection organizations)
          Given a collection of WTOrganizations, return a collection of ESITargetOrganizationLinks that have one of the WTOrganizations as a roleB object.
 Collection getOrganizationLinksForTargets(Collection targets)
          Given a collection of ESITargets, return a collection of ESITargetOrganizationLink objects that have one of the ESITarget objects as a roleA object.
private  Collection getParts(String ufidString)
           
private  Collection getPersistedAssocToRemove(Collection completeAssoc, Collection assoc)
           
 ESITarget getTarget(String id)
          Returns the ESITarget for the given system resided in Site level (ie.
 ESITarget getTarget(String id, WTContainerRef containerRef)
          Returns a target for the given system and container or if parent containers contains the given system.
 Collection getTargetAssnsFromAssns(Collection associations)
          Given a collection of ESITargetAssociations, returns a Collection of ESITargetAssociations that have been persisted.
 Collection getTargetAssnsFromAssns(Collection associations, Persistable base)
          Given a collection of ESITargetAssociations, returns a Collection of ESITargetAssociations that have been persisted.
 Collection getTargetAssnsFromObjects(Collection objects)
          Returns a Collection of ESITargetAssociations that are associated with the objects in the argument collection.
 Collection getTargetAssnsFromObjects(Collection objects, Persistable base)
          Returns a Collection of ESITargetAssociations that are associated with the objects in the argument collection.
 Collection getTargetAssociations(Persistable object)
          Returns a Collection of ESITargetAssociations that are associated with the argument.
 Collection getTargetAssociations(Persistable object, Persistable base)
          Returns a Collection of ESITargetAssociations that are associated with the argument.
 Group getTargetAssociations(String ufids, String groupName)
          Given a string of concatenated UFIDs, return the ESITarget objects that are associated with those objects.
 ESITarget newESITarget(String name, String description, String system)
          Creates and saves ESITarget in Site level by default (ie.
 ESITarget newESITarget(String name, String description, String system, WTContainerRef containerRef)
          Creates and saves ESITarget in the given container.
 ESITargetAssignmentLink newESITargetAssignmentLink(Persistable persistable, ESITarget target)
          Returns an instance of ESITargetAssignmentLink.
 ESITargetOrganizationLink newESITargetOrganizationLink(WTOrganization org, ESITarget target)
          Returns an instance of ESITargetOrganizationLink.
 void removeTargetAssociations(Collection associations)
          Deletes the ESITargetAssignments that are related to the objects in the argument.
private  void setAssignmentState(Group grp, Collection pts, Collection assns)
          Given a collection of ESITargetAssociations, determines whether the every target in the collection is associated with each persistable in the collection.Uses the ESI mapper to create I*E elements from the ESITargets in the input collection.
private  void validateArgument(String arg, String name)
          Makes sure that a String is not null, not an empty string, and not all blanks.
 void validateDelete(ESITarget tgt)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

VECTOR_SIZE_MULTIPLIER

private static final int VECTOR_SIZE_MULTIPLIER

NULL_STRING

private static final String NULL_STRING
See Also:
Constant Field Values

UFID_DELIMITER

private static final String UFID_DELIMITER

ESITARGET_MAPFILE

private static String ESITARGET_MAPFILE

USED_RESOURCE

private static String USED_RESOURCE

taskHelper

private TaskHelper taskHelper
Constructor Detail

ESITargetUtility

public ESITargetUtility()
Method Detail

adjustTargetAssignments

public final void adjustTargetAssignments(String ufids,
                                          Group targetInfo)
                                   throws WTException
Given a concatenated set of UFIDs (for WTParts) and a Collection of ESITarget UFIDs, make (or remove) any required assignments.

Supported API: true

Parameters:
ufids - A concatenated list of UFIDs of the objects to operate on.
targetInfo - A collection of Info*Engine elements containing the UFIDs of the ESITargets to assign/remove and the operation to perform.
Throws:
WTException

assignTargets

public final void assignTargets(Persistable object,
                                Group targets)
                         throws WTException
Given a Persistable object and an Infoengine group of ESITarget objects, create an ESITargetAssignmentLink for each unassigned ESITarget object in the group. Save the results. Use a database transaction to insure that all are saved or none are saved. Throw an exception if one or more ESITarget object in the group is already assigned.

Supported API: true

Parameters:
object - A Persistable object to be assigned to the unassigned targets.
targets - An Infoengine group of ESITarget objects to be assigned to the Persistable object, if these ESITarget objects are unassigned.
Throws:
WTException

assignTargets

public final void assignTargets(Collection targetAssociations)
                         throws WTException
Given a collection of ESITargetAssociation objects, create an ESITargetAssignmentLink object for each entry in the collection that is not already persisted in the database. Save the results in the database. Uses a database transaction to ensure that all are saved or none are saved.

Supported API: true

Parameters:
targetAssociations - A collection of ESITargetAssociations.
Throws:
WTException

connectTargetToOrganization

public final void connectTargetToOrganization(ESITarget tgt,
                                              WTOrganization org)
                                       throws WTException
Creates an ESITargetAsssociationLink between an WTOrganization and an ESITarget.

Supported API: true

Parameters:
tgt - The ESITarget that is to be associated.
org - The WTOrganization that is to be associated.
Throws:
WTException

createTarget

public ESITarget createTarget(String name,
                              String description,
                              String system,
                              WTContainerRef containerRef)
                       throws ESIException
Creates and persists an ESITarget based upon the following container hierarchy via looking up. If a target, identified by attribute 'system', has been created in a parent container , the same target can't be created in the children containers. The opposite way is allowed. The children should be able to see and use the parent's target. The same level containers (eg. org1 , org2 ) can have the same target.

---Site ( ie. ExchangeContainer) --- Organization ( ie. OrgContainer) --- Application (ie. PDMLinkProduct)

Supported API: true

Parameters:
name - The name for representing ERP connection info on Windchill UI.
description -
system - The connection info for ERP system.
containerRef - The current container this ESI target will be resided.
Returns:
ESITarget
Throws:
ESIException

deleteESITarget

public final void deleteESITarget(ESITarget tgt)
                           throws WTException
Deletes an ESITarget from the database.

Supported API: true

Parameters:
tgt - The object to be deleted.
Throws:
WTException

deleteTargetAssociation

public final void deleteTargetAssociation(ESITargetAssignmentLink link)
                                   throws WTException
Deletes the argument from the database.

Supported API: true

Parameters:
link - The object to be deleted.
Throws:
WTException

disconnectTargetFromOrganization

public final void disconnectTargetFromOrganization(ESITarget tgt,
                                                   WTOrganization org)
                                            throws WTException
Deletes all ESITargetOrganizationLink objects between the target and the WTOrganization.

Supported API: true

Parameters:
tgt - The ESITarget that participates in the relationship.
org - The WTOrganizaion that participates in the relationship(s).
Throws:
WTException

getTargetAssociations

public final Collection getTargetAssociations(Persistable object)
                                       throws WTException
Returns a Collection of ESITargetAssociations that are associated with the argument.

Supported API: true

Parameters:
object - The object whose target associations are to be queried
Returns:
Collection
Throws:
WTException

getTargetAssociations

public final Collection getTargetAssociations(Persistable object,
                                              Persistable base)
                                       throws WTException
Returns a Collection of ESITargetAssociations that are associated with the argument. Uses a ESITargetFinder to obtain the result.

Supported API: true

Parameters:
object - The object of interest.
base - The object to pass to the TargetFinder initiator.
Returns:
Collection
Throws:
WTException

getTargetAssociations

public final Group getTargetAssociations(String ufids,
                                         String groupName)
                                  throws WTException
Given a string of concatenated UFIDs, return the ESITarget objects that are associated with those objects. If the ESITarget is assigned to all of the objects identified by a ufid, indicate that it is a full assignment. Otherwise, indicate that the value is partial.

Supported API: true

Parameters:
ufids - A concatenated list of UFIDs.
groupName - The name of the Info*Engine group to return.
Returns:
Group
Throws:
WTException

getTargetAssnsFromObjects

public final Collection getTargetAssnsFromObjects(Collection objects)
                                           throws WTException
Returns a Collection of ESITargetAssociations that are associated with the objects in the argument collection.

Supported API: true

Parameters:
objects - A collection of Persistables.
Returns:
Collection
Throws:
WTException

getTargetAssnsFromObjects

public final Collection getTargetAssnsFromObjects(Collection objects,
                                                  Persistable base)
                                           throws WTException
Returns a Collection of ESITargetAssociations that are associated with the objects in the argument collection. Uses a target finder to obtain the assignment associations.

Supported API: true

Parameters:
objects - A collection of Persistables.
base - The object to pass to the target finder.
Returns:
Collection
Throws:
WTException

getTargetAssnsFromAssns

public final Collection getTargetAssnsFromAssns(Collection associations)
                                         throws WTException
Given a collection of ESITargetAssociations, returns a Collection of ESITargetAssociations that have been persisted.

Supported API: true

Parameters:
associations - A collection of ESITargetAssociations
Returns:
Collection
Throws:
WTException

getTargetAssnsFromAssns

public final Collection getTargetAssnsFromAssns(Collection associations,
                                                Persistable base)
                                         throws WTException
Given a collection of ESITargetAssociations, returns a Collection of ESITargetAssociations that have been persisted. Uses a target finder to obtain the assignment associations.

Supported API: true

Parameters:
associations - A collection of ESITargetAssociations
base - The object to pass to the target finder.
Returns:
Collection
Throws:
WTException

getTarget

public final ESITarget getTarget(String id)
                          throws WTException
Returns the ESITarget for the given system resided in Site level (ie. exchange container ) .

Supported API: true

Parameters:
id - The system attribute to find.
Returns:
ESITarget
Throws:
WTException

getTarget

public final ESITarget getTarget(String id,
                                 WTContainerRef containerRef)
                          throws WTException
Returns a target for the given system and container or if parent containers contains the given system.

Supported API: true

Parameters:
id - The system attribute to find.
containerRef - The container reference.
Returns:
ESITarget
Throws:
WTException

getOrganizationLinksForTargets

public final Collection getOrganizationLinksForTargets(Collection targets)
                                                throws WTException
Given a collection of ESITargets, return a collection of ESITargetOrganizationLink objects that have one of the ESITarget objects as a roleA object.

Supported API: true

Parameters:
targets - A collection of ESITargets.
Returns:
Collection
Throws:
WTException

getOrganizationLinksForOrganizations

public final Collection getOrganizationLinksForOrganizations(Collection organizations)
                                                      throws WTException
Given a collection of WTOrganizations, return a collection of ESITargetOrganizationLinks that have one of the WTOrganizations as a roleB object.

Supported API: true

Parameters:
organizations - A collection of WTOrganizations.
Returns:
Collection
Throws:
WTException

newESITarget

public final ESITarget newESITarget(String name,
                                    String description,
                                    String system)
                             throws WTException
Creates and saves ESITarget in Site level by default (ie. exhange container ) .

Supported API: true

Parameters:
name - The value for the ESITarget name attribute. Must not be null. May be up to 2048 characters long.
description - The value of the description attribute for the object to be created. May be null. May be up to 2048 characters long.
system - The value for the ESITarget system attribute. Must not be null. May be up to 2048 characters long. Must be unique in the database.
Returns:
ESITarget
Throws:
WTException

newESITarget

public final ESITarget newESITarget(String name,
                                    String description,
                                    String system,
                                    WTContainerRef containerRef)
                             throws WTException
Creates and saves ESITarget in the given container.

Supported API: true

Parameters:
name - The value for the ESITarget name attribute. Must not be null. May be up to 2048 characters long.
description - The value of the description attribute for the object to be created. May be null. May be up to 2048 characters long.
system - The value for the ESITarget system attribute. Must not be null. May be up to 2048 characters long. Must be unique in the database.
containerRef - The container reference.
Returns:
ESITarget
Throws:
WTException

newESITargetAssignmentLink

public final ESITargetAssignmentLink newESITargetAssignmentLink(Persistable persistable,
                                                                ESITarget target)
                                                         throws WTException
Returns an instance of ESITargetAssignmentLink. If ESIProperties specifies a subclass of ESITargetAssignmentLink, an instance of that class will be returned. This method will attempt to invoke the newESITargetAssignmentLink(Persistable, ESITarget) method on the class identified in ESIProperties.

Supported API: true

Parameters:
persistable - The object that is to be related to an ESI target.
target - The ESITarget that is to receive ESI releases of the object.
Returns:
ESITargetAssignmentLink
Throws:
WTException

newESITargetOrganizationLink

public final ESITargetOrganizationLink newESITargetOrganizationLink(WTOrganization org,
                                                                    ESITarget target)
                                                             throws WTException
Returns an instance of ESITargetOrganizationLink. If ESIProperties specifies a subclass of ESITargetOrganizationLink, an instance of that class will be returned. This method will attempt to invoke the newESITargetOrganizationLink(ESITarget, WTOrganization) method on the class identified in ESIProperties.

Supported API: true

Parameters:
org - The WTOrganization to associate.
target - The ESITarget to associate.
Returns:
ESITargetOrganizationLink
Throws:
WTException

removeTargetAssociations

public final void removeTargetAssociations(Collection associations)
                                    throws WTException
Deletes the ESITargetAssignments that are related to the objects in the argument.

Supported API: true

Parameters:
associations - A collection of ESITargetAssociation objects.
Throws:
WTException

validateDelete

public final void validateDelete(ESITarget tgt)
                          throws WTException
Deprecated.  

Deprecated at X05/R8.0, replaced by Referential Integrity exception delegate. Throws an exception if the argument is not eligible to be deleted.
  1. Examines ESI properties to determine whether or not to check ESITargetAssignmentLink objects. If the check is to be made, the method throws a WTException if the argument is associated to one or more ESITargetAssignmentLink (or ESIProperties-designated subclass) objects.
  2. Examines ESI properties to determine whether or not to check ESITargetOrganizationLink objects. If the check is to be made, the method throws a WTException if the argument is associated to one or more ESITargetOrganizationLink (or ESIProperties-designated subclass) objects.



Supported API: false

Parameters:
tgt - The ESITarget to evaluate.
Throws:
WTException

getParts

private Collection getParts(String ufidString)
                     throws WTException
Throws:
WTException

deleteExistingAssignments

private Collection deleteExistingAssignments(Collection coll)
                                      throws WTException
Throws:
WTException

validateArgument

private void validateArgument(String arg,
                              String name)
                       throws MissingParameterException
Makes sure that a String is not null, not an empty string, and not all blanks.

Parameters:
arg - The argument to validate.
name - The name to use if an error is discovered.
Throws:
MissingParameterException - Thrown if the argument is not valid.

setAssignmentState

private void setAssignmentState(Group grp,
                                Collection pts,
                                Collection assns)
                         throws WTException
Given a collection of ESITargetAssociations, determines whether the every target in the collection is associated with each persistable in the collection.Uses the ESI mapper to create I*E elements from the ESITargets in the input collection. Each element is updated by adding two I*E Atts.

Supported API: false

Parameters:
grp - The Info*Engine group that is to contain the output of the method.
pts - A collection of parts ufids. The size of this collection is the maximum size of several collections created by this method.
assns - A collection of ESITargetAssociations that is to be processed.
Throws:
WTException - Thrown if any error occurs

getPersistedAssocToRemove

private Collection getPersistedAssocToRemove(Collection completeAssoc,
                                             Collection assoc)