forked from iotoasis/SO
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Device Subscription에 따른 로직 변경 iotoasis#291
- Loading branch information
Showing
13 changed files
with
229 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
so-device/src/main/java/com/pineone/icbms/so/device/store/DeviceSubscriptionStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.pineone.icbms.so.device.store; | ||
|
||
import com.pineone.icbms.so.device.store.mongo.DeviceSubscriptionObject; | ||
|
||
public interface DeviceSubscriptionStore { | ||
void create(DeviceSubscriptionObject deviceSubscriptionObject); | ||
DeviceSubscriptionObject retrieve(String commandId); | ||
void delete(String commandId); | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
...e/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionMongoStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.pineone.icbms.so.device.store.mongo; | ||
|
||
import com.pineone.icbms.so.device.store.DeviceSubscriptionStore; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Repository; | ||
|
||
/** | ||
* MongoDB와 DeviceSubscrption 연결 | ||
*/ | ||
@Repository | ||
public class DeviceSubscriptionMongoStore implements DeviceSubscriptionStore { | ||
|
||
public static final Logger logger = LoggerFactory.getLogger(DeviceSubscriptionMongoStore.class); | ||
|
||
@Autowired | ||
DeviceSubscriptionRepository deviceSubscriptionRepository; | ||
|
||
@Override | ||
public void create(DeviceSubscriptionObject deviceSubscriptionObject) { | ||
logger.debug("Device = " + deviceSubscriptionObject.toString()); | ||
deviceSubscriptionRepository.save(deviceSubscriptionObject); | ||
} | ||
|
||
@Override | ||
public DeviceSubscriptionObject retrieve(String commandId) { | ||
logger.debug("Command ID = " + commandId); | ||
return deviceSubscriptionRepository.findBy_commandId(commandId); | ||
} | ||
|
||
@Override | ||
public void delete(String commandId) { | ||
logger.debug("Command ID = " + commandId); | ||
deviceSubscriptionRepository.delete(commandId); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...evice/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.pineone.icbms.so.device.store.mongo; | ||
|
||
import org.springframework.data.mongodb.core.mapping.Document; | ||
|
||
/** | ||
* Device Subscription에 대한 데이터 | ||
*/ | ||
@Document(collection = "DeviceSubscription") | ||
public class DeviceSubscriptionObject { | ||
// | ||
|
||
private String _id; | ||
|
||
private String _commandId; | ||
|
||
private String deviceStatus; | ||
|
||
public DeviceSubscriptionObject() { | ||
} | ||
|
||
public DeviceSubscriptionObject(String _commandId, String deviceStatus) { | ||
this._commandId = _commandId; | ||
this.deviceStatus = deviceStatus; | ||
} | ||
|
||
public DeviceSubscriptionObject(String _id, String _commandId, String deviceStatus) { | ||
this._id = _id; | ||
this._commandId = _commandId; | ||
this.deviceStatus = deviceStatus; | ||
} | ||
|
||
public String get_commandId() { | ||
return _commandId; | ||
} | ||
|
||
public void set_commandId(String _commandId) { | ||
this._commandId = _commandId; | ||
} | ||
|
||
public String getDeviceStatus() { | ||
return deviceStatus; | ||
} | ||
|
||
public void setDeviceStatus(String deviceStatus) { | ||
this.deviceStatus = deviceStatus; | ||
} | ||
|
||
public String get_id() { | ||
return _id; | ||
} | ||
|
||
public void set_id(String _id) { | ||
this._id = _id; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DeviceSubscriptionObject{" + | ||
"_id='" + _id + '\'' + | ||
", _commandId='" + _commandId + '\'' + | ||
", deviceStatus='" + deviceStatus + '\'' + | ||
'}'; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...e/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.pineone.icbms.so.device.store.mongo; | ||
|
||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
|
||
public interface DeviceSubscriptionRepository extends MongoRepository<DeviceSubscriptionObject, String> { | ||
|
||
DeviceSubscriptionObject findBy_commandId(String commandId); | ||
|
||
} |
Oops, something went wrong.