Custom workflow actions #825237/HEAD / v30 |
Tags:
not added yet
Custom workflow actionsDeveloping own/custom Workflow Actions in Java requires a Java 7 or newer Standard Edition (SE) Java Development Kit (JDK) plus the following frameworks/libraries:
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 workflow actions for. Workflow Actions are methods of Java classes. For example: Create a new baseline: package com.intland.codebeamer.example.actions; import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.intland.codebeamer.controller.ArtifactController; import com.intland.codebeamer.manager.workflow.ActionCall; import com.intland.codebeamer.manager.workflow.ActionParam; import com.intland.codebeamer.manager.workflow.WorkflowAction; import com.intland.codebeamer.manager.workflow.ActionParam.Type; import com.intland.codebeamer.manager.workflow.WorkflowPhase; import com.intland.codebeamer.persistence.dto.ArtifactDto; import com.intland.codebeamer.persistence.dto.TrackerDto; import com.intland.codebeamer.persistence.dto.UserDto; @Component("baselineCreator") @WorkflowAction(value="baselineCreator", iconUrl="/images/Snapshot.png", helpUrl="https://codebeamer.com/cb/wiki/816624") public class BaselineCreator { @Autowired private ArtifactController artifactController; @ActionCall(WorkflowPhase.After) public ArtifactDto createBaseline(HttpServletRequest request, UserDto user, TrackerDto tracker, @ActionParam(value="baselineScope", options={"project", "tracker"}, required=true) String scope, @ActionParam(value="baselineName", required=true, width=60) String name, @ActionParam(value="baselineDescription", type=Type.wikitext, width=60, height=2) String description ) throws Exception { ArtifactDto baseline = ... artifactController.createArtifact(request, user, tracker.getProject(), baseline, null); return baseline; } } We recommend, that the package of your custom actions should be a sub-package of com.intland.codebeamer, e.g. com.intland.codebeamer.<mycompany>.actions You can use any package name, but when using a sub-package of com.intland.codebeamer, your new actions can be automatically detected and deployed by the Component scan during CodeBeamer startup: package com.intland.codebeamer.example.actions; import org.springframework.stereotype.Component; @Component("baselineCreator") public class BaselineCreator { ... }The component id/name (if any) should be the same than the @WorkflowAction id/name (see below). If your custom workflow action is not a Component in a sub-package of com.intland.codebeamer, then you must provide extra <bean> configuration for your custom workflow action in ~/CB-../tomcat/webapps/cb/WEB-INF/classes/my-ApplicationContext.xml Classes providing workflow actions must be annotated as @WorkflowAction. import com.intland.codebeamer.manager.workflow.WorkflowAction; @WorkflowAction(value="baselineCreator", iconUrl="/images/Snapshot.png", helpUrl="https://codebeamer.com/cb/wiki/816624") public class BaselineCreator { ... }There is no special interface to implement or base class to extend. The @WorkflowAction annotation has the following attributes:
If an action implementation needs access to other CodeBeamer APIs, the action class should simply declare appropriate @Autowired variables: import org.springframework.beans.factory.annotation.Autowired; import com.intland.codebeamer.controller.ArtifactController; public class BaselineCreator { @Autowired private ArtifactController artifactController; ... } Each class annotated as @WorkflowAction, must have (at least) one method annotated with @ActionCall: import com.intland.codebeamer.manager.workflow.ActionCall; import com.intland.codebeamer.manager.workflow.WorkflowAction; import com.intland.codebeamer.manager.workflow.WorkflowPhase; @WorkflowAction(value="baselineCreator", iconUrl="/images/Snapshot.png", helpUrl="https://codebeamer.com/cb/wiki/816624") public class BaselineCreator { ... @ActionCall(WorkflowPhase.After) public ArtifactDto createBaseline(...) { ... } }Action methods can have any name and return type and should be public. The @ActionCall annotation has only one parameter, that defines the phase of event processing, where the method should be called:
Methods annotated as @ActionCall must be Context specific information required by the method, must be declared as parameters. The following context information is available:
You can also declare a parameter with a specific source/context type, e.g. WorkflowTransitionDto. The value of such parameters will be null, if the actual source/context is not an object of this type.
Parameters with simple types (int, double, long and boolean) are implicitly required.
The @ActionParam annotation supports the following attributes:
Methods annotated as @ActionCall can throw any type of Exceptions. Two types of exceptions have a special meaning:
Action configuration localizationThe Workflow Actions configuration GUI will show actions and custom action parameters using their
Via custom language resource files (see Codebeamer Localization Guide), you can provide language specific texts for action and parameter names. E.g. English texts in ~/CB-../tomcat/webapps/cb/WEB-INF/classes/my-ApplicationResources.properties tracker.action.baselineCreator.label=Create a new baseline tracker.action.baselineCreator.baselineScope.label=Scope tracker.action.baselineCreator.baselineScope.tooltip=The scope of the new baseline tracker.action.baselineCreator.baselineScope.tracker.label=Tracker tracker.action.baselineCreator.baselineScope.tracker.tooltip=Create a new baseline on the current tracker tracker.action.baselineCreator.baselineScope.project.label=Project tracker.action.baselineCreator.baselineScope.project.tooltip=Create a new baseline on the whole project tracker.action.baselineCreator.baselineName.label=Name tracker.action.baselineCreator.baselineName.tooltip=The name of the new baseline tracker.action.baselineCreator.baselineDescription.label=Description tracker.action.baselineCreator.baselineDescription.tooltip=The description of the new baseline E.g. German texts in ~/CB-../tomcat/webapps/cb/WEB-INF/classes/my-ApplicationResources_de.properties tracker.action.baselineCreator.label=Den aktuellen Versionsstand sichern tracker.action.baselineCreator.baselineScope.label=Umfang tracker.action.baselineCreator.baselineScope.tooltip=Der Umfang des neuen Versionsstands tracker.action.baselineCreator.baselineScope.tracker.label=Tracker tracker.action.baselineCreator.baselineScope.tracker.tooltip=Sichere den Versionsstand des aktuellen Trackers tracker.action.baselineCreator.baselineScope.project.label=Projekt tracker.action.baselineCreator.baselineScope.project.tooltip=Sichere den Versionstands des kompletten Projekts tracker.action.baselineCreator.baselineName.label=Name tracker.action.baselineCreator.baselineName.tooltip=Der Name des neuen Versionstands tracker.action.baselineCreator.baselineDescription.label=Beschreibung tracker.action.baselineCreator.baselineDescription.tooltip=Die Beschreibung des neuen Versionstands The resource name for label and tooltip of a workflow action is:
Context specific actionsIf your custom workflow action 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 @ActionPredicate: import com.intland.codebeamer.manager.workflow.ActionPredicate; import com.intland.codebeamer.persistence.dto.TrackerTypeDto; @WorkflowAction(value="scmChangeFileZipper", iconUrl="/images/cvs_view.gif") public class ScmChangeFileZipper { @ActionPredicate public boolean isApplicable(TrackerTypeDto type) { return TrackerTypeDto.isTrackerType(type); } ... } Methods annotated with @ActionPredicate 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 workflow actionsTo deploy your custom workflow action, 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 action's package name. ~/CB-../tomcat/webapps/cb/WEB-INF/classes/my-ApplicationContext.xml Finally you have to restart CodeBeamer, for your newly deployed actions to get loaded. |
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.