/app/models/Notifications/Publication.java
Java | 263 lines | 210 code | 42 blank | 11 comment | 23 complexity | 2ec730f2e948e290bab80d4f83b0c1ec MD5 | raw file
- package models.Notifications;
- import com.amazonaws.util.json.JSONObject;
- import com.google.gson.Gson;
- import com.google.gson.JsonElement;
- import com.google.gson.JsonObject;
- import com.mongodb.BasicDBObject;
- import com.mongodb.DBObject;
- import models.Review;
- import org.apache.commons.lang3.text.WordUtils;
- import org.bson.types.ObjectId;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * Created by marcosflorezsierra on 14/03/14.
- */
- public class Publication {
- public String pubId;
- public String venueId;
- public String title="";
- public String photoURL="";
- public String shortDescription="";
- public String longDescription="";
- public String venueName;
- public String venueLocation="";
- public String creationDate="";
- public String startDate="";
- public String endDate="";
- @Override
- public String toString() {
- return "Publication{" +
- "title='" + title + '\'' +
- ", endDate='" + endDate + '\'' +
- ", startDate='" + startDate + '\'' +
- ", creationDate='" + creationDate + '\'' +
- ", venueLocation='" + venueLocation + '\'' +
- ", venueName='" + venueName + '\'' +
- ", venueId='" + venueId + '\'' +
- ", longDescription='" + longDescription + '\'' +
- ", shortDescription='" + shortDescription + '\'' +
- ", photoURL='" + photoURL + '\'' +
- '}';
- }
- List<String> interests;
- int numFavourites=0;
- List<String> followers=new ArrayList<String>();
- public Publication() {
- }
- public Publication(DBObject object){
- Object o;
- if (object.containsField("_id")) {
- pubId = object.get("_id").toString();
- }
- o=object.get("title");
- if (o!=null) {
- this.title = o.toString();
- }
- if (object.containsField("venueId")) {
- this.venueId = object.get("venueId").toString();;
- }
- o=object.get("venueName");
- if (o!=null) {
- this.venueName = o.toString();
- }
- if (object.containsField("creationDate")) {
- this.creationDate = object.get("creationDate").toString();
- }
- if (object.containsField("startDate")) {
- this.startDate = object.get("startDate").toString();
- }
- if (object.containsField("endDate")) {
- this.endDate = object.get("endDate").toString();
- }
- if (object.containsField("photoURL")) {
- this.photoURL = object.get("photoURL").toString();
- }
- if (object.containsField("longDescription")) {
- this.longDescription = object.get("longDescription").toString();
- }
- if (object.containsField("shortDescription")) {
- this.shortDescription = object.get("shortDescription").toString();
- }
- o=object.get("venueLocation");
- if (o!=null) {
- this.venueLocation= WordUtils.capitalize(o.toString());
- }
- ArrayList<Object> al = (ArrayList<Object>) object.get("coordinates");
- /*
- al = (ArrayList<Object>) object.get("types");
- if (al != null) {
- for (Object ob : al) {
- this.types.add( ob.toString());
- }
- }
- */
- }
- public String getShortDescription() {
- return shortDescription;
- }
- public void setShortDescription(String shortDescription) {
- this.shortDescription = shortDescription;
- }
- public String getLongDescription() {
- return longDescription;
- }
- public void setLongDescription(String longDescription) {
- this.longDescription = longDescription;
- }
- public List<String> getInterests() {
- return interests;
- }
- public void setInterests(List<String> interests) {
- this.interests = interests;
- }
- public String getPubId() {
- return pubId;
- }
- public void setPubId(String pubId) {
- this.pubId = pubId;
- }
- public String getVenueId() {
- return venueId;
- }
- public void setVenueId(String venueId) {
- this.venueId = venueId;
- }
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
- public String getPhotoURL() {
- return photoURL;
- }
- public void setPhotoURL(String photoURL) {
- this.photoURL = photoURL;
- }
- public String getVenueName() {
- return venueName;
- }
- public void setVenueName(String venueName) {
- this.venueName = venueName;
- }
- public String getVenueLocation() {
- return venueLocation;
- }
- public void setVenueLocation(String venueLocation) {
- this.venueLocation = venueLocation;
- }
- public String getCreationDate() {
- return creationDate;
- }
- public void setCreationDate(String creationDate) {
- this.creationDate = creationDate;
- }
- public String getStartDate() {
- return startDate;
- }
- public void setStartDate(String startDate) {
- this.startDate = startDate;
- }
- public String getEndDate() {
- return endDate;
- }
- public void setEndDate(String endDate) {
- this.endDate = endDate;
- }
- public int getNumFavourites() {
- return numFavourites;
- }
- public void setNumFavourites(int numFavourites) {
- this.numFavourites = numFavourites;
- }
- public DBObject toDBO() {
- BasicDBObject doc = new BasicDBObject();
- if(venueId!=null){
- doc.append("venueId", venueId);
- }
- if(venueName!=null){
- doc.append("venueName", venueName);
- }
- if(pubId!=null){
- doc.append("_id", new ObjectId(pubId));
- }
- if(title!=null){
- doc.append("title", title);
- }
- if(interests!=null){
- doc.append("interests",interests);
- }
- if(longDescription!=null){
- doc.append("longDescription", longDescription);
- }
- if(shortDescription!=null){
- doc.append("shortDescription", shortDescription);
- }
- if(creationDate!=null){
- doc.append("creationDate", creationDate);
- }
- if(endDate!=null){
- doc.append("endDate", endDate);
- }
- if(startDate!=null){
- doc.append("startDate", startDate);
- }
- if(venueLocation!=null){
- doc.append("venueLocation", venueLocation);
- }
- if(photoURL!=null){
- doc.append("photoURL", photoURL);
- }
- doc.append("followers",followers);
- return doc;
- }
- public String toJson(){
- return com.mongodb.util.JSON.serialize(this.toDBO());
- }
- public String getDate(){
- return creationDate;
- }
- }