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

@@ -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());