powered by ASAP

Java command annotations are used for the developing Java commands in PAK. This chapter describes the functionality of the @Group annotation. It also gives an example of how you can use this annotation in your implementation.

1. Basics

The @Group annotation marks several optional persistent variables that should belong to one group. Variables of the same group behave like one variable with respect to the mandatory property of the @Persistent annotation. In case none of the variables is assigned to a value the user will not be able to execute the command. One group needs at least two variables assigned to it and the group name should be user-friendly.

Since the user can specify values for all variables of one group at the same time, the code must implement the handling of this case, see line 34 of Listing 1.
This annotation does only makes sense in combination with the @Persistent annotation and the variable has to be optional.

2. Properties

There is a String property value defined for the @Group annotation. This specifies the group name under which the variable will be placed and should be short and human-readable.

3. Usage

Listing 1 demonstrates how the @Group annotation has to be used in your command.

Listing 1. Usage of the @Group annotation
 * @workflowDocu This command gets an element by its id or key.
public class GetElement {
	private static final String IDENTIFIER_GROUP = "Identifier";


	 * @workflowDocu Id of the issue element to fetch
	@Persistent(mandatory = false) (2)
	private String id;

	 * @workflowDocu Key of the issue element to fetch
	@Persistent(mandatory = false) (4)
	private String key;


	 * Fetch the element with a given id or key.
	public void fetchElement() {
		// Check whether both variables of group "Identifier" have a value assigned
		if (StringUtils.isNotBlank(id) && StringUtils.isNotBlank(key)) {
			// Add handling of this case

1 Use of the @Group annotation for the 1st variable
2 1st variable is set to optional
3 Use of the @Group annotation for the 2nd variable
4 2nd variable is set to optional

The result of the example of Listing 1 is shown in the following images. Figure 1 displays the grouping of the two variables id and key. As you can see, both variables are bordered red. As soon as one of the variables get a value assigned, the command can be executed. In figure Figure 2 a value for id is set and in Figure 3 for key.

GetElement group
Figure 1. Grouped Command with two variables
GetElement group id set
Figure 2. Grouped Command – Id assigned to value
GetElement group key set
Figure 3. Grouped Command – Key assigned to value