Rev 1775 | Rev 1782 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1775 | Rev 1781 | ||
---|---|---|---|
Line 7... | Line 7... | ||
7 | import org.apache.log4j.Logger; |
7 | import org.apache.log4j.Logger; |
8 | import org.apache.struts.action.ActionForm; |
8 | import org.apache.struts.action.ActionForm; |
9 | import org.json.JSONArray; |
9 | import org.json.JSONArray; |
10 | import org.json.JSONException; |
10 | import org.json.JSONException; |
11 | import org.json.JSONObject; |
11 | import org.json.JSONObject; |
12 | import pt.estgp.estgweb.domain.BpmnProcessImpl; |
12 | import pt.estgp.estgweb.domain.*; |
13 | import pt.estgp.estgweb.domain.DomainObjectFactory; |
- | |
14 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
13 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
15 | import pt.estgp.estgweb.web.controllers.utils.AbstractWidgetAjaxController; |
14 | import pt.estgp.estgweb.web.controllers.utils.AbstractWidgetAjaxController; |
16 | import pt.estgp.estgweb.web.utils.JspInterfacesJsonGen; |
15 | import pt.estgp.estgweb.web.utils.JspInterfacesJsonGen; |
17 | 16 | ||
18 | import javax.servlet.http.HttpServletRequest; |
17 | import javax.servlet.http.HttpServletRequest; |
19 | import javax.servlet.http.HttpServletResponse; |
18 | import javax.servlet.http.HttpServletResponse; |
20 | import java.io.IOException; |
19 | import java.io.IOException; |
21 | import java.io.InputStreamReader; |
20 | import java.io.InputStreamReader; |
- | 21 | import java.util.Iterator; |
|
22 | 22 | ||
23 | /** |
23 | /** |
24 | * @author Jorge Machado |
24 | * @author Jorge Machado |
25 | * @date 26/Fev/2008 |
25 | * @date 26/Fev/2008 |
26 | * @time 18:01:54 |
26 | * @time 18:01:54 |
Line 89... | Line 89... | ||
89 | AbstractDao.getCurrentSession().getTransaction().commit(); |
89 | AbstractDao.getCurrentSession().getTransaction().commit(); |
90 | 90 | ||
91 | return processJson; |
91 | return processJson; |
92 | } |
92 | } |
93 | 93 | ||
- | 94 | public JSONObject addActorPool(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
|
- | 95 | { |
|
- | 96 | ||
- | 97 | 1.5.0/docs/api/java/lang/Long.html">Long processId = 1.5.0/docs/api/java/lang/Long.html">Long.parseLong(request.getParameter("processId")); |
|
- | 98 | AbstractDao.getCurrentSession().beginTransaction(); |
|
- | 99 | ||
- | 100 | BpmnProcessImpl persistent = (BpmnProcessImpl) DaoFactory.getBpmnProcessDaoImpl().get(processId); |
|
- | 101 | BpmnActorPool actorPool = DomainObjectFactory.createBpmnActorPoolImpl(); |
|
- | 102 | ||
- | 103 | actorPool.setProcess(persistent); |
|
- | 104 | persistent.getActorPools().add(actorPool); |
|
- | 105 | DaoFactory.getBpmnActorPoolDaoImpl().save(actorPool); |
|
- | 106 | ||
- | 107 | JSONObject actorPoolJson = actorPool.toJsonObject(); |
|
- | 108 | AbstractDao.getCurrentSession().getTransaction().commit(); |
|
- | 109 | ||
- | 110 | return actorPoolJson; |
|
- | 111 | } |
|
- | 112 | ||
- | 113 | public boolean updateTask(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
|
- | 114 | { |
|
- | 115 | ||
- | 116 | BpmnFlowComponentTask taskView = (BpmnFlowComponentTask) DomainObject.fromJson(request.getParameter("object")); |
|
- | 117 | ||
- | 118 | AbstractDao.getCurrentSession().beginTransaction(); |
|
- | 119 | ||
- | 120 | BpmnFlowComponentTask persistent = (BpmnFlowComponentTask) DaoFactory.getBpmnFlowComponentTaskDaoImpl().get(taskView.getId()); |
|
- | 121 | persistent.setTitle(taskView.getTitle()); |
|
- | 122 | persistent.setDescription(taskView.getDescription()); |
|
- | 123 | ||
- | 124 | if(persistent instanceof BpmnFlowComponentTaskActor) |
|
- | 125 | { |
|
- | 126 | ((BpmnFlowComponentTaskActor)persistent).setInterfacePlugin(((BpmnFlowComponentTaskActor) taskView).getInterfacePlugin()); |
|
- | 127 | //((BpmnFlowComponentTaskActor)persistent).set(((BpmnFlowComponentTaskActor)taskView).getInterfacePlugin()); |
|
- | 128 | ((BpmnFlowComponentTaskActor)persistent).setInterfacePlugin(((BpmnFlowComponentTaskActor)taskView).getInterfacePlugin()); |
|
- | 129 | } |
|
- | 130 | AbstractDao.getCurrentSession().getTransaction().commit(); |
|
- | 131 | ||
- | 132 | //return actorPoolJson; |
|
- | 133 | return false; |
|
- | 134 | } |
|
- | 135 | ||
- | 136 | public JSONObject addTaskActor(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
|
- | 137 | { |
|
- | 138 | ||
- | 139 | 1.5.0/docs/api/java/lang/Long.html">Long poolId = 1.5.0/docs/api/java/lang/Long.html">Long.parseLong(request.getParameter("poolId")); |
|
- | 140 | ||
- | 141 | AbstractDao.getCurrentSession().beginTransaction(); |
|
- | 142 | ||
- | 143 | BpmnActorPoolImpl persistent = (BpmnActorPoolImpl) DaoFactory.getBpmnActorPoolDaoImpl().get(poolId); |
|
- | 144 | ||
- | 145 | BpmnFlowComponentTaskActor taskActor = DomainObjectFactory.createBpmnFlowComponentTaskActorImpl(); |
|
- | 146 | ||
- | 147 | taskActor.setActorPool(persistent); |
|
- | 148 | persistent.getFlowComponents().add(taskActor); |
|
- | 149 | ||
- | 150 | DaoFactory.getBpmnFlowComponentTaskActorDaoImpl().save(taskActor); |
|
- | 151 | ||
- | 152 | JSONObject taskActorJson = taskActor.toJsonObject(); |
|
- | 153 | AbstractDao.getCurrentSession().getTransaction().commit(); |
|
- | 154 | ||
- | 155 | return taskActorJson; |
|
- | 156 | } |
|
- | 157 | ||
- | 158 | ||
- | 159 | public boolean removeTask(ActionForm form,HttpServletRequest request, HttpServletResponse response) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
|
- | 160 | { |
|
- | 161 | //TODO NO SERVICO QUANDO HOUVER CHECK PROCESSOS ABERTOS INSTANCIAS |
|
- | 162 | ||
- | 163 | 1.5.0/docs/api/java/lang/Long.html">Long poolId = 1.5.0/docs/api/java/lang/Long.html">Long.parseLong(request.getParameter("poolId")); |
|
- | 164 | 1.5.0/docs/api/java/lang/Long.html">Long taskId = 1.5.0/docs/api/java/lang/Long.html">Long.parseLong(request.getParameter("taskId")); |
|
- | 165 | ||
- | 166 | AbstractDao.getCurrentSession().beginTransaction(); |
|
- | 167 | ||
- | 168 | BpmnActorPoolImpl poolPersistent = (BpmnActorPoolImpl) DaoFactory.getBpmnActorPoolDaoImpl().get(poolId); |
|
- | 169 | BpmnFlowComponentTask taskPersistent = DaoFactory.getBpmnFlowComponentTaskDaoImpl().get(taskId); |
|
- | 170 | logger.warn("Removing bpmn task: " + taskPersistent.getId() + " " + taskPersistent.getTitle() + " from pool " + poolPersistent.getId() + " " + poolPersistent.getName() + " from process " + poolPersistent.getProcess().getId() + " " + poolPersistent.getProcess().getName()); |
|
- | 171 | if(taskPersistent.getFlowConnectors() != null) |
|
- | 172 | { |
|
- | 173 | Iterator<BpmnFlowConnector> iter = taskPersistent.getFlowConnectors().iterator(); |
|
- | 174 | while(iter.hasNext()) |
|
- | 175 | { |
|
- | 176 | BpmnFlowConnector con = iter.next(); |
|
- | 177 | logger.warn("Removing bpmn connector: " + con.getId() + " " + con.getNameConnection() + ":" + con.getKeyValue() ); |
|
- | 178 | iter.remove(); |
|
- | 179 | } |
|
- | 180 | } |
|
- | 181 | ||
- | 182 | poolPersistent.getFlowComponents().remove(taskPersistent); |
|
- | 183 | DaoFactory.getBpmnFlowComponentTaskDaoImpl().delete(taskPersistent); |
|
- | 184 | ||
- | 185 | AbstractDao.getCurrentSession().getTransaction().commit(); |
|
- | 186 | ||
- | 187 | return true; |
|
- | 188 | } |
|
- | 189 | ||
94 | } |
190 | } |