HttpServletResponse resp) {
JSONObject devices = new JSONObject();
// pumps
List pumps = fireApplication.getPumps();
JSONArray pumpsArray = new JSONArray();
for (Iterator it = pumps.iterator(); it.hasNext();) {
EndPointService es = (EndPointService) it.next();
String name = es.getName();
String friendlyName = getDeviceFriendlyNameId(es);
name = name + " " + friendlyName;
// remove first # from friendlyname
friendlyName = friendlyName.replaceAll("#", "");
String id = PUMP_PREFIX_ID + friendlyName;
Map properties = new HashMap();
properties.put(ID_PROP, id);
properties.put(NAME_PROP, name);
properties.put(TECHNO_PROP, ZIGBEE_TECHNO);
properties.put(IMG_PROP, PUMP_IMG);
JSONObject pumpJs = new JSONObject(properties);
pumpsArray.add(pumpJs);
}
// GreenNet switches is also viewed as a pump (i.e. actuator)
List greenNetSwitches = fireApplication.getGreenNetSwitches();
for(Iterator it = greenNetSwitches.iterator(); it.hasNext();) {
Device greenNetSwitch = (Device) it.next();
String id = ((Actuator)greenNetSwitch).getNode().getIdentifier();
String name = "Air extractor";
Map properties = new HashMap();
properties.put(ID_PROP, id);
properties.put(NAME_PROP, name);
properties.put(TECHNO_PROP, GREENNET_TECHNO);
properties.put(IMG_PROP, GREENNET_AIR_EJECTOR_IMG);
JSONObject pumpJs = new JSONObject(properties);
pumpsArray.add(pumpJs);
}
devices.put(PUMPS_PROP, pumpsArray);
// ias zones
List zones = fireApplication.getZoneDevices();
JSONArray zonesArray = new JSONArray();
for (Iterator it = zones.iterator(); it.hasNext();) {
EndPointService es = (EndPointService) it.next();
String name = es.getName();
String friendlyName = getDeviceFriendlyNameId(es);
name = name + " " + friendlyName;
// remove first # from friendlyname
friendlyName = friendlyName.replaceAll("#", "");
String id = IAS_ZONES_PREFIX_ID + friendlyName;
Map properties = new HashMap();
properties.put(ID_PROP, id);
properties.put(NAME_PROP, name);
properties.put(TECHNO_PROP, ZIGBEE_TECHNO);
properties.put(IMG_PROP, SMOKE_DETECTOR_IMG);
JSONObject zoneJs = new JSONObject(properties);
zonesArray.add(zoneJs);
}
devices.put(IAS_ZONES_PROP, zonesArray);
// warning devices
List warnings = fireApplication.getWarningDevices();
JSONArray warningArray = new JSONArray();
for (Iterator it = warnings.iterator(); it.hasNext();) {
EndPointService es = (EndPointService) it.next();
String name = es.getName();
String friendlyName = getDeviceFriendlyNameId(es);
name = name + " " + friendlyName;
// remove first # from friendlyname
friendlyName = friendlyName.replaceAll("#", "");
String id = IAS_WARNING_PREFIX_ID + friendlyName;
Map properties = new HashMap();
properties.put(ID_PROP, id);
properties.put(NAME_PROP, name);
properties.put(TECHNO_PROP, ZIGBEE_TECHNO);
properties.put(IMG_PROP, WARNING_IMG);
JSONObject warningJs = new JSONObject(properties);
warningArray.add(warningJs);
}
// x3d dimmers are also considered as warning devices
List x3dDimmers = fireApplication.getX3DDimmers();
int index = 1;
for(Iterator it = x3dDimmers.iterator(); it.hasNext();) {
X3DLightDimmer dimmer = (X3DLightDimmer) it.next();
String id = X3D_DIMMER_PREFIX_ID + dimmer.getX3DDevice().getDeviceUri();
id = id.replaceAll(" ", "");
id = id.replaceAll("/", "");
id = id.replaceAll(":", "");
String name = "X3D Dimmer #" + index;
index++;
Map properties = new HashMap();
properties.put(ID_PROP, id);
properties.put(NAME_PROP, name);
properties.put(TECHNO_PROP, X3D_TECHNO);
properties.put(IMG_PROP, X3D_DIMMER_IMG);
JSONObject warningJs = new JSONObject(properties);
warningArray.add(warningJs);
}
// hue light are also considered as warning devices
List hueLights = fireApplication.getHueLights();
for(Iterator it = hueLights.iterator(); it.hasNext();) {
HueLightDevice hld = (HueLightDevice) it.next();
String name = hld.getName();
String id = HUE_PREFIX_ID + hld.getId();
Map properties = new HashMap();
properties.put(ID_PROP, id);
properties.put(NAME_PROP, name);
properties.put(TECHNO_PROP, HUE_TECHNO);
properties.put(IMG_PROP, HUE_LIGHT_IMG);
JSONObject warningJs = new JSONObject(properties);
warningArray.add(warningJs);
}
devices.put(IAS_WARNING_PROP, warningArray);