Anonymous avatar Anonymous committed 8d3c387

Initial import from SourceForge

Comments (0)

Files changed (2)

src/java/com/opensymphony/workflow/loader/AbstractDescriptor.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.workflow.loader;
+
+import com.opensymphony.workflow.util.XMLizable;
+
+import java.io.Serializable;
+
+
+/**
+ * User: hani
+ * Date: May 28, 2003
+ * Time: 12:44:54 AM
+ */
+public abstract class AbstractDescriptor implements XMLizable, Serializable {
+    //~ Instance fields ////////////////////////////////////////////////////////
+
+    private AbstractDescriptor parent;
+    private boolean hasId = false;
+    private int id;
+
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    public void setId(int id) {
+        this.id = id;
+        hasId = true;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setParent(AbstractDescriptor parent) {
+        this.parent = parent;
+    }
+
+    public AbstractDescriptor getParent() {
+        return parent;
+    }
+
+    public boolean hasId() {
+        return hasId;
+    }
+}

src/java/com/opensymphony/workflow/loader/WorkflowSerializer.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.workflow.loader;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStreamWriter;
+
+
+/**
+ * DOCUMENT ME!
+ *
+ * @author $author$
+ * @version $Revision: 1.1.1.1 $
+ */
+public class WorkflowSerializer {
+    //~ Instance fields ////////////////////////////////////////////////////////
+
+    private VelocityEngine engine;
+
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    public byte[] generateWorkflowXML(WorkflowDescriptor wf) throws Exception {
+        initVelocity();
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        OutputStreamWriter writer = new OutputStreamWriter(baos);
+        Template template = engine.getTemplate("workflowtemplate.vm");
+        VelocityContext ctx = new VelocityContext();
+        ctx.put("workflow", wf);
+        template.merge(ctx, writer);
+        writer.flush();
+        baos.flush();
+
+        return baos.toByteArray();
+    }
+
+    protected void initVelocity() throws Exception {
+        if (engine == null) {
+            engine = new VelocityEngine();
+            engine.setProperty("resource.loader", "class");
+            engine.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
+            engine.init();
+        }
+    }
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.