fixed
sensor readallbydomain
This commit is contained in:
parent
a07d063be1
commit
500d976908
|
@ -3,7 +3,10 @@ package com.loafle.overflow.module.infra.dao;
|
||||||
import com.loafle.overflow.module.domain.model.Domain;
|
import com.loafle.overflow.module.domain.model.Domain;
|
||||||
import com.loafle.overflow.module.infra.model.Infra;
|
import com.loafle.overflow.module.infra.model.Infra;
|
||||||
import com.loafle.overflow.module.probe.model.Probe;
|
import com.loafle.overflow.module.probe.model.Probe;
|
||||||
|
import com.loafle.overflow.module.target.model.Target;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -15,4 +18,9 @@ import java.util.List;
|
||||||
public interface InfraDAO extends JpaRepository<Infra, Long> {
|
public interface InfraDAO extends JpaRepository<Infra, Long> {
|
||||||
public List<Infra> findAllByProbe(Probe probe);
|
public List<Infra> findAllByProbe(Probe probe);
|
||||||
|
|
||||||
|
List<Infra> findAllByProbe(List<Probe> probeList);
|
||||||
|
|
||||||
|
|
||||||
|
@Query("SELECT DISTINCT i.target FROM Infra i WHERE i.probe IN (:probeList)")
|
||||||
|
List<Target> findAllTargetByProbeList(@Param("probeList") List<Probe> probeList);
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ import com.loafle.overflow.module.domain.model.Domain;
|
||||||
import com.loafle.overflow.module.infra.dao.InfraDAO;
|
import com.loafle.overflow.module.infra.dao.InfraDAO;
|
||||||
import com.loafle.overflow.module.infra.model.Infra;
|
import com.loafle.overflow.module.infra.model.Infra;
|
||||||
import com.loafle.overflow.module.probe.model.Probe;
|
import com.loafle.overflow.module.probe.model.Probe;
|
||||||
|
import com.loafle.overflow.module.target.model.Target;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -31,4 +32,11 @@ public class InfraService {
|
||||||
return this.infraDAO.findAllByProbe(probe);
|
return this.infraDAO.findAllByProbe(probe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Infra> readAllByProbeList(List<Probe> probeList) {
|
||||||
|
return this.infraDAO.findAllByProbe(probeList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Target> readAllTargetByProbeList(List<Probe> probeList) {
|
||||||
|
return this.infraDAO.findAllTargetByProbeList(probeList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.loafle.overflow.module.sensor.dao;
|
package com.loafle.overflow.module.sensor.dao;
|
||||||
|
|
||||||
|
|
||||||
|
import com.loafle.overflow.module.probe.model.Probe;
|
||||||
import com.loafle.overflow.module.sensor.model.Sensor;
|
import com.loafle.overflow.module.sensor.model.Sensor;
|
||||||
import com.loafle.overflow.module.target.model.Target;
|
import com.loafle.overflow.module.target.model.Target;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
@ -14,4 +15,7 @@ import java.util.List;
|
||||||
@Repository
|
@Repository
|
||||||
public interface SensorDAO extends JpaRepository<Sensor, Long> {
|
public interface SensorDAO extends JpaRepository<Sensor, Long> {
|
||||||
List<Sensor> findAllByTarget(Target target);
|
List<Sensor> findAllByTarget(Target target);
|
||||||
|
|
||||||
|
List<Sensor> findAllByTarget(List<Target> targetList);
|
||||||
|
// List<Sensor> findAllByTargetList(List<Target> targets);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
package com.loafle.overflow.module.sensor.service;
|
package com.loafle.overflow.module.sensor.service;
|
||||||
|
|
||||||
|
import com.loafle.overflow.module.domain.model.Domain;
|
||||||
|
import com.loafle.overflow.module.infra.model.Infra;
|
||||||
|
import com.loafle.overflow.module.infra.service.InfraService;
|
||||||
import com.loafle.overflow.module.meta.model.MetaSensorStatus;
|
import com.loafle.overflow.module.meta.model.MetaSensorStatus;
|
||||||
|
import com.loafle.overflow.module.probe.model.Probe;
|
||||||
|
import com.loafle.overflow.module.probe.service.ProbeService;
|
||||||
import com.loafle.overflow.module.sensor.dao.SensorDAO;
|
import com.loafle.overflow.module.sensor.dao.SensorDAO;
|
||||||
import com.loafle.overflow.module.sensor.model.Sensor;
|
import com.loafle.overflow.module.sensor.model.Sensor;
|
||||||
import com.loafle.overflow.module.target.model.Target;
|
import com.loafle.overflow.module.target.model.Target;
|
||||||
|
import com.loafle.overflow.module.target.service.TargetService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +25,12 @@ public class SensorService {
|
||||||
@Autowired
|
@Autowired
|
||||||
SensorDAO sensorDAO;
|
SensorDAO sensorDAO;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ProbeService probeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InfraService infraService;
|
||||||
|
|
||||||
public Sensor regist(Sensor sensor) {
|
public Sensor regist(Sensor sensor) {
|
||||||
return this.sensorDAO.save(sensor);
|
return this.sensorDAO.save(sensor);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +39,14 @@ public class SensorService {
|
||||||
return this.sensorDAO.findAllByTarget(target);
|
return this.sensorDAO.findAllByTarget(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Sensor> readAllByDomain(Domain domain) {
|
||||||
|
|
||||||
|
List<Probe> probeList = this.probeService.readAllByDomain(domain);
|
||||||
|
|
||||||
|
List<Target> targetList = this.infraService.readAllTargetByProbeList(probeList);
|
||||||
|
|
||||||
|
return this.sensorDAO.findAllByTarget(targetList);
|
||||||
|
}
|
||||||
public Sensor read(String id) {
|
public Sensor read(String id) {
|
||||||
return this.sensorDAO.findOne(Long.valueOf(id));
|
return this.sensorDAO.findOne(Long.valueOf(id));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package com.loafle.overflow.module.target.dao;
|
package com.loafle.overflow.module.target.dao;
|
||||||
|
|
||||||
|
import com.loafle.overflow.module.infra.model.Infra;
|
||||||
import com.loafle.overflow.module.probe.model.Probe;
|
import com.loafle.overflow.module.probe.model.Probe;
|
||||||
import com.loafle.overflow.module.target.model.Target;
|
import com.loafle.overflow.module.target.model.Target;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -13,5 +16,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface TargetDAO extends JpaRepository<Target, Long> {
|
public interface TargetDAO extends JpaRepository<Target, Long> {
|
||||||
// List<Target> findAllByProbe(Probe probe);
|
// List<Target> findAllByProbe(Probe probe);]
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package com.loafle.overflow.module.infra.service;
|
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.Infra;
|
||||||
import com.loafle.overflow.module.meta.model.MetaInfraType;
|
import com.loafle.overflow.module.meta.model.MetaInfraType;
|
||||||
import com.loafle.overflow.module.probe.model.Probe;
|
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.module.target.model.Target;
|
||||||
import com.loafle.overflow.spring.AppConfigTest;
|
import com.loafle.overflow.spring.AppConfigTest;
|
||||||
import org.codehaus.jackson.map.ObjectMapper;
|
import org.codehaus.jackson.map.ObjectMapper;
|
||||||
|
@ -14,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by snoop on 17. 7. 27.
|
* Created by snoop on 17. 7. 27.
|
||||||
*/
|
*/
|
||||||
|
@ -24,6 +28,9 @@ public class InfraServiceTest {
|
||||||
@Autowired
|
@Autowired
|
||||||
private InfraService infraService;
|
private InfraService infraService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ProbeService probeService;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void regist() throws Exception {
|
public void regist() throws Exception {
|
||||||
|
@ -77,4 +84,18 @@ public class InfraServiceTest {
|
||||||
System.out.println(json);
|
System.out.println(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void readAllByProbeList() {
|
||||||
|
|
||||||
|
Domain domain = new Domain();
|
||||||
|
domain.setId(1);
|
||||||
|
|
||||||
|
List<Probe> pl = this.probeService.readAllByDomain(domain);
|
||||||
|
|
||||||
|
List<Infra> fl = this.infraService.readAllByProbeList(pl);
|
||||||
|
|
||||||
|
System.out.println(fl.size());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,7 +1,11 @@
|
||||||
package com.loafle.overflow.module.sensor.service;
|
package com.loafle.overflow.module.sensor.service;
|
||||||
|
|
||||||
|
import com.loafle.overflow.module.domain.model.Domain;
|
||||||
|
import com.loafle.overflow.module.infra.service.InfraService;
|
||||||
import com.loafle.overflow.module.meta.model.MetaCrawler;
|
import com.loafle.overflow.module.meta.model.MetaCrawler;
|
||||||
import com.loafle.overflow.module.meta.model.MetaSensorStatus;
|
import com.loafle.overflow.module.meta.model.MetaSensorStatus;
|
||||||
|
import com.loafle.overflow.module.probe.model.Probe;
|
||||||
|
import com.loafle.overflow.module.probe.service.ProbeService;
|
||||||
import com.loafle.overflow.module.sensor.model.Sensor;
|
import com.loafle.overflow.module.sensor.model.Sensor;
|
||||||
import com.loafle.overflow.module.target.model.Target;
|
import com.loafle.overflow.module.target.model.Target;
|
||||||
import com.loafle.overflow.spring.AppConfigTest;
|
import com.loafle.overflow.spring.AppConfigTest;
|
||||||
|
@ -20,13 +24,15 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* Created by insanity on 17. 6. 28.
|
* Created by insanity on 17. 6. 28.
|
||||||
*/
|
*/
|
||||||
@Ignore
|
//@Ignore
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = {AppConfigTest.class})
|
@ContextConfiguration(classes = {AppConfigTest.class})
|
||||||
public class SensorServiceTest {
|
public class SensorServiceTest {
|
||||||
@Autowired
|
@Autowired
|
||||||
SensorService sensorService;
|
SensorService sensorService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void regist() throws Exception {
|
public void regist() throws Exception {
|
||||||
|
@ -69,4 +75,16 @@ public class SensorServiceTest {
|
||||||
|
|
||||||
System.out.println(json);
|
System.out.println(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void readAllByTargetList() {
|
||||||
|
|
||||||
|
Domain domain = new Domain();
|
||||||
|
domain.setId(1);
|
||||||
|
|
||||||
|
List<Sensor> sl = this.sensorService.readAllByDomain(domain);
|
||||||
|
|
||||||
|
Assert.assertNotEquals(sl.size(), 0);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,36 @@
|
||||||
package com.loafle.overflow.module.target.dao;
|
package com.loafle.overflow.module.target.dao;
|
||||||
|
|
||||||
|
import com.loafle.overflow.module.domain.model.Domain;
|
||||||
|
import com.loafle.overflow.module.infra.model.Infra;
|
||||||
|
import com.loafle.overflow.module.infra.service.InfraService;
|
||||||
|
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.junit.Assert;
|
||||||
|
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.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by insanity on 17. 6. 28.
|
* Created by insanity on 17. 6. 28.
|
||||||
*/
|
*/
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
@ContextConfiguration(classes = {AppConfigTest.class})
|
||||||
public class TargetDAOTest {
|
public class TargetDAOTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TargetDAO targetDAO;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ProbeService probeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InfraService infraService;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user