OSLC Connect for Windchill provides a set of OSLC Links validators that can be used in Workflow management or Lifecycle Event listeners. The goal is to test the value of a property on a remote artifact.
There are 3 different validators:
The main class to access the validators is OslcPropertyValidator which has 3 methods:
OslcPropertyValidator.oneLinkMatcher(primaryBusinessObject) OslcPropertyValidator.allLinksMatcher(primaryBusinessObject) OslcPropertyValidator.noneLinkMatcher(primaryBusinessObject)
The primaryBusinessObject parameter expected is the Part or the Change Object (extending the wt.fc.WTObject abstract class) on which to apply the criteria.
The matcher will then allow to validate the criteria on a specific link type or on all of them:
OslcPropertyValidator.oneLinkMatcher(primaryBusinessObject).validateForLinkType("http://open-services.net/ns/cm#implementsRequirement","status","approved");
OslcPropertyValidator.oneLinkMatcher(primaryBusinessObject).validate("status","approved");
The matchers will return the response as a Feedback object containing error messages if something went wrong or if the criteria is not validated. The OslcPropertyValidator also exposes a class allowing to format the Feedback as a String if it is to be displayed in Workflow activities.
It is to be noted that, in workflow activities, Java classes must be prefixed with the package name as no import statement can be used. To keep examples readable i did not include the package name.
com.sodius.oslc.app.wc.server.process.workflow.OslcPropertyValidator
com.sodius.oslc.server.model.Feedback
The following example shows how the Feedback object can be used in a workflow activity (the result variable is the system variable used by Workflows to trigger routing):
Feedback feedback = OslcPropertyValidator.oneLinkMatcher(primaryBusinessObject).validateForLinkType("http://open-services.net/ns/cm#implementsRequirement","status","approved"); if (feedback.hasErrors()) { result = "KO"; oslcReview = OslcPropertyValidator.formatFeedbackToString(feedback); } else { result="OK"; }
The Feedback object will also contain, as information messages, the result of the criteria matching on all links tested (only the lines starting with INFO or ERROR in the following example are from the Feebdback messages).