Rev 1780 | Rev 1782 | Go to most recent revision | 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; |
1670 | jmachado | 10 | |
11 | import java.io.IOException; |
||
1775 | jmachado | 12 | import java.util.ArrayList; |
1781 | jmachado | 13 | import java.util.Date; |
14 | import java.util.List; |
||
1670 | jmachado | 15 | |
1653 | jmachado | 16 | /** |
17 | * Created by jorgemachado on 03/02/17. |
||
18 | */ |
||
1670 | jmachado | 19 | public class BpmnProcessImpl extends BpmnProcess |
20 | { |
||
1780 | jmachado | 21 | static Genson genson = new GensonBuilder() |
22 | .useClassMetadata(true) |
||
1781 | jmachado | 23 | .useFields(false, VisibilityFilter.NONE) |
24 | .useRuntimeType(true) |
||
1775 | jmachado | 25 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
1781 | jmachado | 26 | .include(1.5.0/docs/api/java/util/ArrayList.html">ArrayList.class) |
27 | .include(5+0%2Fdocs%2Fapi+List">List.class) |
||
1780 | jmachado | 28 | .include(1.5.0/docs/api/java/lang/Boolean.html">Boolean.class) |
29 | .include(1.5.0/docs/api/java/lang/Integer.html">Integer.class) |
||
30 | .include(1.5.0/docs/api/java/lang/Long.html">Long.class) |
||
31 | .include(1.5.0/docs/api/java/lang/Double.html">Double.class) |
||
32 | .include(1.5.0/docs/api/java/lang/Float.html">Float.class) |
||
1781 | jmachado | 33 | .include(5+0%2Fdocs%2Fapi+Date">Date.class) |
1670 | jmachado | 34 | .include(BpmnProcess.class) |
1775 | jmachado | 35 | .include(BpmnFlowComponent.class) |
36 | .include(BpmnActorPool.class) |
||
37 | .include(BpmnAbstractActorSelector.class) |
||
38 | .include(BpmnProcessVariable.class) |
||
39 | .include(1.5.0/docs/api/java/lang/String.html">String.class) |
||
1778 | jmachado | 40 | |
41 | |||
1781 | jmachado | 42 | .exclude("process", BpmnActorPool.class) |
43 | .exclude("actorPool", BpmnFlowComponent.class) |
||
44 | .exclude("flowComponent", BpmnFlowConnector.class) |
||
1779 | jmachado | 45 | |
1781 | jmachado | 46 | //.include("flowComponentsArray") |
1670 | jmachado | 47 | .create(); |
48 | |||
1781 | jmachado | 49 | |
50 | |||
1780 | jmachado | 51 | public JSONObject toJsonObject() throws JSONException |
1670 | jmachado | 52 | { |
53 | return new JSONObject(genson.serialize(this)); |
||
54 | } |
||
55 | |||
1780 | jmachado | 56 | public 1.5.0/docs/api/java/lang/String.html">String toJson() { |
1670 | jmachado | 57 | return genson.serialize(this); |
58 | } |
||
1775 | jmachado | 59 | |
1776 | jmachado | 60 | public static 1.5.0/docs/api/java/lang/String.html">String toJsonArray(ArrayList<BpmnProcess> processes) |
1775 | jmachado | 61 | { |
62 | return genson.serialize(processes); |
||
63 | } |
||
64 | |||
1781 | jmachado | 65 | public static BpmnProcessImpl fromJson(1.5.0/docs/api/java/lang/String.html">String processJson) { |
1775 | jmachado | 66 | return genson.deserialize(processJson,BpmnProcessImpl.class); |
67 | } |
||
1778 | jmachado | 68 | |
1780 | jmachado | 69 | //TESTES |
1778 | jmachado | 70 | 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 | 71 | |
1781 | jmachado | 72 | AbstractDao.getCurrentSession().beginTransaction(); |
73 | BpmnProcess process = DaoFactory.getBpmnProcessDaoImpl().get(new 1.5.0/docs/api/java/lang/Long.html">Long(1)); |
||
74 | 1.5.0/docs/api/java/lang/System.html">System.out.println(process.toJson()); |
||
1780 | jmachado | 75 | |
1781 | jmachado | 76 | BpmnFlowComponentTaskActorImpl a = (BpmnFlowComponentTaskActorImpl) DaoFactory.getBpmnFlowComponentTaskActorDaoImpl().findAll().get(0); |
77 | 1.5.0/docs/api/java/lang/System.html">System.out.println(a.toJson()); |
||
78 | AbstractDao.getCurrentSession().getTransaction().commit(); |
||
79 | |||
1778 | jmachado | 80 | } |
1653 | jmachado | 81 | } |