From 25f8293205420e3d22e413b6271cb4309650d494 Mon Sep 17 00:00:00 2001 From: geek Date: Thu, 22 Jun 2017 17:56:56 +0900 Subject: [PATCH] spring change --- pom.xml | 50 +++-- .../java/com/loafle/overflow/AppConfig.java | 25 +++ .../loafle/overflow/JdbcConfiguration.java | 79 ++++++++ .../overflow/module/agent/dao/AgentDAO.java | 11 +- .../module/agent/dao/JPAAgentDAO.java | 64 +++---- .../overflow/module/apikey/dao/ApiKeyDao.java | 8 +- .../module/apikey/dao/JPAApiKeyDao.java | 56 +++--- .../module/crawler/dao/CrawlerDAO.java | 8 +- .../crawler/dao/CrawlerInputItemDAO.java | 8 +- .../dao/CrawlerInputItemMappingDAO.java | 9 +- .../module/crawler/dao/JPACrawlerDAO.java | 54 +++--- .../crawler/dao/JPACrawlerInputItemDAO.java | 20 +- .../dao/JPACrawlerInputItemMappingDAO.java | 58 +++--- .../module/discovery/dao/HostDao.java | 6 +- .../module/discovery/dao/JPAHostDao.java | 20 +- .../module/discovery/dao/JPAPortDao.java | 20 +- .../module/discovery/dao/JPAServiceDao.java | 20 +- .../module/discovery/dao/JPAZoneDao.java | 22 +-- .../module/discovery/dao/PortDao.java | 7 +- .../module/discovery/dao/ServiceDao.java | 6 +- .../module/discovery/dao/ZoneDao.java | 6 +- .../module/email/dao/EmailAuthDAO.java | 11 +- .../module/email/dao/JPAEmailAuthDAO.java | 118 ++++++------ .../module/member/dao/JPAMemberDAO.java | 52 ++--- .../overflow/module/member/dao/MemberDAO.java | 8 +- .../noauthagent/dao/JPANoAuthAgentDAO.java | 84 ++++----- .../noauthagent/dao/NoAuthAgentDao.java | 10 +- .../module/sensor/dao/JPASensorDao.java | 54 +++--- .../sensor/dao/JPASensorItemCategoryDao.java | 18 +- .../module/sensor/dao/JPASensorItemDao.java | 60 +++--- .../sensor/dao/JPASensorItemMappingDao.java | 56 +++--- .../overflow/module/sensor/dao/SensorDao.java | 9 +- .../sensor/dao/SensorItemCategoryDao.java | 8 +- .../module/sensor/dao/SensorItemDao.java | 11 +- .../sensor/dao/SensorItemMappingDao.java | 14 +- .../com/loafle/overflow/proxy/db/DBProxy.java | 114 ++++++----- src/main/resources/META-INF/persistence.xml | 30 --- src/main/resources/database.properties | 11 ++ .../overflow/agent/dao/JPAAgentDAOTest.java | 72 +++---- .../overflow/apikey/dao/JPAApiKeyDaoTest.java | 108 +++++------ .../crawler/dao/JPACrawlerDAOTest.java | 156 +++++++-------- .../dao/JPACrawlerInputItemDAOTest.java | 124 ++++++------ .../JPACrawlerInputItemMappingDAOTest.java | 178 +++++++++--------- .../email/dao/JPAEmailAuthDAOTest.java | 152 +++++++-------- .../overflow/member/dao/JPAMemberDAOTest.java | 84 ++++----- .../module/member/dao/MemberDAOTest.java | 38 ++++ .../dao/JPANoAuthAgentDAOTest.java | 116 ++++++------ .../overflow/sensor/dao/JPASensorDaoTest.java | 110 +++++------ .../dao/JPASensorItemCategoryDaoTest.java | 72 +++---- .../sensor/dao/JPASensorItemDaoTest.java | 122 ++++++------ .../dao/JPASensorItemMappingDaoTest.java | 118 ++++++------ 51 files changed, 1436 insertions(+), 1239 deletions(-) create mode 100644 src/main/java/com/loafle/overflow/AppConfig.java create mode 100644 src/main/java/com/loafle/overflow/JdbcConfiguration.java delete mode 100644 src/main/resources/META-INF/persistence.xml create mode 100644 src/main/resources/database.properties create mode 100644 src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java diff --git a/pom.xml b/pom.xml index 5319182..2da61f4 100644 --- a/pom.xml +++ b/pom.xml @@ -5,9 +5,9 @@ 4.0.0 - com.loafle - maven_parent_jar - 1.0.0-RELEASE + com.loafle + maven_parent_jar + 1.0.0-RELEASE com.loafle @@ -17,7 +17,9 @@ 1.2.0 + 4.3.9.RELEASE 4.3.10.Final + 1.11.4.RELEASE @@ -43,11 +45,19 @@ test - + - org.hibernate - hibernate-entitymanager - 5.2.10.Final + org.springframework.data + spring-data-jpa + ${spring-data-jpa} + + + + + org.springframework + spring-test + ${spring-test-version} + test @@ -63,22 +73,30 @@ 1.9.13 + + - com.loafle - overflow_jpa_base_dao - 1.0.0-SNAPSHOT + org.hibernate + hibernate-entitymanager + 5.2.10.Final + + + + org.hibernate + hibernate-core + 5.2.10.Final - - - + + + - - - + + + diff --git a/src/main/java/com/loafle/overflow/AppConfig.java b/src/main/java/com/loafle/overflow/AppConfig.java new file mode 100644 index 0000000..9df52ab --- /dev/null +++ b/src/main/java/com/loafle/overflow/AppConfig.java @@ -0,0 +1,25 @@ +package com.loafle.overflow; + +import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.io.ClassPathResource; + +/** + * Created by insanity on 17. 6. 13. + */ +@Configuration +@ComponentScan(basePackages = {"com.loafle.overflow"}, excludeFilters = @ComponentScan.Filter({Configuration.class})) +@PropertySource({"classpath:database.properties"}) +public class AppConfig { + @Bean + public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() { + PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); + ppc.setLocation(new ClassPathResource("database.properties")); + ppc.setIgnoreUnresolvablePlaceholders(true); + + return ppc; + } +} diff --git a/src/main/java/com/loafle/overflow/JdbcConfiguration.java b/src/main/java/com/loafle/overflow/JdbcConfiguration.java new file mode 100644 index 0000000..f3adcf4 --- /dev/null +++ b/src/main/java/com/loafle/overflow/JdbcConfiguration.java @@ -0,0 +1,79 @@ +package com.loafle.overflow; + +import org.hibernate.cfg.Environment; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; +import org.springframework.transaction.annotation.TransactionManagementConfigurer; + +import javax.persistence.EntityManager; +import javax.sql.DataSource; +import java.util.Properties; + + +/** + * Created by root on 17. 6. 13. + */ +@Configuration +@EnableTransactionManagement +@EnableJpaRepositories(basePackages = {"com.loafle.overflow"}) +public class JdbcConfiguration implements TransactionManagementConfigurer { + @Value("${spring.datasource.driver-class-name}") + private String driver; + @Value("${spring.datasource.url}") + private String url; + @Value("${spring.datasource.username}") + private String username; + @Value("${spring.datasource.password}") + private String password; + @Value("${spring.jpa.hibernate.dialect}") + private String dialect; + @Value("${spring.jpa.hibernate.ddl-auto}") + private String hbm2ddlAuto; + + @Bean + public DataSource configureDataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(driver); + dataSource.setUrl(url); + dataSource.setUsername(username); + dataSource.setPassword(password); + return dataSource; + } + + @Bean + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); + entityManagerFactoryBean.setDataSource(configureDataSource()); + entityManagerFactoryBean.setPackagesToScan("com.loafle.overflow"); + entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); + + Properties jpaProperties = new Properties(); + jpaProperties.put(Environment.DIALECT, dialect); + jpaProperties.put(Environment.HBM2DDL_AUTO, hbm2ddlAuto); + jpaProperties.put(Environment.SHOW_SQL, true); + + entityManagerFactoryBean.setJpaProperties(jpaProperties); + + return entityManagerFactoryBean; + } + + @Bean + @Qualifier(value = "transactionManager") + public PlatformTransactionManager annotationDrivenTransactionManager() { + return new JpaTransactionManager(); + } + + @Bean + public EntityManager entityManager() { + return entityManagerFactory().getObject().createEntityManager(); + } +} diff --git a/src/main/java/com/loafle/overflow/module/agent/dao/AgentDAO.java b/src/main/java/com/loafle/overflow/module/agent/dao/AgentDAO.java index ae60601..db0f143 100644 --- a/src/main/java/com/loafle/overflow/module/agent/dao/AgentDAO.java +++ b/src/main/java/com/loafle/overflow/module/agent/dao/AgentDAO.java @@ -1,14 +1,15 @@ package com.loafle.overflow.module.agent.dao; import com.loafle.overflow.module.agent.model.Agent; -import com.loafle.overflow.commons.dao.BaseDAO; -import com.loafle.overflow.module.member.model.Member; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; import java.util.List; /** * Created by insanity on 17. 5. 29. */ -public interface AgentDAO extends BaseDAO { - public List findAgentListByMemberId(Member member); -} +@Repository +public interface AgentDAO extends JpaRepository { +// public List findAgentListByMemberId(Member member); +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/module/agent/dao/JPAAgentDAO.java b/src/main/java/com/loafle/overflow/module/agent/dao/JPAAgentDAO.java index 7ef6926..bce8923 100644 --- a/src/main/java/com/loafle/overflow/module/agent/dao/JPAAgentDAO.java +++ b/src/main/java/com/loafle/overflow/module/agent/dao/JPAAgentDAO.java @@ -1,32 +1,32 @@ -package com.loafle.overflow.module.agent.dao; - -import com.loafle.overflow.module.agent.model.Agent; -import com.loafle.overflow.commons.dao.JPABaseDAO; -import com.loafle.overflow.module.member.model.Member; - -import javax.persistence.Query; -import java.util.ArrayList; -import java.util.List; - - -/** - * Created by insanity on 17. 5. 29. - */ -public class JPAAgentDAO extends JPABaseDAO implements AgentDAO { - - public List findAgentListByMemberId(Member member) { - Query query = getEntityManager() - .createNativeQuery("SELECT agt.* FROM AGENT agt WHERE agt.MEMBER_ID = :member", Agent.class); - query.setParameter("member", member.getId()); - - List list = new ArrayList<>(); - try { - list = query.getResultList(); - }catch(Exception e) { - e.printStackTrace(); - }finally { - return list; - } - } - -} +//package com.loafle.overflow.module.agent.dao; +// +//import com.loafle.overflow.module.agent.model.Agent; +//import com.loafle.overflow.commons.dao.JPABaseDAO; +//import com.loafle.overflow.module.member.model.Member; +// +//import javax.persistence.Query; +//import java.util.ArrayList; +//import java.util.List; +// +// +///** +// * Created by insanity on 17. 5. 29. +// */ +//public class JPAAgentDAO extends JPABaseDAO implements AgentDAO { +// +// public List findAgentListByMemberId(Member member) { +// Query query = getEntityManager() +// .createNativeQuery("SELECT agt.* FROM AGENT agt WHERE agt.MEMBER_ID = :member", Agent.class); +// query.setParameter("member", member.getId()); +// +// List list = new ArrayList<>(); +// try { +// list = query.getResultList(); +// }catch(Exception e) { +// e.printStackTrace(); +// }finally { +// return list; +// } +// } +// +//} diff --git a/src/main/java/com/loafle/overflow/module/apikey/dao/ApiKeyDao.java b/src/main/java/com/loafle/overflow/module/apikey/dao/ApiKeyDao.java index 2202d28..a42deda 100644 --- a/src/main/java/com/loafle/overflow/module/apikey/dao/ApiKeyDao.java +++ b/src/main/java/com/loafle/overflow/module/apikey/dao/ApiKeyDao.java @@ -1,12 +1,14 @@ package com.loafle.overflow.module.apikey.dao; import com.loafle.overflow.module.apikey.model.Apikey; -import com.loafle.overflow.commons.dao.BaseDAO; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; /** * Created by root on 17. 6. 1. */ -public interface ApiKeyDao extends BaseDAO { - Apikey findByApiKey(Apikey apikey); +@Repository +public interface ApiKeyDao extends JpaRepository { +// Apikey findByApiKey(Apikey apikey); } diff --git a/src/main/java/com/loafle/overflow/module/apikey/dao/JPAApiKeyDao.java b/src/main/java/com/loafle/overflow/module/apikey/dao/JPAApiKeyDao.java index d9e073b..b1433f4 100644 --- a/src/main/java/com/loafle/overflow/module/apikey/dao/JPAApiKeyDao.java +++ b/src/main/java/com/loafle/overflow/module/apikey/dao/JPAApiKeyDao.java @@ -1,28 +1,28 @@ -package com.loafle.overflow.module.apikey.dao; - -import com.loafle.overflow.module.apikey.model.Apikey; -import com.loafle.overflow.commons.dao.JPABaseDAO; - - -import javax.persistence.Query; - -/** - * Created by root on 17. 6. 1. - */ -public class JPAApiKeyDao extends JPABaseDAO implements ApiKeyDao { - public Apikey findByApiKey(Apikey apikey) { - - Query query = getEntityManager().createNativeQuery("SELECT ak.* FROM API_KEY ak WHERE ak.API_KEY = :apikey", Apikey.class); - query.setParameter("apikey", apikey.getApiKey()); - - Apikey ak = null; - try { - ak = (Apikey)query.getSingleResult(); - }catch(Exception e) { - e.printStackTrace(); - }finally { - return ak; - } - - } -} +//package com.loafle.overflow.module.apikey.dao; +// +//import com.loafle.overflow.module.apikey.model.Apikey; +//import com.loafle.overflow.commons.dao.JPABaseDAO; +// +// +//import javax.persistence.Query; +// +///** +// * Created by root on 17. 6. 1. +// */ +//public class JPAApiKeyDao extends JPABaseDAO implements ApiKeyDao { +// public Apikey findByApiKey(Apikey apikey) { +// +// Query query = getEntityManager().createNativeQuery("SELECT ak.* FROM API_KEY ak WHERE ak.API_KEY = :apikey", Apikey.class); +// query.setParameter("apikey", apikey.getApiKey()); +// +// Apikey ak = null; +// try { +// ak = (Apikey)query.getSingleResult(); +// }catch(Exception e) { +// e.printStackTrace(); +// }finally { +// return ak; +// } +// +// } +//} diff --git a/src/main/java/com/loafle/overflow/module/crawler/dao/CrawlerDAO.java b/src/main/java/com/loafle/overflow/module/crawler/dao/CrawlerDAO.java index 9347e13..67b3f62 100644 --- a/src/main/java/com/loafle/overflow/module/crawler/dao/CrawlerDAO.java +++ b/src/main/java/com/loafle/overflow/module/crawler/dao/CrawlerDAO.java @@ -1,13 +1,15 @@ package com.loafle.overflow.module.crawler.dao; -import com.loafle.overflow.commons.dao.BaseDAO; import com.loafle.overflow.module.crawler.model.Crawler; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; import java.util.List; /** * Created by geek@loafle.com on 17. 6. 8. */ -public interface CrawlerDAO extends BaseDAO { - public List findAll(); +@Repository +public interface CrawlerDAO extends JpaRepository { +// public List findAll(); } diff --git a/src/main/java/com/loafle/overflow/module/crawler/dao/CrawlerInputItemDAO.java b/src/main/java/com/loafle/overflow/module/crawler/dao/CrawlerInputItemDAO.java index 2e609b0..1670837 100644 --- a/src/main/java/com/loafle/overflow/module/crawler/dao/CrawlerInputItemDAO.java +++ b/src/main/java/com/loafle/overflow/module/crawler/dao/CrawlerInputItemDAO.java @@ -1,10 +1,12 @@ package com.loafle.overflow.module.crawler.dao; -import com.loafle.overflow.commons.dao.BaseDAO; import com.loafle.overflow.module.crawler.model.CrawlerInputItem; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; /** * Created by geek@loafle.com on 17. 6. 8. */ -public interface CrawlerInputItemDAO extends BaseDAO { -} +@Repository +public interface CrawlerInputItemDAO extends JpaRepository { +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/module/crawler/dao/CrawlerInputItemMappingDAO.java b/src/main/java/com/loafle/overflow/module/crawler/dao/CrawlerInputItemMappingDAO.java index 2e911ba..4b09c46 100644 --- a/src/main/java/com/loafle/overflow/module/crawler/dao/CrawlerInputItemMappingDAO.java +++ b/src/main/java/com/loafle/overflow/module/crawler/dao/CrawlerInputItemMappingDAO.java @@ -1,14 +1,15 @@ package com.loafle.overflow.module.crawler.dao; -import com.loafle.overflow.commons.dao.BaseDAO; -import com.loafle.overflow.module.crawler.model.Crawler; import com.loafle.overflow.module.crawler.model.CrawlerInputItemMapping; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; import java.util.List; /** * Created by geek@loafle.com on 17. 6. 8. */ -public interface CrawlerInputItemMappingDAO extends BaseDAO { - public List findByCrawlerId(Crawler crawler); +@Repository +public interface CrawlerInputItemMappingDAO extends JpaRepository { +// public List findByCrawlerId(Crawler crawler); } diff --git a/src/main/java/com/loafle/overflow/module/crawler/dao/JPACrawlerDAO.java b/src/main/java/com/loafle/overflow/module/crawler/dao/JPACrawlerDAO.java index 8991eaf..7d7f7a9 100644 --- a/src/main/java/com/loafle/overflow/module/crawler/dao/JPACrawlerDAO.java +++ b/src/main/java/com/loafle/overflow/module/crawler/dao/JPACrawlerDAO.java @@ -1,27 +1,27 @@ -package com.loafle.overflow.module.crawler.dao; - -import com.loafle.overflow.commons.dao.JPABaseDAO; -import com.loafle.overflow.module.crawler.model.Crawler; - -import javax.persistence.Query; -import java.util.List; - -/** - * Created by geek@loafle.com on 17. 6. 8. - */ -public class JPACrawlerDAO extends JPABaseDAO implements CrawlerDAO { - @Override - public List findAll() { - Query query = getEntityManager().createNativeQuery("SELECT c.* FROM CRAWLER c ", Crawler.class); - - List crs = null; - - try { - crs = (List)query.getResultList(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - return crs; - } - } -} +//package com.loafle.overflow.module.crawler.dao; +// +//import com.loafle.overflow.commons.dao.JPABaseDAO; +//import com.loafle.overflow.module.crawler.model.Crawler; +// +//import javax.persistence.Query; +//import java.util.List; +// +///** +// * Created by geek@loafle.com on 17. 6. 8. +// */ +//public class JPACrawlerDAO extends JPABaseDAO implements CrawlerDAO { +// @Override +// public List findAll() { +// Query query = getEntityManager().createNativeQuery("SELECT c.* FROM CRAWLER c ", Crawler.class); +// +// List crs = null; +// +// try { +// crs = (List)query.getResultList(); +// } catch (Exception e) { +// e.printStackTrace(); +// } finally { +// return crs; +// } +// } +//} diff --git a/src/main/java/com/loafle/overflow/module/crawler/dao/JPACrawlerInputItemDAO.java b/src/main/java/com/loafle/overflow/module/crawler/dao/JPACrawlerInputItemDAO.java index d0483d3..3f74d96 100644 --- a/src/main/java/com/loafle/overflow/module/crawler/dao/JPACrawlerInputItemDAO.java +++ b/src/main/java/com/loafle/overflow/module/crawler/dao/JPACrawlerInputItemDAO.java @@ -1,10 +1,10 @@ -package com.loafle.overflow.module.crawler.dao; - -import com.loafle.overflow.commons.dao.JPABaseDAO; -import com.loafle.overflow.module.crawler.model.CrawlerInputItem; - -/** - * Created by geek@loafle.com on 17. 6. 8. - */ -public class JPACrawlerInputItemDAO extends JPABaseDAO implements CrawlerInputItemDAO { -} +//package com.loafle.overflow.module.crawler.dao; +// +//import com.loafle.overflow.commons.dao.JPABaseDAO; +//import com.loafle.overflow.module.crawler.model.CrawlerInputItem; +// +///** +// * Created by geek@loafle.com on 17. 6. 8. +// */ +//public class JPACrawlerInputItemDAO extends JPABaseDAO implements CrawlerInputItemDAO { +//} diff --git a/src/main/java/com/loafle/overflow/module/crawler/dao/JPACrawlerInputItemMappingDAO.java b/src/main/java/com/loafle/overflow/module/crawler/dao/JPACrawlerInputItemMappingDAO.java index f434a96..a094f0f 100644 --- a/src/main/java/com/loafle/overflow/module/crawler/dao/JPACrawlerInputItemMappingDAO.java +++ b/src/main/java/com/loafle/overflow/module/crawler/dao/JPACrawlerInputItemMappingDAO.java @@ -1,29 +1,29 @@ -package com.loafle.overflow.module.crawler.dao; - -import com.loafle.overflow.commons.dao.JPABaseDAO; -import com.loafle.overflow.module.crawler.model.Crawler; -import com.loafle.overflow.module.crawler.model.CrawlerInputItemMapping; - -import javax.persistence.Query; -import java.util.List; - -/** - * Created by geek@loafle.com on 17. 6. 8. - */ -public class JPACrawlerInputItemMappingDAO extends JPABaseDAO implements CrawlerInputItemMappingDAO { - @Override - public List 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 crs = null; - - try { - crs = (List)query.getResultList(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - return crs; - } - } -} +//package com.loafle.overflow.module.crawler.dao; +// +//import com.loafle.overflow.commons.dao.JPABaseDAO; +//import com.loafle.overflow.module.crawler.model.Crawler; +//import com.loafle.overflow.module.crawler.model.CrawlerInputItemMapping; +// +//import javax.persistence.Query; +//import java.util.List; +// +///** +// * Created by geek@loafle.com on 17. 6. 8. +// */ +//public class JPACrawlerInputItemMappingDAO extends JPABaseDAO implements CrawlerInputItemMappingDAO { +// @Override +// public List 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 crs = null; +// +// try { +// crs = (List)query.getResultList(); +// } catch (Exception e) { +// e.printStackTrace(); +// } finally { +// return crs; +// } +// } +//} diff --git a/src/main/java/com/loafle/overflow/module/discovery/dao/HostDao.java b/src/main/java/com/loafle/overflow/module/discovery/dao/HostDao.java index 7aaf782..71276bc 100644 --- a/src/main/java/com/loafle/overflow/module/discovery/dao/HostDao.java +++ b/src/main/java/com/loafle/overflow/module/discovery/dao/HostDao.java @@ -1,10 +1,12 @@ package com.loafle.overflow.module.discovery.dao; -import com.loafle.overflow.commons.dao.BaseDAO; import com.loafle.overflow.module.discovery.model.Host; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; /** * Created by root on 17. 6. 4. */ -public interface HostDao extends BaseDAO { +@Repository +public interface HostDao extends JpaRepository { } diff --git a/src/main/java/com/loafle/overflow/module/discovery/dao/JPAHostDao.java b/src/main/java/com/loafle/overflow/module/discovery/dao/JPAHostDao.java index fb5acf7..201fce8 100644 --- a/src/main/java/com/loafle/overflow/module/discovery/dao/JPAHostDao.java +++ b/src/main/java/com/loafle/overflow/module/discovery/dao/JPAHostDao.java @@ -1,10 +1,10 @@ -package com.loafle.overflow.module.discovery.dao; - -import com.loafle.overflow.commons.dao.JPABaseDAO; -import com.loafle.overflow.module.discovery.model.Host; - -/** - * Created by root on 17. 6. 4. - */ -public class JPAHostDao extends JPABaseDAO implements HostDao { -} +//package com.loafle.overflow.module.discovery.dao; +// +//import com.loafle.overflow.commons.dao.JPABaseDAO; +//import com.loafle.overflow.module.discovery.model.Host; +// +///** +// * Created by root on 17. 6. 4. +// */ +//public class JPAHostDao extends JPABaseDAO implements HostDao { +//} diff --git a/src/main/java/com/loafle/overflow/module/discovery/dao/JPAPortDao.java b/src/main/java/com/loafle/overflow/module/discovery/dao/JPAPortDao.java index eab935b..e8085bc 100644 --- a/src/main/java/com/loafle/overflow/module/discovery/dao/JPAPortDao.java +++ b/src/main/java/com/loafle/overflow/module/discovery/dao/JPAPortDao.java @@ -1,10 +1,10 @@ -package com.loafle.overflow.module.discovery.dao; - -import com.loafle.overflow.commons.dao.JPABaseDAO; -import com.loafle.overflow.module.discovery.model.Port; - -/** - * Created by root on 17. 6. 4. - */ -public class JPAPortDao extends JPABaseDAO implements PortDao { -} +//package com.loafle.overflow.module.discovery.dao; +// +//import com.loafle.overflow.commons.dao.JPABaseDAO; +//import com.loafle.overflow.module.discovery.model.Port; +// +///** +// * Created by root on 17. 6. 4. +// */ +//public class JPAPortDao extends JPABaseDAO implements PortDao { +//} diff --git a/src/main/java/com/loafle/overflow/module/discovery/dao/JPAServiceDao.java b/src/main/java/com/loafle/overflow/module/discovery/dao/JPAServiceDao.java index b3407d8..c2d5899 100644 --- a/src/main/java/com/loafle/overflow/module/discovery/dao/JPAServiceDao.java +++ b/src/main/java/com/loafle/overflow/module/discovery/dao/JPAServiceDao.java @@ -1,10 +1,10 @@ -package com.loafle.overflow.module.discovery.dao; - -import com.loafle.overflow.commons.dao.JPABaseDAO; -import com.loafle.overflow.module.discovery.model.Service; - -/** - * Created by root on 17. 6. 4. - */ -public class JPAServiceDao extends JPABaseDAO implements ServiceDao { -} +//package com.loafle.overflow.module.discovery.dao; +// +//import com.loafle.overflow.commons.dao.JPABaseDAO; +//import com.loafle.overflow.module.discovery.model.Service; +// +///** +// * Created by root on 17. 6. 4. +// */ +//public class JPAServiceDao extends JPABaseDAO implements ServiceDao { +//} diff --git a/src/main/java/com/loafle/overflow/module/discovery/dao/JPAZoneDao.java b/src/main/java/com/loafle/overflow/module/discovery/dao/JPAZoneDao.java index 7a26f33..ca35368 100644 --- a/src/main/java/com/loafle/overflow/module/discovery/dao/JPAZoneDao.java +++ b/src/main/java/com/loafle/overflow/module/discovery/dao/JPAZoneDao.java @@ -1,11 +1,11 @@ -package com.loafle.overflow.module.discovery.dao; - - -import com.loafle.overflow.commons.dao.JPABaseDAO; -import com.loafle.overflow.module.discovery.model.Zone; - -/** - * Created by root on 17. 6. 4. - */ -public class JPAZoneDao extends JPABaseDAO implements ZoneDao { -} +//package com.loafle.overflow.module.discovery.dao; +// +// +//import com.loafle.overflow.commons.dao.JPABaseDAO; +//import com.loafle.overflow.module.discovery.model.Zone; +// +///** +// * Created by root on 17. 6. 4. +// */ +//public class JPAZoneDao extends JPABaseDAO implements ZoneDao { +//} diff --git a/src/main/java/com/loafle/overflow/module/discovery/dao/PortDao.java b/src/main/java/com/loafle/overflow/module/discovery/dao/PortDao.java index 63806b1..a4ec309 100644 --- a/src/main/java/com/loafle/overflow/module/discovery/dao/PortDao.java +++ b/src/main/java/com/loafle/overflow/module/discovery/dao/PortDao.java @@ -1,10 +1,13 @@ package com.loafle.overflow.module.discovery.dao; -import com.loafle.overflow.commons.dao.BaseDAO; import com.loafle.overflow.module.discovery.model.Port; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; /** * Created by root on 17. 6. 4. */ -public interface PortDao extends BaseDAO { + +@Repository +public interface PortDao extends JpaRepository { } diff --git a/src/main/java/com/loafle/overflow/module/discovery/dao/ServiceDao.java b/src/main/java/com/loafle/overflow/module/discovery/dao/ServiceDao.java index e12f810..282e890 100644 --- a/src/main/java/com/loafle/overflow/module/discovery/dao/ServiceDao.java +++ b/src/main/java/com/loafle/overflow/module/discovery/dao/ServiceDao.java @@ -1,10 +1,12 @@ package com.loafle.overflow.module.discovery.dao; -import com.loafle.overflow.commons.dao.BaseDAO; import com.loafle.overflow.module.discovery.model.Service; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; /** * Created by root on 17. 6. 4. */ -public interface ServiceDao extends BaseDAO { +@Repository +public interface ServiceDao extends JpaRepository { } diff --git a/src/main/java/com/loafle/overflow/module/discovery/dao/ZoneDao.java b/src/main/java/com/loafle/overflow/module/discovery/dao/ZoneDao.java index 4124296..1537fba 100644 --- a/src/main/java/com/loafle/overflow/module/discovery/dao/ZoneDao.java +++ b/src/main/java/com/loafle/overflow/module/discovery/dao/ZoneDao.java @@ -1,10 +1,12 @@ package com.loafle.overflow.module.discovery.dao; -import com.loafle.overflow.commons.dao.BaseDAO; import com.loafle.overflow.module.discovery.model.Zone; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; /** * Created by root on 17. 6. 4. */ -public interface ZoneDao extends BaseDAO { +@Repository +public interface ZoneDao extends JpaRepository { } diff --git a/src/main/java/com/loafle/overflow/module/email/dao/EmailAuthDAO.java b/src/main/java/com/loafle/overflow/module/email/dao/EmailAuthDAO.java index 0dc49ab..ba8127e 100644 --- a/src/main/java/com/loafle/overflow/module/email/dao/EmailAuthDAO.java +++ b/src/main/java/com/loafle/overflow/module/email/dao/EmailAuthDAO.java @@ -1,17 +1,20 @@ package com.loafle.overflow.module.email.dao; -import com.loafle.overflow.commons.dao.BaseDAO; import com.loafle.overflow.module.email.model.EmailAuth; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; import java.util.List; /** * Created by geek@loafle.com on 17. 6. 6. */ -public interface EmailAuthDAO extends BaseDAO { - public EmailAuth findByAuthToken(EmailAuth emailAuth); +@Repository +public interface EmailAuthDAO extends JpaRepository { +// public EmailAuth findByAuthToken(EmailAuth emailAuth); - public List findByMemberId(EmailAuth emailAuth); +// public List findByMemberId(EmailAuth emailAuth); // public EmailAuth updateEmailAuth(EmailAuth emailAuth); } + diff --git a/src/main/java/com/loafle/overflow/module/email/dao/JPAEmailAuthDAO.java b/src/main/java/com/loafle/overflow/module/email/dao/JPAEmailAuthDAO.java index ecb10c0..8f627de 100644 --- a/src/main/java/com/loafle/overflow/module/email/dao/JPAEmailAuthDAO.java +++ b/src/main/java/com/loafle/overflow/module/email/dao/JPAEmailAuthDAO.java @@ -1,63 +1,63 @@ -package com.loafle.overflow.module.email.dao; - -import com.loafle.overflow.commons.dao.JPABaseDAO; -import com.loafle.overflow.module.email.model.EmailAuth; - -import javax.persistence.Query; -import java.util.List; - -/** - * Created by geek@loafle.com on 17. 6. 6. - */ -public class JPAEmailAuthDAO extends JPABaseDAO implements EmailAuthDAO { - - public EmailAuth findByAuthToken(EmailAuth emailAuth) { - Query query = getEntityManager().createNativeQuery("SELECT e.* FROM EMAIL_AUTH e WHERE e.auth_token = :auth_token", EmailAuth.class); - query.setParameter("auth_token", emailAuth.getAuthToken()); - - EmailAuth auth = null; - - try { - auth = (EmailAuth)query.getSingleResult(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - return auth; - } - } - - @Override - public List findByMemberId(EmailAuth emailAuth) { - Query query = getEntityManager().createNativeQuery("SELECT e.* FROM EMAIL_AUTH e WHERE e.member_id = :member_id", EmailAuth.class); - query.setParameter("member_id", emailAuth.getMember().getId()); - - List auths = null; - - try { - auths = (List)query.getResultList(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - return auths; - } - } - -// @Override -// public EmailAuth updateEmailAuth(EmailAuth emailAuth) { -// EntityTransaction tx = this.getEntityManager().getTransaction(); -// if (!tx.isActive()) { -// tx.begin(); -// } +//package com.loafle.overflow.module.email.dao; +// +//import com.loafle.overflow.commons.dao.JPABaseDAO; +//import com.loafle.overflow.module.email.model.EmailAuth; +// +//import javax.persistence.Query; +//import java.util.List; +// +///** +// * Created by geek@loafle.com on 17. 6. 6. +// */ +//public class JPAEmailAuthDAO extends JPABaseDAO implements EmailAuthDAO { +// +// public EmailAuth findByAuthToken(EmailAuth emailAuth) { +// Query query = getEntityManager().createNativeQuery("SELECT e.* FROM EMAIL_AUTH e WHERE e.auth_token = :auth_token", EmailAuth.class); +// query.setParameter("auth_token", emailAuth.getAuthToken()); +// +// EmailAuth auth = null; // // try { -// emailAuth.setUpdateDate(new Date()); -// -// EmailAuth result = this.getEntityManager().merge(emailAuth); -// tx.commit(); -// return result; -// }catch (Exception e) { -// tx.rollback(); -// return null; +// auth = (EmailAuth)query.getSingleResult(); +// } catch (Exception e) { +// e.printStackTrace(); +// } finally { +// return auth; // } // } -} +// +// @Override +// public List findByMemberId(EmailAuth emailAuth) { +// Query query = getEntityManager().createNativeQuery("SELECT e.* FROM EMAIL_AUTH e WHERE e.member_id = :member_id", EmailAuth.class); +// query.setParameter("member_id", emailAuth.getMember().getId()); +// +// List auths = null; +// +// try { +// auths = (List)query.getResultList(); +// } catch (Exception e) { +// e.printStackTrace(); +// } finally { +// return auths; +// } +// } +// +//// @Override +//// public EmailAuth updateEmailAuth(EmailAuth emailAuth) { +//// EntityTransaction tx = this.getEntityManager().getTransaction(); +//// if (!tx.isActive()) { +//// tx.begin(); +//// } +//// +//// try { +//// emailAuth.setUpdateDate(new Date()); +//// +//// EmailAuth result = this.getEntityManager().merge(emailAuth); +//// tx.commit(); +//// return result; +//// }catch (Exception e) { +//// tx.rollback(); +//// return null; +//// } +//// } +//} diff --git a/src/main/java/com/loafle/overflow/module/member/dao/JPAMemberDAO.java b/src/main/java/com/loafle/overflow/module/member/dao/JPAMemberDAO.java index 91edc26..4187217 100644 --- a/src/main/java/com/loafle/overflow/module/member/dao/JPAMemberDAO.java +++ b/src/main/java/com/loafle/overflow/module/member/dao/JPAMemberDAO.java @@ -1,26 +1,26 @@ -package com.loafle.overflow.module.member.dao; - -import com.loafle.overflow.commons.dao.JPABaseDAO; -import com.loafle.overflow.module.member.model.Member; - -import javax.persistence.Query; - -/** - * Created by insanity on 17. 5. 25. - */ -public class JPAMemberDAO extends JPABaseDAO implements MemberDAO{ - public Member findByEmail(Member member) { - - Query query = getEntityManager().createNativeQuery("SELECT m.* FROM MEMBER m WHERE m.email = :email", Member.class); - query.setParameter("email", member.getEmail()); - - Member retMember = null; - try { - retMember = (Member)query.getSingleResult(); - }catch(Exception e) { - e.printStackTrace(); - }finally { - return retMember; - } - } -} +//package com.loafle.overflow.module.member.dao; +// +//import com.loafle.overflow.commons.dao.JPABaseDAO; +//import com.loafle.overflow.module.member.model.Member; +// +//import javax.persistence.Query; +// +///** +// * Created by insanity on 17. 5. 25. +// */ +//public class JPAMemberDAO extends JPABaseDAO implements MemberDAO{ +// public Member findByEmail(Member member) { +// +// Query query = getEntityManager().createNativeQuery("SELECT m.* FROM MEMBER m WHERE m.email = :email", Member.class); +// query.setParameter("email", member.getEmail()); +// +// Member retMember = null; +// try { +// retMember = (Member)query.getSingleResult(); +// }catch(Exception e) { +// e.printStackTrace(); +// }finally { +// return retMember; +// } +// } +//} diff --git a/src/main/java/com/loafle/overflow/module/member/dao/MemberDAO.java b/src/main/java/com/loafle/overflow/module/member/dao/MemberDAO.java index 6dd4bb9..45f6c76 100644 --- a/src/main/java/com/loafle/overflow/module/member/dao/MemberDAO.java +++ b/src/main/java/com/loafle/overflow/module/member/dao/MemberDAO.java @@ -1,11 +1,13 @@ package com.loafle.overflow.module.member.dao; -import com.loafle.overflow.commons.dao.BaseDAO; import com.loafle.overflow.module.member.model.Member; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; /** * Created by insanity on 17. 5. 25. */ -public interface MemberDAO extends BaseDAO { - public Member findByEmail(Member member); +@Repository +public interface MemberDAO extends JpaRepository { +// public Member findByEmail(Member member); } diff --git a/src/main/java/com/loafle/overflow/module/noauthagent/dao/JPANoAuthAgentDAO.java b/src/main/java/com/loafle/overflow/module/noauthagent/dao/JPANoAuthAgentDAO.java index 6a19216..36b7fbd 100644 --- a/src/main/java/com/loafle/overflow/module/noauthagent/dao/JPANoAuthAgentDAO.java +++ b/src/main/java/com/loafle/overflow/module/noauthagent/dao/JPANoAuthAgentDAO.java @@ -1,42 +1,42 @@ -package com.loafle.overflow.module.noauthagent.dao; - -import com.loafle.overflow.commons.dao.JPABaseDAO; -import com.loafle.overflow.module.noauthagent.model.NoAuthAgent; - -import javax.persistence.Query; -import java.util.List; - -/** - * Created by root on 17. 5. 30. - */ -public class JPANoAuthAgentDAO extends JPABaseDAO implements NoAuthAgentDao { - public NoAuthAgent findByTempKey(NoAuthAgent noAuthAgent) { - Query query = getEntityManager().createNativeQuery("SELECT na.* FROM NOAUTH_AGENT na WHERE na.TEMP_KEY = :tempkey", NoAuthAgent.class); - query.setParameter("tempkey", noAuthAgent.getTempKey()); - - NoAuthAgent authAgent = null; - try { - authAgent = (NoAuthAgent)query.getSingleResult(); - }catch(Exception e) { - e.printStackTrace(); - }finally { - return authAgent; - } - } - - public List findAllByNoAuth(NoAuthAgent noAuthAgent) { - - Query query = getEntityManager().createNativeQuery("SELECT na.* FROM NOAUTH_AGENT na WHERE na.AUTH_STATUS != :authStatus", NoAuthAgent.class); - query.setParameter("authStatus", noAuthAgent.getAuthStatus().toString()); - - List authAgentList = null; - try { - authAgentList = (List)query.getResultList(); - }catch(Exception e) { - e.printStackTrace(); - }finally { - return authAgentList; - } - - } -} +//package com.loafle.overflow.module.noauthagent.dao; +// +//import com.loafle.overflow.commons.dao.JPABaseDAO; +//import com.loafle.overflow.module.noauthagent.model.NoAuthAgent; +// +//import javax.persistence.Query; +//import java.util.List; +// +///** +// * Created by root on 17. 5. 30. +// */ +//public class JPANoAuthAgentDAO extends JPABaseDAO implements NoAuthAgentDao { +// public NoAuthAgent findByTempKey(NoAuthAgent noAuthAgent) { +// Query query = getEntityManager().createNativeQuery("SELECT na.* FROM NOAUTH_AGENT na WHERE na.TEMP_KEY = :tempkey", NoAuthAgent.class); +// query.setParameter("tempkey", noAuthAgent.getTempKey()); +// +// NoAuthAgent authAgent = null; +// try { +// authAgent = (NoAuthAgent)query.getSingleResult(); +// }catch(Exception e) { +// e.printStackTrace(); +// }finally { +// return authAgent; +// } +// } +// +// public List findAllByNoAuth(NoAuthAgent noAuthAgent) { +// +// Query query = getEntityManager().createNativeQuery("SELECT na.* FROM NOAUTH_AGENT na WHERE na.AUTH_STATUS != :authStatus", NoAuthAgent.class); +// query.setParameter("authStatus", noAuthAgent.getAuthStatus().toString()); +// +// List authAgentList = null; +// try { +// authAgentList = (List)query.getResultList(); +// }catch(Exception e) { +// e.printStackTrace(); +// }finally { +// return authAgentList; +// } +// +// } +//} diff --git a/src/main/java/com/loafle/overflow/module/noauthagent/dao/NoAuthAgentDao.java b/src/main/java/com/loafle/overflow/module/noauthagent/dao/NoAuthAgentDao.java index e94838f..8a84222 100644 --- a/src/main/java/com/loafle/overflow/module/noauthagent/dao/NoAuthAgentDao.java +++ b/src/main/java/com/loafle/overflow/module/noauthagent/dao/NoAuthAgentDao.java @@ -1,14 +1,16 @@ package com.loafle.overflow.module.noauthagent.dao; -import com.loafle.overflow.commons.dao.BaseDAO; import com.loafle.overflow.module.noauthagent.model.NoAuthAgent; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; import java.util.List; /** * Created by root on 17. 5. 30. */ -public interface NoAuthAgentDao extends BaseDAO { - NoAuthAgent findByTempKey(NoAuthAgent noAuthAgent); - List findAllByNoAuth(NoAuthAgent noAuthAgent); +@Repository +public interface NoAuthAgentDao extends JpaRepository { +// NoAuthAgent findByTempKey(NoAuthAgent noAuthAgent); +// List findAllByNoAuth(NoAuthAgent noAuthAgent); } diff --git a/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorDao.java b/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorDao.java index b7adb7d..b205658 100644 --- a/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorDao.java +++ b/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorDao.java @@ -1,27 +1,27 @@ -package com.loafle.overflow.module.sensor.dao; - - -import com.loafle.overflow.commons.dao.JPABaseDAO; - -import javax.persistence.Query; -import java.util.List; - -/** - * Created by root on 17. 6. 9. - */ -public class JPASensorDao extends JPABaseDAO implements SensorDao { - - public List findAllByTargetId(Target target) { - Query query = getEntityManager().createNativeQuery("SELECT s.* FROM Sensor s WHERE s.TARGET_ID = :targetId", Sensor.class); - query.setParameter("targetId", target.getId()); - - List sensors = null; - try { - sensors = (List)query.getResultList(); - }catch(Exception e) { - e.printStackTrace(); - }finally { - return sensors; - } - } -} +//package com.loafle.overflow.module.sensor.dao; +// +// +//import com.loafle.overflow.commons.dao.JPABaseDAO; +// +//import javax.persistence.Query; +//import java.util.List; +// +///** +// * Created by root on 17. 6. 9. +// */ +//public class JPASensorDao extends JPABaseDAO implements SensorDao { +// +// public List findAllByTargetId(Target target) { +// Query query = getEntityManager().createNativeQuery("SELECT s.* FROM Sensor s WHERE s.TARGET_ID = :targetId", Sensor.class); +// query.setParameter("targetId", target.getId()); +// +// List sensors = null; +// try { +// sensors = (List)query.getResultList(); +// }catch(Exception e) { +// e.printStackTrace(); +// }finally { +// return sensors; +// } +// } +//} diff --git a/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorItemCategoryDao.java b/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorItemCategoryDao.java index fc055a7..f241eb4 100644 --- a/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorItemCategoryDao.java +++ b/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorItemCategoryDao.java @@ -1,9 +1,9 @@ -package com.loafle.overflow.module.sensor.dao; - -import com.loafle.overflow.commons.dao.JPABaseDAO; - -/** - * Created by root on 17. 6. 9. - */ -public class JPASensorItemCategoryDao extends JPABaseDAO implements SensorItemCategoryDao { -} +//package com.loafle.overflow.module.sensor.dao; +// +//import com.loafle.overflow.commons.dao.JPABaseDAO; +// +///** +// * Created by root on 17. 6. 9. +// */ +//public class JPASensorItemCategoryDao extends JPABaseDAO implements SensorItemCategoryDao { +//} diff --git a/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorItemDao.java b/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorItemDao.java index 700297c..3a42bc9 100644 --- a/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorItemDao.java +++ b/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorItemDao.java @@ -1,30 +1,30 @@ -package com.loafle.overflow.module.sensor.dao; - -import com.loafle.overflow.commons.dao.JPABaseDAO; -import com.loafle.overflow.module.crawler.model.Crawler; - - -import javax.persistence.Query; -import java.util.List; - -/** - * Created by root on 17. 6. 9. - */ -public class JPASensorItemDao extends JPABaseDAO implements SensorItemDao { - - public List findAllByCrawlerId(Crawler crawler) { - - Query query = getEntityManager().createNativeQuery("SELECT si.* FROM SensorItem si WHERE si.CRAWLER_ID = :crawlerId", SensorItem.class); - query.setParameter("crawlerId", crawler.getId()); - - List sensorItems = null; - try { - sensorItems = (List)query.getResultList(); - }catch(Exception e) { - e.printStackTrace(); - }finally { - return sensorItems; - } - - } -} +//package com.loafle.overflow.module.sensor.dao; +// +//import com.loafle.overflow.commons.dao.JPABaseDAO; +//import com.loafle.overflow.module.crawler.model.Crawler; +// +// +//import javax.persistence.Query; +//import java.util.List; +// +///** +// * Created by root on 17. 6. 9. +// */ +//public class JPASensorItemDao extends JPABaseDAO implements SensorItemDao { +// +// public List findAllByCrawlerId(Crawler crawler) { +// +// Query query = getEntityManager().createNativeQuery("SELECT si.* FROM SensorItem si WHERE si.CRAWLER_ID = :crawlerId", SensorItem.class); +// query.setParameter("crawlerId", crawler.getId()); +// +// List sensorItems = null; +// try { +// sensorItems = (List)query.getResultList(); +// }catch(Exception e) { +// e.printStackTrace(); +// }finally { +// return sensorItems; +// } +// +// } +//} diff --git a/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorItemMappingDao.java b/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorItemMappingDao.java index d650315..4c74b5d 100644 --- a/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorItemMappingDao.java +++ b/src/main/java/com/loafle/overflow/module/sensor/dao/JPASensorItemMappingDao.java @@ -1,28 +1,28 @@ -package com.loafle.overflow.module.sensor.dao; - -import com.loafle.overflow.commons.dao.JPABaseDAO; - -import javax.persistence.Query; -import java.util.List; - -/** - * Created by root on 17. 6. 9. - */ -public class JPASensorItemMappingDao extends JPABaseDAO implements SensorItemMappingDao { - - public List findAllBySensorId(Sensor sensor) { - - Query query = getEntityManager().createNativeQuery("SELECT sim.* FROM SensorItemMapping sim WHERE sim.SENSOR_ID = :sensorId", SensorItemMapping.class); - query.setParameter("sensorId", sensor.getId()); - - List sensorItemMappings = null; - try { - sensorItemMappings = (List)query.getResultList(); - }catch(Exception e) { - e.printStackTrace(); - }finally { - return sensorItemMappings; - } - - } -} +//package com.loafle.overflow.module.sensor.dao; +// +//import com.loafle.overflow.commons.dao.JPABaseDAO; +// +//import javax.persistence.Query; +//import java.util.List; +// +///** +// * Created by root on 17. 6. 9. +// */ +//public class JPASensorItemMappingDao extends JPABaseDAO implements SensorItemMappingDao { +// +// public List findAllBySensorId(Sensor sensor) { +// +// Query query = getEntityManager().createNativeQuery("SELECT sim.* FROM SensorItemMapping sim WHERE sim.SENSOR_ID = :sensorId", SensorItemMapping.class); +// query.setParameter("sensorId", sensor.getId()); +// +// List sensorItemMappings = null; +// try { +// sensorItemMappings = (List)query.getResultList(); +// }catch(Exception e) { +// e.printStackTrace(); +// }finally { +// return sensorItemMappings; +// } +// +// } +//} diff --git a/src/main/java/com/loafle/overflow/module/sensor/dao/SensorDao.java b/src/main/java/com/loafle/overflow/module/sensor/dao/SensorDao.java index e5f7767..9018878 100644 --- a/src/main/java/com/loafle/overflow/module/sensor/dao/SensorDao.java +++ b/src/main/java/com/loafle/overflow/module/sensor/dao/SensorDao.java @@ -1,14 +1,17 @@ package com.loafle.overflow.module.sensor.dao; -import com.loafle.overflow.commons.dao.BaseDAO; +import com.loafle.overflow.module.sensor.model.Sensor; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; import java.util.List; /** * Created by root on 17. 6. 9. */ -public interface SensorDao extends BaseDAO { +@Repository +public interface SensorDao extends JpaRepository { - List findAllByTargetId(Target target); +// List findAllByTargetId(Target target); } diff --git a/src/main/java/com/loafle/overflow/module/sensor/dao/SensorItemCategoryDao.java b/src/main/java/com/loafle/overflow/module/sensor/dao/SensorItemCategoryDao.java index 07b0c26..2cf03d0 100644 --- a/src/main/java/com/loafle/overflow/module/sensor/dao/SensorItemCategoryDao.java +++ b/src/main/java/com/loafle/overflow/module/sensor/dao/SensorItemCategoryDao.java @@ -1,9 +1,11 @@ package com.loafle.overflow.module.sensor.dao; -import com.loafle.overflow.commons.dao.BaseDAO; + +import org.springframework.stereotype.Repository; /** * Created by root on 17. 6. 9. */ -public interface SensorItemCategoryDao extends BaseDAO { -} +//@Repository +//public interface SensorItemCategoryDao extends JpaRepository { +//} diff --git a/src/main/java/com/loafle/overflow/module/sensor/dao/SensorItemDao.java b/src/main/java/com/loafle/overflow/module/sensor/dao/SensorItemDao.java index b773a66..d7df07b 100644 --- a/src/main/java/com/loafle/overflow/module/sensor/dao/SensorItemDao.java +++ b/src/main/java/com/loafle/overflow/module/sensor/dao/SensorItemDao.java @@ -1,15 +1,16 @@ package com.loafle.overflow.module.sensor.dao; -import com.loafle.overflow.commons.dao.BaseDAO; - -import com.loafle.overflow.module.crawler.model.Crawler; +import com.loafle.overflow.module.sensor.model.SensorItem; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; import java.util.List; /** * Created by root on 17. 6. 9. */ -public interface SensorItemDao extends BaseDAO{ +@Repository +public interface SensorItemDao extends JpaRepository { - List findAllByCrawlerId(Crawler crawler); +// List findAllByCrawlerId(Crawler crawler); } diff --git a/src/main/java/com/loafle/overflow/module/sensor/dao/SensorItemMappingDao.java b/src/main/java/com/loafle/overflow/module/sensor/dao/SensorItemMappingDao.java index 4dc4190..edf2bb0 100644 --- a/src/main/java/com/loafle/overflow/module/sensor/dao/SensorItemMappingDao.java +++ b/src/main/java/com/loafle/overflow/module/sensor/dao/SensorItemMappingDao.java @@ -1,14 +1,12 @@ package com.loafle.overflow.module.sensor.dao; -import com.loafle.overflow.commons.dao.BaseDAO; - -import java.util.List; /** * Created by root on 17. 6. 9. */ -public interface SensorItemMappingDao extends BaseDAO { - - List findAllBySensorId(Sensor sensor); - -} +//@Repository +//public interface SensorItemMappingDao extends JpaRepository { +// +//// List findAllBySensorId(Sensor sensor); +// +//} diff --git a/src/main/java/com/loafle/overflow/proxy/db/DBProxy.java b/src/main/java/com/loafle/overflow/proxy/db/DBProxy.java index 9a0b515..b917a7d 100644 --- a/src/main/java/com/loafle/overflow/proxy/db/DBProxy.java +++ b/src/main/java/com/loafle/overflow/proxy/db/DBProxy.java @@ -1,28 +1,22 @@ package com.loafle.overflow.proxy.db; - - - -import com.loafle.overflow.dao.agent.dao.JPAAgentDAO; -import com.loafle.overflow.dao.apikey.dao.JPAApiKeyDao; -import com.loafle.overflow.commons.dao.JPABaseDAO; -import com.loafle.overflow.dao.crawler.dao.JPACrawlerDAO; -import com.loafle.overflow.dao.crawler.dao.JPACrawlerInputItemDAO; -import com.loafle.overflow.dao.crawler.dao.JPACrawlerInputItemMappingDAO; import com.loafle.overflow.db.api.DBGrpc; - import com.loafle.overflow.db.api.DBInput; import com.loafle.overflow.db.api.DBOutput; -import com.loafle.overflow.dao.email.dao.JPAEmailAuthDAO; -import com.loafle.overflow.dao.member.dao.JPAMemberDAO; -import com.loafle.overflow.dao.noauthagent.dao.JPANoAuthAgentDAO; -import com.loafle.overflow.dao.sensor.dao.JPASensorDao; -import com.loafle.overflow.dao.sensor.dao.JPASensorItemCategoryDao; -import com.loafle.overflow.dao.sensor.dao.JPASensorItemDao; -import com.loafle.overflow.dao.sensor.dao.JPASensorItemMappingDao; -import com.loafle.overflow.dao.target.dao.JPATargetDao; +import com.loafle.overflow.module.agent.dao.AgentDAO; +import com.loafle.overflow.module.apikey.dao.ApiKeyDao; +import com.loafle.overflow.module.crawler.dao.CrawlerDAO; +import com.loafle.overflow.module.crawler.dao.CrawlerInputItemDAO; +import com.loafle.overflow.module.crawler.dao.CrawlerInputItemMappingDAO; +import com.loafle.overflow.module.email.dao.EmailAuthDAO; +import com.loafle.overflow.module.member.dao.MemberDAO; +import com.loafle.overflow.module.noauthagent.dao.NoAuthAgentDao; +import com.loafle.overflow.module.sensor.dao.SensorDao; +import com.loafle.overflow.module.sensor.dao.SensorItemDao; import io.grpc.ServerBuilder; import org.codehaus.jackson.map.ObjectMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.jpa.repository.JpaRepository; import java.io.IOException; import java.lang.reflect.InvocationTargetException; @@ -42,37 +36,71 @@ public class DBProxy { private static final Logger logger = Logger.getLogger(DBProxy.class.getName()); private io.grpc.Server server; - private static Map daoMap = null; + private static Map daoMap = null; + + @Autowired + private MemberDAO memberDAO; + + @Autowired + private AgentDAO agentDAO; + + @Autowired + private NoAuthAgentDao noAuthAgentDAO; + + @Autowired + private ApiKeyDao apiKeyDao; + + @Autowired + private EmailAuthDAO emailAuthDAO; + +// @Autowired +// private TargetDao targetDao; + + @Autowired + private CrawlerDAO crawlerDAO; + + @Autowired + private CrawlerInputItemDAO crawlerInputItemDAO; + + @Autowired + private CrawlerInputItemMappingDAO crawlerInputItemMappingDAO; + + @Autowired + private SensorDao sensorDao; + +// @Autowired +// private SensorItemCategoryDao sensorItemCategoryDao; + + @Autowired + private SensorItemDao sensorItemDao; + +// @Autowired +// private SensorItemMappingDao sensorItemMappingDao; public DBProxy() { daoMap = new ConcurrentHashMap(); - JPAMemberDAO memberDao = new JPAMemberDAO(); - JPAAgentDAO agentDao = new JPAAgentDAO(); - JPANoAuthAgentDAO jpaNoAuthAgentDAO = new JPANoAuthAgentDAO(); - JPAApiKeyDao jpaApiKeyDao = new JPAApiKeyDao(); - JPAEmailAuthDAO emailAuthDAO = new JPAEmailAuthDAO(); - daoMap.put("member", memberDao); - daoMap.put("agent", agentDao); - daoMap.put("noauthAgent", jpaNoAuthAgentDAO); - daoMap.put("apiKey", jpaApiKeyDao); + daoMap.put("member", memberDAO); + daoMap.put("agent", agentDAO); + daoMap.put("noauthAgent", noAuthAgentDAO); + daoMap.put("apiKey", apiKeyDao); daoMap.put("emailAuth", emailAuthDAO); - daoMap.put("target", new JPATargetDao()); - daoMap.put("crawler", new JPACrawlerDAO()); - daoMap.put("crawlerInputItem", new JPACrawlerInputItemDAO()); - daoMap.put("crawlerInputItemMapping", new JPACrawlerInputItemMappingDAO()); +// daoMap.put("target", targetDao); + daoMap.put("crawler", crawlerDAO); + daoMap.put("crawlerInputItem", crawlerInputItemDAO); + daoMap.put("crawlerInputItemMapping", crawlerInputItemMappingDAO); - daoMap.put("sensor", new JPASensorDao()); - daoMap.put("sensorItemCategory", new JPASensorItemCategoryDao()); - daoMap.put("sensorItem", new JPASensorItemDao()); - daoMap.put("sensorItemMapping", new JPASensorItemMappingDao()); + daoMap.put("sensor", sensorDao); +// daoMap.put("sensorItemCategory", sensorItemCategoryDao); + daoMap.put("sensorItem", sensorItemDao); +// daoMap.put("sensorItemMapping", sensorItemMappingDao); } public void start(int port) throws IOException { server = ServerBuilder.forPort(port) - .addService(new ServiceImpl()) - .build() - .start(); + .addService(new ServiceImpl()) + .build() + .start(); logger.info("Server started, listening on " + port); Runtime.getRuntime().addShutdownHook(new Thread() { @Override @@ -97,7 +125,7 @@ public class DBProxy { io.grpc.stub.StreamObserver responseObserver) { String targetDAO = request.getTargetDao(); - JPABaseDAO dao = daoMap.get(targetDAO); + JpaRepository dao = daoMap.get(targetDAO); if(dao != null) { try { @@ -105,8 +133,8 @@ public class DBProxy { String jsonResult = doQuery(request, dao); DBOutput reply = DBOutput.newBuilder() - .setResult(jsonResult) - .build(); + .setResult(jsonResult) + .build(); responseObserver.onNext(reply); responseObserver.onCompleted(); }catch(Exception e) { @@ -119,7 +147,7 @@ public class DBProxy { } } - private String doQuery(DBInput request, JPABaseDAO dao) throws Exception { + private String doQuery(DBInput request, JpaRepository dao) throws Exception { String methodName = request.getMethod(); Map params = request.getParamsMap(); diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml deleted file mode 100644 index 5063762..0000000 --- a/src/main/resources/META-INF/persistence.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - com.loafle.overflow.member.model.Member - com.loafle.overflow.noauthagent.model.NoAuthAgent - com.loafle.overflow.apikey.model.Apikey - com.loafle.overflow.agent.model.Agent - com.loafle.overflow.email.model.EmailAuth - com.loafle.overflow.target.model.Target - com.loafle.overflow.crawler.model.Crawler - com.loafle.overflow.crawler.model.CrawlerInputItem - com.loafle.overflow.crawler.model.CrawlerInputItemMapping - - com.loafle.overflow.sensor.model.Sensor - com.loafle.overflow.sensor.model.SensorItem - com.loafle.overflow.sensor.model.SensorItemMapping - com.loafle.overflow.sensor.model.SensorItemCategory - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/database.properties b/src/main/resources/database.properties new file mode 100644 index 0000000..7347b51 --- /dev/null +++ b/src/main/resources/database.properties @@ -0,0 +1,11 @@ +spring.datasource.url=jdbc:postgresql://192.168.1.106:5432/postgres +spring.datasource.username=vertx +spring.datasource.password=qwe123 +spring.datasource.driver-class-name=org.postgresql.Driver + +spring.jpa.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +spring.jpa.database=postgresql +spring.jpa.hibernate.ddl-auto=create +#spring.jpa.hibernate.ddl-auto=update +spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy +spring.jpa.show-sql=true diff --git a/src/test/java/com/loafle/overflow/agent/dao/JPAAgentDAOTest.java b/src/test/java/com/loafle/overflow/agent/dao/JPAAgentDAOTest.java index 979b604..f2604fa 100644 --- a/src/test/java/com/loafle/overflow/agent/dao/JPAAgentDAOTest.java +++ b/src/test/java/com/loafle/overflow/agent/dao/JPAAgentDAOTest.java @@ -1,36 +1,36 @@ -package com.loafle.overflow.agent.dao; - -import com.loafle.overflow.module.agent.dao.JPAAgentDAO; -import com.loafle.overflow.module.agent.model.Agent; -import com.loafle.overflow.module.member.model.Member; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -/** - * Created by root on 17. 6. 4. - */ -@Ignore -public class JPAAgentDAOTest { - - private JPAAgentDAO jpaAgentDAO = null; - - @Before - public void before() { - this.jpaAgentDAO = new JPAAgentDAO(); - } - - - @Test - public void createAgent() { - Member m = new Member(); - m.setId(Long.valueOf(1)); - Agent agent = new Agent(); - agent.setDescription("test agent"); - agent.setMember(m); - Agent savedAgent = jpaAgentDAO.create(agent); - - System.out.println(savedAgent.getDescription()); - } - -} \ No newline at end of file +//package com.loafle.overflow.agent.dao; +// +//import com.loafle.overflow.module.agent.dao.JPAAgentDAO; +//import com.loafle.overflow.module.agent.model.Agent; +//import com.loafle.overflow.module.member.model.Member; +//import org.junit.Before; +//import org.junit.Ignore; +//import org.junit.Test; +// +///** +// * Created by root on 17. 6. 4. +// */ +//@Ignore +//public class JPAAgentDAOTest { +// +// private JPAAgentDAO jpaAgentDAO = null; +// +// @Before +// public void before() { +// this.jpaAgentDAO = new JPAAgentDAO(); +// } +// +// +// @Test +// public void createAgent() { +// Member m = new Member(); +// m.setId(Long.valueOf(1)); +// Agent agent = new Agent(); +// agent.setDescription("test agent"); +// agent.setMember(m); +// Agent savedAgent = jpaAgentDAO.create(agent); +// +// System.out.println(savedAgent.getDescription()); +// } +// +//} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/apikey/dao/JPAApiKeyDaoTest.java b/src/test/java/com/loafle/overflow/apikey/dao/JPAApiKeyDaoTest.java index 203a220..1a055f5 100644 --- a/src/test/java/com/loafle/overflow/apikey/dao/JPAApiKeyDaoTest.java +++ b/src/test/java/com/loafle/overflow/apikey/dao/JPAApiKeyDaoTest.java @@ -1,54 +1,54 @@ -package com.loafle.overflow.apikey.dao; - -import com.loafle.overflow.module.apikey.dao.JPAApiKeyDao; -import com.loafle.overflow.module.apikey.model.Apikey; -import com.loafle.overflow.module.member.model.Member; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.Date; - -/** - * Created by root on 17. 6. 4. - */ -public class JPAApiKeyDaoTest { - - private JPAApiKeyDao jpaApiKeyDao; - - @Before - public void Before() { - this.jpaApiKeyDao = new JPAApiKeyDao(); - } - - - @Ignore - @Test - public void findByApiKey() throws Exception { - - Apikey apikey = new Apikey(); - - apikey.setApiKey("1111111"); - - Apikey a = this.jpaApiKeyDao.findByApiKey(apikey); - - System.out.println(a.getId()); - - } - - @Ignore - @Test - public void createApiKey() { - Apikey apikey = new Apikey(); - - apikey.setApiKey("1111111"); - apikey.setCreateDate(new Date()); - Member member = new Member(); - member.setId((long)2); - apikey.setMember(member); - - - jpaApiKeyDao.create(apikey); - } - -} \ No newline at end of file +//package com.loafle.overflow.apikey.dao; +// +//import com.loafle.overflow.module.apikey.dao.JPAApiKeyDao; +//import com.loafle.overflow.module.apikey.model.Apikey; +//import com.loafle.overflow.module.member.model.Member; +//import org.junit.Before; +//import org.junit.Ignore; +//import org.junit.Test; +// +//import java.util.Date; +// +///** +// * Created by root on 17. 6. 4. +// */ +//public class JPAApiKeyDaoTest { +// +// private JPAApiKeyDao jpaApiKeyDao; +// +// @Before +// public void Before() { +// this.jpaApiKeyDao = new JPAApiKeyDao(); +// } +// +// +// @Ignore +// @Test +// public void findByApiKey() throws Exception { +// +// Apikey apikey = new Apikey(); +// +// apikey.setApiKey("1111111"); +// +// Apikey a = this.jpaApiKeyDao.findByApiKey(apikey); +// +// System.out.println(a.getId()); +// +// } +// +// @Ignore +// @Test +// public void createApiKey() { +// Apikey apikey = new Apikey(); +// +// apikey.setApiKey("1111111"); +// apikey.setCreateDate(new Date()); +// Member member = new Member(); +// member.setId((long)2); +// apikey.setMember(member); +// +// +// jpaApiKeyDao.create(apikey); +// } +// +//} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/crawler/dao/JPACrawlerDAOTest.java b/src/test/java/com/loafle/overflow/crawler/dao/JPACrawlerDAOTest.java index 3c1d5d1..137aec0 100644 --- a/src/test/java/com/loafle/overflow/crawler/dao/JPACrawlerDAOTest.java +++ b/src/test/java/com/loafle/overflow/crawler/dao/JPACrawlerDAOTest.java @@ -1,78 +1,78 @@ -package com.loafle.overflow.crawler.dao; - - -import com.loafle.overflow.module.crawler.dao.JPACrawlerDAO; -import com.loafle.overflow.module.crawler.model.Crawler; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by geek@loafle.com on 17. 6. 8. - */ -@Ignore -public class JPACrawlerDAOTest { - - private JPACrawlerDAO jpaCrawlerDAO = null; - - @Before - public void before() { - this.jpaCrawlerDAO = new JPACrawlerDAO(); - - } - - // TODO Crawler Meta Data Insert - @Test - public void TestInsertList() { - List crawlers = new ArrayList(); - - Crawler crawler1 = new Crawler(); - crawler1.setName("SNMP Crawler"); - crawler1.setDescription("SNMP Crawler"); - crawler1.setCrawlerType("SNMP"); - - Crawler crawler2 = new Crawler(); - crawler2.setName("WMI Crawler"); - crawler2.setDescription("WMI Crawler"); - crawler2.setCrawlerType("WMI"); - - Crawler crawler3 = new Crawler(); - crawler3.setName("HTTP Crawler"); - crawler3.setDescription("HTTP Crawler"); - crawler3.setCrawlerType("Network"); - - Crawler crawler4 = new Crawler(); - crawler4.setName("FTP Crawler"); - crawler4.setDescription("FTP Crawler"); - crawler4.setCrawlerType("Network"); - - crawlers.add(crawler1); - crawlers.add(crawler2); - crawlers.add(crawler3); - crawlers.add(crawler4); - - this.jpaCrawlerDAO.createAll(crawlers); - } - - @Test - public void TestInsert() { - Crawler crawler = new Crawler(); - crawler.setName("Mysql Crawler"); - crawler.setDescription("Mysql Crawler"); - crawler.setCrawlerType("MysqlCrawler"); - this.jpaCrawlerDAO.create(crawler); - } - // TODO Crawler Select Test - - @Test - public void TestListAll() { - List ls = this.jpaCrawlerDAO.findAll(); - System.out.println(ls.size()); - } - // TODO Crawler Update Test - - // TODO Crawler Delete Test -} \ No newline at end of file +//package com.loafle.overflow.crawler.dao; +// +// +//import com.loafle.overflow.module.crawler.dao.JPACrawlerDAO; +//import com.loafle.overflow.module.crawler.model.Crawler; +//import org.junit.Before; +//import org.junit.Ignore; +//import org.junit.Test; +// +//import java.util.ArrayList; +//import java.util.List; +// +///** +// * Created by geek@loafle.com on 17. 6. 8. +// */ +//@Ignore +//public class JPACrawlerDAOTest { +// +// private JPACrawlerDAO jpaCrawlerDAO = null; +// +// @Before +// public void before() { +// this.jpaCrawlerDAO = new JPACrawlerDAO(); +// +// } +// +// // TODO Crawler Meta Data Insert +// @Test +// public void TestInsertList() { +// List crawlers = new ArrayList(); +// +// Crawler crawler1 = new Crawler(); +// crawler1.setName("SNMP Crawler"); +// crawler1.setDescription("SNMP Crawler"); +// crawler1.setCrawlerType("SNMP"); +// +// Crawler crawler2 = new Crawler(); +// crawler2.setName("WMI Crawler"); +// crawler2.setDescription("WMI Crawler"); +// crawler2.setCrawlerType("WMI"); +// +// Crawler crawler3 = new Crawler(); +// crawler3.setName("HTTP Crawler"); +// crawler3.setDescription("HTTP Crawler"); +// crawler3.setCrawlerType("Network"); +// +// Crawler crawler4 = new Crawler(); +// crawler4.setName("FTP Crawler"); +// crawler4.setDescription("FTP Crawler"); +// crawler4.setCrawlerType("Network"); +// +// crawlers.add(crawler1); +// crawlers.add(crawler2); +// crawlers.add(crawler3); +// crawlers.add(crawler4); +// +// this.jpaCrawlerDAO.createAll(crawlers); +// } +// +// @Test +// public void TestInsert() { +// Crawler crawler = new Crawler(); +// crawler.setName("Mysql Crawler"); +// crawler.setDescription("Mysql Crawler"); +// crawler.setCrawlerType("MysqlCrawler"); +// this.jpaCrawlerDAO.create(crawler); +// } +// // TODO Crawler Select Test +// +// @Test +// public void TestListAll() { +// List ls = this.jpaCrawlerDAO.findAll(); +// System.out.println(ls.size()); +// } +// // TODO Crawler Update Test +// +// // TODO Crawler Delete Test +//} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/crawler/dao/JPACrawlerInputItemDAOTest.java b/src/test/java/com/loafle/overflow/crawler/dao/JPACrawlerInputItemDAOTest.java index 16e9388..50c403b 100644 --- a/src/test/java/com/loafle/overflow/crawler/dao/JPACrawlerInputItemDAOTest.java +++ b/src/test/java/com/loafle/overflow/crawler/dao/JPACrawlerInputItemDAOTest.java @@ -1,62 +1,62 @@ -package com.loafle.overflow.crawler.dao; - -import com.loafle.overflow.module.crawler.dao.JPACrawlerInputItemDAO; -import com.loafle.overflow.module.crawler.model.CrawlerInputItem; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by geek@loafle.com on 17. 6. 8. - */ -@Ignore -public class JPACrawlerInputItemDAOTest { - - private JPACrawlerInputItemDAO inputItemDAO = null; - - @Before - public void before() { - this.inputItemDAO = new JPACrawlerInputItemDAO(); - } - - @Test - public void TestInsertList() { - List cris = new ArrayList(); - - CrawlerInputItem item1 = new CrawlerInputItem(); - item1.setName("ID"); - item1.setDataType("String"); - item1.setDescription("Auth ID"); - - CrawlerInputItem item2 = new CrawlerInputItem(); - item2.setName("PW"); - item2.setDataType("String"); - item2.setDescription("Auth PW"); - - CrawlerInputItem item3 = new CrawlerInputItem(); - item3.setName("AuthType"); - item3.setDataType("Select"); - item3.setDescription("MD5||SHA"); - - CrawlerInputItem item4 = new CrawlerInputItem(); - item4.setName("community"); - item4.setDataType("String"); - item4.setDescription("community"); - - CrawlerInputItem item5 = new CrawlerInputItem(); - item5.setName("textfield"); - item5.setDataType("String"); - item5.setDescription("User ID"); - - cris.add(item1); - cris.add(item2); - cris.add(item3); - cris.add(item4); - cris.add(item5); - - this.inputItemDAO.createAll(cris); - } -} \ No newline at end of file +//package com.loafle.overflow.crawler.dao; +// +//import com.loafle.overflow.module.crawler.dao.JPACrawlerInputItemDAO; +//import com.loafle.overflow.module.crawler.model.CrawlerInputItem; +//import org.junit.Before; +//import org.junit.Ignore; +//import org.junit.Test; +// +//import java.util.ArrayList; +//import java.util.List; +// +///** +// * Created by geek@loafle.com on 17. 6. 8. +// */ +//@Ignore +//public class JPACrawlerInputItemDAOTest { +// +// private JPACrawlerInputItemDAO inputItemDAO = null; +// +// @Before +// public void before() { +// this.inputItemDAO = new JPACrawlerInputItemDAO(); +// } +// +// @Test +// public void TestInsertList() { +// List cris = new ArrayList(); +// +// CrawlerInputItem item1 = new CrawlerInputItem(); +// item1.setName("ID"); +// item1.setDataType("String"); +// item1.setDescription("Auth ID"); +// +// CrawlerInputItem item2 = new CrawlerInputItem(); +// item2.setName("PW"); +// item2.setDataType("String"); +// item2.setDescription("Auth PW"); +// +// CrawlerInputItem item3 = new CrawlerInputItem(); +// item3.setName("AuthType"); +// item3.setDataType("Select"); +// item3.setDescription("MD5||SHA"); +// +// CrawlerInputItem item4 = new CrawlerInputItem(); +// item4.setName("community"); +// item4.setDataType("String"); +// item4.setDescription("community"); +// +// CrawlerInputItem item5 = new CrawlerInputItem(); +// item5.setName("textfield"); +// item5.setDataType("String"); +// item5.setDescription("User ID"); +// +// cris.add(item1); +// cris.add(item2); +// cris.add(item3); +// cris.add(item4); +// cris.add(item5); +// +// this.inputItemDAO.createAll(cris); +// } +//} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/crawler/dao/JPACrawlerInputItemMappingDAOTest.java b/src/test/java/com/loafle/overflow/crawler/dao/JPACrawlerInputItemMappingDAOTest.java index 1a5ffa3..c03a170 100644 --- a/src/test/java/com/loafle/overflow/crawler/dao/JPACrawlerInputItemMappingDAOTest.java +++ b/src/test/java/com/loafle/overflow/crawler/dao/JPACrawlerInputItemMappingDAOTest.java @@ -1,89 +1,89 @@ -package com.loafle.overflow.crawler.dao; - -import com.loafle.overflow.module.crawler.dao.JPACrawlerInputItemMappingDAO; -import com.loafle.overflow.module.crawler.model.Crawler; -import com.loafle.overflow.module.crawler.model.CrawlerInputItem; -import com.loafle.overflow.module.crawler.model.CrawlerInputItemMapping; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by geek@loafle.com on 17. 6. 8. - */ -@Ignore -public class JPACrawlerInputItemMappingDAOTest { - - private JPACrawlerInputItemMappingDAO mappingDAO = null; - - @Before - public void before() { - this.mappingDAO = new JPACrawlerInputItemMappingDAO(); - } - - @Test - public void TestInsert() { - CrawlerInputItemMapping itemMapping = new CrawlerInputItemMapping(); - itemMapping.setCrawler(new Crawler((long)5)); - itemMapping.setCrawlerInputItem(new CrawlerInputItem((long)1)); - itemMapping.setPriority((short) 1); - itemMapping.setRequiredType(true); - - CrawlerInputItemMapping itemMapping1 = new CrawlerInputItemMapping(); - itemMapping1.setCrawler(new Crawler((long)5)); - itemMapping1.setCrawlerInputItem(new CrawlerInputItem((long)2)); - itemMapping1.setPriority((short) 2); - itemMapping1.setRequiredType(true); - - CrawlerInputItemMapping itemMapping2 = new CrawlerInputItemMapping(); - itemMapping2.setCrawler(new Crawler((long)1)); - itemMapping2.setCrawlerInputItem(new CrawlerInputItem((long)1)); - itemMapping2.setPriority((short) 1); - itemMapping2.setRequiredType(true); - - CrawlerInputItemMapping itemMapping3 = new CrawlerInputItemMapping(); - itemMapping3.setCrawler(new Crawler((long)1)); - itemMapping3.setCrawlerInputItem(new CrawlerInputItem((long)2)); - itemMapping3.setPriority((short) 2); - itemMapping3.setRequiredType(true); - - CrawlerInputItemMapping itemMapping4 = new CrawlerInputItemMapping(); - itemMapping4.setCrawler(new Crawler((long)1)); - itemMapping4.setCrawlerInputItem(new CrawlerInputItem((long)3)); - itemMapping4.setPriority((short) 3); - itemMapping4.setRequiredType(true); - - CrawlerInputItemMapping itemMapping5 = new CrawlerInputItemMapping(); - itemMapping5.setCrawler(new Crawler((long)2)); - itemMapping5.setCrawlerInputItem(new CrawlerInputItem((long)1)); - itemMapping5.setPriority((short) 1); - itemMapping5.setRequiredType(true); - - CrawlerInputItemMapping itemMapping6 = new CrawlerInputItemMapping(); - itemMapping6.setCrawler(new Crawler((long)2)); - itemMapping6.setCrawlerInputItem(new CrawlerInputItem((long)2)); - itemMapping6.setPriority((short) 2); - itemMapping6.setRequiredType(true); - - List crs = new ArrayList(); - crs.add(itemMapping); - crs.add(itemMapping1); - crs.add(itemMapping2); - crs.add(itemMapping3); - crs.add(itemMapping4); - crs.add(itemMapping5); - crs.add(itemMapping6); - - this.mappingDAO.createAll(crs); - } - - @Test - public void TestFindByCrawlerId() { - List ls = this.mappingDAO.findByCrawlerId(new Crawler((long)5)); - System.out.println(ls.size()); - } - -} \ No newline at end of file +//package com.loafle.overflow.crawler.dao; +// +//import com.loafle.overflow.module.crawler.dao.JPACrawlerInputItemMappingDAO; +//import com.loafle.overflow.module.crawler.model.Crawler; +//import com.loafle.overflow.module.crawler.model.CrawlerInputItem; +//import com.loafle.overflow.module.crawler.model.CrawlerInputItemMapping; +//import org.junit.Before; +//import org.junit.Ignore; +//import org.junit.Test; +// +//import java.util.ArrayList; +//import java.util.List; +// +///** +// * Created by geek@loafle.com on 17. 6. 8. +// */ +//@Ignore +//public class JPACrawlerInputItemMappingDAOTest { +// +// private JPACrawlerInputItemMappingDAO mappingDAO = null; +// +// @Before +// public void before() { +// this.mappingDAO = new JPACrawlerInputItemMappingDAO(); +// } +// +// @Test +// public void TestInsert() { +// CrawlerInputItemMapping itemMapping = new CrawlerInputItemMapping(); +// itemMapping.setCrawler(new Crawler((long)5)); +// itemMapping.setCrawlerInputItem(new CrawlerInputItem((long)1)); +// itemMapping.setPriority((short) 1); +// itemMapping.setRequiredType(true); +// +// CrawlerInputItemMapping itemMapping1 = new CrawlerInputItemMapping(); +// itemMapping1.setCrawler(new Crawler((long)5)); +// itemMapping1.setCrawlerInputItem(new CrawlerInputItem((long)2)); +// itemMapping1.setPriority((short) 2); +// itemMapping1.setRequiredType(true); +// +// CrawlerInputItemMapping itemMapping2 = new CrawlerInputItemMapping(); +// itemMapping2.setCrawler(new Crawler((long)1)); +// itemMapping2.setCrawlerInputItem(new CrawlerInputItem((long)1)); +// itemMapping2.setPriority((short) 1); +// itemMapping2.setRequiredType(true); +// +// CrawlerInputItemMapping itemMapping3 = new CrawlerInputItemMapping(); +// itemMapping3.setCrawler(new Crawler((long)1)); +// itemMapping3.setCrawlerInputItem(new CrawlerInputItem((long)2)); +// itemMapping3.setPriority((short) 2); +// itemMapping3.setRequiredType(true); +// +// CrawlerInputItemMapping itemMapping4 = new CrawlerInputItemMapping(); +// itemMapping4.setCrawler(new Crawler((long)1)); +// itemMapping4.setCrawlerInputItem(new CrawlerInputItem((long)3)); +// itemMapping4.setPriority((short) 3); +// itemMapping4.setRequiredType(true); +// +// CrawlerInputItemMapping itemMapping5 = new CrawlerInputItemMapping(); +// itemMapping5.setCrawler(new Crawler((long)2)); +// itemMapping5.setCrawlerInputItem(new CrawlerInputItem((long)1)); +// itemMapping5.setPriority((short) 1); +// itemMapping5.setRequiredType(true); +// +// CrawlerInputItemMapping itemMapping6 = new CrawlerInputItemMapping(); +// itemMapping6.setCrawler(new Crawler((long)2)); +// itemMapping6.setCrawlerInputItem(new CrawlerInputItem((long)2)); +// itemMapping6.setPriority((short) 2); +// itemMapping6.setRequiredType(true); +// +// List crs = new ArrayList(); +// crs.add(itemMapping); +// crs.add(itemMapping1); +// crs.add(itemMapping2); +// crs.add(itemMapping3); +// crs.add(itemMapping4); +// crs.add(itemMapping5); +// crs.add(itemMapping6); +// +// this.mappingDAO.createAll(crs); +// } +// +// @Test +// public void TestFindByCrawlerId() { +// List ls = this.mappingDAO.findByCrawlerId(new Crawler((long)5)); +// System.out.println(ls.size()); +// } +// +//} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/email/dao/JPAEmailAuthDAOTest.java b/src/test/java/com/loafle/overflow/email/dao/JPAEmailAuthDAOTest.java index 36e9511..5a920ef 100644 --- a/src/test/java/com/loafle/overflow/email/dao/JPAEmailAuthDAOTest.java +++ b/src/test/java/com/loafle/overflow/email/dao/JPAEmailAuthDAOTest.java @@ -1,77 +1,77 @@ -package com.loafle.overflow.email.dao; - -import com.loafle.overflow.module.email.dao.JPAEmailAuthDAO; -import com.loafle.overflow.module.email.model.EmailAuth; -import com.loafle.overflow.module.member.model.Member; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.Date; -import java.util.List; - -/** - * Created by geek@loafle.com on 17. 6. 6. - */ -@Ignore -public class JPAEmailAuthDAOTest { - - private JPAEmailAuthDAO emailAuthDAO = null; - - @Before - public void before() { - - this.emailAuthDAO = new JPAEmailAuthDAO(); - } - - @Test - @Ignore - public void createEmailAuth() { - EmailAuth auth = new EmailAuth(); - - auth.setAuthToken("0F2003A6-83B0-40F5-B56A-0485F458CA911"); - auth.setMember(new Member(Long.valueOf(1))); - auth.setIsInvalid(false); +//package com.loafle.overflow.email.dao; +// +//import com.loafle.overflow.module.email.dao.JPAEmailAuthDAO; +//import com.loafle.overflow.module.email.model.EmailAuth; +//import com.loafle.overflow.module.member.model.Member; +//import org.junit.Assert; +//import org.junit.Before; +//import org.junit.Ignore; +//import org.junit.Test; +// +//import java.util.Date; +//import java.util.List; +// +///** +// * Created by geek@loafle.com on 17. 6. 6. +// */ +//@Ignore +//public class JPAEmailAuthDAOTest { +// +// private JPAEmailAuthDAO emailAuthDAO = null; +// +// @Before +// public void before() { +// +// this.emailAuthDAO = new JPAEmailAuthDAO(); +// } +// +// @Test +// @Ignore +// public void createEmailAuth() { +// EmailAuth auth = new EmailAuth(); +// +// auth.setAuthToken("0F2003A6-83B0-40F5-B56A-0485F458CA911"); +// auth.setMember(new Member(Long.valueOf(1))); +// auth.setIsInvalid(false); +//// auth.setUpdateDate(new Date()); +// auth.setIsConfirm(false); +// EmailAuth ret = emailAuthDAO.create(auth); +// System.out.println(ret.getId()); +// } +// +// @Test +// @Ignore +// public void updateEmailAuth() { +// EmailAuth auth = this.emailAuthDAO.find("1"); +// +// auth.setIsInvalid(true); // auth.setUpdateDate(new Date()); - auth.setIsConfirm(false); - EmailAuth ret = emailAuthDAO.create(auth); - System.out.println(ret.getId()); - } - - @Test - @Ignore - public void updateEmailAuth() { - EmailAuth auth = this.emailAuthDAO.find("1"); - - auth.setIsInvalid(true); - auth.setUpdateDate(new Date()); - auth.setConfirmDate(new Date()); - - this.emailAuthDAO.update(auth); - System.out.println(auth.getConfirmDate()); - } - - @Test - @Ignore - public void TestFindByAuthToken() { - EmailAuth auth = new EmailAuth(); - auth.setAuthToken("3C03F8AB-1D4D-4C8A-8C36-EE2D644988B5"); - - EmailAuth temp = this.emailAuthDAO.findByAuthToken(auth); - - System.out.println(temp.getId()); - Assert.assertNotNull(temp); - } - - @Test - @Ignore - public void TestFindByMemberId() { - EmailAuth auth = new EmailAuth(); - auth.setMember(new Member((long)4)); - List ems = this.emailAuthDAO.findByMemberId(auth); - - System.out.println(ems.get(0).getMember().getEmail()); - Assert.assertEquals((long)1, (long)ems.size()); - } -} \ No newline at end of file +// auth.setConfirmDate(new Date()); +// +// this.emailAuthDAO.update(auth); +// System.out.println(auth.getConfirmDate()); +// } +// +// @Test +// @Ignore +// public void TestFindByAuthToken() { +// EmailAuth auth = new EmailAuth(); +// auth.setAuthToken("3C03F8AB-1D4D-4C8A-8C36-EE2D644988B5"); +// +// EmailAuth temp = this.emailAuthDAO.findByAuthToken(auth); +// +// System.out.println(temp.getId()); +// Assert.assertNotNull(temp); +// } +// +// @Test +// @Ignore +// public void TestFindByMemberId() { +// EmailAuth auth = new EmailAuth(); +// auth.setMember(new Member((long)4)); +// List ems = this.emailAuthDAO.findByMemberId(auth); +// +// System.out.println(ems.get(0).getMember().getEmail()); +// Assert.assertEquals((long)1, (long)ems.size()); +// } +//} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/member/dao/JPAMemberDAOTest.java b/src/test/java/com/loafle/overflow/member/dao/JPAMemberDAOTest.java index 37d1861..915e944 100644 --- a/src/test/java/com/loafle/overflow/member/dao/JPAMemberDAOTest.java +++ b/src/test/java/com/loafle/overflow/member/dao/JPAMemberDAOTest.java @@ -1,42 +1,42 @@ -package com.loafle.overflow.member.dao; - -import com.loafle.overflow.module.member.dao.JPAMemberDAO; -import com.loafle.overflow.module.member.model.Member; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -/** - * Created by root on 17. 6. 4. - */ -@Ignore -public class JPAMemberDAOTest { - - private JPAMemberDAO jpaMemberDAO = null; - - @Before - public void before() { - - this.jpaMemberDAO = new JPAMemberDAO(); - } - - @Test - public void findByEmail() throws Exception { - } - -// @Ignore - @Test - public void createMember() { - Member m = new Member(); - - m.setName("geek"); - m.setCompany("loafle"); - m.setDigest("bbbbbbbbb"); - m.setPwSalt("salktttt"); - m.setPhone("000-000-0000"); - m.setEmail("geek@loafle.com"); - - this.jpaMemberDAO.create(m); - } - -} \ No newline at end of file +//package com.loafle.overflow.member.dao; +// +//import com.loafle.overflow.module.member.dao.JPAMemberDAO; +//import com.loafle.overflow.module.member.model.Member; +//import org.junit.Before; +//import org.junit.Ignore; +//import org.junit.Test; +// +///** +// * Created by root on 17. 6. 4. +// */ +//@Ignore +//public class JPAMemberDAOTest { +// +// private JPAMemberDAO jpaMemberDAO = null; +// +// @Before +// public void before() { +// +// this.jpaMemberDAO = new JPAMemberDAO(); +// } +// +// @Test +// public void findByEmail() throws Exception { +// } +// +//// @Ignore +// @Test +// public void createMember() { +// Member m = new Member(); +// +// m.setName("geek"); +// m.setCompany("loafle"); +// m.setDigest("bbbbbbbbb"); +// m.setPwSalt("salktttt"); +// m.setPhone("000-000-0000"); +// m.setEmail("geek@loafle.com"); +// +// this.jpaMemberDAO.create(m); +// } +// +//} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java b/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java new file mode 100644 index 0000000..4bfe07b --- /dev/null +++ b/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java @@ -0,0 +1,38 @@ +package com.loafle.overflow.module.member.dao; + +import com.loafle.overflow.AppConfig; +import com.loafle.overflow.JdbcConfiguration; +import com.loafle.overflow.module.member.model.Member; +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 static org.junit.Assert.*; + +/** + * Created by root on 17. 6. 22. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) +public class MemberDAOTest { + + + @Autowired + private MemberDAO repo; + + @Test + public void createMember() { + Member m = new Member(); + + m.setName("insanity2"); + m.setCompany("loafle"); + m.setDigest("bbbbbbbbb"); + m.setPwSalt("salktttt"); + m.setPhone("000-000-0000"); + m.setEmail("insanity1@loafle.com"); + + repo.save(m); + } +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/noauthagent/dao/JPANoAuthAgentDAOTest.java b/src/test/java/com/loafle/overflow/noauthagent/dao/JPANoAuthAgentDAOTest.java index 11bab5b..c2e6dc0 100644 --- a/src/test/java/com/loafle/overflow/noauthagent/dao/JPANoAuthAgentDAOTest.java +++ b/src/test/java/com/loafle/overflow/noauthagent/dao/JPANoAuthAgentDAOTest.java @@ -1,58 +1,58 @@ -package com.loafle.overflow.noauthagent.dao; - -import com.loafle.overflow.module.noauthagent.dao.JPANoAuthAgentDAO; -import com.loafle.overflow.module.noauthagent.model.NoAuthAgent; -import com.loafle.overflow.module.noauthagent.type.AuthType; -import org.junit.Before; -import org.junit.Test; - -import java.util.Date; - -/** - * Created by root on 17. 6. 4. - */ -public class JPANoAuthAgentDAOTest { - - private JPANoAuthAgentDAO jpaNoAuthAgentDAO = null; - - @Before - public void Before() { - this.jpaNoAuthAgentDAO = new JPANoAuthAgentDAO(); - } - - @Test - public void findByTempKey() throws Exception { - - NoAuthAgent noAuthAgent = new NoAuthAgent(); - noAuthAgent.setTempKey("3398473-90847903874"); - - NoAuthAgent aa = this.jpaNoAuthAgentDAO.findByTempKey(noAuthAgent); - - System.out.println(aa.getAuthStatus()); - - } - - @Test - public void findAllByNoAuth() throws Exception { - } - - - @Test - public void createNoAuthAgent() { - NoAuthAgent noAuthAgent = new NoAuthAgent(); - - - noAuthAgent.setApiKey("aaaaaaa"); - noAuthAgent.setDate(new Date()); - noAuthAgent.setHostName("Snoop pc"); - noAuthAgent.setLocalIP(4123); - noAuthAgent.setTempKey("3398473-90847903874"); - noAuthAgent.setAuthStatus(AuthType.WAIT); - - this.jpaNoAuthAgentDAO.create(noAuthAgent); - } - - - - -} \ No newline at end of file +//package com.loafle.overflow.noauthagent.dao; +// +//import com.loafle.overflow.module.noauthagent.dao.JPANoAuthAgentDAO; +//import com.loafle.overflow.module.noauthagent.model.NoAuthAgent; +//import com.loafle.overflow.module.noauthagent.type.AuthType; +//import org.junit.Before; +//import org.junit.Test; +// +//import java.util.Date; +// +///** +// * Created by root on 17. 6. 4. +// */ +//public class JPANoAuthAgentDAOTest { +// +// private JPANoAuthAgentDAO jpaNoAuthAgentDAO = null; +// +// @Before +// public void Before() { +// this.jpaNoAuthAgentDAO = new JPANoAuthAgentDAO(); +// } +// +// @Test +// public void findByTempKey() throws Exception { +// +// NoAuthAgent noAuthAgent = new NoAuthAgent(); +// noAuthAgent.setTempKey("3398473-90847903874"); +// +// NoAuthAgent aa = this.jpaNoAuthAgentDAO.findByTempKey(noAuthAgent); +// +// System.out.println(aa.getAuthStatus()); +// +// } +// +// @Test +// public void findAllByNoAuth() throws Exception { +// } +// +// +// @Test +// public void createNoAuthAgent() { +// NoAuthAgent noAuthAgent = new NoAuthAgent(); +// +// +// noAuthAgent.setApiKey("aaaaaaa"); +// noAuthAgent.setDate(new Date()); +// noAuthAgent.setHostName("Snoop pc"); +// noAuthAgent.setLocalIP(4123); +// noAuthAgent.setTempKey("3398473-90847903874"); +// noAuthAgent.setAuthStatus(AuthType.WAIT); +// +// this.jpaNoAuthAgentDAO.create(noAuthAgent); +// } +// +// +// +// +//} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/sensor/dao/JPASensorDaoTest.java b/src/test/java/com/loafle/overflow/sensor/dao/JPASensorDaoTest.java index d42c783..c6bb3df 100644 --- a/src/test/java/com/loafle/overflow/sensor/dao/JPASensorDaoTest.java +++ b/src/test/java/com/loafle/overflow/sensor/dao/JPASensorDaoTest.java @@ -1,55 +1,55 @@ -package com.loafle.overflow.sensor.dao; - -import com.loafle.overflow.module.crawler.model.Crawler; -import com.loafle.overflow.module.sensor.dao.JPASensorDao; -import com.loafle.overflow.module.sensor.dao.SensorDao; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -/** - * Created by root on 17. 6. 9. - */ -public class JPASensorDaoTest { - - private SensorDao sensorDao = null; - - @Before - public void before() { - this.sensorDao = new JPASensorDao(); - } - - @Test - public void findAllByAgentID() throws Exception { - } - - - @Ignore - @Test - public void create() { - - - Sensor sensor = new Sensor(); - - Crawler crawler = new Crawler(); - crawler.setId(1L); - - Target target = new Target(); - target.setId(1L); - - sensor.setCrawler(crawler); - sensor.setInterval(1); - sensor.setNotification("nothing"); - sensor.setTarget(target); - - this.sensorDao.create(sensor); - - } - - @Test - public void list() { - -// this.sensorDao.findAllByAgentID() - } - -} \ No newline at end of file +//package com.loafle.overflow.sensor.dao; +// +//import com.loafle.overflow.module.crawler.model.Crawler; +//import com.loafle.overflow.module.sensor.dao.JPASensorDao; +//import com.loafle.overflow.module.sensor.dao.SensorDao; +//import org.junit.Before; +//import org.junit.Ignore; +//import org.junit.Test; +// +///** +// * Created by root on 17. 6. 9. +// */ +//public class JPASensorDaoTest { +// +// private SensorDao sensorDao = null; +// +// @Before +// public void before() { +// this.sensorDao = new JPASensorDao(); +// } +// +// @Test +// public void findAllByAgentID() throws Exception { +// } +// +// +// @Ignore +// @Test +// public void create() { +// +// +// Sensor sensor = new Sensor(); +// +// Crawler crawler = new Crawler(); +// crawler.setId(1L); +// +// Target target = new Target(); +// target.setId(1L); +// +// sensor.setCrawler(crawler); +// sensor.setInterval(1); +// sensor.setNotification("nothing"); +// sensor.setTarget(target); +// +// this.sensorDao.create(sensor); +// +// } +// +// @Test +// public void list() { +// +//// this.sensorDao.findAllByAgentID() +// } +// +//} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/sensor/dao/JPASensorItemCategoryDaoTest.java b/src/test/java/com/loafle/overflow/sensor/dao/JPASensorItemCategoryDaoTest.java index 8d30f26..7e77725 100644 --- a/src/test/java/com/loafle/overflow/sensor/dao/JPASensorItemCategoryDaoTest.java +++ b/src/test/java/com/loafle/overflow/sensor/dao/JPASensorItemCategoryDaoTest.java @@ -1,36 +1,36 @@ -package com.loafle.overflow.sensor.dao; - -import com.loafle.overflow.module.sensor.dao.JPASensorItemCategoryDao; -import com.loafle.overflow.module.sensor.dao.SensorItemCategoryDao; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -/** - * Created by root on 17. 6. 9. - */ -public class JPASensorItemCategoryDaoTest { - - private SensorItemCategoryDao sensorItemCategoryDao = null; - - @Before - public void before() { - - this.sensorItemCategoryDao = new JPASensorItemCategoryDao(); - } - - - @Ignore - @Test - public void create() { - - SensorItemCategory sensorItemCategory = new SensorItemCategory(); - - sensorItemCategory.setName("count"); - sensorItemCategory.setDescription("count !!!!"); - - this.sensorItemCategoryDao.create(sensorItemCategory); - - } - -} \ No newline at end of file +//package com.loafle.overflow.sensor.dao; +// +//import com.loafle.overflow.module.sensor.dao.JPASensorItemCategoryDao; +//import com.loafle.overflow.module.sensor.dao.SensorItemCategoryDao; +//import org.junit.Before; +//import org.junit.Ignore; +//import org.junit.Test; +// +///** +// * Created by root on 17. 6. 9. +// */ +//public class JPASensorItemCategoryDaoTest { +// +// private SensorItemCategoryDao sensorItemCategoryDao = null; +// +// @Before +// public void before() { +// +// this.sensorItemCategoryDao = new JPASensorItemCategoryDao(); +// } +// +// +// @Ignore +// @Test +// public void create() { +// +// SensorItemCategory sensorItemCategory = new SensorItemCategory(); +// +// sensorItemCategory.setName("count"); +// sensorItemCategory.setDescription("count !!!!"); +// +// this.sensorItemCategoryDao.create(sensorItemCategory); +// +// } +// +//} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/sensor/dao/JPASensorItemDaoTest.java b/src/test/java/com/loafle/overflow/sensor/dao/JPASensorItemDaoTest.java index 2be4f9c..09f640e 100644 --- a/src/test/java/com/loafle/overflow/sensor/dao/JPASensorItemDaoTest.java +++ b/src/test/java/com/loafle/overflow/sensor/dao/JPASensorItemDaoTest.java @@ -1,61 +1,61 @@ -package com.loafle.overflow.sensor.dao; - -import com.loafle.overflow.module.crawler.model.Crawler; -import com.loafle.overflow.module.sensor.dao.JPASensorItemDao; -import com.loafle.overflow.module.sensor.dao.SensorItemDao; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.List; - -/** - * Created by root on 17. 6. 9. - */ -public class JPASensorItemDaoTest { - - private SensorItemDao sensorItemDao = null; - - @Before - public void before() { - this.sensorItemDao = new JPASensorItemDao(); - } - - @Ignore - @Test - public void create() { - - - SensorItem sensorItem = new SensorItem(); - - Crawler crawler = new Crawler(); - crawler.setId(1L); - - SensorItemCategory category = new SensorItemCategory(); - category.setId(1L); - - sensorItem.setCrawler(crawler); - sensorItem.setDataType("int"); - sensorItem.setDescription("count getget"); - sensorItem.setName("net.mysql.connection_count"); - sensorItem.setSensorItemCategory(category); - - this.sensorItemDao.create(sensorItem); - - } - - @Ignore - @Test - public void list() { - - Crawler crawler = new Crawler(); - crawler.setId(1L); - - List is = this.sensorItemDao.findAllByCrawlerId(crawler); - - - System.out.println(is.size()); - - } - -} \ No newline at end of file +//package com.loafle.overflow.sensor.dao; +// +//import com.loafle.overflow.module.crawler.model.Crawler; +//import com.loafle.overflow.module.sensor.dao.JPASensorItemDao; +//import com.loafle.overflow.module.sensor.dao.SensorItemDao; +//import org.junit.Before; +//import org.junit.Ignore; +//import org.junit.Test; +// +//import java.util.List; +// +///** +// * Created by root on 17. 6. 9. +// */ +//public class JPASensorItemDaoTest { +// +// private SensorItemDao sensorItemDao = null; +// +// @Before +// public void before() { +// this.sensorItemDao = new JPASensorItemDao(); +// } +// +// @Ignore +// @Test +// public void create() { +// +// +// SensorItem sensorItem = new SensorItem(); +// +// Crawler crawler = new Crawler(); +// crawler.setId(1L); +// +// SensorItemCategory category = new SensorItemCategory(); +// category.setId(1L); +// +// sensorItem.setCrawler(crawler); +// sensorItem.setDataType("int"); +// sensorItem.setDescription("count getget"); +// sensorItem.setName("net.mysql.connection_count"); +// sensorItem.setSensorItemCategory(category); +// +// this.sensorItemDao.create(sensorItem); +// +// } +// +// @Ignore +// @Test +// public void list() { +// +// Crawler crawler = new Crawler(); +// crawler.setId(1L); +// +// List is = this.sensorItemDao.findAllByCrawlerId(crawler); +// +// +// System.out.println(is.size()); +// +// } +// +//} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/sensor/dao/JPASensorItemMappingDaoTest.java b/src/test/java/com/loafle/overflow/sensor/dao/JPASensorItemMappingDaoTest.java index 3581885..be7552d 100644 --- a/src/test/java/com/loafle/overflow/sensor/dao/JPASensorItemMappingDaoTest.java +++ b/src/test/java/com/loafle/overflow/sensor/dao/JPASensorItemMappingDaoTest.java @@ -1,59 +1,59 @@ -package com.loafle.overflow.sensor.dao; - -import com.loafle.overflow.module.sensor.dao.JPASensorItemMappingDao; -import com.loafle.overflow.module.sensor.dao.SensorItemMappingDao; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.List; - -/** - * Created by root on 17. 6. 9. - */ -public class JPASensorItemMappingDaoTest { - - private SensorItemMappingDao sensorItemMappingDao = null; - - @Before - public void before() { - this.sensorItemMappingDao = new JPASensorItemMappingDao(); - } - - - @Ignore - @Test - public void create() { - - SensorItemMapping mapping = new SensorItemMapping(); - - Sensor sensor = new Sensor(); - - sensor.setId(1L); - - SensorItem sensorItem = new SensorItem(); - - sensorItem.setId(1L); - - mapping.setSensor(sensor); - - mapping.setSensorItem(sensorItem); - - this.sensorItemMappingDao.create(mapping); - - } - - @Test - public void list() { - - Sensor sensor = new Sensor(); - - sensor.setId(1L); - - List ml = this.sensorItemMappingDao.findAllBySensorId(sensor); - - System.out.println(ml.size()); - - } - -} \ No newline at end of file +//package com.loafle.overflow.sensor.dao; +// +//import com.loafle.overflow.module.sensor.dao.JPASensorItemMappingDao; +//import com.loafle.overflow.module.sensor.dao.SensorItemMappingDao; +//import org.junit.Before; +//import org.junit.Ignore; +//import org.junit.Test; +// +//import java.util.List; +// +///** +// * Created by root on 17. 6. 9. +// */ +//public class JPASensorItemMappingDaoTest { +// +// private SensorItemMappingDao sensorItemMappingDao = null; +// +// @Before +// public void before() { +// this.sensorItemMappingDao = new JPASensorItemMappingDao(); +// } +// +// +// @Ignore +// @Test +// public void create() { +// +// SensorItemMapping mapping = new SensorItemMapping(); +// +// Sensor sensor = new Sensor(); +// +// sensor.setId(1L); +// +// SensorItem sensorItem = new SensorItem(); +// +// sensorItem.setId(1L); +// +// mapping.setSensor(sensor); +// +// mapping.setSensorItem(sensorItem); +// +// this.sensorItemMappingDao.create(mapping); +// +// } +// +// @Test +// public void list() { +// +// Sensor sensor = new Sensor(); +// +// sensor.setId(1L); +// +// List ml = this.sensorItemMappingDao.findAllBySensorId(sensor); +// +// System.out.println(ml.size()); +// +// } +// +//} \ No newline at end of file