Rev 1791 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1653 | jmachado | 1 | package pt.estgp.estgweb.domain; |
2 | |||
1670 | jmachado | 3 | import com.owlike.genson.Genson; |
1780 | jmachado | 4 | import com.owlike.genson.GensonBuilder; |
1781 | jmachado | 5 | import com.owlike.genson.reflect.VisibilityFilter; |
6 | import jomm.dao.impl.AbstractDao; |
||
1670 | jmachado | 7 | import org.json.JSONException; |
8 | import org.json.JSONObject; |
||
1781 | jmachado | 9 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
1814 | jmachado | 10 | import pt.estgp.estgweb.domain.typesgen.*; |
1670 | jmachado | 11 | |
12 | import java.io.IOException; |
||
1775 | jmachado | 13 | import java.util.ArrayList; |
1781 | jmachado | 14 | import java.util.Date; |
15 | import java.util.List; |
||
1782 | jmachado | 16 | import java.util.Set; |
1670 | jmachado | 17 | |
1653 | jmachado | 18 | /** |
19 | * Created by jorgemachado on 03/02/17. |
||
20 | */ |
||
1670 | jmachado | 21 | public class BpmnProcessImpl extends BpmnProcess |
22 | { |
||
1780 | jmachado | 23 | static Genson genson = new GensonBuilder() |
24 | .useClassMetadata(true) |
||
1782 | jmachado | 25 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
1781 | jmachado | 26 | .useFields(false, VisibilityFilter.NONE) |
1782 | jmachado | 27 | .useDateAsTimestamp(true) |
28 | |||
1781 | jmachado | 29 | .useRuntimeType(true) |
1782 | jmachado | 30 | //.useMethods(true) |
1781 | jmachado | 31 | .include(1.5.0/docs/api/java/util/ArrayList.html">ArrayList.class) |
1782 | jmachado | 32 | .include(1.5.0/docs/api/java/util/Set.html">Set.class) |
1781 | jmachado | 33 | .include(5+0%2Fdocs%2Fapi+List">List.class) |
1780 | jmachado | 34 | .include(1.5.0/docs/api/java/lang/Boolean.html">Boolean.class) |
35 | .include(1.5.0/docs/api/java/lang/Integer.html">Integer.class) |
||
36 | .include(1.5.0/docs/api/java/lang/Long.html">Long.class) |
||
37 | .include(1.5.0/docs/api/java/lang/Double.html">Double.class) |
||
38 | .include(1.5.0/docs/api/java/lang/Float.html">Float.class) |
||
1781 | jmachado | 39 | .include(5+0%2Fdocs%2Fapi+Date">Date.class) |
1670 | jmachado | 40 | .include(BpmnProcess.class) |
1782 | jmachado | 41 | .include(BpmnFlowConnectorImpl.class) |
42 | //.include(BpmnFlowConnector.class) |
||
43 | |||
1775 | jmachado | 44 | .include(BpmnFlowComponent.class) |
45 | .include(BpmnActorPool.class) |
||
46 | .include(BpmnAbstractActorSelector.class) |
||
1782 | jmachado | 47 | .include(BpmnVariable.class) |
1775 | jmachado | 48 | .include(1.5.0/docs/api/java/lang/String.html">String.class) |
1791 | jmachado | 49 | .include(Todos.class) |
50 | .include(Todo.class) |
||
51 | .include(ConnectorSoa.class) |
||
52 | .include(OperationMethodCall.class) |
||
53 | .include(Argument.class) |
||
54 | .include(1.5.0/docs/api/java/rmi/server/Operation.html">Operation.class) |
||
55 | .include(VariableType.class) |
||
1778 | jmachado | 56 | |
57 | |||
1781 | jmachado | 58 | .exclude("process", BpmnActorPool.class) |
59 | .exclude("actorPool", BpmnFlowComponent.class) |
||
1782 | jmachado | 60 | .include("flowComponentId", BpmnFlowConnectorImpl.class) |
1781 | jmachado | 61 | .exclude("flowComponent", BpmnFlowConnector.class) |
1779 | jmachado | 62 | |
1782 | jmachado | 63 | |
1781 | jmachado | 64 | //.include("flowComponentsArray") |
1670 | jmachado | 65 | .create(); |
66 | |||
1781 | jmachado | 67 | |
1791 | jmachado | 68 | public static JSONObject toJson(5+0%2Fdocs%2Fapi+Object">Object bpmnObject) throws JSONException |
69 | { |
||
70 | return new JSONObject(genson.serialize(bpmnObject)); |
||
71 | } |
||
1781 | jmachado | 72 | |
1780 | jmachado | 73 | public JSONObject toJsonObject() throws JSONException |
1670 | jmachado | 74 | { |
75 | return new JSONObject(genson.serialize(this)); |
||
76 | } |
||
77 | |||
1780 | jmachado | 78 | public 1.5.0/docs/api/java/lang/String.html">String toJson() { |
1670 | jmachado | 79 | return genson.serialize(this); |
80 | } |
||
1775 | jmachado | 81 | |
1776 | jmachado | 82 | public static 1.5.0/docs/api/java/lang/String.html">String toJsonArray(ArrayList<BpmnProcess> processes) |
1775 | jmachado | 83 | { |
84 | return genson.serialize(processes); |
||
85 | } |
||
86 | |||
1781 | jmachado | 87 | public static BpmnProcessImpl fromJson(1.5.0/docs/api/java/lang/String.html">String processJson) { |
1775 | jmachado | 88 | return genson.deserialize(processJson,BpmnProcessImpl.class); |
89 | } |
||
1778 | jmachado | 90 | |
1780 | jmachado | 91 | //TESTES |
1778 | jmachado | 92 | public static void main(1.5.0/docs/api/java/lang/String.html">String[] args) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
1780 | jmachado | 93 | |
1781 | jmachado | 94 | AbstractDao.getCurrentSession().beginTransaction(); |
95 | BpmnProcess process = DaoFactory.getBpmnProcessDaoImpl().get(new 1.5.0/docs/api/java/lang/Long.html">Long(1)); |
||
96 | 1.5.0/docs/api/java/lang/System.html">System.out.println(process.toJson()); |
||
1780 | jmachado | 97 | |
1781 | jmachado | 98 | BpmnFlowComponentTaskActorImpl a = (BpmnFlowComponentTaskActorImpl) DaoFactory.getBpmnFlowComponentTaskActorDaoImpl().findAll().get(0); |
1814 | jmachado | 99 | |
1781 | jmachado | 100 | AbstractDao.getCurrentSession().getTransaction().commit(); |
101 | |||
1778 | jmachado | 102 | } |
1653 | jmachado | 103 | } |