Custom State Transition Predicates
A 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.
Developing own/custom predicates in Java requires a Java 7 or newer Standard Edition (SE) Java Development Kit (JDK) plus the following frameworks/libraries:
Framework/Library
Component
Version
3.4
spring-core
3.2.x
spring-context
3.2.x
spring-beans
3.2.x
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, for example,
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 classCustomPredicate {

...
}
The @TransitionPredicate annotation has only one parameter:
value the unique id/name of the predicate. This value must not be changed over the lifetime of a predicate, otherwise configured state transitions conditions for this predicate will not longer work!.
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 classCustomPredicate{

@TransitionApplicable
public boolean isApplicable(WorkflowTransitionDto transition, TrackerItemDto item) {
booleanresult = ...

return result;
}
}
Methods annotated as @TransitionApplicable must be
Public
Return boolean true if the specified transition is applicable for the specified tracker item (in the specified context), false otherwise.
Context specific information required by the method in order to make it's decision, must be declared as method parameters.
The following context information is available:
UserDto, to receive the user, that wants to execute the state transition on the item.
HttpServletRequest, to receive the current request.
WorkflowTransitionDto, to receive the state transition to be applied to the item.
TrackerItemDto, to receive the tracker item where the state transition should be applied to.
ProjectDto, to receive the context project.
TrackerDto, to receive the context tracker.
TrackerTypeDto is the type of the context tracker.
TrackerTypeDto.Kind is the kind of the context tracker
Tracker for work items
Category for configuration items
Repository for source code commits/pushs
Was this helpful?