Sensor series
This commit is contained in:
snoop 2017-06-09 16:19:49 +09:00
parent 79d1e64a3a
commit ddf34392db
10 changed files with 21 additions and 10 deletions

View File

@ -1,8 +1,9 @@
package com.loafle.overflow.sensor.dao; package com.loafle.overflow.sensor.dao;
import com.loafle.overflow.agent.model.Agent;
import com.loafle.overflow.commons.dao.JPABaseDAO; import com.loafle.overflow.commons.dao.JPABaseDAO;
import com.loafle.overflow.sensor.model.Sensor; import com.loafle.overflow.sensor.model.Sensor;
import com.loafle.overflow.target.model.Target;
import javax.persistence.Query; import javax.persistence.Query;
import java.util.List; import java.util.List;
@ -12,9 +13,9 @@ import java.util.List;
*/ */
public class JPASensorDao extends JPABaseDAO<Sensor> implements SensorDao { public class JPASensorDao extends JPABaseDAO<Sensor> implements SensorDao {
public List<Sensor> findAllByAgentID(Agent agent) { public List<Sensor> findAllByTargetId(Target target) {
Query query = getEntityManager().createNativeQuery("SELECT s.* FROM Sensor s WHERE s.TARGET_ID = :memberId", Sensor.class); Query query = getEntityManager().createNativeQuery("SELECT s.* FROM Sensor s WHERE s.TARGET_ID = :targetId", Sensor.class);
query.setParameter("memberId", agent.getMember().getId()); query.setParameter("targetId", target.getId());
List<Sensor> sensors = null; List<Sensor> sensors = null;
try { try {

View File

@ -13,7 +13,7 @@ import java.util.List;
*/ */
public class JPASensorItemDao extends JPABaseDAO<SensorItem> implements SensorItemDao { public class JPASensorItemDao extends JPABaseDAO<SensorItem> implements SensorItemDao {
public List<SensorItem> findAllByCrawlerID(Crawler crawler) { public List<SensorItem> findAllByCrawlerId(Crawler crawler) {
Query query = getEntityManager().createNativeQuery("SELECT si.* FROM SensorItem si WHERE si.CRAWLER_ID = :crawlerId", SensorItem.class); Query query = getEntityManager().createNativeQuery("SELECT si.* FROM SensorItem si WHERE si.CRAWLER_ID = :crawlerId", SensorItem.class);
query.setParameter("crawlerId", crawler.getId()); query.setParameter("crawlerId", crawler.getId());

View File

@ -12,7 +12,7 @@ import java.util.List;
*/ */
public class JPASensorItemMappingDao extends JPABaseDAO<SensorItemMapping> implements SensorItemMappingDao { public class JPASensorItemMappingDao extends JPABaseDAO<SensorItemMapping> implements SensorItemMappingDao {
public List<SensorItemMapping> findAllBySensorID(Sensor sensor) { public List<SensorItemMapping> findAllBySensorId(Sensor sensor) {
Query query = getEntityManager().createNativeQuery("SELECT sim.* FROM SensorItemMapping sim WHERE sim.SENSOR_ID = :sensorId", SensorItemMapping.class); Query query = getEntityManager().createNativeQuery("SELECT sim.* FROM SensorItemMapping sim WHERE sim.SENSOR_ID = :sensorId", SensorItemMapping.class);
query.setParameter("sensorId", sensor.getId()); query.setParameter("sensorId", sensor.getId());

View File

@ -1,8 +1,9 @@
package com.loafle.overflow.sensor.dao; package com.loafle.overflow.sensor.dao;
import com.loafle.overflow.agent.model.Agent;
import com.loafle.overflow.commons.dao.BaseDAO; import com.loafle.overflow.commons.dao.BaseDAO;
import com.loafle.overflow.sensor.model.Sensor; import com.loafle.overflow.sensor.model.Sensor;
import com.loafle.overflow.target.model.Target;
import java.util.List; import java.util.List;
@ -11,5 +12,5 @@ import java.util.List;
*/ */
public interface SensorDao extends BaseDAO<Sensor> { public interface SensorDao extends BaseDAO<Sensor> {
List<Sensor> findAllByAgentID(Agent agent); List<Sensor> findAllByTargetId(Target target);
} }

View File

@ -12,5 +12,5 @@ import java.util.List;
*/ */
public interface SensorItemDao extends BaseDAO<SensorItem>{ public interface SensorItemDao extends BaseDAO<SensorItem>{
List<SensorItem> findAllByCrawlerID(Crawler crawler); List<SensorItem> findAllByCrawlerId(Crawler crawler);
} }

View File

@ -11,6 +11,6 @@ import java.util.List;
*/ */
public interface SensorItemMappingDao extends BaseDAO<SensorItemMapping> { public interface SensorItemMappingDao extends BaseDAO<SensorItemMapping> {
List<SensorItemMapping> findAllBySensorID(Sensor sensor); List<SensorItemMapping> findAllBySensorId(Sensor sensor);
} }

View File

@ -4,6 +4,7 @@ import com.loafle.overflow.crawler.model.Crawler;
import com.loafle.overflow.sensor.model.Sensor; import com.loafle.overflow.sensor.model.Sensor;
import com.loafle.overflow.target.model.Target; import com.loafle.overflow.target.model.Target;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -25,6 +26,7 @@ public class JPASensorDaoTest {
} }
@Ignore
@Test @Test
public void create() { public void create() {

View File

@ -2,6 +2,7 @@ package com.loafle.overflow.sensor.dao;
import com.loafle.overflow.sensor.model.SensorItemCategory; import com.loafle.overflow.sensor.model.SensorItemCategory;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -20,6 +21,7 @@ public class JPASensorItemCategoryDaoTest {
} }
@Ignore
@Test @Test
public void create() { public void create() {

View File

@ -4,6 +4,7 @@ import com.loafle.overflow.crawler.model.Crawler;
import com.loafle.overflow.sensor.model.SensorItem; import com.loafle.overflow.sensor.model.SensorItem;
import com.loafle.overflow.sensor.model.SensorItemCategory; import com.loafle.overflow.sensor.model.SensorItemCategory;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import java.util.List; import java.util.List;
@ -22,6 +23,7 @@ public class JPASensorItemDaoTest {
this.sensorItemDao = new JPASensorItemDao(); this.sensorItemDao = new JPASensorItemDao();
} }
@Ignore
@Test @Test
public void create() { public void create() {
@ -44,6 +46,7 @@ public class JPASensorItemDaoTest {
} }
@Ignore
@Test @Test
public void list() { public void list() {

View File

@ -4,6 +4,7 @@ import com.loafle.overflow.sensor.model.Sensor;
import com.loafle.overflow.sensor.model.SensorItem; import com.loafle.overflow.sensor.model.SensorItem;
import com.loafle.overflow.sensor.model.SensorItemMapping; import com.loafle.overflow.sensor.model.SensorItemMapping;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import java.util.List; import java.util.List;
@ -23,6 +24,7 @@ public class JPASensorItemMappingDaoTest {
} }
@Ignore
@Test @Test
public void create() { public void create() {