/* * Copyright (C) 2010-2012 Stichting Akvo (Akvo Foundation) * * This file is part of Akvo FLOW. * * Akvo FLOW is free software: you can redistribute it and modify it under the terms of * the GNU Affero General Public License (AGPL) as published by the Free Software Foundation, * either version 3 of the License or any later version. * * Akvo FLOW is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Affero General Public License included below for more details. * * The full license text can also be seen at <http://www.gnu.org/licenses/agpl.html>. */ package com.gallatinsystems.device.domain; import java.lang.reflect.Field; import java.util.Date; import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.PersistenceCapable; import javax.jdo.annotations.Persistent; import javax.jdo.annotations.PrimaryKey; /** * Persistent class for storing an assignment of a survey to a device. */ @PersistenceCapable(identityType = IdentityType.APPLICATION) public class DeviceSurveyJobQueue { private String devicePhoneNumber; private String imei; private String androidId; private Long surveyID; private Date effectiveStartDate; private Date effectiveEndDate; private DistributionStatus surveyDistributionStatus; private String language; private String name; private Long assignmentId; @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Long id; public enum DistributionStatus { UNSENT, SENT } public DeviceSurveyJobQueue() { this.name = "test"; this.language = "english"; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Long getAssignmentId() { return assignmentId; } public void setAssignmentId(Long assignmentId) { this.assignmentId = assignmentId; } public String getAndroidId() { return androidId; } public void setAndroidId(String androidId) { this.androidId = androidId; } public String getDevicePhoneNumber() { return devicePhoneNumber; } public void setDevicePhoneNumber(String devicePhoneNumber) { this.devicePhoneNumber = devicePhoneNumber; } public String getImei() { return imei; } public void setImei(String imei) { this.imei = imei; } public Long getSurveyID() { return surveyID; } public void setSurveyID(Long surveyID) { this.surveyID = surveyID; } public Date getEffectiveStartDate() { return effectiveStartDate; } public void setEffectiveStartDate(Date effectiveStartDate) { this.effectiveStartDate = effectiveStartDate; } public Date getEffectiveEndDate() { return effectiveEndDate; } public void setEffectiveEndDate(Date effectiveEndDate) { this.effectiveEndDate = effectiveEndDate; } public DistributionStatus getSurveyDistributionStatus() { return surveyDistributionStatus; } public void setSurveyDistributionStatus( DistributionStatus surveyDistributionStatus) { this.surveyDistributionStatus = surveyDistributionStatus; } public String getLanguage() { return language; } public void setLanguage(String language) { this.language = language; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String toString() { StringBuilder result = new StringBuilder(); String newLine = System.getProperty("line.separator"); result.append(this.getClass().getName()); result.append(" Object {"); result.append(newLine); // determine fields declared in this class only (no fields of // superclass) Field[] fields = this.getClass().getDeclaredFields(); // print field names paired with their values for (Field field : fields) { result.append(" "); try { result.append(field.getName()); result.append(": "); // requires access to private field: result.append(field.get(this)); } catch (IllegalAccessException ex) { System.out.println(ex); } result.append(newLine); } result.append("}"); return result.toString(); } }