From 162e1859c23e7b9e59d3c2b69fcdbaf507be6987 Mon Sep 17 00:00:00 2001 From: pahnjy Date: Thu, 8 Dec 2016 16:42:59 +0900 Subject: [PATCH] =?UTF-8?q?Device=20Result=20=EB=B6=80=EB=B6=84=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=20#293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../icbms/so/device/logic/DeviceManager.java | 2 - .../so/device/logic/DeviceManagerLogic.java | 50 -------------- .../so/device/pr/DevicePresentation.java | 13 ---- .../so/device/store/DeviceResultStore.java | 13 ---- .../store/memory/DeviceResultMemory.java | 51 -------------- .../store/mongo/DeviceResultDataObject.java | 67 ------------------- .../store/mongo/DeviceResultMongoStore.java | 61 ----------------- .../store/mongo/DeviceResultRepository.java | 7 -- 8 files changed, 264 deletions(-) delete mode 100644 so-device/src/main/java/com/pineone/icbms/so/device/store/DeviceResultStore.java delete mode 100644 so-device/src/main/java/com/pineone/icbms/so/device/store/memory/DeviceResultMemory.java delete mode 100644 so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceResultDataObject.java delete mode 100644 so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceResultMongoStore.java delete mode 100644 so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceResultRepository.java diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManager.java b/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManager.java index a88f4a4b..f563ceb0 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManager.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManager.java @@ -2,7 +2,6 @@ import com.pineone.icbms.so.device.entity.Device; import com.pineone.icbms.so.device.entity.DeviceStatusData; -import com.pineone.icbms.so.device.entity.ResultMessage; import java.util.List; @@ -10,7 +9,6 @@ public interface DeviceManager { void deviceRegister(String deviceUri, String time); void deviceRelease(String deviceId); String deviceExecute(String deviceId,String deviceCommand, String sessionId); - String deviceControlResult(ResultMessage resultMessage); Device deviceSearchById(String deviceId); List deviceSearchByLocation(String location); List requestDeviceServiceList(String location); diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java b/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java index 6b032dae..bab1f60b 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java @@ -3,7 +3,6 @@ import com.pineone.icbms.so.device.entity.*; import com.pineone.icbms.so.device.proxy.DeviceControlProxy; import com.pineone.icbms.so.device.proxy.DeviceICollectionProxy; -import com.pineone.icbms.so.device.store.DeviceResultStore; import com.pineone.icbms.so.device.store.DeviceStore; import com.pineone.icbms.so.device.store.DeviceSubscriptionStore; import com.pineone.icbms.so.device.store.mongo.DeviceSubscriptionObject; @@ -35,9 +34,6 @@ public class DeviceManagerLogic implements DeviceManager { @Autowired private DeviceStore deviceStore; - @Autowired - private DeviceResultStore deviceResultStore; - @Autowired private SessionStore sessionStore; @@ -185,26 +181,6 @@ public void run() { return resultMessage.getCode(); } - @Override - public String deviceControlResult(ResultMessage resultMessage) { - logger.debug("ResultMessage = " + resultMessage.toString()); - DeviceResult deviceResult = deviceResultStore.retrieve(resultMessage.get_commandId()); - - if(deviceResult != null && deviceResult.getCommandId() != null){ - // It has been confirmed for the linked data. - if(ClientProfile.RESPONSE_SUCCESS_CODE.equals(resultMessage.getCode()) || - ClientProfile.RESPONSE_SUCCESS.equals(resultMessage.getCode()) || - ClientProfile.RESPONSE_SUCCESS_ONEM2MCODE.equals(resultMessage.getCode())){ - - deviceResult.setResult2(resultMessage.getCode()); - deviceResultStore.update(deviceResult); - } - return resultMessage.getCode(); - } else { - return "No device Control Message."; - } - } - @Override public Device deviceSearchById(String deviceId) { logger.debug(LogPrint.LogMethodNamePrint() + " | Device ID = " + deviceId); @@ -257,10 +233,6 @@ public void deviceUpdate(DeviceStatusData deviceStatusData) { deviceSubscriptionRelease(deviceUri + (ClientProfile.actionDeviceCommand(device.getDeviceUri()) ? ClientProfile.SI_CONTAINER_ACTION : ClientProfile.SI_CONTAINER_POWER) + ClientProfile.SI_CONTAINER_STATUS); deviceSubscriptionStore.delete(deviceSubscriptionObject.get_id()); } - - if(!deviceStatusData.getDeviceStatus().isEmpty() && !deviceStatusData.checkDeviceStatus(device.getDeviceStatus())) { - - } } } @@ -297,28 +269,6 @@ private Device deviceRequest(String uri){ return deviceICollectionProxy.findDeviceByID(uri); } - /** - * Device 제어 결과 저장. 2차년도에는 Device Subscription으로 불필요. - * @param deviceId - * @param commandId - * @param deviceCommand - * @param resultMessage - */ - private void controlResultsStorage(String deviceId, String commandId, String deviceCommand, ResultMessage resultMessage){ - - DeviceResult deviceResult = new DeviceResult(); - - deviceResult.setCommandId(commandId); - deviceResult.setSendMessage(deviceId + deviceCommand); - deviceResult.setDeviceUrl(deviceId); - deviceResult.setValue(deviceCommand); - deviceResult.setResult1(resultMessage.getCode()); - deviceResult.setResult2(""); - - deviceResultStore.create(deviceResult); - - } - /** * Device 생성 * Device Id, createTime,exfitedTime 추가 diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/pr/DevicePresentation.java b/so-device/src/main/java/com/pineone/icbms/so/device/pr/DevicePresentation.java index 934257f9..fe71f9ce 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/pr/DevicePresentation.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/pr/DevicePresentation.java @@ -132,19 +132,6 @@ public void deviceDisableNotification(@RequestBody deviceReleaseMessage message) deviceManager.deviceRelease(message.getDeviceId()); } - - /** - * Device 제어 결과 노티 SI -> SO - */ - @RequestMapping(value ="/monitor",method = RequestMethod.POST) - @ResponseStatus(value = HttpStatus.OK) - public String asynchronousControlResult(@RequestBody ResultMessage message){ - // NOTO : Device the result is stored in the data memory. - logger.info(LogPrint.inputInfoLogPrint() + "Result = " + message.getCode()); - logger.debug("ResultMessage = " + message.toString()); - return deviceManager.deviceControlResult(message); - } - /** * Device Operation을 검색 */ diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/store/DeviceResultStore.java b/so-device/src/main/java/com/pineone/icbms/so/device/store/DeviceResultStore.java deleted file mode 100644 index b9988c3c..00000000 --- a/so-device/src/main/java/com/pineone/icbms/so/device/store/DeviceResultStore.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.pineone.icbms.so.device.store; - -import com.pineone.icbms.so.device.entity.DeviceResult; - -public interface DeviceResultStore { - - void create(DeviceResult deviceResult); - DeviceResult retrieve(String id); - - void update(DeviceResult deviceResult); - void delete(String id); - -} diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/store/memory/DeviceResultMemory.java b/so-device/src/main/java/com/pineone/icbms/so/device/store/memory/DeviceResultMemory.java deleted file mode 100644 index e8089faf..00000000 --- a/so-device/src/main/java/com/pineone/icbms/so/device/store/memory/DeviceResultMemory.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.pineone.icbms.so.device.store.memory; - -import com.pineone.icbms.so.device.entity.DeviceResult; -import com.pineone.icbms.so.device.store.DeviceResultStore; - -import java.util.HashMap; -import java.util.Map; - -public class DeviceResultMemory implements DeviceResultStore { - - // - static private Map deviceResultRepository = new HashMap<>(); - private static DeviceResultMemory instance; - - private DeviceResultMemory() { - } - - public static DeviceResultMemory getInstance(){ - if(instance == null) { - instance = new DeviceResultMemory(); - } - return instance; - } - - - - @Override - public void create(DeviceResult deviceResult) { - // - deviceResultRepository.put(deviceResult.getCommandId(),deviceResult); - } - - @Override - public DeviceResult retrieve(String id) { - // - DeviceResult deviceResult = deviceResultRepository.get(id); - return deviceResult; - } - - @Override - public void update(DeviceResult deviceResult) { - // - deviceResultRepository.put(deviceResult.getCommandId(),deviceResult); - } - - @Override - public void delete(String id) { - deviceResultRepository.remove(id); - - } -} diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceResultDataObject.java b/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceResultDataObject.java deleted file mode 100644 index 46b0d764..00000000 --- a/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceResultDataObject.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.pineone.icbms.so.device.store.mongo; - -import org.springframework.data.mongodb.core.mapping.Document; - -@Document(collection = "DeviceResult") -public class DeviceResultDataObject { - - String sendMessage; - - String result1; - - String result2; - - String commandId; - - String value; - - String deviceUrl; - - public DeviceResultDataObject() { - } - - public DeviceResultDataObject(String sendMessage, String result1, String result2, String commandId, String value, String deviceUrl) { - this.sendMessage = sendMessage; - this.result1 = result1; - this.result2 = result2; - this.commandId = commandId; - this.value = value; - this.deviceUrl = deviceUrl; - } - - public String getSendMessage() { - return sendMessage; - } - - public String getResult1() { - return result1; - } - - public String getResult2() { - return result2; - } - - public String getCommandId() { - return commandId; - } - - public String getValue() { - return value; - } - - public String getDeviceUrl() { - return deviceUrl; - } - - @Override - public String toString() { - return "DeviceResultDataObject{" + - "sendMessage='" + sendMessage + '\'' + - ", result1='" + result1 + '\'' + - ", result2='" + result2 + '\'' + - ", commandId='" + commandId + '\'' + - ", value='" + value + '\'' + - ", deviceUrl='" + deviceUrl + '\'' + - '}'; - } -} diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceResultMongoStore.java b/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceResultMongoStore.java deleted file mode 100644 index 82e9abc3..00000000 --- a/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceResultMongoStore.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.pineone.icbms.so.device.store.mongo; - -import com.pineone.icbms.so.device.entity.DeviceResult; -import com.pineone.icbms.so.device.store.DeviceResultStore; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Repository; - - -@Repository -public class DeviceResultMongoStore implements DeviceResultStore { - - public static final Logger logger = LoggerFactory.getLogger(DeviceResultMongoStore.class); - - @Autowired - DeviceResultRepository deviceResultRepository; - - @Override - public void create(DeviceResult deviceResult) { - logger.debug("DeviceResult = " + deviceResult.toString()); - DeviceResultDataObject d = deviceResultToDataObject(deviceResult); - deviceResultRepository.save(d); - } - - @Override - public DeviceResult retrieve(String id) { - logger.debug("DeviceResult ID = " + id); - DeviceResultDataObject d = deviceResultRepository.findOne(id); - DeviceResult deviceResult = DeviceResultObjectToDeviceResult(d); - logger.debug("DeviceResult = " + deviceResult.toString()); - return deviceResult; - } - - @Override - public void update(DeviceResult deviceResult) { - logger.debug("DeviceResult = " + deviceResult.toString()); - DeviceResultDataObject d = deviceResultToDataObject(deviceResult); - deviceResultRepository.save(d); - } - - @Override - public void delete(String id) { - logger.debug("DeviceResult ID = " + id); - deviceResultRepository.delete(id); - } - - private DeviceResultDataObject deviceResultToDataObject(DeviceResult deviceResult){ - if(deviceResult == null) { - return null; - } - return new DeviceResultDataObject(deviceResult.getSendMessage(),deviceResult.getResult1(),deviceResult.getResult2(),deviceResult.getCommandId(),deviceResult.getValue(),deviceResult.getDeviceUrl()); - } - - private DeviceResult DeviceResultObjectToDeviceResult(DeviceResultDataObject deviceResultDataObject){ - if(deviceResultDataObject == null){ - return null; - } - return new DeviceResult(deviceResultDataObject.getSendMessage(), deviceResultDataObject.getResult1(), deviceResultDataObject.getResult2(), deviceResultDataObject.getCommandId(), deviceResultDataObject.getValue(), deviceResultDataObject.getDeviceUrl()); - } -} diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceResultRepository.java b/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceResultRepository.java deleted file mode 100644 index fb48ba8e..00000000 --- a/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceResultRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.pineone.icbms.so.device.store.mongo; - -import org.springframework.data.mongodb.repository.MongoRepository; - -public interface DeviceResultRepository extends MongoRepository { - -}