1 package com.atlassian.plugins.codegen.modules.jira;
2
3 import com.atlassian.plugins.codegen.PluginProjectChangeset;
4 import com.atlassian.plugins.codegen.annotations.JiraPluginModuleCreator;
5 import com.atlassian.plugins.codegen.modules.AbstractPluginModuleCreator;
6
7 import static com.atlassian.plugins.codegen.modules.Dependencies.MOCKITO_TEST;
8
9
10
11
12 @JiraPluginModuleCreator
13 public class WorkflowConditionModuleCreator extends AbstractPluginModuleCreator<WorkflowElementProperties>
14 {
15
16 public static final String MODULE_NAME = "Workflow Condition";
17 private static final String TEMPLATE_PREFIX = "templates/jira/workflow/condition/";
18
19
20 private static final String CLASS_TEMPLATE = TEMPLATE_PREFIX + "WorkflowCondition.java.vtl";
21 private static final String FACTORY_TEMPLATE = TEMPLATE_PREFIX + "WorkflowConditionFactory.java.vtl";
22 private static final String UNIT_TEST_TEMPLATE = TEMPLATE_PREFIX + "WorkflowConditionTest.java.vtl";
23 private static final String VIEW_TEMPLATE = TEMPLATE_PREFIX + "workflow-condition.vm.vtl";
24 private static final String INPUT_TEMPLATE = TEMPLATE_PREFIX + "workflow-condition-input.vm.vtl";
25 private static final String TEMPLATE_PATH = "conditions";
26
27
28 private static final String EXAMPLE_CLASS_TEMPLATE = TEMPLATE_PREFIX + "Example" + CLASS_TEMPLATE;
29
30 private static final String PLUGIN_MODULE_TEMPLATE = TEMPLATE_PREFIX + "workflow-condition-plugin.xml.vtl";
31
32 @Override
33 public PluginProjectChangeset createModule(WorkflowElementProperties props) throws Exception
34 {
35 PluginProjectChangeset ret = new PluginProjectChangeset()
36 .withDependencies(MOCKITO_TEST)
37 .with(createModule(props, PLUGIN_MODULE_TEMPLATE));
38
39 if (props.includeExamples())
40 {
41 return ret.with(createClass(props, EXAMPLE_CLASS_TEMPLATE));
42 }
43 else
44 {
45 String moduleKey = props.getModuleKey();
46 String viewFileName = moduleKey + ".vm";
47 String inputFileName = moduleKey + "-input.vm";
48 return ret.with(createClassAndTests(props, CLASS_TEMPLATE, UNIT_TEST_TEMPLATE))
49 .with(createClass(props, props.getFactoryClassId(), FACTORY_TEMPLATE))
50 .with(createTemplateResource(props, TEMPLATE_PATH, viewFileName, VIEW_TEMPLATE))
51 .with(createTemplateResource(props, TEMPLATE_PATH, inputFileName, INPUT_TEMPLATE));
52 }
53 }
54
55 @Override
56 public String getModuleName()
57 {
58 return MODULE_NAME;
59 }
60 }