Class AbstractAddUsageResolver

Direct Known Subclasses:
AbstractAssembleUnderDiscrepancyResolver, AbstractSubcontractDiscrepancyResolver, com.ptc.windchill.associativity.reconciliation.resolver.AddedUsageDiscrepancyResolver

public abstract class AbstractAddUsageResolver extends AbstractDiscrepancyResolver
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 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
  • Method Details

    • getTargetPathResolverInstance

      protected abstract TargetPathResolver getTargetPathResolverInstance(ReconciliationContext context)
      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 override resolveDiscrepancies(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:
      resolve in class AbstractDiscrepancyResolver
      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 of resolve(ReconciliationContext, Collection) as thats meant more for internal usages and handles some other initializations

      Supported API: true
      Parameters:
      context -
      discrepancies -
      Returns:
      Throws:
      WTException
    • getChildrenPaths

      protected Set<AssociativePath> getChildrenPaths(NavigationCriteria upnc, Set<AssociativePath> allPathsToProcessFurther) throws WTException


      Supported API: true
      Parameters:
      upnc -
      allPathsToProcessFurther -
      Returns:
      Throws:
      WTException
    • filterValidForFurtherProcessing

      protected Set<AssociativePath> filterValidForFurtherProcessing(ReconciliationContext context, Set<AssociativePath> upPaths) throws WTException
      Another version of isValidForFurtherProcessing(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 the ADDUSAGE_DONT_TRAVERSE_STRUCTURE flag in context to filter out all the paths. If need control based on how the node was transformed, then you should still use the isValidForFurtherProcessing(ReconciliationContext, TransformationReport) else you can use this method.
      Supported API: true

      Parameters:
      context - - the common data for reconciliation
      upPaths - - 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 reconciliation
      upPath - - 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

      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 like DefaultTransformOption.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 data
      upPath - - the upstream path which needs to be transformed
      downParentPaths - - 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



      Supported API: true
      Parameters:
      rc -
      upPath -
      downParentPath -
      Returns:
      Throws:
      WTException
    • handleNewPart



      Supported API: true
      Parameters:
      rc -
      upPath -
      downParentPath -
      Returns:
      Throws:
      WTException
    • getExistingDownstream

      protected Collection<Associative> getExistingDownstream(ReconciliationContext context, AssociativePath upPath) throws WTException
      OOTB the code calls the configured ExistingDownstreamResolver.

      Supported API: true
      Parameters:
      context - - global data for overall service call
      upPath - - 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 the CommonEquivalenceContext

      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 else DefaultTransformOption.SAME

      Supported API: true

      Parameters:
      context - - the common data for reconciliation
      upPath - - 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 reconciliation
      upPath - - 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 else ChildStructureOption.DO_DUPLICATE_STRUCTURE_WITHOUT_PROPAGATING_THE_CHILDREN
      Supported API: true

      Parameters:
      context - - the common data for reconciliation
      upPath - - 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 reconciliation
      upPath - - 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 reconciliation
      upPath - - 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 override areValuesEqual(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

      protected boolean areValuesEqual(String configuredValue, Object persistedValue) throws WTException
      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 attribute
      persistedValue - - the persisted value from the database for a given attribute.
      Returns:
      Throws:
      WTException