Custom state transition predicates #825588/HEAD / v30 |
Tags:
not added yet
Custom state transition predicatesA state transition predicate implements a Condition (Filter) for State Transitions, that checks, whether a specific state transition is applicable for a specific tracker item in a specific context.
You also need cb.jar from the directory ~/CB-../tomcat/webapps/cb/WEB-INF/lib of the CodeBeamer 7.8.0 or newer installation, you want to develop new custom transition predicates for. A predicate is simply a method of a Java class. For example: package com.intland.codebeamer.example.predicates; import org.springframework.stereotype.Component; import com.intland.codebeamer.manager.workflow.TransitionPredicate; import com.intland.codebeamer.manager.workflow.TransitionApplicable; import com.intland.codebeamer.persistence.dto.TrackerItemDto; import com.intland.codebeamer.persistence.dto.WorkflowTransitionDto; @Component("customPredicate") @TransitionPredicate("customPredicate") public class CustomPredicate { @TransitionApplicable public boolean isApplicable(WorkflowTransitionDto transition, TrackerItemDto item) { boolean result = ... return result; } } We recommend, that the package of your custom predicates should be a sub-package of com.intland.codebeamer, e.g. com.intland.codebeamer.<mycompany>.predicates You can use any package name, but when using a sub-package of com.intland.codebeamer, your new predicate can be automatically detected and deployed by the Component scan during CodeBeamer startup: package com.intland.codebeamer.example.predicates; import org.springframework.stereotype.Component; @Component("customPredicate") public class CustomPredicate { ... }The component id/name (if any) should be the same than the @TransitionPredicate id/name (see below). If your custom transition predicate is not a Component in a sub-package of com.intland.codebeamer, then you must provide extra <bean> configuration for your custom predicate in ~/CB-../tomcat/webapps/cb/WEB-INF/classes/my-ApplicationContext.xml Java classes providing state transition predicates must be annotated as @TransitionPredicate. import com.intland.codebeamer.manager.workflow.TransitionPredicate; @TransitionPredicate("customPredicate") public class CustomPredicate { ... } The @TransitionPredicate annotation has only one parameter:
There is no special interface to implement or base class to extend. But each class annotated as @TransitionPredicate, must have (at least) one method annotated with @TransitionApplicable: package com.intland.codebeamer.example.predicates; import com.intland.codebeamer.manager.workflow.TransitionPredicate; import com.intland.codebeamer.manager.workflow.TransitionApplicable; import com.intland.codebeamer.persistence.dto.TrackerItemDto; import com.intland.codebeamer.persistence.dto.WorkflowTransitionDto; @TransitionPredicate("customPredicate") public class CustomPredicate { @TransitionApplicable public boolean isApplicable(WorkflowTransitionDto transition, TrackerItemDto item) { boolean result = ... return result; } }
Context specific predicatesIf your custom state transition predicate is only applicable in a specific context, e.g. only for trackers/items of a specific type, then the implementing class should declare an additional predicate/method annotated with @PredicateApplicable. E.g. package com.intland.codebeamer.example.predicates; import com.intland.codebeamer.manager.workflow.TransitionPredicate; import com.intland.codebeamer.manager.workflow.PredicateApplicable; import com.intland.codebeamer.persistence.dto.TrackerDto; import com.intland.codebeamer.persistence.dto.TrackerTypeDto; @TransitionPredicate("customPredicate") public class CustomPredicate { @PredicateApplicable public boolean isApplicable(TrackerDto tracker) { return tracker.isA(TackerTypeDto.REQUIREMENT, TrackerTypeDto.USERSTORY); } } Methods annotated with @PredicateApplicable must be
The method must declare parameters for all required context information, that it needs to make it's decision. The following context information is available:
Deploying state transition predicatesTo deploy your custom predicates, the Java code must be compiled and the resulting *.class file must be uploaded to the appropriate sub-directory under ~/CB-.../tomcat/webapps/cb/WEB-INF/classes/..., where the sub-directory is the equivalent of the predicates's package name. ~/CB-../tomcat/webapps/cb/WEB-INF/classes/my-ApplicationContext.xml Finally you have to restart CodeBeamer, for your newly deployed predicates to get loaded. Caution! Old pre-CB-7.8 state transition predicates implementing StateTransitionPredicate or derived from DefaultStateTransitionPredicate are not longer supported in CB-7.8 or newer! Any attempt to deploy such old predicates via ~/CB-.../tomcat/webapps/cb/WEB-INF/classes/my-applicationContext.xml will cause the CodeBeamer startup to fail. If you had developed custom predicates, you should first check, whether the default Expression predicate can now be used for this task. Only if that is not possible, you should try to migrate your custom predicate. |
Fast Links
codebeamer Overview codebeamer Knowledge Base Services by Intland Software |
This website stores cookies on your computer. These cookies are used to improve your browsing experience, constantly optimize the functionality and content of our website, furthermore helps us to understand your interests and provide more personalized services to you, both on this website and through other media. With your permission we and our partners may use precise geolocation data and identification through device scanning. You may click accept to consent to our and our partners’ processing as described above. Please be aware that some processing of your personal data may not require your consent, but you have a right to object to such processing. By using our website, you acknowledge this notice of our cookie practices. By accepting and continuing to browse this site, you agree to this use. For more information about the cookies we use, please visit our Privacy Policy.Your preferences will apply to this website only.
Note that user-behavior analytics are being captured on this server for the purpose of improving the Codebeamer user experience.