package com.giannoules.proxstor.api;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import org.joda.time.DateTime;

@XmlRootElement
public class Locality {
    
    String localityId;             // unique ID of locality
    
    public String locId;           // associated locId (manual & auto)
    public String devId;           // device associated with checkin
    public String sensorId;        // sensor associated with checkin

    public boolean manual;         // manual entry?
    public boolean active;         // is locality currently active?

//    List<String> sensors;          // list of sensors sensed in this locality

    public DateTime arrival;        // arrival time
    public DateTime departure;     // departure time

    
    public Locality() {
    }
    
    public Locality(Sensor s) {
//        sensors = new ArrayList<>();
//        sensors.add(s.getSensorId());
    }
    
    public void setLocalityId(String id) {
        localityId = id;
    }
    
    public String getLocalityId() {
        return localityId;
    }
    
//    public List<String> getSensors() {
//        return sensors;
//    }
//    
//    public void addSensor(Sensor s) {
//        if (sensors == null) {
//            sensors = new ArrayList<>();
//        }
//        if (!sensors.contains(s.getSensorId())) {
//            sensors.add(s.getSensorId());
//        }
//    }

    public String getDeviceId() {
        return devId;
    }

    public void setDeviceId(String deviceId) {
        this.devId = deviceId;
    }

    public boolean isManual() {
        return manual;
    }

    public void setManual(boolean manual) {
        this.manual = manual;
    }

    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

//    public SensorType getSensorType() {
//        return sensorType;
//    }
//
//    public void setSensorType(SensorType sensorType) {
//        this.sensorType = sensorType;
//    }
//
//    public String getSensorValue() {
//        return sensorValue;
//    }
//
//    public void setSensorValue(String sensorValue) {
//        this.sensorValue = sensorValue;
//    }

    public void setSensorId(String sensorId) {
        this.sensorId = sensorId;
    }
    
    public String getSensorId() {
        return sensorId;
    }
    
    public String getLocationId() {
        return locId;
    }

    public void setLocationId(String locationId) {
        this.locId = locationId;
    }

    public DateTime getArrival() {
        return arrival;
    }

    public void setArrival(DateTime arrive) {
        this.arrival = arrive;
    }

    public DateTime getDeparture() {
        return departure;
    }

    public void setDeparture(DateTime departure) {
        this.departure = departure;
    }
    
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(localityId).append(": ");
        sb.append("devId: ").append(devId).append(" ");
        sb.append("manual: ").append(manual).append(" ");
//        sb.append("sensorType: ").append(sensorType).append(" ");
//        sb.append("sensorValue: ").append(sensorValue).append(" ");
        sb.append("sensorId: " + sensorId);
        sb.append("arrive: ").append(arrival).append(" ");
        sb.append("depart: ").append(departure);
        return sb.toString();
    }
    
}

@@ -35,82 +35,8 @@
 i;%0A%0A
-import java.util.ArrayList;%0Aimport java.util.Date;%0Aimport java.util.List;%0A
 impo
@@ -243,24 +243,24 @@
 ring loc
-Id;     
+ationId;
       //
@@ -274,16 +274,21 @@
 ated loc
+ation
 Id (manu
@@ -319,22 +319,22 @@
 ring dev
+ice
 Id;
-   
         
@@ -562,89 +562,8 @@
 e?%0A%0A
-//    List%3CString%3E sensors;          // list of sensors sensed in this locality%0A%0A
     
@@ -586,17 +586,16 @@
 arrival;
- 
        /
@@ -707,130 +707,8 @@
    %0A
-    public Locality(Sensor s) %7B%0A//        sensors = new ArrayList%3C%3E();%0A//        sensors.add(s.getSensorId());%0A    %7D%0A    %0A
     
@@ -860,335 +860,8 @@
    %0A
-//    public List%3CString%3E getSensors() %7B%0A//        return sensors;%0A//    %7D%0A//    %0A//    public void addSensor(Sensor s) %7B%0A//        if (sensors == null) %7B%0A//            sensors = new ArrayList%3C%3E();%0A//        %7D%0A//        if (!sensors.contains(s.getSensorId())) %7B%0A//            sensors.add(s.getSensorId());%0A//        %7D%0A//    %7D%0A%0A
     
@@ -908,16 +908,19 @@
 turn dev
+ice
 Id;%0A    
@@ -985,16 +985,19 @@
 this.dev
+ice
 Id = dev
@@ -1300,384 +1300,8 @@
  %7D%0A%0A
-//    public SensorType getSensorType() %7B%0A//        return sensorType;%0A//    %7D%0A//%0A//    public void setSensorType(SensorType sensorType) %7B%0A//        this.sensorType = sensorType;%0A//    %7D%0A//%0A//    public String getSensorValue() %7B%0A//        return sensorValue;%0A//    %7D%0A//%0A//    public void setSensorValue(String sensorValue) %7B%0A//        this.sensorValue = sensorValue;%0A//    %7D%0A%0A
     
@@ -1512,16 +1512,21 @@
 turn loc
+ation
 Id;%0A    
@@ -1595,16 +1595,21 @@
 this.loc
+ation
 Id = loc
@@ -2118,16 +2118,19 @@
 pend(dev
+ice
 Id).appe
@@ -2188,34 +2188,32 @@
 l).append(%22 %22);%0A
-//
         sb.appen
@@ -2225,160 +2225,42 @@
 nsor
-Type: %22).append(sensorType).append(%22 %22);%0A//        sb.append(%22sensorValue: %22).append(sensorValue).append(%22 %22);%0A        sb.append(%22sensorId: %22 + sensorId
+Id: %22).append(sensorId).append(%22 %22
 );%0A 

remove list of sensors