Procedure
The procedure to include custom configuration or custom logic is given below:
1. Create a new CUSTOM_DISCREPANCY in DiscrepancyTypeRB.rbInfo using enumCustomize tool.
2. Create a new delegate CustomDiscrepancyDelegate and add an entry in the WT_HOME/codebase/com/ptc/windchill/associativity/xconfs/associativity.service.properties.xconf file.
<Option cardinality="singleton" selector="CUSTOM_DISCREPANCY" requestor="null"
serviceClass="com.ptc.windchill.associativity.reconciliation.part.CustomDiscrepancyDelegate"/>
Implement the following methods in CustomDiscrepancyDelegate:
public Collection<Discrepancy2> detect(ReconciliationContext context, AssociativePath currentPath,AssociativePath oldPath) throws WTException ;
Provides the logic to detect discrepancies.
public void verify(ReconciliationContext context, Collection<? extends Discrepancy2> discrepancies) throws WTException;
Provides the logic to verify the discrepancies. It provides separation of logic to find a discrepancy and verify if it is valid and can be handled by resolve.
public ReconciliationReport resolve(ReconciliationContext context, Collection<? extends Discrepancy2> discrepancies) throws WTException;
Provides the logic to resolve the discrepancies.
protected AbstractDiscrepancy2 getDiscrepancyInstance(ReconciliationContext context) throws WTException;
Returns an instance of custom discrepancy. This can be overridden to use the instance from JSON (ReconciliationContext, String) method to populate default information.
public boolean isOccurrenceBased();
Specifies whether the discrepancy is occurrence based or usage based.
public String toJSON(ReconciliationContext context, Discrepancy2 discrepancy) throws WTException;
Provides a way to transfer information from server to client. Each delegate ensures that all the required information is translated so that it can be converted back to Discrepancy2. If it is required to be resolved, call the super method before adding specific information to JSON.
public Discrepancy2 fromJSON(ReconciliationContext context, String discrepancyData) throws WTException;
Provides a way to transfer client information back to server objects. Each delegate ensures that all the required data is translated to be consistent with JSON (ReconciliationContext, Discrepancy2). Call the super method before handling specific information.
The configuration for CustomDiscrepancyDelegate is given below:
public class CustomDiscrepancyDelegate extends AbstractDiscrepancyDelegate {
private static final Logger logger LogR.getLogger(CustomDiscrepancyDelegate.class.getName());

@Override
protected AbstractDiscrepancy2 getDiscrepancyInstance(ReconciliationContext context) throws WTException {
return new CustomDiscrepancy();
}

@Override
public Collection<Discrepancy2> detect(ReconciliationContext context, AssociativePath currentPath, AssociativePath oldPath) throws WTException {
// Provide logic for discrepancy detection
}

@Override
public void verify(ReconciliationContext context, Collection<? extends Discrepancy2> discrepancies) throws WTException {
// Provide logic for discrepancy verify
}

@Override
public ReconciliationReport resolve (ReconciliationContext context, Collection<? extends Discrepancy?> discrepancies) throws WTException {
// Provide logic for discrepancy resolve
}

@Override
public String toJSON(ReconciliationContext context, Discrepancy2 discrepancy) throws WTException {
if (!(discrepancy instanceof CustomDiscrepancy)) {
if (logger.isDebugEnabled()) {
logger.debug("Discrepancy is not of type CustomDiscrepancy. Returning");
}
return "";
}
return super.toJSON(context, discrepancy);
}

public Discrepancy2 fromJSON(ReconciliationContext context, String discrepancyData) throws WTException {
return super.fromJSON(context, discrepancyData);
}

@Override
public boolean isoccurrenceBased() {
// set it to true if discrepancy is occurrence based
return false;
}

/**
* Possible values for compare mode are CompareMode.UPSTREAM,CompareMode.DOWNSTREAM,CompareMode.BOTH
* Default value is compare upstream CompareMode.UPSTREAM .
* For custom delegate to support SSA and reconciliation return CompareMode.BOTH & enhance detect logic
* to support downstream comparison.
* There could be cases where some discrepancies don't make sense for downstream compare or
* vice versa so return appropriate enumeration value.
*
*/
public default CompareMode getCompareMode() {
return CompareMode.UPSTREAM;
}
}
Was this helpful?