/v3.2/nimbits-model/src/com/nimbits/client/model/point/PointModel.java
Java | 776 lines | 559 code | 198 blank | 19 comment | 2 complexity | 99bdb624594e781889c0f85830f92c04 MD5 | raw file
1/* 2 * Copyright (c) 2010 Tonic Solutions LLC. 3 * 4 * http://www.nimbits.com 5 * 6 * 7 * 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 8 * 9 * http://www.gnu.org/licenses/gpl.html 10 * 11 * 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. 12 */ 13 14package com.nimbits.client.model.point; 15 16import com.nimbits.client.model.ClientType; 17import com.nimbits.client.model.common.CommonFactoryLocator; 18import com.nimbits.client.model.value.AlertType; 19import com.nimbits.client.model.value.Value; 20 21import java.io.Serializable; 22import java.util.Date; 23import java.util.List; 24 25 26public class PointModel implements Serializable, Point { 27 28 29 private long id; 30 31 private static final long serialVersionUID = 1L; 32 33 private AlertType alertState; 34 35 private String uuid; 36 37 private Date lastChecked; 38 39 private String host; 40 41 private long catID; 42 43 private boolean isSystemPoint; 44 45 private long userFK; 46 47 private String name; 48 49 private Date createDate; 50 51 private long X; 52 53 private long Y; 54 55 private long Z; 56 57 private long target; 58 59 private String formula; 60 61 private double highAlarm = 0.0; 62 63 private int expire = 90; 64 65 private String unit; 66 67 private double compression = 0.1; 68 69 private double lowAlarm = 0.0; 70 71 private boolean highAlarmOn; 72 73 private boolean lowAlarmOn; 74 75 private int alarmDelay = 1; 76 77 private long lastAlarmSent; 78 79 private String description; 80 81 private boolean isPublic; 82 83 private boolean postToFacebook; 84 85 private boolean alarmToFacebook; 86 87 @Override 88 public boolean isAlarmToEmail() { 89 return alarmToEmail; 90 } 91 92 @Override 93 public void setAlarmToEmail(boolean alarmToEmail) { 94 this.alarmToEmail = alarmToEmail; 95 } 96 97 private boolean alarmToEmail; 98 99 private boolean sendIM; 100 101 private boolean sendAlarmIM; 102 103 private boolean sendTweet; 104 105 private boolean sendAlarmTweet; 106 107 private String tag; 108 109 110 private double lowestRecordedValue; 111 112 private double highestRecordedValue; 113 // 114 // private double lastRecordedValue; 115 116 private Date lastRecordedTimestamp; 117 118 private String lastNote; 119 120 private double lat; 121 122 private double lng; 123 124 private boolean idleAlarmOn; 125 126 private Integer idleSeconds = 0; 127 128 //reset on any data write 129 private boolean idleAlarmSent; 130 131 //reset on any data write 132 private boolean ignoreIncomingCompressedValues; 133 134 //reset on any data write 135 private boolean readOnly; 136 137 public void setClientType(ClientType clientType) { 138 this.clientType = clientType; 139 } 140 141 private ClientType clientType; 142 143 public PointModel(Point p) { 144 this.id = p.getId(); 145 this.uuid = p.getUuid(); 146 this.lastChecked = p.getLastChecked(); 147 this.host = p.getHost(); 148 this.catID = p.getCatID(); 149 this.isSystemPoint = p.isSystemPoint(); 150 this.userFK = p.getUserFK(); 151 this.name = p.getName().getValue(); 152 this.createDate = p.getCreateDate(); 153 this.X = p.getX(); 154 this.Y = p.getY(); 155 this.Z = p.getZ(); 156 this.target = p.getTarget(); 157 this.formula = p.getFormula(); 158 this.highAlarm = p.getHighAlarm(); 159 this.expire = p.getExpire(); 160 this.unit = p.getUnit(); 161 this.compression = p.getCompression(); 162 this.lowAlarm = p.getLowAlarm(); 163 this.highAlarmOn = p.isHighAlarmOn(); 164 this.lowAlarmOn = p.isLowAlarmOn(); 165 this.alarmDelay = p.getAlarmDelay(); 166 this.lastAlarmSent = p.getLastAlarmSent(); 167 this.description = p.getDescription(); 168 this.isPublic = p.isPublic(); 169 this.postToFacebook = p.isPostToFacebook(); 170 this.alarmToFacebook = p.getAlarmToFacebook(); 171 this.sendIM = p.getSendIM(); 172 this.sendAlarmIM = p.getSendAlarmIM(); 173 this.sendTweet = p.getSendTweet(); 174 this.sendAlarmTweet = p.getSendAlarmTweet(); 175 this.tag = p.getTag(); 176 this.lowestRecordedValue = p.getLowestRecordedValue(); 177 this.highestRecordedValue = p.getHighestRecordedValue(); 178 this.lastRecordedTimestamp = p.getLastRecordedTimestamp(); 179 this.lastNote = p.getLastNote(); 180 this.lat = p.getLat(); 181 this.lng = p.getLng(); 182 183 this.idleAlarmOn = p.isIdleAlarmOn(); 184 this.idleSeconds = p.getIdleSeconds(); 185 this.idleAlarmSent = p.getIdleAlarmSent(); 186 this.ignoreIncomingCompressedValues = p.getIgnoreIncomingCompressedValues(); 187 this.readOnly = p.getReadOnly(); 188 this.targetValue = p.getTargetValue(); 189 this.jsonPointDataArray = p.getJsonPointDataArray(); 190 this.values = p.getValues(); 191 this.value = p.getValue(); 192 193 this.alarmToEmail = p.isAlarmToEmail(); 194 195 } 196 197 198 @Override 199 public boolean isIdleAlarmOn() { 200 return idleAlarmOn; 201 } 202 203 @Override 204 public AlertType getAlertState() { 205 return this.alertState; 206 } 207 208 @Override 209 public void setAlertState(final AlertType alertState) { 210 this.alertState = alertState; 211 } 212 213 @Override 214 public void setIdleAlarmOn(final boolean idleAlarmOn) { 215 this.idleAlarmOn = idleAlarmOn; 216 } 217 218 @Override 219 public int getIdleSeconds() { 220 return idleSeconds; 221 } 222 223 @Override 224 public void setIdleSeconds(final int idleSeconds) { 225 this.idleSeconds = idleSeconds; 226 } 227 228 @Override 229 public boolean getIdleAlarmSent() { 230 return idleAlarmSent; 231 } 232 233 @Override 234 public void setIdleAlarmSent(final boolean idleAlarmSent) { 235 this.idleAlarmSent = idleAlarmSent; 236 } 237 238 // Constructors 239 public PointModel() { 240 } 241 242 public PointModel(final long userFK, final PointName pointName, final long catID, final String uuid) { 243 this(); 244 this.userFK = userFK; 245 this.name = pointName.getValue(); 246 this.catID = catID; 247 this.uuid = uuid; 248 249 250 } 251 252 public PointModel(final long userFK, final PointName pointName, final String uuid) { 253 this(); 254 this.userFK = userFK; 255 this.name = pointName.getValue(); 256 this.highestRecordedValue = 0.0; 257 this.lowestRecordedValue = 0.0; 258 this.lastRecordedTimestamp = new Date(); 259 this.uuid = uuid; 260 } 261 262 public PointModel(final PointName name, final String uuid) { 263 this.name = name.getValue(); 264 this.highestRecordedValue = 0.0; 265 this.lowestRecordedValue = 0.0; 266 this.lastRecordedTimestamp = new Date(); 267 this.uuid = uuid; 268 269 } 270 271 public PointModel(final long id, final long userFk) { 272 this.id = id; 273 this.userFK = userFk; 274 275 } 276 // End Constructors 277 278 private double targetValue; 279 280 private String jsonPointDataArray; 281 282 private List<Value> values; 283 284 private Value value; 285 286 @Override 287 public int getAlarmDelay() { 288 return alarmDelay; 289 } 290 291 @Override 292 public boolean getAlarmToFacebook() { 293 294 return alarmToFacebook; 295 296 } 297 298 @Override 299 public long getCatID() { 300 return catID; 301 } 302 303 @Override 304 public double getCompression() { 305 return this.compression; 306 } 307 308 @Override 309 public Date getCreateDate() { 310 return new Date(this.createDate.getTime()); 311 } 312 313 @Override 314 public String getDescription() { 315 316 return this.description == null ? "" : this.description; 317 } 318 319 @Override 320 public int getExpire() { 321 return expire; 322 } 323 324 @Override 325 public String getFormula() { 326 return this.formula; 327 } 328 329 @Override 330 public double getHighAlarm() { 331 return highAlarm; 332 } 333 334 @Override 335 public double getHighestRecordedValue() { 336 337 return highestRecordedValue; 338 } 339 340 @Override 341 public String getHost() { 342 return host; 343 } 344 345 @Override 346 public long getId() { 347 return id; 348 } 349 350 351 @Override 352 public String getJsonPointDataArray() { 353 return jsonPointDataArray; 354 } 355 356 @Override 357 public long getLastAlarmSent() { 358 return lastAlarmSent; 359 } 360 361 @Override 362 public Date getLastChecked() { 363 364 return new Date(this.lastChecked.getTime()); 365 } 366 367 @Override 368 public double getLastLat() { 369 370 return lat; 371 } 372 373 @Override 374 public double getLastLng() { 375 376 return lng; 377 } 378 379 @Override 380 public String getLastNote() { 381 return lastNote; 382 } 383 384 @Override 385 public Date getLastRecordedTimestamp() { 386 return lastRecordedTimestamp == null ? new Date() : new Date(this.lastRecordedTimestamp.getTime()); 387 } 388 389 @Override 390 public double getLat() { 391 return getLastLat(); 392 } 393 394 @Override 395 public double getLng() { 396 return getLastLng(); 397 } 398 399 @Override 400 public double getLowAlarm() { 401 return lowAlarm; 402 } 403 404 @Override 405 public double getLowestRecordedValue() { 406 407 return lowestRecordedValue; 408 } 409 410 @Override 411 public PointName getName() { 412 return CommonFactoryLocator.getInstance().createPointName(this.name); 413 } 414 415 @Override 416 public boolean getSendAlarmIM() { 417 418 return sendAlarmIM; 419 } 420 421 @Override 422 public boolean getSendAlarmTweet() { 423 424 return sendAlarmTweet; 425 } 426 427 @Override 428 public boolean getSendIM() { 429 430 return sendIM; 431 } 432 433 @Override 434 public boolean getSendTweet() { 435 436 return sendTweet; 437 } 438 439 @Override 440 public String getTag() { 441 return tag; 442 } 443 444 @Override 445 public long getTarget() { 446 return target; 447 } 448 449 @Override 450 public String getUnit() { 451 return unit; 452 } 453 454 455 @Override 456 public long getUserFK() { 457 return userFK; 458 } 459 460 @Override 461 public String getUuid() { 462 return uuid; 463 } 464 465 @Override 466 public Value getValue() { 467 return value; 468 } 469 470 @Override 471 public List<Value> getValues() { 472 return values; 473 } 474 475 @Override 476 public long getX() { 477 return X; 478 } 479 480 @Override 481 public long getY() { 482 return Y; 483 } 484 485 @Override 486 public long getZ() { 487 return Z; 488 } 489 490 @Override 491 public boolean isHighAlarmOn() { 492 return highAlarmOn; 493 } 494 495 @Override 496 public boolean isLowAlarmOn() { 497 return lowAlarmOn; 498 } 499 500 @Override 501 public boolean isPostToFacebook() { 502 return postToFacebook; 503 } 504 505 @Override 506 public boolean isPublic() { 507 return isPublic; 508 } 509 510 @Override 511 public boolean isSystemPoint() { 512 return isSystemPoint; 513 } 514 515 @Override 516 public void setAlarmDelay(final int alarmDelay) { 517 this.alarmDelay = alarmDelay; 518 } 519 520 @Override 521 public void setAlarmToFacebook(final boolean alarmToFacebook) { 522 this.alarmToFacebook = alarmToFacebook; 523 } 524 525 @Override 526 public void setCatID(final long catID) { 527 this.catID = catID; 528 } 529 530 @Override 531 public void setCompression(final double compression) { 532 this.compression = compression; 533 } 534 535 @Override 536 public void setCreateDate(final Date createDate) { 537 this.createDate = new Date(createDate.getTime()); 538 } 539 540 @Override 541 public void setDescription(final String value) { 542 this.description = value; 543 544 } 545 546 @Override 547 public void setExpire(final int expire) { 548 this.expire = expire; 549 } 550 551 @Override 552 public void setFormula(final String formula) { 553 this.formula = formula; 554 } 555 556 @Override 557 public void setHighAlarm(double highAlarm) { 558 this.highAlarm = highAlarm; 559 } 560 561 @Override 562 public void setHighAlarmOn(final boolean highAlarmOn) { 563 this.highAlarmOn = highAlarmOn; 564 } 565 566 @Override 567 public void setHighestRecordedValue(final double highestRecordedValue) { 568 this.highestRecordedValue = highestRecordedValue; 569 } 570 571 @Override 572 public void setHost(final String host) { 573 this.host = host; 574 } 575 576 @Override 577 public void setId(final long id) { 578 this.id = id; 579 } 580 581 @Override 582 public void setJsonPointDataArray(final String jsonPointDataArray) { 583 this.jsonPointDataArray = jsonPointDataArray; 584 } 585 586 @Override 587 public void setLastAlarmSent(final long lastAlarmSent) { 588 this.lastAlarmSent = lastAlarmSent; 589 } 590 591 @Override 592 public void setLastChecked(final Date lastChecked) { 593 this.lastChecked = new Date(lastChecked.getTime()); 594 } 595 596 @Override 597 public void setLastLat(final double lastLat) { 598 this.lat = lastLat; 599 } 600 601 @Override 602 public void setLastLng(final double lastLng) { 603 this.lng = lastLng; 604 } 605 606 @Override 607 public void setLastNote(final String lastNote) { 608 this.lastNote = lastNote; 609 } 610 611 @Override 612 public void setLastRecordedTimestamp(final Date lastRecordedTimestamp) { 613 this.lastRecordedTimestamp = new Date(lastRecordedTimestamp.getTime()); 614 } 615 616 @Override 617 public void setLat(final double lat) { 618 this.lat = lat; 619 } 620 621 @Override 622 public void setLng(final double lng) { 623 this.lng = lng; 624 } 625 626 @Override 627 public void setLowAlarm(final double lowAlarm) { 628 this.lowAlarm = lowAlarm; 629 } 630 631 @Override 632 public void setLowAlarmOn(final boolean lowAlarmOn) { 633 this.lowAlarmOn = lowAlarmOn; 634 } 635 636 @Override 637 public void setLowestRecordedValue(final double lowestRecordedValue) { 638 this.lowestRecordedValue = lowestRecordedValue; 639 } 640 641 642 @Override 643 public void setName(final PointName name) { 644 this.name = name.getValue(); 645 } 646 647 @Override 648 public void setPostToFacebook(final boolean postToFacebook) { 649 this.postToFacebook = postToFacebook; 650 } 651 652 @Override 653 public void setPublic(final boolean isPublic) { 654 this.isPublic = isPublic; 655 } 656 657 @Override 658 public void setSendAlarmIM(final boolean sendAlarmIM) { 659 this.sendAlarmIM = sendAlarmIM; 660 } 661 662 @Override 663 public void setSendAlarmTweet(final boolean sendAlarmTweet) { 664 this.sendAlarmTweet = sendAlarmTweet; 665 } 666 667 @Override 668 public void setSendIM(final boolean sendIM) { 669 this.sendIM = sendIM; 670 } 671 672 @Override 673 public void setSendTweet(final boolean sendTweet) { 674 this.sendTweet = sendTweet; 675 } 676 677 @Override 678 public void setSystemPoint(final boolean isSystemPoint) { 679 this.isSystemPoint = isSystemPoint; 680 } 681 682 @Override 683 public void setTag(final String tag) { 684 this.tag = tag; 685 } 686 687 @Override 688 public void setTarget(final long long1) { 689 this.target = long1; 690 } 691 692 @Override 693 public void setUnit(final String unit) { 694 this.unit = unit; 695 } 696 697 @Override 698 public void setUserFK(final long userFK) { 699 this.userFK = userFK; 700 } 701 702 @Override 703 public void setUuid(final String uuid) { 704 this.uuid = uuid; 705 } 706 707 @Override 708 public void setValue(final Value value) { 709 this.value = value; 710 } 711 712 @Override 713 public void setValues(final List<Value> values) { 714 this.values = values; 715 } 716 717 @Override 718 public void setX(final long x) { 719 X = x; 720 } 721 722 @Override 723 public void setY(final long y) { 724 Y = y; 725 } 726 727 @Override 728 public void setZ(final long z) { 729 Z = z; 730 } 731 732 @Override 733 public String toString() { 734 return name; 735 736 } 737 738 @Override 739 public void setTargetValue(final double targetValue) { 740 this.targetValue = targetValue; 741 } 742 743 @Override 744 public double getTargetValue() { 745 746 return targetValue; 747 } 748 749 @Override 750 public void setIgnoreIncomingCompressedValues( 751 final boolean ignoreIncomingCompressedValues) { 752 this.ignoreIncomingCompressedValues = ignoreIncomingCompressedValues; 753 } 754 755 @Override 756 public boolean getIgnoreIncomingCompressedValues() { 757 758 return ignoreIncomingCompressedValues; 759 } 760 761 @Override 762 public void setReadOnly(final boolean readOnly) { 763 this.readOnly = readOnly; 764 } 765 766 @Override 767 public boolean getReadOnly() { 768 769 return readOnly; 770 } 771 772 773 public ClientType getClientType() { 774 return clientType; 775 } 776}