Customizing Rule Set Selection for Regulatory Submission Validation
This topic describes how to configure a supported and customizable API that dynamically determines the Rule Set Name used during the validation of Regulatory Submissions.
This means that rather than applying a fixed rule set to all submissions, the system calls the API in order to determine the appropriate Rule Set Name.
Intended Outcome
The goal of this enhancement is to provide Regulatory Submission implementors with a flexible and extendable mechanism to determine the appropriate validation rule set for a given submission.
Solution
To achieve this, a new supported and extendable API is introduced within the RegulatorySubmissionProcessorInterface. This API allows implementors to override the logic used to determine the rule set name for validation. The solution includes:
A primary validation method that uses the new API
Two supporting APIs that can be overridden to customize rule set selection and relationship resolution.
A default implementation that handles common use cases and ensures backward compatibility
Solution Elements
The next table describes the solution elements.
Element
Type
Description
validateRegSubmission
API
This API is used to validate a regulatory submission.
getBusinessRuleSetName
API
This API is used to retrieve the name of the rule set that must be used for validating the submission.
getBusinessRuleRelationship
API
This API is used to determine the correct relationship context for the submission.
Default Behavior
When validating a regulatory submission, the system determines the appropriate rule set name using the default implementation of the supported API. The behavior varies depending on whether the submission is a Non-revisable or Revisable type.
Creating Custom Classes
To customize the rule set selection logic, extend the default processor by creating a subclass of the default RegulatorySubmissionProcessorInterface and override getBusinessRuleSetName, and getBusinessRuleRelationship.
public class ExampleRegulatorySubmissionProcessor extends AbstractRegulatorySubmissionProcessor
{

/**
* Returns the relationship key used to lookup the correct association objects in relation to the primary business object.
* <br/><br />
* Default implementation returns "RegulatorySubmission" registered to the {@link RegMstrObjectsRelationshipDelegate} in the service xconf.
*
*
* <BR>
* <BR>
* <B>Supported API: </B>true <BR>
*
* @param submission
* - A Regulatory Submission
* @return String
*/
@Override
public String getBusinessRuleRelationship(RegulatorySubmission submission)
{
return "RegulatorySubmission";
}

/**
* Returns the rule set key for the BusinessRuleSet to validate against. Default implementation returns null.
*
* <BR>
* <BR>
* <B>Supported API: </B>true <BR>
*
* @param submission
* - A Regulatory Submission
* @return String
*/
@Override
public String getBusinessRuleSetName(RegulatorySubmission submission)
{
return null;
}

/**
* Returns a RuleValidationResultSet after validating the "Simple" or "Revision-Controlled" Regulatory Submission
* against applicable BusinessRules. BusinessRuleSet to validate against is fetched by the name returned from
* getBusinessRuleSetName(RegulatorySubmission).
*
* <BR>
* <BR>
* <B>Supported API: </B>true <BR>
*
* @param submission
* - A Regulatory Submission
* @return RuleValidationResultSet
* @throws WTException
*/
@Override
public RuleValidationResultSet validateRegSubmission(RegulatorySubmission submission,
boolean useWorkingCopy) throws WTException
{
Workable workable = null;

if (useWorkingCopy && submission instanceof Workable)
{
workable = (Workable) submission;
}

try
{
if (useWorkingCopy
&& workable != null
&& WorkInProgressHelper.isCheckedOut(workable)
&& !WorkInProgressHelper.isWorkingCopy(workable))
{
RegulatorySubmission workingCopy = (RegulatorySubmission) WorkInProgressHelper.service
.workingCopyOf(workable);
if (OwnershipHelper.isOwnedBy(workingCopy, SessionHelper.getPrincipal()))
{
submission = workingCopy;
}
}
} catch (WorkInProgressException exception)
{
// Do nothing, user does not have access to the working copy
}

String ruleName = getBusinessRuleSetName(submission);
String relationship = getBusinessRuleRelationship(submission);
if (ruleName == null || relationship == null)
{
return new RuleValidationResultSet();
}


BusinessRuleSetBean defaultBean = BusinessRuleSetBean.newBusinessRuleSetBean(ruleName, relationship);
BusinessRuleSetBean[] beans = new BusinessRuleSetBean[] { defaultBean };
RuleValidationResultSet resultSet = BusinessRulesHelper.engine.execute(submission, beans);

return resultSet;
}

}
The RelationshipDelegate example:
public class ExampleRegMstrObjectsRelationshipDelegate implements BusinessRuleSetRelationshipDelegate
{

@SuppressWarnings("unchecked")
@Override
public WTCollection getTargetObjects(Object primaryBusinessObject) throws WTException
{
WTCollection targetObjects = new WTHashSet();
if (primaryBusinessObject instanceof RegulatorySubmission)
{
RegulatorySubmission submission = (RegulatorySubmission) primaryBusinessObject;
targetObjects.add(submission);
targetObjects.addAll(
RegulatorySubmissionHelper.service.getSubjectLinksForRegulatorySubmission(submission, false));
targetObjects.addAll(
RegulatorySubmissionHelper.service.getDriverLinksForRegulatorySubmission(submission, false));
targetObjects.addAll(TableDataHelper.getService().getTableData(submission));
}

return targetObjects;
}
}
This delegate is registered in the service.xconf with the selector being the same value that is returned from the getBusinessRuleRelationship(RegulatorySubmission submission), like this:
<!-- Configure Regulatory Submission Object Relationship Delegate -->
<Service context="default" name="com.ptc.core.businessRules.relationship.BusinessRuleSetRelationshipDelegate">
<Option
cardinality="singleton"
requestor="null"
selector="RegulatorySubmission"
serviceClass="com.ptc.qualitymanagement.regmstr.businessrules.ExampleRegMstrObjectsRelationshipDelegate"
/>
</Service>
Было ли это полезно?