/v3.2/nimbits-model/src/com/nimbits/client/model/point/PointModel.java
http://nimbits-server.googlecode.com/ · Java · 776 lines · 559 code · 198 blank · 19 comment · 2 complexity · 99bdb624594e781889c0f85830f92c04 MD5 · raw file
- /*
- * Copyright (c) 2010 Tonic Solutions LLC.
- *
- * http://www.nimbits.com
- *
- *
- * Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.gnu.org/licenses/gpl.html
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- */
-
- package com.nimbits.client.model.point;
-
- import com.nimbits.client.model.ClientType;
- import com.nimbits.client.model.common.CommonFactoryLocator;
- import com.nimbits.client.model.value.AlertType;
- import com.nimbits.client.model.value.Value;
-
- import java.io.Serializable;
- import java.util.Date;
- import java.util.List;
-
-
- public class PointModel implements Serializable, Point {
-
-
- private long id;
-
- private static final long serialVersionUID = 1L;
-
- private AlertType alertState;
-
- private String uuid;
-
- private Date lastChecked;
-
- private String host;
-
- private long catID;
-
- private boolean isSystemPoint;
-
- private long userFK;
-
- private String name;
-
- private Date createDate;
-
- private long X;
-
- private long Y;
-
- private long Z;
-
- private long target;
-
- private String formula;
-
- private double highAlarm = 0.0;
-
- private int expire = 90;
-
- private String unit;
-
- private double compression = 0.1;
-
- private double lowAlarm = 0.0;
-
- private boolean highAlarmOn;
-
- private boolean lowAlarmOn;
-
- private int alarmDelay = 1;
-
- private long lastAlarmSent;
-
- private String description;
-
- private boolean isPublic;
-
- private boolean postToFacebook;
-
- private boolean alarmToFacebook;
-
- @Override
- public boolean isAlarmToEmail() {
- return alarmToEmail;
- }
-
- @Override
- public void setAlarmToEmail(boolean alarmToEmail) {
- this.alarmToEmail = alarmToEmail;
- }
-
- private boolean alarmToEmail;
-
- private boolean sendIM;
-
- private boolean sendAlarmIM;
-
- private boolean sendTweet;
-
- private boolean sendAlarmTweet;
-
- private String tag;
-
-
- private double lowestRecordedValue;
-
- private double highestRecordedValue;
- //
- // private double lastRecordedValue;
-
- private Date lastRecordedTimestamp;
-
- private String lastNote;
-
- private double lat;
-
- private double lng;
-
- private boolean idleAlarmOn;
-
- private Integer idleSeconds = 0;
-
- //reset on any data write
- private boolean idleAlarmSent;
-
- //reset on any data write
- private boolean ignoreIncomingCompressedValues;
-
- //reset on any data write
- private boolean readOnly;
-
- public void setClientType(ClientType clientType) {
- this.clientType = clientType;
- }
-
- private ClientType clientType;
-
- public PointModel(Point p) {
- this.id = p.getId();
- this.uuid = p.getUuid();
- this.lastChecked = p.getLastChecked();
- this.host = p.getHost();
- this.catID = p.getCatID();
- this.isSystemPoint = p.isSystemPoint();
- this.userFK = p.getUserFK();
- this.name = p.getName().getValue();
- this.createDate = p.getCreateDate();
- this.X = p.getX();
- this.Y = p.getY();
- this.Z = p.getZ();
- this.target = p.getTarget();
- this.formula = p.getFormula();
- this.highAlarm = p.getHighAlarm();
- this.expire = p.getExpire();
- this.unit = p.getUnit();
- this.compression = p.getCompression();
- this.lowAlarm = p.getLowAlarm();
- this.highAlarmOn = p.isHighAlarmOn();
- this.lowAlarmOn = p.isLowAlarmOn();
- this.alarmDelay = p.getAlarmDelay();
- this.lastAlarmSent = p.getLastAlarmSent();
- this.description = p.getDescription();
- this.isPublic = p.isPublic();
- this.postToFacebook = p.isPostToFacebook();
- this.alarmToFacebook = p.getAlarmToFacebook();
- this.sendIM = p.getSendIM();
- this.sendAlarmIM = p.getSendAlarmIM();
- this.sendTweet = p.getSendTweet();
- this.sendAlarmTweet = p.getSendAlarmTweet();
- this.tag = p.getTag();
- this.lowestRecordedValue = p.getLowestRecordedValue();
- this.highestRecordedValue = p.getHighestRecordedValue();
- this.lastRecordedTimestamp = p.getLastRecordedTimestamp();
- this.lastNote = p.getLastNote();
- this.lat = p.getLat();
- this.lng = p.getLng();
-
- this.idleAlarmOn = p.isIdleAlarmOn();
- this.idleSeconds = p.getIdleSeconds();
- this.idleAlarmSent = p.getIdleAlarmSent();
- this.ignoreIncomingCompressedValues = p.getIgnoreIncomingCompressedValues();
- this.readOnly = p.getReadOnly();
- this.targetValue = p.getTargetValue();
- this.jsonPointDataArray = p.getJsonPointDataArray();
- this.values = p.getValues();
- this.value = p.getValue();
-
- this.alarmToEmail = p.isAlarmToEmail();
-
- }
-
-
- @Override
- public boolean isIdleAlarmOn() {
- return idleAlarmOn;
- }
-
- @Override
- public AlertType getAlertState() {
- return this.alertState;
- }
-
- @Override
- public void setAlertState(final AlertType alertState) {
- this.alertState = alertState;
- }
-
- @Override
- public void setIdleAlarmOn(final boolean idleAlarmOn) {
- this.idleAlarmOn = idleAlarmOn;
- }
-
- @Override
- public int getIdleSeconds() {
- return idleSeconds;
- }
-
- @Override
- public void setIdleSeconds(final int idleSeconds) {
- this.idleSeconds = idleSeconds;
- }
-
- @Override
- public boolean getIdleAlarmSent() {
- return idleAlarmSent;
- }
-
- @Override
- public void setIdleAlarmSent(final boolean idleAlarmSent) {
- this.idleAlarmSent = idleAlarmSent;
- }
-
- // Constructors
- public PointModel() {
- }
-
- public PointModel(final long userFK, final PointName pointName, final long catID, final String uuid) {
- this();
- this.userFK = userFK;
- this.name = pointName.getValue();
- this.catID = catID;
- this.uuid = uuid;
-
-
- }
-
- public PointModel(final long userFK, final PointName pointName, final String uuid) {
- this();
- this.userFK = userFK;
- this.name = pointName.getValue();
- this.highestRecordedValue = 0.0;
- this.lowestRecordedValue = 0.0;
- this.lastRecordedTimestamp = new Date();
- this.uuid = uuid;
- }
-
- public PointModel(final PointName name, final String uuid) {
- this.name = name.getValue();
- this.highestRecordedValue = 0.0;
- this.lowestRecordedValue = 0.0;
- this.lastRecordedTimestamp = new Date();
- this.uuid = uuid;
-
- }
-
- public PointModel(final long id, final long userFk) {
- this.id = id;
- this.userFK = userFk;
-
- }
- // End Constructors
-
- private double targetValue;
-
- private String jsonPointDataArray;
-
- private List<Value> values;
-
- private Value value;
-
- @Override
- public int getAlarmDelay() {
- return alarmDelay;
- }
-
- @Override
- public boolean getAlarmToFacebook() {
-
- return alarmToFacebook;
-
- }
-
- @Override
- public long getCatID() {
- return catID;
- }
-
- @Override
- public double getCompression() {
- return this.compression;
- }
-
- @Override
- public Date getCreateDate() {
- return new Date(this.createDate.getTime());
- }
-
- @Override
- public String getDescription() {
-
- return this.description == null ? "" : this.description;
- }
-
- @Override
- public int getExpire() {
- return expire;
- }
-
- @Override
- public String getFormula() {
- return this.formula;
- }
-
- @Override
- public double getHighAlarm() {
- return highAlarm;
- }
-
- @Override
- public double getHighestRecordedValue() {
-
- return highestRecordedValue;
- }
-
- @Override
- public String getHost() {
- return host;
- }
-
- @Override
- public long getId() {
- return id;
- }
-
-
- @Override
- public String getJsonPointDataArray() {
- return jsonPointDataArray;
- }
-
- @Override
- public long getLastAlarmSent() {
- return lastAlarmSent;
- }
-
- @Override
- public Date getLastChecked() {
-
- return new Date(this.lastChecked.getTime());
- }
-
- @Override
- public double getLastLat() {
-
- return lat;
- }
-
- @Override
- public double getLastLng() {
-
- return lng;
- }
-
- @Override
- public String getLastNote() {
- return lastNote;
- }
-
- @Override
- public Date getLastRecordedTimestamp() {
- return lastRecordedTimestamp == null ? new Date() : new Date(this.lastRecordedTimestamp.getTime());
- }
-
- @Override
- public double getLat() {
- return getLastLat();
- }
-
- @Override
- public double getLng() {
- return getLastLng();
- }
-
- @Override
- public double getLowAlarm() {
- return lowAlarm;
- }
-
- @Override
- public double getLowestRecordedValue() {
-
- return lowestRecordedValue;
- }
-
- @Override
- public PointName getName() {
- return CommonFactoryLocator.getInstance().createPointName(this.name);
- }
-
- @Override
- public boolean getSendAlarmIM() {
-
- return sendAlarmIM;
- }
-
- @Override
- public boolean getSendAlarmTweet() {
-
- return sendAlarmTweet;
- }
-
- @Override
- public boolean getSendIM() {
-
- return sendIM;
- }
-
- @Override
- public boolean getSendTweet() {
-
- return sendTweet;
- }
-
- @Override
- public String getTag() {
- return tag;
- }
-
- @Override
- public long getTarget() {
- return target;
- }
-
- @Override
- public String getUnit() {
- return unit;
- }
-
-
- @Override
- public long getUserFK() {
- return userFK;
- }
-
- @Override
- public String getUuid() {
- return uuid;
- }
-
- @Override
- public Value getValue() {
- return value;
- }
-
- @Override
- public List<Value> getValues() {
- return values;
- }
-
- @Override
- public long getX() {
- return X;
- }
-
- @Override
- public long getY() {
- return Y;
- }
-
- @Override
- public long getZ() {
- return Z;
- }
-
- @Override
- public boolean isHighAlarmOn() {
- return highAlarmOn;
- }
-
- @Override
- public boolean isLowAlarmOn() {
- return lowAlarmOn;
- }
-
- @Override
- public boolean isPostToFacebook() {
- return postToFacebook;
- }
-
- @Override
- public boolean isPublic() {
- return isPublic;
- }
-
- @Override
- public boolean isSystemPoint() {
- return isSystemPoint;
- }
-
- @Override
- public void setAlarmDelay(final int alarmDelay) {
- this.alarmDelay = alarmDelay;
- }
-
- @Override
- public void setAlarmToFacebook(final boolean alarmToFacebook) {
- this.alarmToFacebook = alarmToFacebook;
- }
-
- @Override
- public void setCatID(final long catID) {
- this.catID = catID;
- }
-
- @Override
- public void setCompression(final double compression) {
- this.compression = compression;
- }
-
- @Override
- public void setCreateDate(final Date createDate) {
- this.createDate = new Date(createDate.getTime());
- }
-
- @Override
- public void setDescription(final String value) {
- this.description = value;
-
- }
-
- @Override
- public void setExpire(final int expire) {
- this.expire = expire;
- }
-
- @Override
- public void setFormula(final String formula) {
- this.formula = formula;
- }
-
- @Override
- public void setHighAlarm(double highAlarm) {
- this.highAlarm = highAlarm;
- }
-
- @Override
- public void setHighAlarmOn(final boolean highAlarmOn) {
- this.highAlarmOn = highAlarmOn;
- }
-
- @Override
- public void setHighestRecordedValue(final double highestRecordedValue) {
- this.highestRecordedValue = highestRecordedValue;
- }
-
- @Override
- public void setHost(final String host) {
- this.host = host;
- }
-
- @Override
- public void setId(final long id) {
- this.id = id;
- }
-
- @Override
- public void setJsonPointDataArray(final String jsonPointDataArray) {
- this.jsonPointDataArray = jsonPointDataArray;
- }
-
- @Override
- public void setLastAlarmSent(final long lastAlarmSent) {
- this.lastAlarmSent = lastAlarmSent;
- }
-
- @Override
- public void setLastChecked(final Date lastChecked) {
- this.lastChecked = new Date(lastChecked.getTime());
- }
-
- @Override
- public void setLastLat(final double lastLat) {
- this.lat = lastLat;
- }
-
- @Override
- public void setLastLng(final double lastLng) {
- this.lng = lastLng;
- }
-
- @Override
- public void setLastNote(final String lastNote) {
- this.lastNote = lastNote;
- }
-
- @Override
- public void setLastRecordedTimestamp(final Date lastRecordedTimestamp) {
- this.lastRecordedTimestamp = new Date(lastRecordedTimestamp.getTime());
- }
-
- @Override
- public void setLat(final double lat) {
- this.lat = lat;
- }
-
- @Override
- public void setLng(final double lng) {
- this.lng = lng;
- }
-
- @Override
- public void setLowAlarm(final double lowAlarm) {
- this.lowAlarm = lowAlarm;
- }
-
- @Override
- public void setLowAlarmOn(final boolean lowAlarmOn) {
- this.lowAlarmOn = lowAlarmOn;
- }
-
- @Override
- public void setLowestRecordedValue(final double lowestRecordedValue) {
- this.lowestRecordedValue = lowestRecordedValue;
- }
-
-
- @Override
- public void setName(final PointName name) {
- this.name = name.getValue();
- }
-
- @Override
- public void setPostToFacebook(final boolean postToFacebook) {
- this.postToFacebook = postToFacebook;
- }
-
- @Override
- public void setPublic(final boolean isPublic) {
- this.isPublic = isPublic;
- }
-
- @Override
- public void setSendAlarmIM(final boolean sendAlarmIM) {
- this.sendAlarmIM = sendAlarmIM;
- }
-
- @Override
- public void setSendAlarmTweet(final boolean sendAlarmTweet) {
- this.sendAlarmTweet = sendAlarmTweet;
- }
-
- @Override
- public void setSendIM(final boolean sendIM) {
- this.sendIM = sendIM;
- }
-
- @Override
- public void setSendTweet(final boolean sendTweet) {
- this.sendTweet = sendTweet;
- }
-
- @Override
- public void setSystemPoint(final boolean isSystemPoint) {
- this.isSystemPoint = isSystemPoint;
- }
-
- @Override
- public void setTag(final String tag) {
- this.tag = tag;
- }
-
- @Override
- public void setTarget(final long long1) {
- this.target = long1;
- }
-
- @Override
- public void setUnit(final String unit) {
- this.unit = unit;
- }
-
- @Override
- public void setUserFK(final long userFK) {
- this.userFK = userFK;
- }
-
- @Override
- public void setUuid(final String uuid) {
- this.uuid = uuid;
- }
-
- @Override
- public void setValue(final Value value) {
- this.value = value;
- }
-
- @Override
- public void setValues(final List<Value> values) {
- this.values = values;
- }
-
- @Override
- public void setX(final long x) {
- X = x;
- }
-
- @Override
- public void setY(final long y) {
- Y = y;
- }
-
- @Override
- public void setZ(final long z) {
- Z = z;
- }
-
- @Override
- public String toString() {
- return name;
-
- }
-
- @Override
- public void setTargetValue(final double targetValue) {
- this.targetValue = targetValue;
- }
-
- @Override
- public double getTargetValue() {
-
- return targetValue;
- }
-
- @Override
- public void setIgnoreIncomingCompressedValues(
- final boolean ignoreIncomingCompressedValues) {
- this.ignoreIncomingCompressedValues = ignoreIncomingCompressedValues;
- }
-
- @Override
- public boolean getIgnoreIncomingCompressedValues() {
-
- return ignoreIncomingCompressedValues;
- }
-
- @Override
- public void setReadOnly(final boolean readOnly) {
- this.readOnly = readOnly;
- }
-
- @Override
- public boolean getReadOnly() {
-
- return readOnly;
- }
-
-
- public ClientType getClientType() {
- return clientType;
- }
- }