spring change

This commit is contained in:
geek 2017-06-22 17:56:56 +09:00
parent 37b9da0f66
commit 25f8293205
51 changed files with 1436 additions and 1239 deletions

32
pom.xml
View File

@ -17,7 +17,9 @@
<properties>
<grpc.version>1.2.0</grpc.version>
<spring-test-version>4.3.9.RELEASE</spring-test-version>
<hibernate.version>4.3.10.Final</hibernate.version>
<spring-data-jpa>1.11.4.RELEASE</spring-data-jpa>
</properties>
<dependencies>
@ -43,11 +45,19 @@
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
<!-- Spring Dependency-->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.10.Final</version>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>${spring-data-jpa}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring-test-version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
@ -63,10 +73,18 @@
<version>1.9.13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
<dependency>
<groupId>com.loafle</groupId>
<artifactId>overflow_jpa_base_dao</artifactId>
<version>1.0.0-SNAPSHOT</version>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.10.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.10.Final</version>
</dependency>
<!--<dependency>-->

View File

@ -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;
}
}

View File

@ -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();
}
}

View File

@ -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<Agent> {
public List<Agent> findAgentListByMemberId(Member member);
@Repository
public interface AgentDAO extends JpaRepository<Agent, Long> {
// public List<Agent> findAgentListByMemberId(Member member);
}

View File

@ -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<Agent> implements AgentDAO {
public List<Agent> 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<Agent> 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<Agent> implements AgentDAO {
//
// public List<Agent> 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<Agent> list = new ArrayList<>();
// try {
// list = query.getResultList();
// }catch(Exception e) {
// e.printStackTrace();
// }finally {
// return list;
// }
// }
//
//}

View File

@ -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> {
Apikey findByApiKey(Apikey apikey);
@Repository
public interface ApiKeyDao extends JpaRepository<Apikey, Long> {
// Apikey findByApiKey(Apikey apikey);
}

View File

@ -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<Apikey> 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<Apikey> 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;
// }
//
// }
//}

View File

@ -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<Crawler> {
public List<Crawler> findAll();
@Repository
public interface CrawlerDAO extends JpaRepository<Crawler, Long> {
// public List<Crawler> findAll();
}

View File

@ -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<CrawlerInputItem> {
@Repository
public interface CrawlerInputItemDAO extends JpaRepository<CrawlerInputItem, Long> {
}

View File

@ -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<CrawlerInputItemMapping> {
public List<CrawlerInputItemMapping> findByCrawlerId(Crawler crawler);
@Repository
public interface CrawlerInputItemMappingDAO extends JpaRepository<CrawlerInputItemMapping, Long> {
// public List<CrawlerInputItemMapping> findByCrawlerId(Crawler crawler);
}

View File

@ -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<Crawler> implements CrawlerDAO {
@Override
public List<Crawler> findAll() {
Query query = getEntityManager().createNativeQuery("SELECT c.* FROM CRAWLER c ", Crawler.class);
List<Crawler> crs = null;
try {
crs = (List<Crawler>)query.getResultList();
} catch (Exception e) {
e.printStackTrace();
} finally {
return crs;
}
}
}
//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<Crawler> implements CrawlerDAO {
// @Override
// public List<Crawler> findAll() {
// Query query = getEntityManager().createNativeQuery("SELECT c.* FROM CRAWLER c ", Crawler.class);
//
// List<Crawler> crs = null;
//
// try {
// crs = (List<Crawler>)query.getResultList();
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// return crs;
// }
// }
//}

View File

@ -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<CrawlerInputItem> 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<CrawlerInputItem> implements CrawlerInputItemDAO {
//}

View File

@ -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<CrawlerInputItemMapping> implements CrawlerInputItemMappingDAO {
@Override
public List<CrawlerInputItemMapping> findByCrawlerId(Crawler crawler) {
Query query = getEntityManager().createNativeQuery("SELECT m.* FROM CRAWLER_INPUT_ITEM_MAPPING m WHERE m.crawler_id = :crawler_id", CrawlerInputItemMapping.class);
query.setParameter("crawler_id", crawler.getId());
List<CrawlerInputItemMapping> crs = null;
try {
crs = (List<CrawlerInputItemMapping>)query.getResultList();
} catch (Exception e) {
e.printStackTrace();
} finally {
return crs;
}
}
}
//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<CrawlerInputItemMapping> implements CrawlerInputItemMappingDAO {
// @Override
// public List<CrawlerInputItemMapping> findByCrawlerId(Crawler crawler) {
// Query query = getEntityManager().createNativeQuery("SELECT m.* FROM CRAWLER_INPUT_ITEM_MAPPING m WHERE m.crawler_id = :crawler_id", CrawlerInputItemMapping.class);
// query.setParameter("crawler_id", crawler.getId());
//
// List<CrawlerInputItemMapping> crs = null;
//
// try {
// crs = (List<CrawlerInputItemMapping>)query.getResultList();
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// return crs;
// }
// }
//}

View File

@ -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<Host> {
@Repository
public interface HostDao extends JpaRepository<Host, Long> {
}

View File

@ -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<Host> 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<Host> implements HostDao {
//}

View File

@ -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<Port> 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<Port> implements PortDao {
//}

View File

@ -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<Service> 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<Service> implements ServiceDao {
//}

View File

@ -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<Zone> 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<Zone> implements ZoneDao {
//}

View File

@ -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<Port> {
@Repository
public interface PortDao extends JpaRepository<Port, Long> {
}

View File

@ -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<Service> {
@Repository
public interface ServiceDao extends JpaRepository<Service, Long> {
}

View File

@ -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<Zone> {
@Repository
public interface ZoneDao extends JpaRepository<Zone, Long> {
}

View File

@ -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<EmailAuth> {
public EmailAuth findByAuthToken(EmailAuth emailAuth);
@Repository
public interface EmailAuthDAO extends JpaRepository<EmailAuth, Long> {
// public EmailAuth findByAuthToken(EmailAuth emailAuth);
public List<EmailAuth> findByMemberId(EmailAuth emailAuth);
// public List<EmailAuth> findByMemberId(EmailAuth emailAuth);
// public EmailAuth updateEmailAuth(EmailAuth emailAuth);
}

View File

@ -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<EmailAuth> 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<EmailAuth> 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<EmailAuth> auths = null;
try {
auths = (List<EmailAuth>)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<EmailAuth> 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());
// auth = (EmailAuth)query.getSingleResult();
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// return auth;
// }
// }
//
// EmailAuth result = this.getEntityManager().merge(emailAuth);
// tx.commit();
// return result;
// }catch (Exception e) {
// tx.rollback();
// return null;
// @Override
// public List<EmailAuth> 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<EmailAuth> auths = null;
//
// try {
// auths = (List<EmailAuth>)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;
//// }
//// }
//}

View File

@ -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<Member> 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<Member> 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;
// }
// }
//}

View File

@ -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<Member> {
public Member findByEmail(Member member);
@Repository
public interface MemberDAO extends JpaRepository<Member, Long> {
// public Member findByEmail(Member member);
}

View File

@ -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<NoAuthAgent> 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<NoAuthAgent> 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<NoAuthAgent> authAgentList = null;
try {
authAgentList = (List<NoAuthAgent>)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<NoAuthAgent> 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<NoAuthAgent> 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<NoAuthAgent> authAgentList = null;
// try {
// authAgentList = (List<NoAuthAgent>)query.getResultList();
// }catch(Exception e) {
// e.printStackTrace();
// }finally {
// return authAgentList;
// }
//
// }
//}

View File

@ -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> {
NoAuthAgent findByTempKey(NoAuthAgent noAuthAgent);
List<NoAuthAgent> findAllByNoAuth(NoAuthAgent noAuthAgent);
@Repository
public interface NoAuthAgentDao extends JpaRepository<NoAuthAgent, Long> {
// NoAuthAgent findByTempKey(NoAuthAgent noAuthAgent);
// List<NoAuthAgent> findAllByNoAuth(NoAuthAgent noAuthAgent);
}

View File

@ -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<Sensor> implements SensorDao {
public List<Sensor> 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<Sensor> sensors = null;
try {
sensors = (List<Sensor>)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<Sensor> implements SensorDao {
//
// public List<Sensor> 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<Sensor> sensors = null;
// try {
// sensors = (List<Sensor>)query.getResultList();
// }catch(Exception e) {
// e.printStackTrace();
// }finally {
// return sensors;
// }
// }
//}

View File

@ -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<SensorItemCategory> 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<SensorItemCategory> implements SensorItemCategoryDao {
//}

View File

@ -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<SensorItem> implements SensorItemDao {
public List<SensorItem> 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<SensorItem> sensorItems = null;
try {
sensorItems = (List<SensorItem>)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<SensorItem> implements SensorItemDao {
//
// public List<SensorItem> 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<SensorItem> sensorItems = null;
// try {
// sensorItems = (List<SensorItem>)query.getResultList();
// }catch(Exception e) {
// e.printStackTrace();
// }finally {
// return sensorItems;
// }
//
// }
//}

View File

@ -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<SensorItemMapping> implements SensorItemMappingDao {
public List<SensorItemMapping> 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<SensorItemMapping> sensorItemMappings = null;
try {
sensorItemMappings = (List<SensorItemMapping>)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<SensorItemMapping> implements SensorItemMappingDao {
//
// public List<SensorItemMapping> 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<SensorItemMapping> sensorItemMappings = null;
// try {
// sensorItemMappings = (List<SensorItemMapping>)query.getResultList();
// }catch(Exception e) {
// e.printStackTrace();
// }finally {
// return sensorItemMappings;
// }
//
// }
//}

View File

@ -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<Sensor> {
@Repository
public interface SensorDao extends JpaRepository<Sensor, Long> {
List<Sensor> findAllByTargetId(Target target);
// List<Sensor> findAllByTargetId(Target target);
}

View File

@ -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<SensorItemCategory> {
}
//@Repository
//public interface SensorItemCategoryDao extends JpaRepository<SensorItemCategory, Long> {
//}

View File

@ -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<SensorItem>{
@Repository
public interface SensorItemDao extends JpaRepository<SensorItem, Long> {
List<SensorItem> findAllByCrawlerId(Crawler crawler);
// List<SensorItem> findAllByCrawlerId(Crawler crawler);
}

View File

@ -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<SensorItemMapping> {
List<SensorItemMapping> findAllBySensorId(Sensor sensor);
}
//@Repository
//public interface SensorItemMappingDao extends JpaRepository<SensorItemMapping> {
//
//// List<SensorItemMapping> findAllBySensorId(Sensor sensor);
//
//}

View File

@ -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,30 +36,64 @@ public class DBProxy {
private static final Logger logger = Logger.getLogger(DBProxy.class.getName());
private io.grpc.Server server;
private static Map<String, JPABaseDAO> daoMap = null;
private static Map<String, JpaRepository> 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 {
@ -97,7 +125,7 @@ public class DBProxy {
io.grpc.stub.StreamObserver<com.loafle.overflow.db.api.DBOutput> responseObserver) {
String targetDAO = request.getTargetDao();
JPABaseDAO dao = daoMap.get(targetDAO);
JpaRepository dao = daoMap.get(targetDAO);
if(dao != null) {
try {
@ -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<String, String> params = request.getParamsMap();

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="overflow">
<class>com.loafle.overflow.member.model.Member</class>
<class>com.loafle.overflow.noauthagent.model.NoAuthAgent</class>
<class>com.loafle.overflow.apikey.model.Apikey</class>
<class>com.loafle.overflow.agent.model.Agent</class>
<class>com.loafle.overflow.email.model.EmailAuth</class>
<class>com.loafle.overflow.target.model.Target</class>
<class>com.loafle.overflow.crawler.model.Crawler</class>
<class>com.loafle.overflow.crawler.model.CrawlerInputItem</class>
<class>com.loafle.overflow.crawler.model.CrawlerInputItemMapping</class>
<class>com.loafle.overflow.sensor.model.Sensor</class>
<class>com.loafle.overflow.sensor.model.SensorItem</class>
<class>com.loafle.overflow.sensor.model.SensorItemMapping</class>
<class>com.loafle.overflow.sensor.model.SensorItemCategory</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://192.168.1.106:5432/postgres" />
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="javax.persistence.jdbc.user" value="vertx" />
<property name="javax.persistence.jdbc.password" value="qwe123" />
<!--<property name="hibernate.hbm2ddl.auto" value="create"/>-->
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
</persistence>

View File

@ -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

View File

@ -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());
}
}
//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());
// }
//
//}

View File

@ -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);
}
}
//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);
// }
//
//}

View File

@ -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<Crawler> crawlers = new ArrayList<Crawler>();
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<Crawler> ls = this.jpaCrawlerDAO.findAll();
System.out.println(ls.size());
}
// TODO Crawler Update Test
// TODO Crawler Delete Test
}
//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<Crawler> crawlers = new ArrayList<Crawler>();
//
// 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<Crawler> ls = this.jpaCrawlerDAO.findAll();
// System.out.println(ls.size());
// }
// // TODO Crawler Update Test
//
// // TODO Crawler Delete Test
//}

View File

@ -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<CrawlerInputItem> cris = new ArrayList<CrawlerInputItem>();
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);
}
}
//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<CrawlerInputItem> cris = new ArrayList<CrawlerInputItem>();
//
// 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);
// }
//}

View File

@ -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<CrawlerInputItemMapping> crs = new ArrayList<CrawlerInputItemMapping>();
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<CrawlerInputItemMapping> ls = this.mappingDAO.findByCrawlerId(new Crawler((long)5));
System.out.println(ls.size());
}
}
//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<CrawlerInputItemMapping> crs = new ArrayList<CrawlerInputItemMapping>();
// 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<CrawlerInputItemMapping> ls = this.mappingDAO.findByCrawlerId(new Crawler((long)5));
// System.out.println(ls.size());
// }
//
//}

View File

@ -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<EmailAuth> ems = this.emailAuthDAO.findByMemberId(auth);
System.out.println(ems.get(0).getMember().getEmail());
Assert.assertEquals((long)1, (long)ems.size());
}
}
// 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<EmailAuth> ems = this.emailAuthDAO.findByMemberId(auth);
//
// System.out.println(ems.get(0).getMember().getEmail());
// Assert.assertEquals((long)1, (long)ems.size());
// }
//}

View File

@ -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);
}
}
//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);
// }
//
//}

View File

@ -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);
}
}

View File

@ -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);
}
}
//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);
// }
//
//
//
//
//}

View File

@ -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()
}
}
//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()
// }
//
//}

View File

@ -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);
}
}
//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);
//
// }
//
//}

View File

@ -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<SensorItem> is = this.sensorItemDao.findAllByCrawlerId(crawler);
System.out.println(is.size());
}
}
//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<SensorItem> is = this.sensorItemDao.findAllByCrawlerId(crawler);
//
//
// System.out.println(is.size());
//
// }
//
//}

View File

@ -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<SensorItemMapping> ml = this.sensorItemMappingDao.findAllBySensorId(sensor);
System.out.println(ml.size());
}
}
//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<SensorItemMapping> ml = this.sensorItemMappingDao.findAllBySensorId(sensor);
//
// System.out.println(ml.size());
//
// }
//
//}