Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ac650575c1
|
@ -1,9 +1,10 @@
|
|||
package com.loafle.overflow.module.infra.dao;
|
||||
|
||||
import com.loafle.overflow.module.domain.model.Domain;
|
||||
import com.loafle.overflow.module.infra.model.Infra;
|
||||
import com.loafle.overflow.module.probe.model.Probe;
|
||||
import com.loafle.overflow.module.target.model.Target;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
@ -16,10 +17,12 @@ import java.util.List;
|
|||
*/
|
||||
@Repository
|
||||
public interface InfraDAO extends JpaRepository<Infra, Long> {
|
||||
public List<Infra> findAllByProbe(Probe probe);
|
||||
List<Infra> findAllByProbe(Probe probe);
|
||||
|
||||
Page<Infra> findAllByProbe(Probe probe, Pageable pageable);
|
||||
|
||||
@Query("SELECT i FROM INFRA i WHERE i.probe IN (:probeList) AND i.target != NULL")
|
||||
List<Infra> findAllByProbeList(@Param("probeList") List<Probe> probeList);
|
||||
Page<Infra> findAllByProbeList(@Param("probeList") List<Probe> probeList, Pageable pageable);
|
||||
|
||||
|
||||
@Query("SELECT DISTINCT i.target FROM INFRA i WHERE i.probe IN (:probeList)")
|
||||
|
|
|
@ -7,6 +7,10 @@ import com.loafle.overflow.module.probe.model.Probe;
|
|||
import com.loafle.overflow.module.probe.service.ProbeService;
|
||||
import com.loafle.overflow.module.target.model.Target;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -32,20 +36,25 @@ public class InfraService {
|
|||
return this.infraDAO.findOne(id);
|
||||
}
|
||||
|
||||
public List<Infra> readAllByProbe(Probe probe) {
|
||||
return this.infraDAO.findAllByProbe(probe);
|
||||
public Page<Infra> readAllByProbe(Probe probe, int pageNo, int countPerPage) {
|
||||
Pageable pageRequest =
|
||||
new PageRequest(pageNo, countPerPage, new Sort(Sort.Direction.DESC, "id"));
|
||||
return this.infraDAO.findAllByProbe(probe, pageRequest);
|
||||
}
|
||||
|
||||
public List<Infra> readAllByDomain(Domain domain) {
|
||||
public Page<Infra> readAllByDomain(Domain domain, int pageNo, int countPerPage) {
|
||||
|
||||
List<Probe> probeList = this.probeService.readAllByDomain(domain);
|
||||
|
||||
return this.infraDAO.findAllByProbeList(probeList);
|
||||
Pageable pageRequest =
|
||||
new PageRequest(pageNo, countPerPage, new Sort(Sort.Direction.DESC, "id"));
|
||||
|
||||
return this.infraDAO.findAllByProbeList(probeList, pageRequest);
|
||||
}
|
||||
|
||||
public List<Infra> readAllByProbeList(List<Probe> probeList) {
|
||||
return this.infraDAO.findAllByProbeList(probeList);
|
||||
}
|
||||
// public List<Infra> readAllByProbeList(List<Probe> probeList) {
|
||||
// return this.infraDAO.findAllByProbeList(probeList);
|
||||
// }
|
||||
|
||||
public List<Target> readAllTargetByDomain(Domain domain) {
|
||||
|
||||
|
@ -59,4 +68,5 @@ public class InfraService {
|
|||
// return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ public class SensorService {
|
|||
return this.sensorDAO.findAllByTargetList(targetList);
|
||||
}
|
||||
|
||||
public List<Sensor> readAllByInfra(Infra infra) {
|
||||
Infra dbInfra = this.infraService.read(infra.getId());
|
||||
public List<Sensor> readAllByInfra(long infraId) {
|
||||
Infra dbInfra = this.infraService.read(infraId);
|
||||
|
||||
if(dbInfra == null || dbInfra.getTarget() == null) return null;
|
||||
|
||||
|
|
|
@ -2,24 +2,15 @@ package com.loafle.overflow.module.infra.service;
|
|||
|
||||
import com.loafle.overflow.module.domain.model.Domain;
|
||||
import com.loafle.overflow.module.infra.model.Infra;
|
||||
import com.loafle.overflow.module.infra.model.InfraMachine;
|
||||
import com.loafle.overflow.module.meta.model.MetaInfraType;
|
||||
import com.loafle.overflow.module.probe.model.Probe;
|
||||
import com.loafle.overflow.module.probe.service.ProbeService;
|
||||
import com.loafle.overflow.module.target.model.Target;
|
||||
import com.loafle.overflow.spring.AppConfigTest;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 7. 27.
|
||||
*/
|
||||
|
@ -57,20 +48,20 @@ public class InfraServiceTest {
|
|||
System.out.println(json);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readAllProbe() throws IOException {
|
||||
|
||||
Probe probe = new Probe();
|
||||
probe.setId(1);
|
||||
|
||||
List<Infra> infraList = this.infraService.readAllByProbe(probe);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String json = objectMapper.writeValueAsString(infraList);
|
||||
|
||||
System.out.println(json);
|
||||
|
||||
}
|
||||
// @Test
|
||||
// public void readAllProbe() throws IOException {
|
||||
//
|
||||
// Probe probe = new Probe();
|
||||
// probe.setId(1);
|
||||
//
|
||||
// List<Infra> infraList = this.infraService.readAllByProbe(probe);
|
||||
//
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
// String json = objectMapper.writeValueAsString(infraList);
|
||||
//
|
||||
// System.out.println(json);
|
||||
//
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void readAllTarget() {
|
||||
|
@ -80,21 +71,21 @@ public class InfraServiceTest {
|
|||
// this.infraService.readAllTargetByProbeList()
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readAllByProbeList() throws IOException {
|
||||
|
||||
Domain domain = new Domain();
|
||||
domain.setId(1);
|
||||
|
||||
|
||||
List<Infra> fl = this.infraService.readAllByDomain(domain);
|
||||
|
||||
System.out.println(fl.size());
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String json = objectMapper.writeValueAsString(fl);
|
||||
|
||||
System.out.println(json);
|
||||
|
||||
}
|
||||
// @Test
|
||||
// public void readAllByProbeList() throws IOException {
|
||||
//
|
||||
// Domain domain = new Domain();
|
||||
// domain.setId(1);
|
||||
//
|
||||
//
|
||||
// List<Infra> fl = this.infraService.readAllByDomain(domain);
|
||||
//
|
||||
// System.out.println(fl.size());
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
// String json = objectMapper.writeValueAsString(fl);
|
||||
//
|
||||
// System.out.println(json);
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
|
@ -93,7 +93,7 @@ public class SensorServiceTest {
|
|||
Infra infra = new InfraMachine();
|
||||
infra.setId(1);
|
||||
|
||||
List<Sensor> sl = this.sensorService.readAllByInfra(infra);
|
||||
List<Sensor> sl = this.sensorService.readAllByInfra(1);
|
||||
|
||||
Assert.assertNotEquals(sl.size(), 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user