1 /*
2 * Copyright 2010 Fraunhofer Gesellschaft, Munich, Germany,
3 * for its Fraunhofer Institute for Computer Architecture and Software
4 * Technology (FIRST), Berlin, Germany. All rights reserved.
5 * http://www.first.fraunhofer.de/
6 */
7
8 package net.kwfgrid.gwes.workflowgenerator;
9
10 import net.kwfgrid.gworkflowdl.structure.Workflow;
11 import net.kwfgrid.gworkflowdl.structure.Factory;
12 import net.kwfgrid.gworkflowdl.structure.JdomString;
13 import net.kwfgrid.gwes.Constants;
14
15 import java.io.IOException;
16
17 /**
18 * Abstract class to be extended to implement workflow generators.
19 * @author Andreas Hoheisel
20 * (<a href="http://www.andreas-hoheisel.de">www.andreas-hoheisel.de</a>)
21 * @version $Id: WorkflowGenerator.java 1532 2011-06-23 15:57:53Z hoheisel $
22 */
23 public abstract class WorkflowGenerator {
24
25 /**
26 * The workflow object. Will be created by the constructor of this abstract class and filled by the constructors of
27 * implementing classes.
28 */
29 protected final Workflow workflow;
30
31 /**
32 * The type of the workflow, e.g., "GWorkflowDL version 2.1".
33 */
34 protected final String workflowType;
35
36 /**
37 * Constructor that generates an empty workflow with a specific description.
38 * Use <code>super(description)</code> in all constructors that extend this abstract class.
39 * @param description The human-readable workflow description.
40 */
41 protected WorkflowGenerator(String description) {
42 workflow = Factory.newWorkflow();
43 workflow.setDescription(description);
44 workflowType = Constants.WORKFLOW_DESCRIPTION_TYPE_DEFAULT;
45 }
46
47 /**
48 * Get the workflow object.
49 * @return The workflow.
50 */
51 public Workflow getWorkflow() {
52 return workflow;
53 }
54
55 /**
56 * Get the type of the workflow, e.g., "GWorkflowDL version 2.1".
57 * @return The type of the workflow as String.
58 */
59 public String getWorkflowType() {
60 return workflowType;
61 }
62
63 /**
64 * Get the workflow identifier.
65 * @return The workflow identifier.
66 */
67 public String getWorkflowID() {
68 return workflow.getID();
69 }
70
71 /**
72 * Convert the generated workflow to XML.
73 * @return A string with the XML of the workflow.
74 * @throws IOException
75 */
76 public String getXML() throws IOException {
77 return JdomString.workflow2string(workflow);
78 }
79
80 }