Rev 1675 | Rev 1778 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1675 | Rev 1776 | ||
---|---|---|---|
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.TransformationException; |
- | |
5 | import jomm.dao.impl.AbstractDao; |
4 | import jomm.dao.impl.AbstractDao; |
6 | import org.json.JSONArray; |
5 | import org.json.JSONArray; |
7 | import org.json.JSONException; |
6 | import org.json.JSONException; |
8 | import org.json.JSONObject; |
7 | import org.json.JSONObject; |
9 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
8 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
Line 106... | Line 105... | ||
106 | .create(); |
105 | .create(); |
107 | 106 | ||
108 | 107 | ||
109 | 108 | ||
110 | 109 | ||
111 | public 1.5.0/docs/api/java/lang/String.html">String toJson() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
110 | public 1.5.0/docs/api/java/lang/String.html">String toJson() throws 1.5.0/docs/api/java/io/IOException.html">IOException |
112 | { |
111 | { |
113 | return gensonSerialize.serialize(this); |
112 | return gensonSerialize.serialize(this); |
114 | } |
113 | } |
115 | 114 | ||
116 | public static JSONArray toJsonArray(List<RepositoryDocumentImpl> docs) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException, JSONException { |
115 | public static JSONArray toJsonArray(List<RepositoryDocumentImpl> docs) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
117 | return new JSONArray(gensonSerialize.serialize(docs)); |
116 | return new JSONArray(gensonSerialize.serialize(docs)); |
118 | } |
117 | } |
119 | 118 | ||
120 | public static RepositoryDocumentImpl loadFromJson(1.5.0/docs/api/java/lang/String.html">String json) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException { |
119 | public static RepositoryDocumentImpl loadFromJson(1.5.0/docs/api/java/lang/String.html">String json) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
121 | return gensonDeserialize.deserialize(json, RepositoryDocumentImpl.class); |
120 | return gensonDeserialize.deserialize(json, RepositoryDocumentImpl.class); |
122 | } |
121 | } |
123 | 122 | ||
124 | public JSONObject toJsonObject() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException, JSONException { |
123 | public JSONObject toJsonObject() throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
125 | return new JSONObject(toJson()); |
124 | return new JSONObject(toJson()); |
126 | } |
125 | } |
127 | 126 | ||
128 | 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, TransformationException { |
127 | 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 { |
129 | AbstractDao.getCurrentSession().beginTransaction(); |
128 | AbstractDao.getCurrentSession().beginTransaction(); |
130 | DocumentPerson p = new DocumentPerson(); |
129 | DocumentPerson p = new DocumentPerson(); |
131 | p.setFirstNames("jorge"); |
130 | p.setFirstNames("jorge"); |
132 | p.setLastName("Machado"); |
131 | p.setLastName("Machado"); |
133 | DocumentPersons ps = new DocumentPersons(); |
132 | DocumentPersons ps = new DocumentPersons(); |