Skip to content

Commit

Permalink
Service,ServiceModel 검색 API 수정 iotoasis#373
Browse files Browse the repository at this point in the history
  • Loading branch information
pahnjy01 committed Feb 10, 2017
1 parent a6f5b53 commit 4f9ee4c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.pineone.icbms.so.service.store.ServiceStore;
import com.pineone.icbms.so.util.TimeStamp;
import com.pineone.icbms.so.util.conversion.DataConversion;
import com.pineone.icbms.so.util.conversion.UUIDConverter;
import com.pineone.icbms.so.util.exception.BadRequestException;
import com.pineone.icbms.so.util.priority.Priority;
import com.pineone.icbms.so.util.session.DefaultSession;
Expand All @@ -25,6 +26,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;


/**
Expand Down Expand Up @@ -88,7 +90,17 @@ public List<Status> retrieveStatusList(ConceptService conceptService) {
@Override
//NOTE: Service 등록정보를 수신받고 SO DB에 저장
public String registerService(Service service) {
logger.debug("Service = " + service.toString());
if(service == null){
logger.warn("You can not register a service. service is Null");
return null;
}
if(service.getId() == null){
service.setId("si-make-"+ UUIDConverter.shortUUID(UUID.randomUUID().toString().toCharArray()));
}
long time = System.currentTimeMillis();
service.setCreateTime(time);
service.setModifiedTime(time);
logger.debug("service = " + service);
ResponseMessage responseMessage = ResponseMessage.newResponseMessage();
String serviceMessageStr = responseMessage.serviceResultMessage(service);
serviceStore.createService(service);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
Expand All @@ -29,7 +30,7 @@ public void createService(Service service) {
//NOTE: Service List 조회
@Override
public List<Service> retrieveServiceList() {
List<ServiceDataObject> serviceDataObjectList = serviceRepository.findAll();
List<ServiceDataObject> serviceDataObjectList = serviceRepository.findAll(new Sort(Sort.Direction.DESC,"createTime"));
List<Service> serviceList = new ArrayList<>();
for (ServiceDataObject serviceDataObject : serviceDataObjectList){
serviceList.add(dataObjectToService(serviceDataObject));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
Expand All @@ -31,7 +32,7 @@ public void createServiceModel(ServiceModel serviceModel) {
//NOTE: SM 리스트 조회
@Override
public List<ServiceModel> retrieveServiceModelList() {
List<ServiceModelDataObject> serviceModelDataObjectList = serviceModelRepository.findAll();
List<ServiceModelDataObject> serviceModelDataObjectList = serviceModelRepository.findAll(new Sort(Sort.Direction.DESC,"createTime"));
List<ServiceModel> serviceModelList = new ArrayList<>();
for(ServiceModelDataObject serviceModelDataObject : serviceModelDataObjectList){
serviceModelList.add(dataObjectToServiceModel(serviceModelDataObject));
Expand Down

0 comments on commit 4f9ee4c

Please sign in to comment.