Rev 1780 | Rev 1782 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1780 | Rev 1781 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | package pt.estgp.estgweb.domain; |
1 | package pt.estgp.estgweb.domain; |
2 | 2 | ||
3 | import com.owlike.genson.Genson; |
3 | import com.owlike.genson.Genson; |
4 | import com.owlike.genson.GensonBuilder; |
4 | import com.owlike.genson.GensonBuilder; |
- | 5 | import com.owlike.genson.reflect.VisibilityFilter; |
|
- | 6 | import jomm.dao.impl.AbstractDao; |
|
5 | import org.json.JSONException; |
7 | import org.json.JSONException; |
6 | import org.json.JSONObject; |
8 | import org.json.JSONObject; |
- | 9 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
|
7 | 10 | ||
8 | import java.io.IOException; |
11 | import java.io.IOException; |
9 | import java.util.ArrayList; |
12 | import java.util.ArrayList; |
- | 13 | import java.util.Date; |
|
- | 14 | import java.util.List; |
|
10 | 15 | ||
11 | /** |
16 | /** |
12 | * Created by jorgemachado on 03/02/17. |
17 | * Created by jorgemachado on 03/02/17. |
13 | */ |
18 | */ |
14 | public class BpmnProcessImpl extends BpmnProcess |
19 | public class BpmnProcessImpl extends BpmnProcess |
15 | { |
20 | { |
16 | static Genson genson = new GensonBuilder() |
21 | static Genson genson = new GensonBuilder() |
17 | .useClassMetadata(true) |
22 | .useClassMetadata(true) |
- | 23 | .useFields(false, VisibilityFilter.NONE) |
|
- | 24 | .useRuntimeType(true) |
|
18 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
25 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
- | 26 | .include(1.5.0/docs/api/java/util/ArrayList.html">ArrayList.class) |
|
- | 27 | .include(5+0%2Fdocs%2Fapi+List">List.class) |
|
19 | .include(1.5.0/docs/api/java/lang/Boolean.html">Boolean.class) |
28 | .include(1.5.0/docs/api/java/lang/Boolean.html">Boolean.class) |
20 | .include(1.5.0/docs/api/java/lang/Integer.html">Integer.class) |
29 | .include(1.5.0/docs/api/java/lang/Integer.html">Integer.class) |
21 | .include(1.5.0/docs/api/java/lang/Long.html">Long.class) |
30 | .include(1.5.0/docs/api/java/lang/Long.html">Long.class) |
22 | .include(1.5.0/docs/api/java/lang/Double.html">Double.class) |
31 | .include(1.5.0/docs/api/java/lang/Double.html">Double.class) |
23 | .include(1.5.0/docs/api/java/lang/Float.html">Float.class) |
32 | .include(1.5.0/docs/api/java/lang/Float.html">Float.class) |
24 | .include(1.5.0/docs/api/java/util/ArrayList.html">ArrayList.class) |
33 | .include(5+0%2Fdocs%2Fapi+Date">Date.class) |
25 | .include(BpmnProcess.class) |
34 | .include(BpmnProcess.class) |
26 | .include(BpmnFlowComponent.class) |
35 | .include(BpmnFlowComponent.class) |
27 | .include(BpmnActorPool.class) |
36 | .include(BpmnActorPool.class) |
28 | .include(BpmnAbstractActorSelector.class) |
37 | .include(BpmnAbstractActorSelector.class) |
29 | .include(BpmnProcessVariable.class) |
38 | .include(BpmnProcessVariable.class) |
30 | .include(1.5.0/docs/api/java/lang/String.html">String.class) |
39 | .include(1.5.0/docs/api/java/lang/String.html">String.class) |
31 | 40 | ||
32 | 41 | ||
- | 42 | .exclude("process", BpmnActorPool.class) |
|
- | 43 | .exclude("actorPool", BpmnFlowComponent.class) |
|
- | 44 | .exclude("flowComponent", BpmnFlowConnector.class) |
|
33 | 45 | ||
34 | //.include(BpmnProcessStep.class) |
46 | //.include("flowComponentsArray") |
35 | .create(); |
47 | .create(); |
36 | 48 | ||
- | 49 | ||
- | 50 | ||
37 | public JSONObject toJsonObject() throws JSONException |
51 | public JSONObject toJsonObject() throws JSONException |
38 | { |
52 | { |
39 | return new JSONObject(genson.serialize(this)); |
53 | return new JSONObject(genson.serialize(this)); |
40 | } |
54 | } |
41 | 55 | ||
Line 46... | Line 60... | ||
46 | public static 1.5.0/docs/api/java/lang/String.html">String toJsonArray(ArrayList<BpmnProcess> processes) |
60 | public static 1.5.0/docs/api/java/lang/String.html">String toJsonArray(ArrayList<BpmnProcess> processes) |
47 | { |
61 | { |
48 | return genson.serialize(processes); |
62 | return genson.serialize(processes); |
49 | } |
63 | } |
50 | 64 | ||
51 | public static BpmnProcessImpl fromJson(1.5.0/docs/api/java/lang/String.html">String processJson) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
65 | public static BpmnProcessImpl fromJson(1.5.0/docs/api/java/lang/String.html">String processJson) { |
52 | return genson.deserialize(processJson,BpmnProcessImpl.class); |
66 | return genson.deserialize(processJson,BpmnProcessImpl.class); |
53 | } |
67 | } |
54 | 68 | ||
55 | //TESTES |
69 | //TESTES |
56 | 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 { |
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 { |
57 | 71 | ||
- | 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()); |
|
- | 75 | ||
- | 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(); |
|
58 | 79 | ||
59 | } |
80 | } |
60 | } |
81 | } |