crawler model dao add
crawler test code add
This commit is contained in:
parent
ea3935251b
commit
71df148395
|
@ -3,8 +3,11 @@ package com.loafle.overflow.crawler.dao;
|
||||||
import com.loafle.overflow.commons.dao.BaseDAO;
|
import com.loafle.overflow.commons.dao.BaseDAO;
|
||||||
import com.loafle.overflow.crawler.model.Crawler;
|
import com.loafle.overflow.crawler.model.Crawler;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geek@loafle.com on 17. 6. 8.
|
* Created by geek@loafle.com on 17. 6. 8.
|
||||||
*/
|
*/
|
||||||
public interface CrawlerDAO extends BaseDAO<Crawler> {
|
public interface CrawlerDAO extends BaseDAO<Crawler> {
|
||||||
|
public List<Crawler> findAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
package com.loafle.overflow.crawler.dao;
|
package com.loafle.overflow.crawler.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.commons.dao.BaseDAO;
|
import com.loafle.overflow.commons.dao.BaseDAO;
|
||||||
|
import com.loafle.overflow.crawler.model.Crawler;
|
||||||
import com.loafle.overflow.crawler.model.CrawlerInputItemMapping;
|
import com.loafle.overflow.crawler.model.CrawlerInputItemMapping;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geek@loafle.com on 17. 6. 8.
|
* Created by geek@loafle.com on 17. 6. 8.
|
||||||
*/
|
*/
|
||||||
public interface CrawlerInputItemMappingDAO extends BaseDAO<CrawlerInputItemMapping> {
|
public interface CrawlerInputItemMappingDAO extends BaseDAO<CrawlerInputItemMapping> {
|
||||||
|
public List<CrawlerInputItemMapping> findByCrawlerId(Crawler crawler);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,25 @@ package com.loafle.overflow.crawler.dao;
|
||||||
import com.loafle.overflow.commons.dao.JPABaseDAO;
|
import com.loafle.overflow.commons.dao.JPABaseDAO;
|
||||||
import com.loafle.overflow.crawler.model.Crawler;
|
import com.loafle.overflow.crawler.model.Crawler;
|
||||||
|
|
||||||
|
import javax.persistence.Query;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geek@loafle.com on 17. 6. 8.
|
* Created by geek@loafle.com on 17. 6. 8.
|
||||||
*/
|
*/
|
||||||
public class JPACrawlerDAO extends JPABaseDAO<Crawler> implements CrawlerDAO {
|
public class JPACrawlerDAO extends JPABaseDAO<Crawler> implements CrawlerDAO {
|
||||||
|
@Override
|
||||||
|
public List<Crawler> findAll() {
|
||||||
|
Query query = getEntityManager().createNativeQuery("SELECT c.* FROM CRAWLER c ", Crawler.class);
|
||||||
|
|
||||||
|
List<Crawler> crs = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
crs = (List<Crawler>)query.getResultList();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
return crs;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,29 @@
|
||||||
package com.loafle.overflow.crawler.dao;
|
package com.loafle.overflow.crawler.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.commons.dao.JPABaseDAO;
|
import com.loafle.overflow.commons.dao.JPABaseDAO;
|
||||||
|
import com.loafle.overflow.crawler.model.Crawler;
|
||||||
import com.loafle.overflow.crawler.model.CrawlerInputItemMapping;
|
import com.loafle.overflow.crawler.model.CrawlerInputItemMapping;
|
||||||
|
|
||||||
|
import javax.persistence.Query;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geek@loafle.com on 17. 6. 8.
|
* Created by geek@loafle.com on 17. 6. 8.
|
||||||
*/
|
*/
|
||||||
public class JPACrawlerInputItemMappingDAO extends JPABaseDAO<CrawlerInputItemMapping> implements CrawlerInputItemMappingDAO {
|
public class JPACrawlerInputItemMappingDAO extends JPABaseDAO<CrawlerInputItemMapping> implements CrawlerInputItemMappingDAO {
|
||||||
|
@Override
|
||||||
|
public List<CrawlerInputItemMapping> findByCrawlerId(Crawler crawler) {
|
||||||
|
Query query = getEntityManager().createNativeQuery("SELECT m.* FROM CRAWLER_INPUT_ITEM_MAPPING m WHERE m.crawler_id = :crawler_id", CrawlerInputItemMapping.class);
|
||||||
|
query.setParameter("crawler_id", crawler.getId());
|
||||||
|
|
||||||
|
List<CrawlerInputItemMapping> crs = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
crs = (List<CrawlerInputItemMapping>)query.getResultList();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
return crs;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,11 @@ public class JPACrawlerDAOTest {
|
||||||
}
|
}
|
||||||
// TODO Crawler Select Test
|
// TODO Crawler Select Test
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void TestListAll() {
|
||||||
|
List<Crawler> ls = this.jpaCrawlerDAO.findAll();
|
||||||
|
System.out.println(ls.size());
|
||||||
|
}
|
||||||
// TODO Crawler Update Test
|
// TODO Crawler Update Test
|
||||||
|
|
||||||
// TODO Crawler Delete Test
|
// TODO Crawler Delete Test
|
||||||
|
|
|
@ -79,4 +79,10 @@ public class JPACrawlerInputItemMappingDAOTest {
|
||||||
this.mappingDAO.createAll(crs);
|
this.mappingDAO.createAll(crs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void TestFindByCrawlerId() {
|
||||||
|
List<CrawlerInputItemMapping> ls = this.mappingDAO.findByCrawlerId(new Crawler((long)5));
|
||||||
|
System.out.println(ls.size());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user