[jbpm-commits] JBoss JBPM SVN: r2534 - in jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server: dao and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Oct 14 05:30:22 EDT 2008
Author: heiko.braun at jboss.com
Date: 2008-10-14 05:30:22 -0400 (Tue, 14 Oct 2008)
New Revision: 2534
Added:
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DiagramDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/DiagramInfoParser.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockDiagramDAO.java
Removed:
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/jbpm3/
Modified:
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DAOFactory.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockDAOFactory.java
Log:
Package restructuring
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java 2008-10-14 09:17:32 UTC (rev 2533)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java 2008-10-14 09:30:22 UTC (rev 2534)
@@ -21,7 +21,7 @@
*/
package org.jboss.bpm.console.server;
-import org.jboss.bpm.console.server.jbpm3.JBPM3Management;
+import org.jboss.bpm.console.server.JBPM3Management;
import javax.ws.rs.core.Application;
import java.util.HashSet;
Copied: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java (from rev 2533, jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/jbpm3/JBPM3Management.java)
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java 2008-10-14 09:30:22 UTC (rev 2534)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.console.server;
+
+import org.jboss.bpm.console.client.model.jbpm3.ActiveNodeInfo;
+import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
+import org.jboss.bpm.console.server.dao.DAOFactory;
+import org.jboss.bpm.console.server.dao.ProcessDAO;
+import org.jboss.bpm.console.server.dao.DiagramDAO;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at Path("jbpm3")
+public class JBPM3Management
+{
+ private DiagramDAO diagramDAO = null;
+ private ProcessDAO processDAO = null;
+
+ private ProcessDAO getProcessDAO(HttpServletRequest request)
+ {
+ if(null==this.processDAO)
+ {
+ DAOFactory factory = DAOFactory.newInstance(request.getSession().getServletContext());
+ this.processDAO = factory.createProcessDAO();
+ }
+
+ return this.processDAO;
+
+ }
+
+ private DiagramDAO getDiagramDAO(HttpServletRequest request)
+ {
+ if(null==this.diagramDAO)
+ {
+ DAOFactory factory = DAOFactory.newInstance(request.getSession().getServletContext());
+ this.diagramDAO = factory.createDiagramDAO();
+ }
+
+ return this.diagramDAO;
+
+ }
+
+ @GET
+ @Path("definitions/{id}/image")
+ @Produces("image/jpeg")
+ public Response getProcessImage(
+ @PathParam("id")
+ long id,
+ @Context
+ HttpServletRequest request
+ )
+ {
+ byte[] image = getDiagramDAO(request).getProcessImage(id);
+ if(null==image)
+ return Response.serverError().build();
+ else
+ return Response.ok(image).type("image/jpeg").build();
+ }
+
+ @GET
+ @Path("definitions/{id}/diagramInfo")
+ @Produces("application/json")
+ public DiagramInfo getDiagramInfo(
+ @PathParam("id")
+ long id,
+ @Context
+ HttpServletRequest request
+ )
+ {
+ return getDiagramDAO(request).getDiagramInfo(id);
+ }
+
+ @GET
+ @Path("instances/{id}/activeNodeInfo")
+ @Produces("application/json")
+ public ActiveNodeInfo getActiveNodeInfo(
+ @PathParam("id")
+ long id,
+ @Context
+ HttpServletRequest request
+ )
+ {
+ return getDiagramDAO(request).getActivNodeInfo(getProcessDAO(request), id);
+ }
+
+}
Property changes on: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DAOFactory.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DAOFactory.java 2008-10-14 09:17:32 UTC (rev 2533)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DAOFactory.java 2008-10-14 09:30:22 UTC (rev 2534)
@@ -21,7 +21,7 @@
*/
package org.jboss.bpm.console.server.dao;
-import org.jboss.bpm.console.server.jbpm3.dao.DiagramDAO;
+import org.jboss.bpm.console.server.dao.DiagramDAO;
import javax.servlet.ServletContext;
Copied: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DiagramDAO.java (from rev 2533, jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/jbpm3/dao/DiagramDAO.java)
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DiagramDAO.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DiagramDAO.java 2008-10-14 09:30:22 UTC (rev 2534)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.console.server.dao;
+
+import org.jboss.bpm.console.client.model.jbpm3.ActiveNodeInfo;
+import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
+import org.jboss.bpm.console.server.dao.ProcessDAO;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public interface DiagramDAO
+{
+ byte[] getProcessImage(long processId);
+
+ DiagramInfo getDiagramInfo(long processId);
+
+ ActiveNodeInfo getActivNodeInfo(ProcessDAO processDAO, long instanceId);
+}
Property changes on: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/DiagramDAO.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/DiagramInfoParser.java (from rev 2533, jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/jbpm3/dao/internal/DiagramInfoParser.java)
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/DiagramInfoParser.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/DiagramInfoParser.java 2008-10-14 09:30:22 UTC (rev 2534)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.console.server.dao.internal;
+
+import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
+import org.jboss.bpm.console.client.model.jbpm3.DiagramNodeInfo;
+import org.jbpm.util.XmlUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+class DiagramInfoParser
+{
+ /**
+ * Will close the stream after successfull read
+ * @param in
+ * @return
+ */
+ public static DiagramInfo parse(InputStream in )
+ {
+ Document document = XmlUtil.parseXmlInputStream(in);
+ Element processDiagramElement = document.getDocumentElement();
+ final String widthString = processDiagramElement.getAttribute("width");
+ final String heightString = processDiagramElement.getAttribute("height");
+ final List<DiagramNodeInfo> diagramNodeInfoList = new ArrayList<DiagramNodeInfo>();
+ final NodeList nodeNodeList = processDiagramElement.getElementsByTagName("node");
+ final int nodeNodeListLength = nodeNodeList.getLength();
+ for (int i = 0; i < nodeNodeListLength; i ++) {
+ final Node nodeNode = nodeNodeList.item(i);
+ if (nodeNode instanceof Node && nodeNode.getParentNode() == processDiagramElement) {
+ final Element nodeElement = (Element) nodeNode;
+ final String nodeName = nodeElement.getAttribute("name");
+ final String nodeXString = nodeElement.getAttribute("x");
+ final String nodeYString = nodeElement.getAttribute("y");
+ final String nodeWidthString = nodeElement.getAttribute("width");
+ final String nodeHeightString = nodeElement.getAttribute("height");
+ final DiagramNodeInfo nodeInfo = new DiagramNodeInfo(
+ nodeName,
+ Integer.parseInt(nodeXString),
+ Integer.parseInt(nodeYString),
+ Integer.parseInt(nodeWidthString),
+ Integer.parseInt(nodeHeightString)
+ );
+ diagramNodeInfoList.add(nodeInfo);
+ }
+ }
+ DiagramInfo diagramInfo = new DiagramInfo(
+ Integer.parseInt(heightString),
+ Integer.parseInt(widthString),
+ diagramNodeInfoList
+ );
+
+ try
+ {
+ in.close();
+ } catch (IOException e)
+ {
+ throw new RuntimeException("Failed to close stream", e);
+ }
+
+ return diagramInfo;
+ }
+}
Property changes on: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/DiagramInfoParser.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockDAOFactory.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockDAOFactory.java 2008-10-14 09:17:32 UTC (rev 2533)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockDAOFactory.java 2008-10-14 09:30:22 UTC (rev 2534)
@@ -23,8 +23,8 @@
import org.jboss.bpm.console.server.dao.DAOFactory;
import org.jboss.bpm.console.server.dao.ProcessDAO;
-import org.jboss.bpm.console.server.jbpm3.dao.DiagramDAO;
-import org.jboss.bpm.console.server.jbpm3.dao.internal.MockDiagramDAO;
+import org.jboss.bpm.console.server.dao.DiagramDAO;
+import org.jboss.bpm.console.server.dao.internal.MockDiagramDAO;
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
Copied: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockDiagramDAO.java (from rev 2533, jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/jbpm3/dao/internal/MockDiagramDAO.java)
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockDiagramDAO.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockDiagramDAO.java 2008-10-14 09:30:22 UTC (rev 2534)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.console.server.dao.internal;
+
+import org.jboss.bpm.console.client.model.ProcessInstance;
+import org.jboss.bpm.console.client.model.jbpm3.ActiveNodeInfo;
+import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
+import org.jboss.bpm.console.client.model.jbpm3.DiagramNodeInfo;
+import org.jboss.bpm.console.server.dao.ProcessDAO;
+import org.jboss.bpm.console.server.dao.DiagramDAO;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class MockDiagramDAO implements DiagramDAO
+{
+
+ public byte[] getProcessImage(long processId)
+ {
+ byte[] imageBytes = null;
+
+ try
+ {
+ InputStream in = MockDiagramDAO.class.getResourceAsStream("1.jpg");
+ if(null==in)
+ throw new IllegalArgumentException("Failed to load image resource");
+ imageBytes = new byte[in.available()];
+ in.read(imageBytes);
+
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+
+ return imageBytes;
+ }
+
+ public DiagramInfo getDiagramInfo(long processId)
+ {
+ InputStream in = MockDiagramDAO.class.getResourceAsStream("gpd.xml");
+ if(null==in)
+ throw new IllegalArgumentException("Failed to load diagram info");
+
+ return DiagramInfoParser.parse(in);
+ }
+
+ public ActiveNodeInfo getActivNodeInfo(ProcessDAO processDAO, long instanceId)
+ {
+
+ ProcessInstance pi = processDAO.getInstanceById(instanceId);
+ DiagramInfo diagram = getDiagramInfo(pi.getParentId());
+ List<DiagramNodeInfo> nodes = diagram.getNodeList();
+
+ DiagramNodeInfo activeNode = null;
+ int i = 0;
+ for(DiagramNodeInfo n : nodes)
+ {
+ // TODO: Fake. Actually this should retrieve the active node
+ if(i==1)
+ {
+ activeNode = n;
+ break;
+ }
+
+ i++;
+
+ }
+
+ if(null==activeNode)
+ throw new RuntimeException("Failed to retrieve active node for instanceId " + instanceId);
+
+ return new ActiveNodeInfo(diagram.getWidth(), diagram.getHeight(), activeNode);
+ }
+}
Property changes on: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockDiagramDAO.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the jbpm-commits
mailing list