sensor.modify
This commit is contained in:
parent
8a188b3873
commit
a6b9b609d1
2
pom.xml
2
pom.xml
|
@ -50,7 +50,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.loafle.overflow</groupId>
|
<groupId>com.loafle.overflow</groupId>
|
||||||
<artifactId>commons-java</artifactId>
|
<artifactId>commons-java</artifactId>
|
||||||
<version>1.0.116-SNAPSHOT</version>
|
<version>1.0.117-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
package com.loafle.overflow.central.module.sensor.service;
|
package com.loafle.overflow.central.module.sensor.service;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.zip.GZIPInputStream;
|
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
|
@ -53,7 +49,7 @@ public class CentralSensorConfigService {
|
||||||
private MessagePublisher messagePublisher;
|
private MessagePublisher messagePublisher;
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public SensorConfig regist(Sensor sensor) throws OverflowException {
|
public SensorConfig regist(Sensor sensor, boolean update) throws OverflowException {
|
||||||
if (null == sensor.getId()) {
|
if (null == sensor.getId()) {
|
||||||
throw new OverflowException(String.format("ID[%s] of Sensor is not valid", sensor.getId()));
|
throw new OverflowException(String.format("ID[%s] of Sensor is not valid", sensor.getId()));
|
||||||
}
|
}
|
||||||
|
@ -66,7 +62,8 @@ public class CentralSensorConfigService {
|
||||||
|
|
||||||
Probe probe = sensor.getTarget().getInfra().getProbe();
|
Probe probe = sensor.getTarget().getInfra().getProbe();
|
||||||
String encryptedSensorConfigBase64 = this.toEncryptString(sensorConfig, probe.getEncryptionKey());
|
String encryptedSensorConfigBase64 = this.toEncryptString(sensorConfig, probe.getEncryptionKey());
|
||||||
this.messagePublisher.publishToProbe(probe.getProbeKey(), "SensorService.AddSensor", encryptedSensorConfigBase64);
|
String method = update ? "SensorService.UpdateSensor" : "SensorService.AddSensor";
|
||||||
|
this.messagePublisher.publishToProbe(probe.getProbeKey(), method, encryptedSensorConfigBase64);
|
||||||
|
|
||||||
return sensorConfig;
|
return sensorConfig;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,11 @@ public class CentralSensorService implements SensorService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Sensor modify(Sensor sensor) throws OverflowException {
|
||||||
|
return this.sensorDAO.save(sensor);
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public Sensor regist(Sensor sensor, List<MetaDisplayItemMapping> metaDisplayItemMappings) throws OverflowException {
|
public Sensor regist(Sensor sensor, List<MetaDisplayItemMapping> metaDisplayItemMappings) throws OverflowException {
|
||||||
|
@ -82,14 +87,15 @@ public class CentralSensorService implements SensorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FiXME : process asynchronously
|
// FiXME : process asynchronously
|
||||||
this.sensorConfigService.regist(retSensor);
|
this.sensorConfigService.regist(retSensor, false);
|
||||||
|
|
||||||
return retSensor;
|
return retSensor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public Sensor modify(Long sensorID, List<MetaDisplayItemMapping> metaDisplayItemMappings) throws OverflowException {
|
public Sensor modifyItems(Long sensorID, List<MetaDisplayItemMapping> metaDisplayItemMappings)
|
||||||
|
throws OverflowException {
|
||||||
Sensor sensor = this.read(sensorID);
|
Sensor sensor = this.read(sensorID);
|
||||||
if (null == sensor) {
|
if (null == sensor) {
|
||||||
throw new OverflowException(String.format("ID[%d] of Sensor is not valid", sensorID));
|
throw new OverflowException(String.format("ID[%d] of Sensor is not valid", sensorID));
|
||||||
|
@ -98,6 +104,8 @@ public class CentralSensorService implements SensorService {
|
||||||
for (MetaDisplayItemMapping metaDisplayItemMapping : metaDisplayItemMappings) {
|
for (MetaDisplayItemMapping metaDisplayItemMapping : metaDisplayItemMappings) {
|
||||||
this.sensorItemService.regist(sensor, metaDisplayItemMapping);
|
this.sensorItemService.regist(sensor, metaDisplayItemMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.sensorConfigService.regist(sensor, true);
|
||||||
return sensor;
|
return sensor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user