Skip to content

Commit

Permalink
ServiceModel API 추가 iotoasis#337
Browse files Browse the repository at this point in the history
  • Loading branch information
pahnjy01 committed Feb 1, 2017
1 parent 063cfb5 commit 23df941
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public interface ServiceModelLogic {
List<String> retrieveServiceIdList();
List<String> retrieveServiceModelIdList();
List<ServiceModel> retrieveServiceModelList();
String retreveServiceModelId(String serviceModelName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ public List<ServiceModel> retrieveServiceModelList() {
return serviceModelList;
}

@Override
public String retreveServiceModelId(String serviceModelName) {
return serviceModelStore.retrieveServiceModelId(serviceModelName);
}

private boolean locationCompare(Session session, String serviceModelLocation){
List<String> contextLocation = null;
if(session.isExistSessionData(DefaultSession.LOCATION_ID)){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,24 @@ public List<ServiceModel> retrieveServiceModelList(){
@ResponseStatus(value = HttpStatus.OK)
public ServiceModel retrieveServiceModelDetailController(@PathVariable String serviceModelId){
logger.info(LogPrint.inputInfoLogPrint() + "ServiceModel ID = " + serviceModelId);
//
ServiceModel serviceModel = serviceModelLogic.retrieveServiceModelDetail(serviceModelId);
logger.debug("ServiceModel = " + serviceModel);
return serviceModel;
}

/**
* ServiceModel ID 조회 By Name
*/
@RequestMapping(value = "/names/{serviceModelName}", method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)
public String retrieveServiceModelId(@PathVariable String serviceModelName){
logger.info(LogPrint.inputInfoLogPrint() + "ServiceModel Name = " + serviceModelName);
String serviceModelId = serviceModelLogic.retreveServiceModelId(serviceModelName);
logger.debug("ServiceModel Name = " + serviceModelId);
return serviceModelId;
}


//NOTE: 응급상황으로 발생하는 ContextModel 에 따른 ServiceModel 실행
@RequestMapping(value = "/control", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public interface ServiceModelStore {
void createServiceModel(ServiceModel serviceModel);
List<ServiceModel> retrieveServiceModelList();
ServiceModel retrieveServiceModelDetail(String ServiceModelId);
String retrieveServiceModelId(String serviceModelName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public ServiceModel retrieveServiceModelDetail(String serviceModelName) {
return serviceModel;
}

@Override
public String retrieveServiceModelId(String serviceModelName) {
return null;
}

public static ServiceModelMapStore getInstance(){
if(instance == null)
instance = new ServiceModelMapStore();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
import org.springframework.data.mongodb.repository.MongoRepository;

public interface ServiceModelRepository extends MongoRepository<ServiceModelDataObject, String> {
ServiceModelDataObject findByname(String servicemodelName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public ServiceModel retrieveServiceModelDetail(String serviceModelId) {
return serviceModel;
}

@Override
public String retrieveServiceModelId(String servicemodelName) {
ServiceModelDataObject serviceModelDataObject = serviceModelRepository.findByname(servicemodelName);
return serviceModelDataObject.getId();
}

private ServiceModelDataObject serviceModelToDataObject(ServiceModel serviceModel) {
if(serviceModel == null) return null;
return new ServiceModelDataObject(serviceModel.getId(), serviceModel.getName(), serviceModel.getServiceIdList());
Expand Down

0 comments on commit 23df941

Please sign in to comment.