diff --git a/config/alfresco/messages/jbpm.properties b/config/alfresco/messages/jbpm.properties new file mode 100644 index 0000000000..e994165d7f --- /dev/null +++ b/config/alfresco/messages/jbpm.properties @@ -0,0 +1,13 @@ +processDefinitionsList=Process Definitions List +searchProcessInstances=Search Process Instances +processDefinitions=Process Definitions +variableName=Variable Name +variableValue=Variable Value +search=Search +id=Id +name=Name +version=Version +instances=Instances +start=Start +end=End +value=Value \ No newline at end of file diff --git a/config/alfresco/web-client-config.xml b/config/alfresco/web-client-config.xml index 222a21777e..b7f6543b71 100644 --- a/config/alfresco/web-client-config.xml +++ b/config/alfresco/web-client-config.xml @@ -193,7 +193,9 @@ description="My Documents Template Page" jsp="/jsp/dashboards/dashlets/my-docs.jsp" allow-narrow="true" /> + jsp="/jbpm/task_list.jsp" allow-narrow="true" /> + taskInstances = taskMgmtSession.findTaskInstances(userBean.getUserName()); + for (TaskInstance taskInstance : taskInstances) + { + taskInstance.getName(); + taskInstance.getTaskMgmtInstance().getTaskMgmtDefinition().getProcessDefinition().getName(); + } + return taskInstances; + } + finally + { + if (xjbpmContext == null) jbpmContext.close(); + } + } + + public DataModel getTaskInstancesModel() + { + if (taskInstances == null) + { + taskInstances = new ListDataModel(getTaskInstances()); + } + return taskInstances; + } + + public List getLatestProcessDefinitions() + { + JbpmContext xjbpmContext = config.getCurrentJbpmContext(); + JbpmContext jbpmContext = (xjbpmContext == null) ? config.createJbpmContext() : xjbpmContext; + try + { + GraphSession graphSession = jbpmContext.getGraphSession(); + List procDefs = graphSession.findLatestProcessDefinitions(); + for (ProcessDefinition procDef : procDefs) + { + procDef.getName(); + Task startTask = procDef.getTaskMgmtDefinition().getStartTask(); + if (startTask != null) + { + startTask.getName(); + } + } + return procDefs; + } + finally + { + if (xjbpmContext == null) jbpmContext.close(); + } + } + + public DataModel getLatestProcessDefinitionsModel() + { + if (processDefs == null) + { + processDefs = new ListDataModel(getLatestProcessDefinitions()); + } + return processDefs; + } + + /** + * selects a task. + */ + public String selectTaskInstance() + { + JbpmContext xjbpmContext = config.getCurrentJbpmContext(); + JbpmContext jbpmContext = (xjbpmContext == null) ? config.createJbpmContext() : xjbpmContext; + + try + { + // Get the task instance id from request parameter + TaskInstance selectedTask = (TaskInstance)taskInstances.getRowData(); + long taskInstanceId = selectedTask.getId(); + TaskMgmtSession taskMgmtSession = jbpmContext.getTaskMgmtSession(); + TaskInstance taskInstance = taskMgmtSession.loadTaskInstance(taskInstanceId); + taskBean.initialize(taskInstance); + + return "task"; + } + finally + { + taskInstances = null; + processDefs = null; + if (xjbpmContext == null ) jbpmContext.close(); + } + } + + /** + * prepares a task form for starting a new process instance. + */ + public String startProcessInstance() + { + JbpmContext xjbpmContext = config.getCurrentJbpmContext(); + JbpmContext jbpmContext = (xjbpmContext == null) ? config.createJbpmContext() : xjbpmContext; + try + { + jbpmContext.setActorId(AuthenticationUtil.getCurrentUserName()); + + // Get the task instance id from request parameter + ProcessDefinition selectedProc = (ProcessDefinition)processDefs.getRowData(); + long processDefinitionId = selectedProc.getId(); + GraphSession graphSession = jbpmContext.getGraphSession(); + ProcessDefinition processDefinition = graphSession.loadProcessDefinition(processDefinitionId); + + // create a new process instance to run + ProcessInstance processInstance = new ProcessInstance(processDefinition); + + // create a new taskinstance for the start task + Task startTask = processInstance.getTaskMgmtInstance().getTaskMgmtDefinition().getStartTask(); + if (startTask != null) + { + TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance(); + taskBean.initialize(taskInstance); + } + + // Save the process instance along with the task instance + jbpmContext.save(processInstance); + + // Fill the task backing bean with useful information + return (startTask == null) ? "home" : "task"; + } + finally + { + if (xjbpmContext == null) jbpmContext.close(); + taskInstances = null; + processDefs = null; + } + } + + public UserBean getUserBean() { + return userBean; + } + public void setUserBean(UserBean userBean) { + this.userBean = userBean; + } + public TaskBean getTaskBean() { + return taskBean; + } + public void setTaskBean(TaskBean taskBean) { + this.taskBean = taskBean; + } +} diff --git a/source/java/org/jbpm/webapp/bean/JsfHelper.java b/source/java/org/jbpm/webapp/bean/JsfHelper.java new file mode 100644 index 0000000000..1d287d1b2b --- /dev/null +++ b/source/java/org/jbpm/webapp/bean/JsfHelper.java @@ -0,0 +1,61 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.bean; + +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; + +public class JsfHelper { + + public static long getId(String parameterName) { + long value = -1; + String valueText = (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(parameterName); + try { + Long id = new Long(valueText); + value = id.longValue(); + } catch (NumberFormatException e) { + throw new RuntimeException("couldn't parse '"+parameterName+"'='"+valueText+"' as a long"); + } + return value; + } + + public static void addMessage(String msg) { + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(msg)); + } + + public static void setSessionAttribute(String key, Object value) { + FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(key, value); + } + + public static Object getSessionAttribute(String key) { + return FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(key); + } + + public static void removeSessionAttribute(String key) { + FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove(key); + } + + public static String getParameter(String name) { + return (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(name); + } + // private static final Log log = LogFactory.getLog(JsfHelper.class); +} diff --git a/source/java/org/jbpm/webapp/bean/MonitoringBean.java b/source/java/org/jbpm/webapp/bean/MonitoringBean.java new file mode 100644 index 0000000000..2d1d254883 --- /dev/null +++ b/source/java/org/jbpm/webapp/bean/MonitoringBean.java @@ -0,0 +1,228 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.bean; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; +import java.util.ListIterator; + +import javax.faces.context.FacesContext; +import javax.faces.model.SelectItem; + +import org.jbpm.JbpmContext; +import org.jbpm.graph.def.ProcessDefinition; + + +/** + * Monitoring Bean Implementation. + * + * @author David Loiseau + */ + +public class MonitoringBean { + + long processInstanceId; + String message; + String variableName; + String variableValue; + String variableNameOperator; + String variableValueOperator; + ArrayList processInstances; + + public String showProcessDefinitions() { + return "processDefinitions"; + } + + public List getProcessDefinitions() { + + ArrayList processDefinitionsList = new ArrayList(); + + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + List processDefinitions = jbpmContext.getGraphSession().findAllProcessDefinitions(); + + if (processDefinitions.isEmpty() == false) { + ListIterator listProcessDefinitions = processDefinitions.listIterator(); + while (listProcessDefinitions.hasNext() ) { + ProcessDefinition processDefinition = (ProcessDefinition)listProcessDefinitions.next(); + + int instancesCount = 0; + try { + Connection connection = jbpmContext.getConnection(); + Statement statement = connection.createStatement(); + + String request = "SELECT COUNT(*) AS instancesCount " + + "FROM jbpm_processinstance " + + "WHERE processdefinition_='" + + processDefinition.getId() + "'"; + ResultSet resultSet = statement.executeQuery(request); + resultSet.next(); + instancesCount = resultSet.getInt("instancesCount"); + } + catch (Exception e) {} + + processDefinitionsList.add( + new ProcessDefinitionBean( + processDefinition.getId(), + processDefinition.getName(), + processDefinition.getVersion(), + instancesCount + )); + } + } + + return(processDefinitionsList); + } + + public String inspectInstance() { + try { + ProcessInstanceBean processInstanceBean = new ProcessInstanceBean(this.processInstanceId); + FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("processInstanceBean", processInstanceBean); + this.message = ""; + return "inspectInstance"; + } + catch (Exception exception) { + this.message = "Error for process instance " + this.processInstanceId; + return ""; + } + } + + public String showSearchInstances() { + return("showSearchInstances"); + } + + public String searchInstances() { + + long count = 0; + + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + + try { + Connection connection = jbpmContext.getConnection(); + Statement statement = connection.createStatement(); + statement.setMaxRows(100); + + String request = "SELECT DISTINCT processinstance_, name_, stringvalue_ FROM jbpm_variableinstance " + + "WHERE name_ " + + this.variableNameOperator + " '" + + variableName + "' AND stringvalue_ " + + this.variableValueOperator + " '" + variableValue + "'"; + + ResultSet resultSet = statement.executeQuery(request); + + processInstances = new ArrayList(); + + while (resultSet.next()) { + processInstances.add(new ProcessInstanceBean( + resultSet.getLong("processinstance_"), + resultSet.getString("name_"), + resultSet.getString("stringvalue_"))); + count++; + } + statement.close(); + } + catch (Exception e) { + this.message = "Search error " + e.getMessage(); + } + + if (count == 1) { + ProcessInstanceBean processInstanceBean = (ProcessInstanceBean)processInstances.iterator().next(); + FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("processInstanceBean", processInstanceBean); + return("inspectInstance"); + } + return ""; + } + + public List getOperatorsList (){ + + ArrayList operatorsList = new ArrayList(); + + SelectItem item = new SelectItem("=", "is equal to"); + operatorsList.add(item); + item = new SelectItem("like", "is like"); + operatorsList.add(item); + return operatorsList; + + } + + public long getProcessInstanceId() { + return processInstanceId; + } + + public void setProcessInstanceId(long processInstanceId) { + this.processInstanceId = processInstanceId; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isShowProcessInstances() { + if (processInstances == null) return false; + if (processInstances.size() == 0) return false; + return true; + } + + public ArrayList getProcessInstances() { + return processInstances; + } + + public String getVariableName() { + return variableName; + } + + public void setVariableName(String variableName) { + this.variableName = variableName; + } + + public String getVariableValue() { + return variableValue; + } + + public void setVariableValue(String variableValue) { + this.variableValue = variableValue; + } + + public String getVariableNameOperator() { + return variableNameOperator; + } + + public void setVariableNameOperator(String variableNameOperator) { + this.variableNameOperator = variableNameOperator; + } + + public String getVariableValueOperator() { + return variableValueOperator; + } + + public void setVariableValueOperator(String variableValueOperator) { + this.variableValueOperator = variableValueOperator; + } + + +} diff --git a/source/java/org/jbpm/webapp/bean/ProcessDefinitionBean.java b/source/java/org/jbpm/webapp/bean/ProcessDefinitionBean.java new file mode 100644 index 0000000000..e78fa6fe09 --- /dev/null +++ b/source/java/org/jbpm/webapp/bean/ProcessDefinitionBean.java @@ -0,0 +1,141 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.bean; + +import java.util.ArrayList; +import java.util.List; +import java.util.ListIterator; + +import javax.faces.context.FacesContext; + +import org.jbpm.JbpmContext; +import org.jbpm.db.GraphSession; +import org.jbpm.graph.def.ProcessDefinition; +import org.jbpm.graph.exe.ProcessInstance; + +/** + * Process Definition Bean Implementation. + * + * @author David Loiseau + */ + +public class ProcessDefinitionBean { + + String name; + int version; + long id; + int instancesCount; + + public ProcessDefinitionBean() { + } + + public ProcessDefinitionBean(long id) { + this.id = id; + initialize(); + } + + public ProcessDefinitionBean(long id, String name, int version, int instancesCount) { + this.id = id; + this.name = name; + this.version = version; + this.instancesCount = instancesCount; + } + + private void initialize() { + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + GraphSession graphSession = jbpmContext.getGraphSession(); + ProcessDefinition processDefinition = graphSession.loadProcessDefinition(id); + this.name = processDefinition.getName(); + this.version = processDefinition.getVersion(); + this.instancesCount = graphSession.findProcessInstances(this.id).size(); + } + + public List getProcessInstances() { + + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + GraphSession graphSession = jbpmContext.getGraphSession(); + + ArrayList processInstancesList = new ArrayList(); + + List listProcessInstance = graphSession.findProcessInstances(this.id); + + if (listProcessInstance.isEmpty() == false) { + ListIterator listProcessInstances = listProcessInstance.listIterator(); + while (listProcessInstances.hasNext()) { + ProcessInstance processInstance = (ProcessInstance) listProcessInstances.next(); + + processInstancesList.add(new ProcessInstanceBean(processInstance.getId(), processInstance.getStart(), processInstance.getEnd())); + } + } + + return processInstancesList; + } + + public String showProcessInstances() { + ProcessDefinitionBean processDefinitionBean = new ProcessDefinitionBean(); + processDefinitionBean.setId(this.id); + FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("processDefinitionBean", processDefinitionBean); + return ("processInstances"); + } + + public String startProcessInstance() { + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + GraphSession graphSession = jbpmContext.getGraphSession(); + ProcessDefinition processDefinition = graphSession.loadProcessDefinition(getId()); + processDefinition.createInstance(); + return showProcessInstances(); + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + this.initialize(); + } + + public int getInstancesCount() { + return instancesCount; + } + + public void setInstancesCount(int instancesCount) { + this.instancesCount = instancesCount; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + +} diff --git a/source/java/org/jbpm/webapp/bean/ProcessInstanceBean.java b/source/java/org/jbpm/webapp/bean/ProcessInstanceBean.java new file mode 100644 index 0000000000..334eeb64c7 --- /dev/null +++ b/source/java/org/jbpm/webapp/bean/ProcessInstanceBean.java @@ -0,0 +1,420 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.bean; + +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.Map.Entry; + +import javax.faces.context.FacesContext; + +import org.jbpm.JbpmContext; +import org.jbpm.db.GraphSession; +import org.jbpm.db.TaskMgmtSession; +import org.jbpm.graph.def.Transition; +import org.jbpm.graph.exe.ProcessInstance; +import org.jbpm.graph.exe.Token; +import org.jbpm.taskmgmt.exe.TaskInstance; + +/** + * Process Instance Bean Implementation. + * + * @author David Loiseau + */ + +public class ProcessInstanceBean { + + long id; + String processDefinitionLabel; + long processDefinitionId; + Date start; + Date end; + + ArrayList tokens; + ArrayList variables; + ArrayList tasks; + ArrayList transitions; + + String variableName; + String variableValue; + + long tokenInstanceId; + long taskInstanceId; + + public ProcessInstanceBean(long id, Date start, Date end) { + this.id = id; + this.start = start; + this.end = end; + } + + public ProcessInstanceBean(long id) { + this.id = id; + this.initialize(); + } + + public ProcessInstanceBean(long id, String variableName, String variableValue) { + this.id = id; + this.variableName = variableName; + this.variableValue = variableValue; + this.initialize(); + } + + public String inspectProcessInstance() { + ProcessInstanceBean processInstanceBean = new ProcessInstanceBean(this.id); + FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("processInstanceBean", processInstanceBean); + return ("inspectInstance"); + } + + public String deleteProcessInstance() { + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + GraphSession graphSession = jbpmContext.getGraphSession(); + graphSession.deleteProcessInstance(this.id); + return ("deleteInstance"); + } + + private void initialize() { + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + GraphSession graphSession = jbpmContext.getGraphSession(); + ProcessInstance processInstance = graphSession.loadProcessInstance(this.id); + this.start = processInstance.getStart(); + this.end = processInstance.getEnd(); + this.processDefinitionId = processInstance.getProcessDefinition().getId(); + this.processDefinitionLabel = processInstance.getProcessDefinition().getName() + " (version " + processInstance.getProcessDefinition().getVersion() + ")"; + + initializeVariablesList(processInstance); + initializeTokensList(processInstance); + initializeTasksList(processInstance); + } + + private void initializeAvailableTransitions(TaskInstance taskInstance) { + + transitions = new ArrayList(); + + if (taskInstance.getAvailableTransitions().isEmpty() == false) { + Iterator availableTransitionsIterator = taskInstance.getAvailableTransitions().iterator(); + while (availableTransitionsIterator.hasNext()) { + Transition transition = (Transition) availableTransitionsIterator.next(); + transitions.add(transition); + + } + } + } + + private void initializeAvailableTransitions(Token token) { + + transitions = new ArrayList(); + + if (token.getNode().getLeavingTransitions().isEmpty() == false) { + Iterator availableTransitionsIterator = token.getNode().getLeavingTransitions().iterator(); + while (availableTransitionsIterator.hasNext()) { + Transition transition = (Transition) availableTransitionsIterator.next(); + transitions.add(transition); + + } + } + } + + private void initializeVariablesList(ProcessInstance processInstance) { + + // Variables list + variables = new ArrayList(); + + if (processInstance.getContextInstance().getVariables() != null && !processInstance.getContextInstance().getVariables().values().isEmpty()) { + int mapsize = processInstance.getContextInstance().getVariables().size(); + Iterator variablesIterator = processInstance.getContextInstance().getVariables().entrySet().iterator(); + for (int i = 0; i < mapsize; i++) { + Entry entry = (Entry) variablesIterator.next(); + variables.add(new VariableBean((String) entry.getKey(), entry.getValue())); + } + } + + } + + private void initializeTasksList(ProcessInstance processInstance) { + + // Tasks list + tasks = new ArrayList(); + if (processInstance.getTaskMgmtInstance().getTaskInstances().isEmpty() == false) { + Iterator tasksIterator = processInstance.getTaskMgmtInstance().getTaskInstances().iterator(); + while (tasksIterator.hasNext()) { + TaskInstance taskInstance = (TaskInstance) tasksIterator.next(); + tasks.add(new TaskBean(taskInstance.getId(), taskInstance.getName(), taskInstance.getActorId(), taskInstance.getEnd())); + } + } + + } + + private void initializeTokensList(ProcessInstance processInstance) { + + // Tokens list + Token rootToken = processInstance.getRootToken(); + + tokens = new ArrayList(); + this.tokenInstanceId = rootToken.getId(); + this.taskInstanceId = 0; + tokens.add(new TokenBean(rootToken.getId(), "Root", rootToken.getNode().getName(), rootToken.getNode().getClass().getName(), rootToken.getStart(), + rootToken.getEnd(), 1)); + try { + if (rootToken.getChildren().isEmpty() == false) { + AddChildrenTokensToTokensList(this.tokens, rootToken, 2); + } + } catch (Exception exception) { + } + + } + + /** + * + * Add token childs to the current token beans list + * + * @param tokensList + * Current token list to update + * @param token + * Token where are the token childs + * @param level + * Level where is the token: 1 for the root token, 2 for the childs + * of the root token, ... + */ + private void AddChildrenTokensToTokensList(ArrayList tokensList, Token token, long level) { + + Iterator childrenIterator = token.getChildren().values().iterator(); + while (childrenIterator.hasNext()) { + Token childToken = (Token) childrenIterator.next(); + tokensList.add(new TokenBean(childToken.getId(), childToken.getName(), childToken.getNode().getName(), childToken.getNode().getClass().getName(), + childToken.getStart(), childToken.getEnd(), level)); + try { + if (childToken.getChildren().isEmpty() == false) { + AddChildrenTokensToTokensList(tokensList, childToken, level + 1); + } + } catch (Exception exception) { + } + } + } + + public String updateVariable() { + + if (this.variableName != null) { + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + GraphSession graphSession = jbpmContext.getGraphSession(); + ProcessInstance processInstance = graphSession.loadProcessInstance(this.id); + if (this.variableValue != null) { + processInstance.getContextInstance().setVariable(this.variableName, this.variableValue); + } else { + processInstance.getContextInstance().deleteVariable(this.variableName); + } + initializeVariablesList(processInstance); + } + return "inspectInstance"; + } + + public String selectToken() { + this.taskInstanceId = 0; + this.tokenInstanceId = JsfHelper.getId("tokenInstanceId"); + return ""; + } + + public String selectTask() { + this.tokenInstanceId = 0; + this.taskInstanceId = JsfHelper.getId("taskInstanceId"); + return ""; + } + + public String signal() { + + selectToken(); + + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + GraphSession graphSession = jbpmContext.getGraphSession(); + + Token token = graphSession.loadToken(this.tokenInstanceId); + + if (token.getNode().getLeavingTransitions().size() > 1) { + initializeAvailableTransitions(token); + return "showTransitions"; + } + + token.signal(); + + this.initializeTokensList(token.getProcessInstance()); + + return "inspectInstance"; + } + + public String selectTransition() { + String transitionName; + + transitionName = JsfHelper.getParameter("transitionName"); + ProcessInstance processInstance = null; + + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + if (this.taskInstanceId > 0) { + TaskMgmtSession taskMgmtSession = jbpmContext.getTaskMgmtSession(); + TaskInstance taskInstance = taskMgmtSession.loadTaskInstance(this.taskInstanceId); + if (transitionName.equals("")) { + taskInstance.end(); + } else { + taskInstance.end(transitionName); + } + processInstance = taskInstance.getToken().getProcessInstance(); + } else if (this.tokenInstanceId > 0) { + GraphSession graphSession = jbpmContext.getGraphSession(); + Token token = graphSession.loadToken(this.tokenInstanceId); + if (transitionName.equals("")) { + token.signal(); + } else { + token.signal(transitionName); + } + processInstance = token.getProcessInstance(); + } + + jbpmContext.save(processInstance); + + this.initializeTasksList(processInstance); + this.initializeTokensList(processInstance); + + return "inspectInstance"; + } + + public String endTask() { + + selectTask(); + + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + TaskMgmtSession taskMgmtSession = jbpmContext.getTaskMgmtSession(); + + TaskInstance taskInstance = taskMgmtSession.loadTaskInstance(this.taskInstanceId); + + if (taskInstance.getAvailableTransitions().size() > 1) { + initializeAvailableTransitions(taskInstance); + return "showTransitions"; + } + + taskInstance.end(); + + ProcessInstance processInstance = taskInstance.getToken().getProcessInstance(); + jbpmContext.save(processInstance); + + this.initializeTasksList(processInstance); + this.initializeTokensList(processInstance); + + return "inspectInstance"; + } + + // Show all the process instances for a given process definition ID + public String showProcessInstances() { + ProcessDefinitionBean processDefinitionBean = new ProcessDefinitionBean(this.processDefinitionId); + FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("processDefinitionBean", processDefinitionBean); + return ("processInstances"); + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public Date getStart() { + return start; + } + + public void setStart(Date start) { + this.start = start; + } + + public Date getEnd() { + return end; + } + + public void setEnd(Date end) { + this.end = end; + } + + public ArrayList getTokens() { + return tokens; + } + + public void setTokens(ArrayList tokens) { + this.tokens = tokens; + } + + public String getProcessDefinitionLabel() { + return processDefinitionLabel; + } + + public void setProcessDefinitionLabel(String processDefinitionLabel) { + this.processDefinitionLabel = processDefinitionLabel; + } + + public ArrayList getVariables() { + return variables; + } + + public ArrayList getTasks() { + return tasks; + } + + public ArrayList getTransitions() { + return transitions; + } + + public void setVariables(ArrayList variables) { + this.variables = variables; + } + + public String getVariableName() { + return variableName; + } + + public void setVariableName(String variableName) { + this.variableName = variableName; + } + + public String getVariableValue() { + return variableValue; + } + + public void setVariableValue(String variableValue) { + this.variableValue = variableValue; + } + + public long getTokenInstanceId() { + return tokenInstanceId; + } + + public void setTokenInstanceId(long tokenInstanceId) { + this.taskInstanceId = 0; + this.tokenInstanceId = tokenInstanceId; + } + + public long getTaskInstanceId() { + return taskInstanceId; + } + + public void setTaskInstanceId(long taskInstanceId) { + this.tokenInstanceId = 0; + this.taskInstanceId = taskInstanceId; + } + +} diff --git a/source/java/org/jbpm/webapp/bean/TaskBean.java b/source/java/org/jbpm/webapp/bean/TaskBean.java new file mode 100644 index 0000000000..dba4ffbe5f --- /dev/null +++ b/source/java/org/jbpm/webapp/bean/TaskBean.java @@ -0,0 +1,269 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.bean; + +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; + +import javax.faces.model.DataModel; +import javax.faces.model.ListDataModel; +import javax.faces.model.SelectItem; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jbpm.JbpmContext; +import org.jbpm.context.def.VariableAccess; +import org.jbpm.graph.def.Transition; +import org.jbpm.graph.exe.ProcessInstance; +import org.jbpm.logging.exe.LoggingInstance; +import org.jbpm.taskmgmt.def.TaskController; +import org.jbpm.taskmgmt.exe.TaskInstance; +import org.jbpm.taskmgmt.log.TaskAssignLog; + +public class TaskBean { + + UserBean userBean = null; + List taskFormParameters; + List availableTransitions; + List availableTransitionItems; + TaskInstance taskInstance; + long taskInstanceId; + DataModel transitions; + +// JbpmContext jbpmContext; +// GraphSession graphSession; +// TaskMgmtSession taskMgmtSession; + + // For monitoring purposes + String name; + String actorId; + Date end; + + public TaskBean() { +// this.jbpmContext = JbpmContext.getCurrentJbpmContext(); +// this.graphSession = jbpmContext.getGraphSession(); +// this.taskMgmtSession = jbpmContext.getTaskMgmtSession(); + + // get the parameters from the session +// this.taskFormParameters = (List) JsfHelper.getSessionAttribute("taskFormParameters"); + } + + public TaskBean(long taskInstanceId, String name, String actorId, Date end) { + this.taskInstanceId = taskInstanceId; + this.name = name; + this.actorId = actorId; + this.end = end; + } + + public void initialize(TaskInstance taskInstance) { + this.taskInstance = taskInstance; + this.taskInstanceId = taskInstance.getId(); + + // set the parameters + this.taskFormParameters = new ArrayList(); + TaskController taskController = taskInstance.getTask().getTaskController(); + if (taskController!=null) { + List variableAccesses = taskController.getVariableAccesses(); + Iterator iter = variableAccesses.iterator(); + while (iter.hasNext()) { + VariableAccess variableAccess = (VariableAccess) iter.next(); + String mappedName = variableAccess.getMappedName(); + Object value = taskInstance.getVariable(mappedName); + TaskFormParameter tfp = new TaskFormParameter(variableAccess, value); + taskFormParameters.add(tfp); + } + } + + // store the parameters in the session + //JsfHelper.setSessionAttribute("taskFormParameters", taskFormParameters); + + // get the available transitions + availableTransitions = null; + + availableTransitions = taskInstance.getAvailableTransitions(); + if ((availableTransitions != null) && (availableTransitions.size() <= 1)) { + transitions = null; + availableTransitions = null; + availableTransitionItems = null; + } else { + transitions = new ListDataModel(availableTransitions); + availableTransitionItems = new ArrayList(); + Iterator iter = availableTransitions.iterator(); + while (iter.hasNext()) { + Transition transition = (Transition) iter.next(); + SelectItem transitionItem = new SelectItem(); + transitionItem.setValue(transition.getName()); + transitionItem.setLabel(transition.getName()); + transitionItem.setDisabled(false); + availableTransitionItems.add(transitionItem); + } + } + + log.debug("initialized availableTransitions " + availableTransitions); + } + + public String save() { + log.debug("saving the task parameters " + taskFormParameters); + + // submit the parameters in the jbpm task controller + TaskInstance taskInstance = JbpmContext.getCurrentJbpmContext().getTaskMgmtSession().loadTaskInstance(taskInstanceId); + + // collect the parameter values from the values that were updated in the + // parameters by jsf. + Iterator iter = taskFormParameters.iterator(); + while (iter.hasNext()) { + TaskFormParameter taskFormParameter = (TaskFormParameter) iter.next(); + + if ((taskFormParameter.isWritable()) && (taskFormParameter.getValue() != null)) { + log.debug("submitting [" + taskFormParameter.getLabel() + "]=" + taskFormParameter.getValue()); + taskInstance.setVariable(taskFormParameter.getLabel(), taskFormParameter.getValue()); + } else { + log.debug("ignoring unwritable [" + taskFormParameter.getLabel() + "]"); + } + } + + // save the process instance and hence the updated task instance variables + JbpmContext.getCurrentJbpmContext().save(taskInstance); + + // remove the parameters from the session + //JsfHelper.removeSessionAttribute("taskFormParameters"); + + return "home"; + } + + public String saveAndClose() { + // save + save(); + + TaskInstance taskInstance = JbpmContext.getCurrentJbpmContext().getTaskMgmtSession().loadTaskInstance(taskInstanceId); + + // close the task instance + if (transitions == null) + { + taskInstance.end(); + } + else + { + Transition selectedTransition = (Transition)transitions.getRowData(); + taskInstance.end(selectedTransition.getName()); + } + + ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance(); + if (processInstance.hasEnded()) { + JsfHelper.addMessage("The process has finished."); + } + + LoggingInstance loggingInstance = processInstance.getLoggingInstance(); + List assignmentLogs = loggingInstance.getLogs(TaskAssignLog.class); + + log.debug("assignmentlogs: " + assignmentLogs); + + if (assignmentLogs.size() == 1) { + TaskAssignLog taskAssignLog = (TaskAssignLog) assignmentLogs.get(0); + JsfHelper.addMessage("A new task has been assigned to '" + taskAssignLog.getTaskNewActorId() + "'"); + + } else if (assignmentLogs.size() > 1) { + String msg = "New tasks have been assigned to: "; + Iterator iter = assignmentLogs.iterator(); + while (iter.hasNext()) { + TaskAssignLog taskAssignLog = (TaskAssignLog) iter.next(); + msg += taskAssignLog.getActorId(); + if (iter.hasNext()) + msg += ", "; + } + msg += "."; + JsfHelper.addMessage(msg); + } + + JbpmContext.getCurrentJbpmContext().save(taskInstance); + + return "home"; + } + + public long getTaskInstanceId() { + return taskInstanceId; + } + public void setTaskInstanceId(long taskInstanceId) { + this.taskInstanceId = taskInstanceId; + } + public UserBean getUserBean() { + return userBean; + } + public void setUserBean(UserBean userBean) { + this.userBean = userBean; + } + public List getTaskFormParameters() { + return taskFormParameters; + } + + public DataModel getTransitions() + { + return transitions; + } + + public List getAvailableTransitions() { + return availableTransitions; + } + public void setAvailableTransitions(List availableTransitions) { + this.availableTransitions = availableTransitions; + } + public List getAvailableTransitionItems() { + return availableTransitionItems; + } + public TaskInstance getTaskInstance() { + return taskInstance; + } + + private static final Log log = LogFactory.getLog(TaskBean.class); + + public String getActorId() { + return actorId; + } + + public void setActorId(String actorId) { + this.actorId = actorId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Date getEnd() { + return end; + } + + public void setEnd(Date end) { + this.end = end; + } + + public boolean isEnded() { + if (end == null) + return true; + return false; + } +} diff --git a/source/java/org/jbpm/webapp/bean/TaskFormParameter.java b/source/java/org/jbpm/webapp/bean/TaskFormParameter.java new file mode 100644 index 0000000000..c3de976756 --- /dev/null +++ b/source/java/org/jbpm/webapp/bean/TaskFormParameter.java @@ -0,0 +1,109 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.bean; + +import java.io.Serializable; + +import org.hibernate.Session; +import org.jbpm.context.def.VariableAccess; +import org.jbpm.taskmgmt.exe.TaskInstance; + +public class TaskFormParameter implements Serializable { + + private static final long serialVersionUID = 1L; + + protected String label = null; + protected String description = null; + protected Object value = null; + protected boolean isReadable = true; + protected boolean isWritable = true; + protected boolean isRequired = true; + + public TaskFormParameter() { + } + + public TaskFormParameter(VariableAccess variableAccess, Object value) { + this.label = variableAccess.getMappedName(); + this.value = value; + this.isReadable = variableAccess.isReadable(); + this.isWritable = variableAccess.isWritable(); + this.isRequired = variableAccess.isRequired(); + } + + public TaskFormParameter(TaskFormParameter other) { + this.label = other.label; + this.description = other.description; + this.value = other.value; + this.isReadable = other.isReadable; + this.isWritable = other.isWritable; + this.isRequired = other.isRequired; + } + + public static TaskFormParameter create(TaskInstance instance, String name, Object value, Session session) { + TaskFormParameter taskFormParameter = null; + return taskFormParameter; + } + + public String toString() { + return "("+label+","+value+")"; + } + + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public boolean isReadable() { + return isReadable; + } + public void setReadable(boolean isReadable) { + this.isReadable = isReadable; + } + public boolean isRequired() { + return isRequired; + } + public void setRequired(boolean isRequired) { + this.isRequired = isRequired; + } + public boolean isWritable() { + return isWritable; + } + public boolean isReadOnly() { + return !isWritable; + } + public void setWritable(boolean isWritable) { + this.isWritable = isWritable; + } + public String getLabel() { + return label; + } + public void setLabel(String label) { + this.label = label; + } + public Object getValue() { + return value; + } + public void setValue(Object value) { + this.value = value; + } +} diff --git a/source/java/org/jbpm/webapp/bean/TokenBean.java b/source/java/org/jbpm/webapp/bean/TokenBean.java new file mode 100644 index 0000000000..ba85f8c1a0 --- /dev/null +++ b/source/java/org/jbpm/webapp/bean/TokenBean.java @@ -0,0 +1,125 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.bean; + +import java.util.Date; + +/** + * Token Bean Implementation. + * + * @author David Loiseau + */ + +public class TokenBean { + + long id; + String name; + String nodeName; + String nodeClassName; + Date start; + Date end; + long level; + + public TokenBean(long id, String name, String nodeName, String nodeClassName, Date start, Date end, long level) { + + this.id = id; + this.name = name; + this.nodeName = nodeName; + this.nodeClassName = nodeClassName; + this.start = start; + this.end = end; + this.level = level; + } + + private String getTypeNameFromClassName(String className) { + String typeName = ""; + if (className.indexOf(".") > 0) { + typeName = className.substring(className.lastIndexOf(".") + 1); + } + return typeName; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLabel() { + String label = ""; + int i = 1; + while (i < this.level) { + label = label + "---"; + i++; + } + if (i > 1) + label = label + " "; + label = label + this.name; + + return label; + } + + public String getNodeName() { + return nodeName; + } + + public void setNodeName(String nodeName) { + this.nodeName = nodeName; + } + + public Date getEnd() { + return end; + } + + public void setEnd(Date end) { + this.end = end; + } + + public Date getStart() { + return start; + } + + public void setStart(Date start) { + this.start = start; + } + + public String getNodeType() { + return getTypeNameFromClassName(this.nodeClassName); + } + + public boolean isSignal() { + if (this.end == null) + return true; + return false; + } + +} diff --git a/source/java/org/jbpm/webapp/bean/UserBean.java b/source/java/org/jbpm/webapp/bean/UserBean.java new file mode 100644 index 0000000000..f5ecd333e7 --- /dev/null +++ b/source/java/org/jbpm/webapp/bean/UserBean.java @@ -0,0 +1,77 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.bean; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.faces.model.SelectItem; + +import org.hibernate.Session; +import org.jbpm.JbpmContext; +import org.jbpm.identity.User; +import org.jbpm.identity.hibernate.IdentitySession; + +public class UserBean { + + String userName; + + public String getUserName() { + return userName; + } + + public void setUserName(String name) { + this.userName = name; + } + + public String login() { + JbpmContext.getCurrentJbpmContext().setActorId(userName); + return "home"; + } + + public List getUsers() { + Session session = JbpmContext.getCurrentJbpmContext().getSession(); + IdentitySession identitySession = new IdentitySession(session); + return identitySession.getUsers(); + } + + public List getUserSelectItems() { + List userSelectItems = new ArrayList(); + + Iterator iter = getUsers().iterator(); + while (iter.hasNext()) { + User user = (User) iter.next(); + userSelectItems.add(new UserSelectItem(user)); + } + + return userSelectItems; + } + + public static class UserSelectItem extends SelectItem { + private static final long serialVersionUID = 1L; + public UserSelectItem(User user) { + setValue(user.getName()); + setLabel(user.getName()); + } + } +} diff --git a/source/java/org/jbpm/webapp/bean/VariableBean.java b/source/java/org/jbpm/webapp/bean/VariableBean.java new file mode 100644 index 0000000000..eefd7b2500 --- /dev/null +++ b/source/java/org/jbpm/webapp/bean/VariableBean.java @@ -0,0 +1,55 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.bean; + +/** + * Variable Bean Implementation. + * + * @author David Loiseau + */ + +public class VariableBean { + + String name; + Object value; + + public VariableBean(String name, Object value) { + this.name = name; + this.value = value; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } +} diff --git a/source/java/org/jbpm/webapp/context/BpmContext.java b/source/java/org/jbpm/webapp/context/BpmContext.java new file mode 100644 index 0000000000..c8c18babdf --- /dev/null +++ b/source/java/org/jbpm/webapp/context/BpmContext.java @@ -0,0 +1,44 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.context; + +import org.jbpm.graph.def.ProcessDefinition; +import org.jbpm.taskmgmt.exe.TaskInstance; + +public class BpmContext { + + ProcessDefinition processDefinition; + TaskInstance taskInstance; + + public ProcessDefinition getProcessDefinition() { + return processDefinition; + } + public void setProcessDefinition(ProcessDefinition processDefinition) { + this.processDefinition = processDefinition; + } + public TaskInstance getTaskInstance() { + return taskInstance; + } + public void setTaskInstance(TaskInstance taskInstance) { + this.taskInstance = taskInstance; + } +} diff --git a/source/java/org/jbpm/webapp/context/Context.java b/source/java/org/jbpm/webapp/context/Context.java new file mode 100644 index 0000000000..89b54a1840 --- /dev/null +++ b/source/java/org/jbpm/webapp/context/Context.java @@ -0,0 +1,60 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.context; + +import java.util.HashMap; +import java.util.Map; + +public class Context { + + static ThreadLocal contextsThreadLocal = new ThreadLocal(); + + public static void create() { + contextsThreadLocal.set(new HashMap()); + } + + public static void destroy() { + contextsThreadLocal.set(null); + } + + public static Object getContext(Class clazz) { + Map contexts = (Map) contextsThreadLocal.get(); + Object context = contexts.get(clazz); + if (context==null) { + try { + context = clazz.newInstance(); + contexts.put(clazz, context); + } catch (Exception e) { + throw new RuntimeException("couldn't instantiate context '"+clazz.getName()+"'"); + } + } + return context; + } + + public static PersistenceContext getPersistenceContext() { + return (PersistenceContext) getContext(PersistenceContext.class); + } + + public static BpmContext getBpmContext() { + return (BpmContext) getContext(BpmContext.class); + } +} diff --git a/source/java/org/jbpm/webapp/context/PersistenceContext.java b/source/java/org/jbpm/webapp/context/PersistenceContext.java new file mode 100644 index 0000000000..0cb090c8d6 --- /dev/null +++ b/source/java/org/jbpm/webapp/context/PersistenceContext.java @@ -0,0 +1,83 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.context; + +import javax.naming.InitialContext; +import javax.rmi.PortableRemoteObject; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.hibernate.SessionFactory; +import org.jbpm.db.JbpmSession; +import org.jbpm.db.JbpmSessionFactory; +import org.jbpm.identity.hibernate.IdentitySession; + +public class PersistenceContext { + + static String jndiName = "java:/jbpm/SessionFactory"; + static JbpmSessionFactory jbpmSessionFactory = null; + static { + try { + InitialContext initialContext = new InitialContext(); + Object o = initialContext.lookup(jndiName); + SessionFactory sessionFactory = (SessionFactory) PortableRemoteObject.narrow(o, SessionFactory.class); + jbpmSessionFactory = new JbpmSessionFactory(null, sessionFactory); + } catch (Exception e) { + throw new RuntimeException("couldn't get the hibernate session factory from jndi entry '"+jndiName+"'", e); + } + } + + boolean isRollbackOnly; + JbpmSession jbpmSession; + IdentitySession identitySession; + + public void beginTransaction() { + isRollbackOnly = false; + log.debug("beginning transaction"); + jbpmSession = jbpmSessionFactory.openJbpmSessionAndBeginTransaction(); + identitySession = new IdentitySession(jbpmSession.getSession()); + } + + public void endTransaction() { + if (isRollbackOnly) { + log.debug("rolling back transaction"); + jbpmSession.rollbackTransactionAndClose(); + } else { + log.debug("committing transaction"); + jbpmSession.commitTransactionAndClose(); + } + } + + public void setRollbackOnly() { + isRollbackOnly = true; + } + + public IdentitySession getIdentitySession() { + return identitySession; + } + + public JbpmSession getJbpmSession() { + return jbpmSession; + } + + private static final Log log = LogFactory.getLog(PersistenceContext.class); +} diff --git a/source/java/org/jbpm/webapp/filter/AuthenticationFilter.java b/source/java/org/jbpm/webapp/filter/AuthenticationFilter.java new file mode 100644 index 0000000000..4f93dac993 --- /dev/null +++ b/source/java/org/jbpm/webapp/filter/AuthenticationFilter.java @@ -0,0 +1,60 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.filter; + +import java.io.IOException; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.jbpm.JbpmContext; +import org.jbpm.webapp.bean.UserBean; + +public class AuthenticationFilter implements Filter { + + public void init(FilterConfig filterConfig) throws ServletException { + } + + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { + HttpServletRequest request = (HttpServletRequest) servletRequest; + HttpSession session = request.getSession(); + UserBean userBean = null; + if (session!=null) { + userBean = (UserBean) session.getAttribute("userBean"); + } + if (userBean!=null) { + String actorId = userBean.getUserName(); + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + jbpmContext.setActorId(actorId); + } + filterChain.doFilter(servletRequest, servletResponse); + } + + public void destroy() { + } +} diff --git a/source/java/org/jbpm/webapp/filter/JbpmContextFilter.java b/source/java/org/jbpm/webapp/filter/JbpmContextFilter.java new file mode 100644 index 0000000000..b2ab089369 --- /dev/null +++ b/source/java/org/jbpm/webapp/filter/JbpmContextFilter.java @@ -0,0 +1,88 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.filter; + +import java.io.IOException; +import java.io.Serializable; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.TransactionUtil; +import org.alfresco.service.transaction.TransactionService; +import org.jbpm.JbpmConfiguration; +import org.jbpm.JbpmContext; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +public class JbpmContextFilter implements Filter, Serializable +{ + + private static final long serialVersionUID = 1L; + + private ServletContext context; + + public void init(FilterConfig filterConfig) throws ServletException + { + this.context = filterConfig.getServletContext(); + } + + public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) + throws IOException, ServletException + { + WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(context); + final JbpmConfiguration jbpmConfig = (JbpmConfiguration) wc.getBean("jbpm_configuration"); + TransactionService trx = (TransactionService) wc.getBean("TransactionService"); + + TransactionUtil.executeInUserTransaction(trx, new TransactionUtil.TransactionWork() + { + public Object doWork() throws Exception + { + JbpmContext jbpmContext = jbpmConfig.createJbpmContext(); + try + { + String actorId = AuthenticationUtil.getCurrentUserName(); + if (actorId != null) + { + jbpmContext.setActorId(actorId); + } + filterChain.doFilter(servletRequest, servletResponse); + } + finally + { + jbpmContext.close(); + } + return null; + } + }); + } + + public void destroy() + { + } +} diff --git a/source/java/org/jbpm/webapp/filter/LogFilter.java b/source/java/org/jbpm/webapp/filter/LogFilter.java new file mode 100644 index 0000000000..4cfa8db033 --- /dev/null +++ b/source/java/org/jbpm/webapp/filter/LogFilter.java @@ -0,0 +1,69 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.filter; + +import java.io.IOException; +import java.util.Enumeration; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class LogFilter implements Filter { + + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { + HttpServletRequest request = (HttpServletRequest) servletRequest; + + log.debug("request "+request.getRequestURL()); + + Enumeration enumeration = request.getParameterNames(); + while (enumeration.hasMoreElements()) { + String paramName = (String) enumeration.nextElement(); + log.debug("request parameter ["+paramName+"]="+request.getParameter(paramName)); + } + + HttpSession session = request.getSession(); + enumeration = session.getAttributeNames(); + while (enumeration.hasMoreElements()) { + String attributeName = (String) enumeration.nextElement(); + log.debug("session parameter ["+attributeName+"]="+session.getAttribute(attributeName)); + } + + filterChain.doFilter(servletRequest, servletResponse); + } + + public void init(FilterConfig filterConfig) throws ServletException { + } + + public void destroy() { + } + + private static final Log log = LogFactory.getLog(LogFilter.class); +} diff --git a/source/java/org/jbpm/webapp/servlet/DeployServlet.java b/source/java/org/jbpm/webapp/servlet/DeployServlet.java new file mode 100644 index 0000000000..d6df976170 --- /dev/null +++ b/source/java/org/jbpm/webapp/servlet/DeployServlet.java @@ -0,0 +1,68 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.servlet; + +import java.io.IOException; +import java.io.PrintWriter; +import java.net.URL; +import java.util.zip.ZipInputStream; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jbpm.JbpmContext; +import org.jbpm.graph.def.ProcessDefinition; + +/** + * servlet to be used by the process designer to deploy processes. + */ +public class DeployServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + String archive = request.getParameter("archive"); + log.debug("deploying archive "+archive); + + PrintWriter writer = response.getWriter(); + try { + URL archiveUrl = new URL(archive); + ZipInputStream zis = new ZipInputStream(archiveUrl.openStream()); + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + ProcessDefinition processDefinition = ProcessDefinition.parseParZipInputStream(zis); + jbpmContext.deployProcessDefinition(processDefinition); + zis.close(); + + writer.write("Deployed archive "+archive+" successfully"); + + } catch (Exception e) { + e.printStackTrace(); + writer.write("Deploying archive "+archive+" failed"); + } + } + + private static Log log = LogFactory.getLog(DeployServlet.class); +} diff --git a/source/java/org/jbpm/webapp/servlet/ProcessImageServlet.java b/source/java/org/jbpm/webapp/servlet/ProcessImageServlet.java new file mode 100644 index 0000000000..85146b8d8d --- /dev/null +++ b/source/java/org/jbpm/webapp/servlet/ProcessImageServlet.java @@ -0,0 +1,55 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.servlet; + +import java.io.IOException; +import java.io.OutputStream; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.jbpm.JbpmContext; +import org.jbpm.graph.def.ProcessDefinition; + +public class ProcessImageServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + long processDefinitionId = Long.parseLong( request.getParameter( "definitionId" ) ); + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + ProcessDefinition processDefinition = jbpmContext.getGraphSession().loadProcessDefinition(processDefinitionId); + byte[] bytes = processDefinition.getFileDefinition().getBytes("processimage.jpg"); + OutputStream out = response.getOutputStream(); + out.write(bytes); + out.flush(); + + // leave this in. it is in case we want to set the mime type later. + // get the mime type + // String contentType = URLConnection.getFileNameMap().getContentTypeFor( fileName ); + // set the content type (=mime type) + // response.setContentType( contentType ); + } +} diff --git a/source/java/org/jbpm/webapp/servlet/UploadServlet.java b/source/java/org/jbpm/webapp/servlet/UploadServlet.java new file mode 100644 index 0000000000..6947436eb4 --- /dev/null +++ b/source/java/org/jbpm/webapp/servlet/UploadServlet.java @@ -0,0 +1,119 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.servlet; + +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.zip.ZipInputStream; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.fileupload.DiskFileUpload; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileUpload; +import org.apache.commons.fileupload.FileUploadException; +import org.apache.commons.fileupload.ParameterParser; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jbpm.JbpmContext; +import org.jbpm.graph.def.ProcessDefinition; + +public class UploadServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + + private class GPDUpload extends DiskFileUpload + { + + @Override + protected byte[] getBoundary(String contentType) + { + return super.getBoundary(contentType.replace(",", ";")); + } + } + + + public void service(HttpServletRequest request, HttpServletResponse response) + throws IOException { + response.setContentType("text/html"); + response.getWriter().println(handleRequest(request)); + } + + public void printInput(HttpServletRequest request) throws IOException { + InputStream inputStream = request.getInputStream(); + StringBuffer buffer = new StringBuffer(); + int read; + while ((read = inputStream.read()) != -1) { + buffer.append((char)read); + } + log.debug(buffer.toString()); + } + + private String handleRequest(HttpServletRequest request) { + if (!FileUpload.isMultipartContent(request)) { + log.debug("Not a multipart request"); + return "Not a multipart request"; + } + try { + GPDUpload fileUpload = new GPDUpload(); + List list = fileUpload.parseRequest(request); + Iterator iterator = list.iterator(); + if (!iterator.hasNext()) { + log.debug("No process file in the request"); + return "No process file in the request"; + } + FileItem fileItem = (FileItem)iterator.next(); + if (fileItem.getContentType().indexOf("application/x-zip-compressed") == -1) { + log.debug("Not a process archive"); + return "Not a process archive"; + } + return doDeployment(fileItem); + } catch (FileUploadException e) { + e.printStackTrace(); + return "FileUploadException"; + } + } + + private String doDeployment(FileItem fileItem) { + try { + ZipInputStream zipInputStream = new ZipInputStream(fileItem.getInputStream()); + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + ProcessDefinition processDefinition = ProcessDefinition.parseParZipInputStream(zipInputStream); + log.debug("Created a processdefinition : " + processDefinition.getName() ); + jbpmContext.deployProcessDefinition(processDefinition); + zipInputStream.close(); + return "Deployed archive " + processDefinition.getName() + " successfully"; + } catch (IOException e) { + return "IOException"; + } + } + + private static Log log = LogFactory.getLog(UploadServlet.class); + +} \ No newline at end of file diff --git a/source/java/org/jbpm/webapp/tag/ProcessImageTag.java b/source/java/org/jbpm/webapp/tag/ProcessImageTag.java new file mode 100644 index 0000000000..5eaf9ffd63 --- /dev/null +++ b/source/java/org/jbpm/webapp/tag/ProcessImageTag.java @@ -0,0 +1,244 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt 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.jbpm.webapp.tag; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.JspWriter; +import javax.servlet.jsp.tagext.TagSupport; + +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.dom4j.XPath; +import org.dom4j.xpath.DefaultXPath; +import org.jbpm.JbpmContext; +import org.jbpm.file.def.FileDefinition; +import org.jbpm.graph.def.ProcessDefinition; +import org.jbpm.graph.exe.Token; +import org.jbpm.taskmgmt.exe.TaskInstance; + +public class ProcessImageTag extends TagSupport { + + private static final long serialVersionUID = 1L; + private long taskInstanceId = -1; + private long tokenInstanceId = -1; + + private byte[] gpdBytes = null; + private byte[] imageBytes = null; + private Token currentToken = null; + private ProcessDefinition processDefinition = null; + + static String currentTokenColor = "red"; + static String childTokenColor = "blue"; + static String tokenNameColor = "blue"; + + + public void release() { + taskInstanceId = -1; + gpdBytes = null; + imageBytes = null; + currentToken = null; + } + + public int doEndTag() throws JspException { + try { + initialize(); + retrieveByteArrays(); + if (gpdBytes != null && imageBytes != null) { + writeTable(); + } + } catch (IOException e) { + e.printStackTrace(); + throw new JspException("table couldn't be displayed", e); + } catch (DocumentException e) { + e.printStackTrace(); + throw new JspException("table couldn't be displayed", e); + } + release(); + return EVAL_PAGE; + } + + private void retrieveByteArrays() { + try { + FileDefinition fileDefinition = processDefinition.getFileDefinition(); + gpdBytes = fileDefinition.getBytes("gpd.xml"); + imageBytes = fileDefinition.getBytes("processimage.jpg"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void writeTable() throws IOException, DocumentException { + + int borderWidth = 4; + Element rootDiagramElement = DocumentHelper.parseText(new String(gpdBytes)).getRootElement(); + int[] boxConstraint; + int[] imageDimension = extractImageDimension(rootDiagramElement); + String imageLink = "/alfresco/processimage?definitionId=" + processDefinition.getId(); + JspWriter jspOut = pageContext.getOut(); + + if (tokenInstanceId > 0) { + + List allTokens = new ArrayList(); + walkTokens(currentToken, allTokens); + + jspOut.println("
"); + + for (int i = 0; i < allTokens.size(); i++) + { + Token token = (Token) allTokens.get(i); + + //check how many tokens are on teh same level (= having the same parent) + int offset = i; + if(i > 0) { + while(offset > 0 && ((Token) allTokens.get(offset - 1)).getParent().equals(token.getParent())) { + offset--; + } + } + boxConstraint = extractBoxConstraint(rootDiagramElement, token); + + //Adjust for borders + //boxConstraint[2]-=borderWidth*2; + //boxConstraint[3]-=borderWidth*2; + + jspOut.println("
"); + + if(token.getName()!=null) + { + jspOut.println(" " + token.getName() +""); + } + + jspOut.println("
"); + } + jspOut.println("
"); + } + else + { + boxConstraint = extractBoxConstraint(rootDiagramElement); + + jspOut.println(""); + jspOut.println(" "); + jspOut.println(" "); + jspOut.println(" "); + jspOut.println("
"); + jspOut.println(" "); + jspOut.println(" "); + jspOut.println(" "); + jspOut.println(" "); + jspOut.println(" "); + jspOut.println(" "); + jspOut.println(" "); + jspOut.println(" "); + jspOut.println("
 
"); + jspOut.println("
"); + } + } + + private int[] extractBoxConstraint(Element root) { + int[] result = new int[4]; + String nodeName = currentToken.getNode().getName(); + XPath xPath = new DefaultXPath("//node[@name='" + nodeName + "']"); + Element node = (Element) xPath.selectSingleNode(root); + result[0] = Integer.valueOf(node.attribute("x").getValue()).intValue(); + result[1] = Integer.valueOf(node.attribute("y").getValue()).intValue(); + result[2] = Integer.valueOf(node.attribute("width").getValue()).intValue(); + result[3] = Integer.valueOf(node.attribute("height").getValue()).intValue(); + return result; + } + + private int[] extractBoxConstraint(Element root, Token token) { + int[] result = new int[4]; + String nodeName = token.getNode().getName(); + XPath xPath = new DefaultXPath("//node[@name='" + nodeName + "']"); + Element node = (Element) xPath.selectSingleNode(root); + result[0] = Integer.valueOf(node.attribute("x").getValue()).intValue(); + result[1] = Integer.valueOf(node.attribute("y").getValue()).intValue(); + result[2] = Integer.valueOf(node.attribute("width").getValue()).intValue(); + result[3] = Integer.valueOf(node.attribute("height").getValue()).intValue(); + return result; + } + + private int[] extractImageDimension(Element root) { + int[] result = new int[2]; + result[0] = Integer.valueOf(root.attribute("width").getValue()).intValue(); + result[1] = Integer.valueOf(root.attribute("height").getValue()).intValue(); + return result; + } + + private void initialize() { + JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); + if (this.taskInstanceId > 0) { + TaskInstance taskInstance = jbpmContext.getTaskMgmtSession().loadTaskInstance(taskInstanceId); + currentToken = taskInstance.getToken(); + } + else + { + if (this.tokenInstanceId > 0) + currentToken = jbpmContext.getGraphSession().loadToken(this.tokenInstanceId); + } + processDefinition = currentToken.getProcessInstance().getProcessDefinition(); + } + + private void walkTokens(Token parent, List allTokens) + { + Map children = parent.getChildren(); + if(children != null && children.size() > 0) + { + Collection childTokens = children.values(); + for (Iterator iterator = childTokens.iterator(); iterator.hasNext();) + { + Token child = (Token) iterator.next(); + walkTokens(child, allTokens); + } + } + + allTokens.add(parent); + } + + public void setTask(long id) { + this.taskInstanceId = id; + } + + public void setToken(long id) { + this.tokenInstanceId = id; + } + +} diff --git a/source/web/WEB-INF/c.tld b/source/web/WEB-INF/c.tld new file mode 100644 index 0000000000..22698c97dc --- /dev/null +++ b/source/web/WEB-INF/c.tld @@ -0,0 +1,563 @@ + + + + + JSTL 1.1 core library + JSTL core + 1.1 + c + http://java.sun.com/jsp/jstl/core + + + + Provides core validation features for JSTL tags. + + + org.apache.taglibs.standard.tlv.JstlCoreTLV + + + + + + Catches any Throwable that occurs in its body and optionally + exposes it. + + catch + org.apache.taglibs.standard.tag.common.core.CatchTag + JSP + + +Name of the exported scoped variable for the +exception thrown from a nested action. The type of the +scoped variable is the type of the exception thrown. + + var + false + false + + + + + + Simple conditional tag that establishes a context for + mutually exclusive conditional operations, marked by + <when> and <otherwise> + + choose + org.apache.taglibs.standard.tag.common.core.ChooseTag + JSP + + + + + Simple conditional tag, which evalutes its body if the + supplied condition is true and optionally exposes a Boolean + scripting variable representing the evaluation of this condition + + if + org.apache.taglibs.standard.tag.rt.core.IfTag + JSP + + +The test condition that determines whether or +not the body content should be processed. + + test + true + true + boolean + + + +Name of the exported scoped variable for the +resulting value of the test condition. The type +of the scoped variable is Boolean. + + var + false + false + + + +Scope for var. + + scope + false + false + + + + + + Retrieves an absolute or relative URL and exposes its contents + to either the page, a String in 'var', or a Reader in 'varReader'. + + import + org.apache.taglibs.standard.tag.rt.core.ImportTag + org.apache.taglibs.standard.tei.ImportTEI + JSP + + +The URL of the resource to import. + + url + true + true + + + +Name of the exported scoped variable for the +resource's content. The type of the scoped +variable is String. + + var + false + false + + + +Scope for var. + + scope + false + false + + + +Name of the exported scoped variable for the +resource's content. The type of the scoped +variable is Reader. + + varReader + false + false + + + +Name of the context when accessing a relative +URL resource that belongs to a foreign +context. + + context + false + true + + + +Character encoding of the content at the input +resource. + + charEncoding + false + true + + + + + + The basic iteration tag, accepting many different + collection types and supporting subsetting and other + functionality + + forEach + org.apache.taglibs.standard.tag.rt.core.ForEachTag + org.apache.taglibs.standard.tei.ForEachTEI + JSP + + +Collection of items to iterate over. + + items + false + true + java.lang.Object + + + +If items specified: +Iteration begins at the item located at the +specified index. First item of the collection has +index 0. +If items not specified: +Iteration begins with index set at the value +specified. + + begin + false + true + int + + + +If items specified: +Iteration ends at the item located at the +specified index (inclusive). +If items not specified: +Iteration ends when index reaches the value +specified. + + end + false + true + int + + + +Iteration will only process every step items of +the collection, starting with the first one. + + step + false + true + int + + + +Name of the exported scoped variable for the +current item of the iteration. This scoped +variable has nested visibility. Its type depends +on the object of the underlying collection. + + var + false + false + + + +Name of the exported scoped variable for the +status of the iteration. Object exported is of type +javax.servlet.jsp.jstl.core.LoopTagStatus. This scoped variable has nested +visibility. + + varStatus + false + false + + + + + + Iterates over tokens, separated by the supplied delimeters + + forTokens + org.apache.taglibs.standard.tag.rt.core.ForTokensTag + JSP + + +String of tokens to iterate over. + + items + true + true + java.lang.String + + + +The set of delimiters (the characters that +separate the tokens in the string). + + delims + true + true + java.lang.String + + + +Iteration begins at the token located at the +specified index. First token has index 0. + + begin + false + true + int + + + +Iteration ends at the token located at the +specified index (inclusive). + + end + false + true + int + + + +Iteration will only process every step tokens +of the string, starting with the first one. + + step + false + true + int + + + +Name of the exported scoped variable for the +current item of the iteration. This scoped +variable has nested visibility. + + var + false + false + + + +Name of the exported scoped variable for the +status of the iteration. Object exported is of +type +javax.servlet.jsp.jstl.core.LoopTag +Status. This scoped variable has nested +visibility. + + varStatus + false + false + + + + + + Like <%= ... >, but for expressions. + + out + org.apache.taglibs.standard.tag.rt.core.OutTag + JSP + + +Expression to be evaluated. + + value + true + true + + + +Default value if the resulting value is null. + + default + false + true + + + +Determines whether characters <,>,&,'," in the +resulting string should be converted to their +corresponding character entity codes. Default value is +true. + + escapeXml + false + true + + + + + + + Subtag of <choose> that follows <when> tags + and runs only if all of the prior conditions evaluated to + 'false' + + otherwise + org.apache.taglibs.standard.tag.common.core.OtherwiseTag + JSP + + + + + Adds a parameter to a containing 'import' tag's URL. + + param + org.apache.taglibs.standard.tag.rt.core.ParamTag + JSP + + +Name of the query string parameter. + + name + true + true + + + +Value of the parameter. + + value + false + true + + + + + + Redirects to a new URL. + + redirect + org.apache.taglibs.standard.tag.rt.core.RedirectTag + JSP + + +The URL of the resource to redirect to. + + url + false + true + + + +Name of the context when redirecting to a relative URL +resource that belongs to a foreign context. + + context + false + true + + + + + + Removes a scoped variable (from a particular scope, if specified). + + remove + org.apache.taglibs.standard.tag.common.core.RemoveTag + empty + + +Name of the scoped variable to be removed. + + var + true + false + + + +Scope for var. + + scope + false + false + + + + + + Sets the result of an expression evaluation in a 'scope' + + set + org.apache.taglibs.standard.tag.rt.core.SetTag + JSP + + +Name of the exported scoped variable to hold the value +specified in the action. The type of the scoped variable is +whatever type the value expression evaluates to. + + var + false + false + + + +Expression to be evaluated. + + value + false + true + + + +Target object whose property will be set. Must evaluate to +a JavaBeans object with setter property property, or to a +java.util.Map object. + + target + false + true + + + +Name of the property to be set in the target object. + + property + false + true + + + +Scope for var. + + scope + false + false + + + + + + Creates a URL with optional query parameters. + + url + org.apache.taglibs.standard.tag.rt.core.UrlTag + JSP + + +Name of the exported scoped variable for the +processed url. The type of the scoped variable is +String. + + var + false + false + + + +Scope for var. + + scope + false + false + + + +URL to be processed. + + value + false + true + + + +Name of the context when specifying a relative URL +resource that belongs to a foreign context. + + context + false + true + + + + + + Subtag of <choose> that includes its body if its + condition evalutes to 'true' + + when + org.apache.taglibs.standard.tag.rt.core.WhenTag + JSP + + +The test condition that determines whether or not the +body content should be processed. + + test + true + true + boolean + + + + diff --git a/source/web/WEB-INF/faces-config-jbpm.xml b/source/web/WEB-INF/faces-config-jbpm.xml new file mode 100644 index 0000000000..e31eed4112 --- /dev/null +++ b/source/web/WEB-INF/faces-config-jbpm.xml @@ -0,0 +1,147 @@ + + + + + + userBean + org.jbpm.webapp.bean.AlfrescoUserBean + session + + authenticationService + #{AuthenticationService} + + + + + homeBean + org.jbpm.webapp.bean.HomeBean + session + + taskBean + #{taskBean} + + + userBean + #{userBean} + + + jbpmConfiguration + #{jbpm_configuration} + + + + + taskBean + org.jbpm.webapp.bean.TaskBean + session + + userBean + #{userBean} + + + + + monitoringBean + org.jbpm.webapp.bean.MonitoringBean + session + + + + /jbpm/login.jsp + + home + /jbpm/home.jsp + + + + + /jbpm/home.jsp + + login + /jbpm/login.jsp + + + + + /jbpm/home.jsp + + task + /jbpm/task.jsp + + + + + /jbpm/task.jsp + + login + /jbpm/login.jsp + + + + + /jbpm/task.jsp + + home + /jbpm/home.jsp + + + + + /jsp/dashboards/container.jsp + + task + /jbpm/task_view.jsp + + + + + /jbpm/task_view.jsp + + home + /jsp/dashboards/container.jsp + + + + + /jbpm/monitor.jsp + + processDefinitions + /jbpm/process_definitions.jsp + + + showSearchInstances + /jbpm/search_instances.jsp + + + + + /jbpm/process_definitions.jsp + + processInstances + /jbpm/process_instances.jsp + + + + + /jbpm/inspect_instance.jsp + + processInstances + /jbpm/process_instances.jsp + + + showTransitions + /jbpm/inspect_instance_transitions.jsp + + + + + * + + inspectInstance + /jbpm/inspect_instance.jsp + + + + diff --git a/source/web/WEB-INF/jbpm.tld b/source/web/WEB-INF/jbpm.tld new file mode 100644 index 0000000000..03dd5ce333 --- /dev/null +++ b/source/web/WEB-INF/jbpm.tld @@ -0,0 +1,36 @@ + + + + + + 1.0 + 1.1 + jBPM tags + jBPM tags + + + + processimage + org.jbpm.webapp.tag.ProcessImageTag + empty + + task + true + true + + + + + processimageToken + org.jbpm.webapp.tag.ProcessImageTag + empty + + token + true + true + + + + diff --git a/source/web/WEB-INF/web.xml b/source/web/WEB-INF/web.xml index 45e03798a7..1c78ae4831 100644 --- a/source/web/WEB-INF/web.xml +++ b/source/web/WEB-INF/web.xml @@ -16,7 +16,7 @@ javax.faces.CONFIG_FILES - /WEB-INF/faces-config-app.xml,/WEB-INF/faces-config-beans.xml,/WEB-INF/faces-config-navigation.xml,/WEB-INF/faces-config-common.xml,/WEB-INF/faces-config-repo.xml,WEB-INF/faces-config-custom.xml,/WEB-INF/faces-config-enterprise.xml + /WEB-INF/faces-config-app.xml,/WEB-INF/faces-config-beans.xml,/WEB-INF/faces-config-navigation.xml,/WEB-INF/faces-config-common.xml,/WEB-INF/faces-config-repo.xml,WEB-INF/faces-config-custom.xml,/WEB-INF/faces-config-enterprise.xml,/WEB-INF/faces-config-jbpm.xml @@ -92,6 +92,31 @@ --> + + + + + + + LogFilter + org.jbpm.webapp.filter.LogFilter + + + JbpmContextFilter + org.jbpm.webapp.filter.JbpmContextFilter + + + + + + + + Authentication Filter /faces/* @@ -111,6 +136,42 @@ /webdav/* + + + + + + + LogFilter + /* + + + JbpmContextFilter + /faces/jbpm/* + + + JbpmContextFilter + /processimage + + + JbpmContextFilter + /faces/jsp/dashboards/* + + + JbpmContextFilter + /upload + + + + + + + org.apache.myfaces.webapp.StartupServletContextListener @@ -179,7 +240,40 @@ 5 - + + + + + + + + + + + ProcessImageServlet + org.jbpm.webapp.servlet.ProcessImageServlet + + + + + DeployServlet + org.jbpm.webapp.servlet.DeployServlet + + + UploadServlet + org.jbpm.webapp.servlet.UploadServlet + + + + + + Faces Servlet /faces/* @@ -224,7 +318,39 @@ WebDAV /webdav/* + + + + + + + + + + ProcessImageServlet + /processimage + + + + + DeployServlet + /deploy + + + UploadServlet + /upload + + + + + + 60 @@ -233,4 +359,9 @@ index.jsp + + http://java.sun.com/jsp/jstl/core + /WEB-INF/c.tld + + diff --git a/source/web/jbpm/admin.jsp b/source/web/jbpm/admin.jsp new file mode 100644 index 0000000000..5f614a7d8e --- /dev/null +++ b/source/web/jbpm/admin.jsp @@ -0,0 +1,47 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> + + + +Administration + + + + +TODO + +<%-- +(this page is not yet implemented) + +

Deploy process

+ +    + + + +

Database Schema

+ + + + + + + +

Scheduler

+ + + + + + + + + + + + + + +--%> + +
diff --git a/source/web/jbpm/css/jbpm.css b/source/web/jbpm/css/jbpm.css new file mode 100644 index 0000000000..f835ebc084 --- /dev/null +++ b/source/web/jbpm/css/jbpm.css @@ -0,0 +1,106 @@ +body, td, p { + font-family:verdana; + font-size:10pt; +} + +a { + color: rgb(110, 110, 110); + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +div.nav2 { + background-color:#5c5c4f; + color:#ffffff; + font-size: 12px; + font-weight: bold; + text-decoration: none; + line-height: 12px; + border: 0px; + margin-left: 0px; + margin-right: 1px; + margin-top: 1px; + margin-bottom: 0px; + padding-top:5px; + padding-bottom:5px; + width:174px; + cursor: pointer; +} + +div.innerNav { + position:relative; + left:10px; +} + +a.nav { + font-size: 12px; + font-weight: bold; + text-decoration: none; + line-height: 12px; + width:100%; + background-color:#5c5c4f; + color:#ffffff; + border: 0px; + margin-left: 0px; + margin-right: 1px; + margin-top: 1px; + margin-bottom: 0px; + padding-left:10px; + padding-right:10px; + padding-top:5px; + padding-bottom:5px; +} + +div.nav { + font-size: 12px; + font-weight: bold; + text-decoration: none; + line-height: 12px; + width:174; + background-color:#5c5c4f; + color:#ffffff; + border: 0px; + height: 20px; + margin-left: 0px; + margin-right: 1px; + margin-top: 1px; + margin-bottom: 0px; + vertical-align:middle; + padding-left:10px; + padding-top:5px; + padding-bottom:5px; +} + +a.ref { + padding: 5px; + color: rgb(110, 110, 110); + text-decoration: none; + font-size: 11px; + line-height: 18px; +} + +h1, h2, h3, h4, h5, h6 { + font-family:arial; + color:purple; + border-bottom:0px; + margin-bottom:0px; + padding-bottom:0px; +} + +td.tablecell { + padding-left:10px; + padding-right:10px; + background-color:#eeeeee; +} + +th.tableheader { + text-align:center; + text-weight:bold; + padding-right:10px; + padding-left:10px; + color:#ffffff; + background-color:#999999; +} diff --git a/source/web/jbpm/footer.jsp b/source/web/jbpm/footer.jsp new file mode 100644 index 0000000000..91b78efbf3 --- /dev/null +++ b/source/web/jbpm/footer.jsp @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/source/web/jbpm/header1.jsp b/source/web/jbpm/header1.jsp new file mode 100644 index 0000000000..a16e14b038 --- /dev/null +++ b/source/web/jbpm/header1.jsp @@ -0,0 +1,35 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> +<%@ page import="org.jbpm.webapp.bean.*" %> + + + +JBoss jBPM + + + + + + + + + + + +
JBoss Inc. + + + + + + + + + + +
+
+ Alfresco Web Client    + Docs    + Forums    + Wiki    + Download    + Contact       +
+
+

diff --git a/source/web/jbpm/header2.jsp b/source/web/jbpm/header2.jsp new file mode 100644 index 0000000000..cb865990f7 --- /dev/null +++ b/source/web/jbpm/header2.jsp @@ -0,0 +1,31 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> + +

+
+
+ + + + +
+ + + + + + + +
green side
+ + + +
+
+ + diff --git a/source/web/jbpm/home.jsp b/source/web/jbpm/home.jsp new file mode 100644 index 0000000000..1304beb2f7 --- /dev/null +++ b/source/web/jbpm/home.jsp @@ -0,0 +1,64 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> + + + + +Home + + + + +

Tasklist

+ + + + + + + + + + + + + + + + + + + + + + + +

Start New Process Execution

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/source/web/jbpm/images/hdr_green_side.gif b/source/web/jbpm/images/hdr_green_side.gif new file mode 100644 index 0000000000..ec5d33d88b Binary files /dev/null and b/source/web/jbpm/images/hdr_green_side.gif differ diff --git a/source/web/jbpm/images/logo_green.gif b/source/web/jbpm/images/logo_green.gif new file mode 100644 index 0000000000..3367b78e24 Binary files /dev/null and b/source/web/jbpm/images/logo_green.gif differ diff --git a/source/web/jbpm/images/logo_red.gif b/source/web/jbpm/images/logo_red.gif new file mode 100644 index 0000000000..be6952d16d Binary files /dev/null and b/source/web/jbpm/images/logo_red.gif differ diff --git a/source/web/jbpm/images/logo_yellow.gif b/source/web/jbpm/images/logo_yellow.gif new file mode 100644 index 0000000000..3e4fb26698 Binary files /dev/null and b/source/web/jbpm/images/logo_yellow.gif differ diff --git a/source/web/jbpm/images/side_nav_green_btm.gif b/source/web/jbpm/images/side_nav_green_btm.gif new file mode 100644 index 0000000000..a3db50a6dc Binary files /dev/null and b/source/web/jbpm/images/side_nav_green_btm.gif differ diff --git a/source/web/jbpm/images/spacer.gif b/source/web/jbpm/images/spacer.gif new file mode 100644 index 0000000000..fc2560981e Binary files /dev/null and b/source/web/jbpm/images/spacer.gif differ diff --git a/source/web/jbpm/images/swoosh_green.gif b/source/web/jbpm/images/swoosh_green.gif new file mode 100644 index 0000000000..253b13d6ac Binary files /dev/null and b/source/web/jbpm/images/swoosh_green.gif differ diff --git a/source/web/jbpm/inspect_instance.jsp b/source/web/jbpm/inspect_instance.jsp new file mode 100644 index 0000000000..b159f79943 --- /dev/null +++ b/source/web/jbpm/inspect_instance.jsp @@ -0,0 +1,190 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> +<%@ taglib uri="/WEB-INF/jbpm.tld" prefix="jbpm" %> + +<%@ page isELIgnored="false" %> + + + + + +Inspect Instance + + + + +
+ +: + +
+: + +
+: + + + + + +
+: + + + + + +
+ +
+ +

Tasks

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Variables

+ + + + + + + + + + + + + + + + + + + +
+ + Variable Name: + +
+ Variable Value: + +
+ +
+ +
+ +

Tokens

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + + + +
diff --git a/source/web/jbpm/inspect_instance_transitions.jsp b/source/web/jbpm/inspect_instance_transitions.jsp new file mode 100644 index 0000000000..9a5c01f2a9 --- /dev/null +++ b/source/web/jbpm/inspect_instance_transitions.jsp @@ -0,0 +1,69 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> +<%@ taglib uri="/WEB-INF/jbpm.tld" prefix="jbpm" %> + + + + + +Transitions + + + + +
+: + +
+: + +
+
+ + +
+ +

Available Transitions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + + + + + + +
diff --git a/source/web/jbpm/layout.jsp b/source/web/jbpm/layout.jsp new file mode 100644 index 0000000000..156f99e3b9 --- /dev/null +++ b/source/web/jbpm/layout.jsp @@ -0,0 +1,105 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %> + +<%@ page import="org.jbpm.webapp.bean.*" %> + + + +JBoss jBPM + + + + + + + + + + + + + +
JBoss Inc. + + + + + + + + + + +
+
+ Docs    + Forums    + Wiki    + Download    + Contact       +
+
+

+ + + +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> + +

+
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
green side
green side
+   +
+ swoosh +
+
+ + + + + + +
+
+ + + + diff --git a/source/web/jbpm/monitor.jsp b/source/web/jbpm/monitor.jsp new file mode 100644 index 0000000000..b11d1fa7ee --- /dev/null +++ b/source/web/jbpm/monitor.jsp @@ -0,0 +1,33 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> + + + + + +Monitoring + + + + +
+ +

+ + + + +

+ + + +

+ + Instance ID: + + + + + + +
diff --git a/source/web/jbpm/process_definitions.jsp b/source/web/jbpm/process_definitions.jsp new file mode 100644 index 0000000000..12343e1105 --- /dev/null +++ b/source/web/jbpm/process_definitions.jsp @@ -0,0 +1,54 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> + + + + + +Process Definitions + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/web/jbpm/process_instances.jsp b/source/web/jbpm/process_instances.jsp new file mode 100644 index 0000000000..8f84fdbf82 --- /dev/null +++ b/source/web/jbpm/process_instances.jsp @@ -0,0 +1,71 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> + + + + + +Process Instances + + + + +
+ +: + +
+ +: + +
+ +: + +
+ +
+ +

Instances

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/source/web/jbpm/process_list.jsp b/source/web/jbpm/process_list.jsp new file mode 100644 index 0000000000..89a3db560b --- /dev/null +++ b/source/web/jbpm/process_list.jsp @@ -0,0 +1,28 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> + + +  + +

+ + + + + + + + + + + + + + + + + + + + + diff --git a/source/web/jbpm/process_view.jsp b/source/web/jbpm/process_view.jsp new file mode 100644 index 0000000000..4ee6dc6978 --- /dev/null +++ b/source/web/jbpm/process_view.jsp @@ -0,0 +1,26 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="/WEB-INF/jbpm.tld" prefix="jbpm" %> + +<%@ page isELIgnored="false" %> + +<% System.out.println(request.getParameter("taskInstanceId")); %> + + + default value + + +Setting the value: "Hello World!" + +

+ + +<%-- --%> + +Process View +<%-- --%> + + + +<%-- --%> diff --git a/source/web/jbpm/search_instances.jsp b/source/web/jbpm/search_instances.jsp new file mode 100644 index 0000000000..dd653f8724 --- /dev/null +++ b/source/web/jbpm/search_instances.jsp @@ -0,0 +1,80 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> + + + + + +Search Instances + + + + + + + + + + +
+ + + + + +
+ +

+ +
+ +


+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/web/jbpm/task.jsp b/source/web/jbpm/task.jsp new file mode 100644 index 0000000000..55ed500db0 --- /dev/null +++ b/source/web/jbpm/task.jsp @@ -0,0 +1,74 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="/WEB-INF/jbpm.tld" prefix="jbpm" %> +<%@ page import="org.jbpm.webapp.bean.*" %> +<%@ page import="org.jbpm.taskmgmt.exe.*" %> + +<%@ page isELIgnored="false" %> + + + + +Task + + + + + + + +
+ + + + +

+ +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + +
 
+ +
+ + +
+ + + + +
+ +
+    + + +
+ + +
diff --git a/source/web/jbpm/task_list.jsp b/source/web/jbpm/task_list.jsp new file mode 100644 index 0000000000..7d3334c8f6 --- /dev/null +++ b/source/web/jbpm/task_list.jsp @@ -0,0 +1,20 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> + + + + + + + + + + + + + + + + + + diff --git a/source/web/jbpm/task_view.jsp b/source/web/jbpm/task_view.jsp new file mode 100644 index 0000000000..ec28f879a8 --- /dev/null +++ b/source/web/jbpm/task_view.jsp @@ -0,0 +1,70 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="/WEB-INF/jbpm.tld" prefix="jbpm" %> +<%@ page import="org.jbpm.webapp.bean.*" %> +<%@ page import="org.jbpm.taskmgmt.exe.*" %> + +<%@ page isELIgnored="false" %> + + + + + + + + + +
+ + + + +

+ +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + +
 
+ +
+ + +
+ + + + +
+ +
+    + + +
+ +