PageRenderTime 121ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/app/models/Notifications/Publication.java

https://bitbucket.org/marcosflorez/mvp
Java | 263 lines | 210 code | 42 blank | 11 comment | 23 complexity | 2ec730f2e948e290bab80d4f83b0c1ec MD5 | raw file
  1. package models.Notifications;
  2. import com.amazonaws.util.json.JSONObject;
  3. import com.google.gson.Gson;
  4. import com.google.gson.JsonElement;
  5. import com.google.gson.JsonObject;
  6. import com.mongodb.BasicDBObject;
  7. import com.mongodb.DBObject;
  8. import models.Review;
  9. import org.apache.commons.lang3.text.WordUtils;
  10. import org.bson.types.ObjectId;
  11. import java.util.ArrayList;
  12. import java.util.List;
  13. /**
  14. * Created by marcosflorezsierra on 14/03/14.
  15. */
  16. public class Publication {
  17. public String pubId;
  18. public String venueId;
  19. public String title="";
  20. public String photoURL="";
  21. public String shortDescription="";
  22. public String longDescription="";
  23. public String venueName;
  24. public String venueLocation="";
  25. public String creationDate="";
  26. public String startDate="";
  27. public String endDate="";
  28. @Override
  29. public String toString() {
  30. return "Publication{" +
  31. "title='" + title + '\'' +
  32. ", endDate='" + endDate + '\'' +
  33. ", startDate='" + startDate + '\'' +
  34. ", creationDate='" + creationDate + '\'' +
  35. ", venueLocation='" + venueLocation + '\'' +
  36. ", venueName='" + venueName + '\'' +
  37. ", venueId='" + venueId + '\'' +
  38. ", longDescription='" + longDescription + '\'' +
  39. ", shortDescription='" + shortDescription + '\'' +
  40. ", photoURL='" + photoURL + '\'' +
  41. '}';
  42. }
  43. List<String> interests;
  44. int numFavourites=0;
  45. List<String> followers=new ArrayList<String>();
  46. public Publication() {
  47. }
  48. public Publication(DBObject object){
  49. Object o;
  50. if (object.containsField("_id")) {
  51. pubId = object.get("_id").toString();
  52. }
  53. o=object.get("title");
  54. if (o!=null) {
  55. this.title = o.toString();
  56. }
  57. if (object.containsField("venueId")) {
  58. this.venueId = object.get("venueId").toString();;
  59. }
  60. o=object.get("venueName");
  61. if (o!=null) {
  62. this.venueName = o.toString();
  63. }
  64. if (object.containsField("creationDate")) {
  65. this.creationDate = object.get("creationDate").toString();
  66. }
  67. if (object.containsField("startDate")) {
  68. this.startDate = object.get("startDate").toString();
  69. }
  70. if (object.containsField("endDate")) {
  71. this.endDate = object.get("endDate").toString();
  72. }
  73. if (object.containsField("photoURL")) {
  74. this.photoURL = object.get("photoURL").toString();
  75. }
  76. if (object.containsField("longDescription")) {
  77. this.longDescription = object.get("longDescription").toString();
  78. }
  79. if (object.containsField("shortDescription")) {
  80. this.shortDescription = object.get("shortDescription").toString();
  81. }
  82. o=object.get("venueLocation");
  83. if (o!=null) {
  84. this.venueLocation= WordUtils.capitalize(o.toString());
  85. }
  86. ArrayList<Object> al = (ArrayList<Object>) object.get("coordinates");
  87. /*
  88. al = (ArrayList<Object>) object.get("types");
  89. if (al != null) {
  90. for (Object ob : al) {
  91. this.types.add( ob.toString());
  92. }
  93. }
  94. */
  95. }
  96. public String getShortDescription() {
  97. return shortDescription;
  98. }
  99. public void setShortDescription(String shortDescription) {
  100. this.shortDescription = shortDescription;
  101. }
  102. public String getLongDescription() {
  103. return longDescription;
  104. }
  105. public void setLongDescription(String longDescription) {
  106. this.longDescription = longDescription;
  107. }
  108. public List<String> getInterests() {
  109. return interests;
  110. }
  111. public void setInterests(List<String> interests) {
  112. this.interests = interests;
  113. }
  114. public String getPubId() {
  115. return pubId;
  116. }
  117. public void setPubId(String pubId) {
  118. this.pubId = pubId;
  119. }
  120. public String getVenueId() {
  121. return venueId;
  122. }
  123. public void setVenueId(String venueId) {
  124. this.venueId = venueId;
  125. }
  126. public String getTitle() {
  127. return title;
  128. }
  129. public void setTitle(String title) {
  130. this.title = title;
  131. }
  132. public String getPhotoURL() {
  133. return photoURL;
  134. }
  135. public void setPhotoURL(String photoURL) {
  136. this.photoURL = photoURL;
  137. }
  138. public String getVenueName() {
  139. return venueName;
  140. }
  141. public void setVenueName(String venueName) {
  142. this.venueName = venueName;
  143. }
  144. public String getVenueLocation() {
  145. return venueLocation;
  146. }
  147. public void setVenueLocation(String venueLocation) {
  148. this.venueLocation = venueLocation;
  149. }
  150. public String getCreationDate() {
  151. return creationDate;
  152. }
  153. public void setCreationDate(String creationDate) {
  154. this.creationDate = creationDate;
  155. }
  156. public String getStartDate() {
  157. return startDate;
  158. }
  159. public void setStartDate(String startDate) {
  160. this.startDate = startDate;
  161. }
  162. public String getEndDate() {
  163. return endDate;
  164. }
  165. public void setEndDate(String endDate) {
  166. this.endDate = endDate;
  167. }
  168. public int getNumFavourites() {
  169. return numFavourites;
  170. }
  171. public void setNumFavourites(int numFavourites) {
  172. this.numFavourites = numFavourites;
  173. }
  174. public DBObject toDBO() {
  175. BasicDBObject doc = new BasicDBObject();
  176. if(venueId!=null){
  177. doc.append("venueId", venueId);
  178. }
  179. if(venueName!=null){
  180. doc.append("venueName", venueName);
  181. }
  182. if(pubId!=null){
  183. doc.append("_id", new ObjectId(pubId));
  184. }
  185. if(title!=null){
  186. doc.append("title", title);
  187. }
  188. if(interests!=null){
  189. doc.append("interests",interests);
  190. }
  191. if(longDescription!=null){
  192. doc.append("longDescription", longDescription);
  193. }
  194. if(shortDescription!=null){
  195. doc.append("shortDescription", shortDescription);
  196. }
  197. if(creationDate!=null){
  198. doc.append("creationDate", creationDate);
  199. }
  200. if(endDate!=null){
  201. doc.append("endDate", endDate);
  202. }
  203. if(startDate!=null){
  204. doc.append("startDate", startDate);
  205. }
  206. if(venueLocation!=null){
  207. doc.append("venueLocation", venueLocation);
  208. }
  209. if(photoURL!=null){
  210. doc.append("photoURL", photoURL);
  211. }
  212. doc.append("followers",followers);
  213. return doc;
  214. }
  215. public String toJson(){
  216. return com.mongodb.util.JSON.serialize(this.toDBO());
  217. }
  218. public String getDate(){
  219. return creationDate;
  220. }
  221. }