Updating how controllers work together with shared data.

This commit is contained in:
Admin
2015-08-14 16:19:51 -05:00
parent 4a80ce4230
commit b9076d1f2e
6 changed files with 74 additions and 44 deletions

View File

@@ -106,8 +106,8 @@ public class DeviceResponse {
deviceState.setCt(313);
List<Double> xv = new LinkedList<>();
xv.add(0.4255);
xv.add(0.3998);
xv.add(Double.valueOf("0.4255"));
xv.add(Double.valueOf("0.3998"));
deviceState.setXy(xv);
deviceState.setColormode("ct");
response.setName(name);

View File

@@ -62,12 +62,15 @@ public class DeviceRepository {
}
private void put(int id, DeviceDescriptor aDescriptor) {
devices.put(String.valueOf(id),aDescriptor);
devices.put(String.valueOf(id), aDescriptor);
}
public void save(DeviceDescriptor aDescriptor) {
int id = random.nextInt(Integer.MAX_VALUE);
aDescriptor.setId(String.valueOf(id));
if(aDescriptor.getId() != null)
devices.remove(aDescriptor.getId());
else
aDescriptor.setId(String.valueOf(id));
put(id, aDescriptor);
JsonTransformer aRenderer = new JsonTransformer();
String jsonValue = aRenderer.render(findAll());