PageRenderTime 19ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/plugin-module-codegen-engine/src/main/java/com/atlassian/plugins/codegen/modules/jira/WorkflowConditionModuleCreator.java

https://bitbucket.org/mmeinhold/amps
Java | 60 lines | 45 code | 10 blank | 5 comment | 1 complexity | 93dc85c892cea354c8a617ff1568918b MD5 | raw file
 1package com.atlassian.plugins.codegen.modules.jira;
 2
 3import com.atlassian.plugins.codegen.PluginProjectChangeset;
 4import com.atlassian.plugins.codegen.annotations.JiraPluginModuleCreator;
 5import com.atlassian.plugins.codegen.modules.AbstractPluginModuleCreator;
 6
 7import static com.atlassian.plugins.codegen.modules.Dependencies.MOCKITO_TEST;
 8
 9/**
10 * @since 3.6
11 */
12@JiraPluginModuleCreator
13public 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    //stub
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    //examples
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            .with(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}