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.HTTPCLIENT_TEST;
8 import static com.atlassian.plugins.codegen.modules.Dependencies.MOCKITO_TEST;
9
10
11
12
13 @JiraPluginModuleCreator
14 public class WorkflowValidatorModuleCreator extends AbstractPluginModuleCreator<WorkflowElementProperties>
15 {
16 public static final String MODULE_NAME = "Workflow Validator";
17 private static final String TEMPLATE_PREFIX = "templates/jira/workflow/validator/";
18
19
20 private static final String FACTORY_TEMPLATE = TEMPLATE_PREFIX + "WorkflowValidatorFactory.java.vtl";
21 private static final String CLASS_TEMPLATE = TEMPLATE_PREFIX + "WorkflowValidator.java.vtl";
22 private static final String UNIT_TEST_TEMPLATE = TEMPLATE_PREFIX + "WorkflowValidatorTest.java.vtl";
23 private static final String VIEW_TEMPLATE = TEMPLATE_PREFIX + "workflow-validator.vm.vtl";
24 private static final String INPUT_TEMPLATE = TEMPLATE_PREFIX + "workflow-validator-input.vm.vtl";
25 private static final String TEMPLATE_PATH = "validators";
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-validator-plugin.xml.vtl";
31
32 @Override
33 public PluginProjectChangeset createModule(WorkflowElementProperties props) throws Exception
34 {
35 PluginProjectChangeset ret = new PluginProjectChangeset()
36 .with(HTTPCLIENT_TEST,
37 MOCKITO_TEST)
38 .with(createModule(props, PLUGIN_MODULE_TEMPLATE));
39
40 if (props.includeExamples())
41 {
42 return ret.with(createClass(props, EXAMPLE_CLASS_TEMPLATE));
43 }
44 else
45 {
46 String moduleKey = props.getModuleKey();
47 String viewFileName = moduleKey + ".vm";
48 String inputFileName = moduleKey + "-input.vm";
49 return ret.with(createClassAndTests(props, CLASS_TEMPLATE, UNIT_TEST_TEMPLATE))
50 .with(createClass(props, props.getFactoryClassId(), FACTORY_TEMPLATE))
51 .with(createTemplateResource(props, TEMPLATE_PATH, viewFileName, VIEW_TEMPLATE))
52 .with(createTemplateResource(props, TEMPLATE_PATH, inputFileName, INPUT_TEMPLATE));
53 }
54 }
55
56 @Override
57 public String getModuleName()
58 {
59 return MODULE_NAME;
60 }
61 }