Class AbstractAddUsageResolver
java.lang.Object
com.ptc.windchill.associativity.reconciliation.AbstractDiscrepancyProcessor
com.ptc.windchill.associativity.reconciliation.resolver.AbstractDiscrepancyResolver
com.ptc.windchill.associativity.reconciliation.resolver.AbstractAddUsageResolver
- Direct Known Subclasses:
AbstractAssembleUnderDiscrepancyResolver,AbstractSubcontractDiscrepancyResolver,com.ptc.windchill.associativity.reconciliation.resolver.AddedUsageDiscrepancyResolver
The base class to define the template for Adding a new usage during first time creation or sync incremental changes.
This is not singleton, but you call
Supported API: true
Extendable: true
resolve(ReconciliationContext, Collection), it creates a new instance
and then uses that. This is done since its a delegate pattern and maybe cached via factory, hence this always creates
a new instance Supported API: true
Extendable: true
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Supported API: trueNested classes/interfaces inherited from class com.ptc.windchill.associativity.reconciliation.AbstractDiscrepancyProcessor
AbstractDiscrepancyProcessor.ConsumptionData -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanareValuesEqual(String configuredValue, Object persistedValue) OOTB does string compare and can be overridden to have custom comparison logic.protected booleanAllows custom logic to decide if default transformation param to be populated.protected abstract voiddoPostTransformation(ReconciliationContext context, AssociativePath upPath, AbstractAddUsageResolver.TransformationReport report) Supported API: trueprotected abstract voiddoPreTransformation(ReconciliationContext context, AssociativePath upPath, AssociativePath downParentPath) Supported API: truedoTransformation(ReconciliationContext context, AssociativePath upPath, Collection<AssociativePath> downParentPaths) Method to transform a upstream path under a target downstream path.protected Set<AssociativePath>filterValidForFurtherProcessing(ReconciliationContext context, Set<AssociativePath> upPaths) Another version ofisValidForFurtherProcessing(ReconciliationContext, TransformationReport), only this gives you access to all the paths which were marked as valid by configuration, but still can be overridden by custom logic to filter out further if we need to process children or not.protected Set<AssociativePath>filterValidForTransformation(ReconciliationContext context, Set<AssociativePath> addedPaths) OOTB allows to check if they are of a given type and match the attributes.protected booleanforceCreateDownstream(ReconciliationContext context, AssociativePath upPath) OOTB returns if force create new downstream is enabled in configuration or not.protected Set<AssociativePath>getChildrenPaths(NavigationCriteria upnc, Set<AssociativePath> allPathsToProcessFurther)
Supported API: trueprotected ViewReferenceAllows custom logic to decide the view for the downstream part.protected Collection<Associative>getExistingDownstream(ReconciliationContext context, AssociativePath upPath) OOTB the code calls the configuredExistingDownstreamResolver.protected abstract ExistingDownstreamResolverHook to provide custom logic to retrieve existing downstream part to be used during transformation.protected ChildStructureOptiongetStructureOption(ReconciliationContext context, AssociativePath upPath) OOTB returns option configured against usage type, else part type elseChildStructureOption.DO_DUPLICATE_STRUCTURE_WITHOUT_PROPAGATING_THE_CHILDREN
Supported API: true
protected abstract TargetPathResolverHook to provide custom logic to find target downstream path for transformation.This method gets the instance then then uses same instance during whole flow.protected TransformOptiongetTransformOption(ReconciliationContext context, AssociativePath upPath) OOTB returns option configured against usage type, else part type elseDefaultTransformOption.SAME
Supported API: true
handleNewBranch(ReconciliationContext rc, AssociativePath upPath, AssociativePath downParentPath)
Supported API: truehandleNewPart(ReconciliationContext rc, AssociativePath upPath, AssociativePath downParentPath)
Supported API: trueprotected booleanisValidForFurtherProcessing(ReconciliationContext context, AbstractAddUsageResolver.TransformationReport report) Method to tell if we should further process a upstream path or not based on the transformation report.protected booleanisValidInstanceForTransformation(ReconciliationContext context, AssociativePath upPath) OOTB checks against the attributes configured against explicit instance of the usage or child.protected booleanisValidInstanceForTransformation(ReconciliationContext context, AssociativePath upPath, Persistable p) Called from within#isValidInstanceForTransformation(AssociativePath).protected booleanisValidTypeForTransformation(ReconciliationContext context, AssociativePath upPath) OOTB checks if the there are properties configured against the explicit type of the usage or child.resolve(ReconciliationContext context, Collection<? extends Discrepancy2> discrepancies) Main method calling all the template methods.protected ReconciliationReportresolveDiscrepancies(ReconciliationContext context, Collection<? extends Discrepancy2> discrepancies) Starting method to override if need to take control of the whole flow for custom processing.protected booleanvalidateForceCreateDownstream(ReconciliationContext context, AssociativePath upPath)
Supported API: trueMethods inherited from class com.ptc.windchill.associativity.reconciliation.resolver.AbstractDiscrepancyResolver
createEquivalenceLinksMethods inherited from class com.ptc.windchill.associativity.reconciliation.AbstractDiscrepancyProcessor
isSamePath
-
Method Details
-
getTargetPathResolverInstance
Hook to provide custom logic to find target downstream path for transformation.This method gets the instance then then uses same instance during whole flow. allows for caching data for performance use cases.
Supported API: true
-
getExistingDownstreamResolverInstance
protected abstract ExistingDownstreamResolver getExistingDownstreamResolverInstance(ReconciliationContext context) Hook to provide custom logic to retrieve existing downstream part to be used during transformation. This method gets the instance then then uses same instance during whole flow. allows for caching data for performance use cases.
Supported API: true
- Returns:
-
resolve
public ReconciliationReport resolve(ReconciliationContext context, Collection<? extends Discrepancy2> discrepancies) throws WTException Main method calling all the template methods. Extenders should ideally overrideresolveDiscrepancies(ReconciliationContext, Collection)instead of this as this does some initializations as well- 1. Collect all the added paths from the discrepancies.
- 2. Then calls
#filterValidForTransformation(Collection)to filter out the paths which are valid for transformation at current level. - 3. For the invalid paths, gets its children and again calls
#filterValidForTransformation(Collection)recursively till leaf - 4. For all the collected valid paths try to get the actual node which should be used in downstream.
Supported API: true- Specified by:
resolvein classAbstractDiscrepancyResolver- Parameters:
context-discrepancies-- Returns:
- Throws:
WTException
-
resolveDiscrepancies
protected ReconciliationReport resolveDiscrepancies(ReconciliationContext context, Collection<? extends Discrepancy2> discrepancies) throws WTException Starting method to override if need to take control of the whole flow for custom processing. Override this method instead ofresolve(ReconciliationContext, Collection)as thats meant more for internal usages and handles some other initializations
Supported API: true- Parameters:
context-discrepancies-- Returns:
- Throws:
WTException
-
filterValidForFurtherProcessing
protected Set<AssociativePath> filterValidForFurtherProcessing(ReconciliationContext context, Set<AssociativePath> upPaths) throws WTException Another version ofisValidForFurtherProcessing(ReconciliationContext, TransformationReport), only this gives you access to all the paths which were marked as valid by configuration, but still can be overridden by custom logic to filter out further if we need to process children or not. OOTB it checks theADDUSAGE_DONT_TRAVERSE_STRUCTUREflag in context to filter out all the paths. If need control based on how the node was transformed, then you should still use theisValidForFurtherProcessing(ReconciliationContext, TransformationReport)else you can use this method.
Supported API: true
- Parameters:
context- - the common data for reconciliationupPaths- - paths valid based on configuration or transformation option for further processing- Returns:
- valid paths to process further
- Throws:
WTException
-
isValidForFurtherProcessing
protected boolean isValidForFurtherProcessing(ReconciliationContext context, AbstractAddUsageResolver.TransformationReport report) throws WTException Method to tell if we should further process a upstream path or not based on the transformation report. OOTB we first check if continue navigation flag is true, then we always navigate the structure. If false, check if option is same or existing, we do not process further. Also if option is new branch/new part, then we check if structure option is to carry forward children, then also we do not process further.
Supported API: true
- Parameters:
context- - the common data for reconciliationupPath- - the upstream path valid for transformation.- Returns:
- true/false
- Throws:
WTException
-
filterValidForTransformation
protected Set<AssociativePath> filterValidForTransformation(ReconciliationContext context, Set<AssociativePath> addedPaths) throws WTException OOTB allows to check if they are of a given type and match the attributes. This method is called for each level of added nodes till leaf if those are invalid for selection. Valid for selection ones are processed as is.
Supported API: true- Parameters:
addedAssociative-- Returns:
- Throws:
WTException
-
doTransformation
protected Collection<AbstractAddUsageResolver.TransformationReport> doTransformation(ReconciliationContext context, AssociativePath upPath, Collection<AssociativePath> downParentPaths) throws WTException Method to transform a upstream path under a target downstream path. Main method to be overriden in case we want custom transformation logic other than available options likeDefaultTransformOption.SAME,DefaultTransformOption.EXISTING,DefaultTransformOption.NEW_BRANCH,DefaultTransformOption.NEW_PART. OOTB we give error if the transformation will try to change the design structure i.e in place new-part for non-root node.
Supported API: true- Parameters:
context- - context to provide global context dataupPath- - the upstream path which needs to be transformeddownParentPaths- - the target downstream path to consume the upstream path. This path has checked-out downstream node under which paste will happen. This can be null or empty. Null or empty means transformation is expected to be in-place or start from root node.- Returns:
- - report for each upstream path with status and other details
- Throws:
WTException
-
validateForceCreateDownstream
protected boolean validateForceCreateDownstream(ReconciliationContext context, AssociativePath upPath) throws WTException
Supported API: true- Parameters:
context-upPath-- Returns:
- Throws:
WTException
-
doPreTransformation
protected abstract void doPreTransformation(ReconciliationContext context, AssociativePath upPath, AssociativePath downParentPath) throws WTException Supported API: true- Parameters:
context-upPath-downParentPath-- Throws:
WTException
-
doPostTransformation
protected abstract void doPostTransformation(ReconciliationContext context, AssociativePath upPath, AbstractAddUsageResolver.TransformationReport report) throws WTException Supported API: true- Parameters:
context-upPath-report-- Throws:
WTException
-
handleNewBranch
protected AbstractAddUsageResolver.TransformationReport handleNewBranch(ReconciliationContext rc, AssociativePath upPath, AssociativePath downParentPath) throws WTException
Supported API: true- Parameters:
rc-upPath-downParentPath-- Returns:
- Throws:
WTException
-
handleNewPart
protected AbstractAddUsageResolver.TransformationReport handleNewPart(ReconciliationContext rc, AssociativePath upPath, AssociativePath downParentPath) throws WTException
Supported API: true- Parameters:
rc-upPath-downParentPath-- Returns:
- Throws:
WTException
-
getExistingDownstream
protected Collection<Associative> getExistingDownstream(ReconciliationContext context, AssociativePath upPath) throws WTException - Parameters:
context- - global data for overall service callupPath- - the path for which we want to fetch the existing downstream- Returns:
- - collection of existing downstream or empty.
- Throws:
WTException
-
doPopulateDefaultParams
protected boolean doPopulateDefaultParams()Allows custom logic to decide if default transformation param to be populated. Default value is true.
Supported API: true
-
getDownstreamViewForTransformation
protected ViewReference getDownstreamViewForTransformation(ReconciliationContext rc, CommonEquivalenceContext cec) Allows custom logic to decide the view for the downstream part. OOTB it uses theCommonEquivalenceContext
Supported API: true- Parameters:
rc-cec-- Returns:
-
getTransformOption
protected TransformOption getTransformOption(ReconciliationContext context, AssociativePath upPath) throws WTException OOTB returns option configured against usage type, else part type elseDefaultTransformOption.SAME
Supported API: true
- Parameters:
context- - the common data for reconciliationupPath- - the upstream path valid for transformation.- Returns:
- - some
TransformOption, never null. - Throws:
WTException
-
forceCreateDownstream
protected boolean forceCreateDownstream(ReconciliationContext context, AssociativePath upPath) throws WTException OOTB returns if force create new downstream is enabled in configuration or not. First checks against usage type. If false, then checks for child and then return final status
Supported API: true
- Parameters:
context- - the common data for reconciliationupPath- - the upstream path valid for transformation.- Returns:
- - true/false, never null.
- Throws:
WTException
-
getStructureOption
protected ChildStructureOption getStructureOption(ReconciliationContext context, AssociativePath upPath) throws WTException OOTB returns option configured against usage type, else part type elseChildStructureOption.DO_DUPLICATE_STRUCTURE_WITHOUT_PROPAGATING_THE_CHILDREN
Supported API: true
- Parameters:
context- - the common data for reconciliationupPath- - the upstream path valid for transformation.- Returns:
- - some
ChildStructureOption, never null - Throws:
WTException
-
isValidTypeForTransformation
protected boolean isValidTypeForTransformation(ReconciliationContext context, AssociativePath upPath) throws WTException OOTB checks if the there are properties configured against the explicit type of the usage or child. First checks if the usage type is valid. If yes, then check if child type is valid. And returns this final status.
Supported API: true
- Parameters:
context- - the common data for reconciliationupPath- - the upstream path valid for transformation.- Returns:
- if the path is valid or not for actual transformation.
- Throws:
WTException
-
isValidInstanceForTransformation
protected boolean isValidInstanceForTransformation(ReconciliationContext context, AssociativePath upPath) throws WTException OOTB checks against the attributes configured against explicit instance of the usage or child. First checks if the usage instance is valid. If yes, then check if child instance is valid. And returns this final status. This will load the configured attributes and check them against the given value and see if instance is valid of not.
Supported API: true
- Parameters:
context- - the common data for reconciliationupPath- - the upstream path valid for transformation.- Returns:
- if the path is valid or not for actual transformation.
- Throws:
WTException
-
isValidInstanceForTransformation
protected boolean isValidInstanceForTransformation(ReconciliationContext context, AssociativePath upPath, Persistable p) throws WTException Called from within#isValidInstanceForTransformation(AssociativePath). OOTB check if all the attributes mentioned have given value using AND or OR based on#doAndForAttributeValidation(). Also OOTB attribute value comparison is done as string. Also if no attributes are configured, then also returns true. There should be rare need to override this as if OOTB logic does not work, ideally#isValidInstanceForTransformation(AssociativePath)should be overridden or if value comparison needs custom logic overrideareValuesEqual(String, Object). Maybe this should be private. Supported API: true- Parameters:
p- - the persistable to validate- Returns:
- - true/false if the instance has valid attribute values. If no attributes are configured, returns true.
- Throws:
WTException
-
areValuesEqual
OOTB does string compare and can be overridden to have custom comparison logic. If the configured value is null/empty and persisted value is null as well, we treat them equal. If both are not null, then we do string compare with ignore case and return result else return false.
Supported API: true
- Parameters:
configuredValue- - string format value read from configuration for a given attributepersistedValue- - the persisted value from the database for a given attribute.- Returns:
- Throws:
WTException
-