From 0fe21027fbd87f95be8237c01925e055e09b3b35 Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 22 Jun 2017 18:34:27 +0900 Subject: [PATCH] test --- .../overflow/models/TblDomainMember.java | 54 ------------ .../overflow/module/agent/model/Agent.java | 82 ------------------- .../domain/Domain.java} | 18 ++-- .../overflow/module/domain/DomainMember.java | 35 ++++++++ .../module/{agent => probe}/dao/AgentDAO.java | 5 +- .../{agent => probe}/dao/JPAAgentDAO.java | 2 +- .../probe/model/Probe.java} | 37 +++------ .../module/target/dao/JPATargetDao.java | 29 +++++++ .../overflow/module/target/dao/TargetDao.java | 13 +++ .../overflow/module/target/model/Target.java | 61 ++++++++++++++ 10 files changed, 158 insertions(+), 178 deletions(-) delete mode 100644 src/main/java/com/loafle/overflow/models/TblDomainMember.java delete mode 100644 src/main/java/com/loafle/overflow/module/agent/model/Agent.java rename src/main/java/com/loafle/overflow/{models/TblDomain.java => module/domain/Domain.java} (72%) create mode 100644 src/main/java/com/loafle/overflow/module/domain/DomainMember.java rename src/main/java/com/loafle/overflow/module/{agent => probe}/dao/AgentDAO.java (70%) rename src/main/java/com/loafle/overflow/module/{agent => probe}/dao/JPAAgentDAO.java (94%) rename src/main/java/com/loafle/overflow/{models/TblProbe.java => module/probe/model/Probe.java} (74%) create mode 100644 src/main/java/com/loafle/overflow/module/target/dao/JPATargetDao.java create mode 100644 src/main/java/com/loafle/overflow/module/target/dao/TargetDao.java create mode 100644 src/main/java/com/loafle/overflow/module/target/model/Target.java diff --git a/src/main/java/com/loafle/overflow/models/TblDomainMember.java b/src/main/java/com/loafle/overflow/models/TblDomainMember.java deleted file mode 100644 index 3649de5..0000000 --- a/src/main/java/com/loafle/overflow/models/TblDomainMember.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.loafle.overflow.models; - -import javax.persistence.*; -import java.sql.Timestamp; - -/** - * Created by root on 17. 6. 22. - */ -@Entity -@Table(name = "TBL_DOMAIN_MEMBER", schema = "public", catalog = "postgres") -public class TblDomainMember { - private long id; - private Timestamp createDate; - - @Id - @Column(name = "ID", nullable = false) - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - @Basic - @Column(name = "CREATE_DATE", nullable = false) - public Timestamp getCreateDate() { - return createDate; - } - - public void setCreateDate(Timestamp createDate) { - this.createDate = createDate; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - TblDomainMember that = (TblDomainMember) o; - - if (id != that.id) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - return result; - } -} diff --git a/src/main/java/com/loafle/overflow/module/agent/model/Agent.java b/src/main/java/com/loafle/overflow/module/agent/model/Agent.java deleted file mode 100644 index 04f30da..0000000 --- a/src/main/java/com/loafle/overflow/module/agent/model/Agent.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.loafle.overflow.module.agent.model; - -import com.loafle.overflow.module.member.model.Member; - -import javax.persistence.*; -import java.io.Serializable; - -/** - * Created by insanity on 17. 5. 29. - */ - -@Entity(name="AGENT") -public class Agent implements Serializable { - @Id - @GeneratedValue(strategy= GenerationType.IDENTITY) - private Long id; - - @ManyToOne - @JoinColumn(name = "MEMBER_ID", nullable=false) - private Member member; - - @Column(name="AUTHORIZED_DATE") - private Long authorizedDate; - - @Column(name="DESCRIPTION") - private String description; - - @Column(name="LAST_POLLING_DATE") - private Long lastPollingDate; - - @Column(name="STATUS") - private String status; - - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Member getMember() { - return member; - } - - public void setMember(Member member) { - this.member = member; - } - - public Long getAuthorizedDate() { - return authorizedDate; - } - - public void setAuthorizedDate(Long authorizedDate) { - this.authorizedDate = authorizedDate; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Long getLastPollingDate() { - return lastPollingDate; - } - - public void setLastPollingDate(Long lastPollingDate) { - this.lastPollingDate = lastPollingDate; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } -} diff --git a/src/main/java/com/loafle/overflow/models/TblDomain.java b/src/main/java/com/loafle/overflow/module/domain/Domain.java similarity index 72% rename from src/main/java/com/loafle/overflow/models/TblDomain.java rename to src/main/java/com/loafle/overflow/module/domain/Domain.java index 01e9646..f43be5e 100644 --- a/src/main/java/com/loafle/overflow/models/TblDomain.java +++ b/src/main/java/com/loafle/overflow/module/domain/Domain.java @@ -1,4 +1,4 @@ -package com.loafle.overflow.models; +package com.loafle.overflow.module.domain; import javax.persistence.*; import java.sql.Timestamp; @@ -8,13 +8,13 @@ import java.sql.Timestamp; */ @Entity @Table(name = "TBL_DOMAIN", schema = "public", catalog = "postgres") -public class TblDomain { +public class Domain { private long id; private String name; private Timestamp createDate; @Id - @Column(name = "ID", nullable = false) + @GeneratedValue(strategy= GenerationType.IDENTITY) public long getId() { return id; } @@ -34,7 +34,7 @@ public class TblDomain { } @Basic - @Column(name = "CREATE_DATE", nullable = true) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) public Timestamp getCreateDate() { return createDate; } @@ -48,7 +48,7 @@ public class TblDomain { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - TblDomain tblDomain = (TblDomain) o; + Domain tblDomain = (Domain) o; if (id != tblDomain.id) return false; if (name != null ? !name.equals(tblDomain.name) : tblDomain.name != null) return false; @@ -56,12 +56,4 @@ public class TblDomain { return true; } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - return result; - } } diff --git a/src/main/java/com/loafle/overflow/module/domain/DomainMember.java b/src/main/java/com/loafle/overflow/module/domain/DomainMember.java new file mode 100644 index 0000000..3d289f0 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/domain/DomainMember.java @@ -0,0 +1,35 @@ +package com.loafle.overflow.module.domain; + +import javax.persistence.*; +import java.sql.Timestamp; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "TBL_DOMAIN_MEMBER", schema = "public", catalog = "postgres") +public class DomainMember { + private long id; + private Timestamp createDate; + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Basic + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) + public Timestamp getCreateDate() { + return createDate; + } + + public void setCreateDate(Timestamp createDate) { + this.createDate = createDate; + } + +} diff --git a/src/main/java/com/loafle/overflow/module/agent/dao/AgentDAO.java b/src/main/java/com/loafle/overflow/module/probe/dao/AgentDAO.java similarity index 70% rename from src/main/java/com/loafle/overflow/module/agent/dao/AgentDAO.java rename to src/main/java/com/loafle/overflow/module/probe/dao/AgentDAO.java index db0f143..63201ba 100644 --- a/src/main/java/com/loafle/overflow/module/agent/dao/AgentDAO.java +++ b/src/main/java/com/loafle/overflow/module/probe/dao/AgentDAO.java @@ -1,11 +1,8 @@ -package com.loafle.overflow.module.agent.dao; +package com.loafle.overflow.module.probe.dao; -import com.loafle.overflow.module.agent.model.Agent; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import java.util.List; - /** * Created by insanity on 17. 5. 29. */ diff --git a/src/main/java/com/loafle/overflow/module/agent/dao/JPAAgentDAO.java b/src/main/java/com/loafle/overflow/module/probe/dao/JPAAgentDAO.java similarity index 94% rename from src/main/java/com/loafle/overflow/module/agent/dao/JPAAgentDAO.java rename to src/main/java/com/loafle/overflow/module/probe/dao/JPAAgentDAO.java index bce8923..6093333 100644 --- a/src/main/java/com/loafle/overflow/module/agent/dao/JPAAgentDAO.java +++ b/src/main/java/com/loafle/overflow/module/probe/dao/JPAAgentDAO.java @@ -1,6 +1,6 @@ //package com.loafle.overflow.module.agent.dao; // -//import com.loafle.overflow.module.agent.model.Agent; +//import com.loafle.overflow.module.probe.model.Agent; //import com.loafle.overflow.commons.dao.JPABaseDAO; //import com.loafle.overflow.module.member.model.Member; // diff --git a/src/main/java/com/loafle/overflow/models/TblProbe.java b/src/main/java/com/loafle/overflow/module/probe/model/Probe.java similarity index 74% rename from src/main/java/com/loafle/overflow/models/TblProbe.java rename to src/main/java/com/loafle/overflow/module/probe/model/Probe.java index a1478ea..914c7f3 100644 --- a/src/main/java/com/loafle/overflow/models/TblProbe.java +++ b/src/main/java/com/loafle/overflow/module/probe/model/Probe.java @@ -1,4 +1,6 @@ -package com.loafle.overflow.models; +package com.loafle.overflow.module.probe.model; + +import com.loafle.overflow.module.domain.Domain; import javax.persistence.*; import java.sql.Timestamp; @@ -8,19 +10,19 @@ import java.sql.Timestamp; */ @Entity @Table(name = "TBL_PROBE", schema = "public", catalog = "postgres") -public class TblProbe { +public class Probe { private long id; private String status; private String description; private Timestamp createDate; private Timestamp lastPollingDate; private Timestamp nextPollingDate; - private long domainId; + private Domain domain; private String probeKey; private String encryptionKey; @Id - @Column(name = "ID", nullable = false) + @GeneratedValue(strategy= GenerationType.IDENTITY) public long getId() { return id; } @@ -60,7 +62,7 @@ public class TblProbe { } @Basic - @Column(name = "LAST_POLLING_DATE", nullable = true) + @Column(name = "LAST_POLLING_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) public Timestamp getLastPollingDate() { return lastPollingDate; } @@ -81,12 +83,12 @@ public class TblProbe { @Basic @Column(name = "DOMAIN_ID", nullable = false) - public long getDomainId() { - return domainId; + public Domain getDomain() { + return domain; } - public void setDomainId(long domainId) { - this.domainId = domainId; + public void setDomainId(Domain domainId) { + this.domain = domain; } @Basic @@ -114,10 +116,10 @@ public class TblProbe { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - TblProbe tblProbe = (TblProbe) o; + Probe tblProbe = (Probe) o; if (id != tblProbe.id) return false; - if (domainId != tblProbe.domainId) return false; + if (domain != tblProbe.domain) return false; if (status != null ? !status.equals(tblProbe.status) : tblProbe.status != null) return false; if (description != null ? !description.equals(tblProbe.description) : tblProbe.description != null) return false; @@ -133,17 +135,4 @@ public class TblProbe { return true; } - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (status != null ? status.hashCode() : 0); - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - result = 31 * result + (lastPollingDate != null ? lastPollingDate.hashCode() : 0); - result = 31 * result + (nextPollingDate != null ? nextPollingDate.hashCode() : 0); - result = 31 * result + (int) (domainId ^ (domainId >>> 32)); - result = 31 * result + (probeKey != null ? probeKey.hashCode() : 0); - result = 31 * result + (encryptionKey != null ? encryptionKey.hashCode() : 0); - return result; - } } diff --git a/src/main/java/com/loafle/overflow/module/target/dao/JPATargetDao.java b/src/main/java/com/loafle/overflow/module/target/dao/JPATargetDao.java new file mode 100644 index 0000000..8168058 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/target/dao/JPATargetDao.java @@ -0,0 +1,29 @@ +package com.loafle.overflow.module.target.dao; + +import com.loafle.overflow.commons.dao.JPABaseDAO; + +import javax.persistence.Query; +import java.util.List; + +/** + * Created by root on 17. 6. 5. + */ +public class JPATargetDao extends JPABaseDAO implements TargetDao { + + public List findAll(Target target) { + + Query query = getEntityManager().createNativeQuery("SELECT tg.* FROM Target tg WHERE tg.MEMBER_ID = :memberId", Target.class); + query.setParameter("memberId", target.getMember().getId()); + + List targets = null; + try { + targets = (List)query.getResultList(); + }catch(Exception e) { + e.printStackTrace(); + }finally { + return targets; + } + + + } +} diff --git a/src/main/java/com/loafle/overflow/module/target/dao/TargetDao.java b/src/main/java/com/loafle/overflow/module/target/dao/TargetDao.java new file mode 100644 index 0000000..43ec2ea --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/target/dao/TargetDao.java @@ -0,0 +1,13 @@ +package com.loafle.overflow.module.target.dao; + +import com.loafle.overflow.commons.dao.BaseDAO; + +import java.util.List; + +/** + * Created by root on 17. 6. 5. + */ +public interface TargetDao extends BaseDAO { + + List findAll(Target target); +} diff --git a/src/main/java/com/loafle/overflow/module/target/model/Target.java b/src/main/java/com/loafle/overflow/module/target/model/Target.java new file mode 100644 index 0000000..362baed --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/target/model/Target.java @@ -0,0 +1,61 @@ +package com.loafle.overflow.module.target.model; + +import com.loafle.overflow.module.infra.Infra; +import com.loafle.overflow.module.probe.model.Probe; + +import javax.persistence.*; +import java.sql.Timestamp; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "TBL_TARGET", schema = "public", catalog = "postgres") +public class Target { + + private long id; + private Timestamp createDate; + private Probe probe; + private Infra infra; + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Basic + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) + public Timestamp getCreateDate() { + return createDate; + } + + public void setCreateDate(Timestamp createDate) { + this.createDate = createDate; + } + + @Basic + @Column(name = "PROBE_ID", nullable = false) + public Probe getProbe() { + return probe; + } + + public void setProbe(Probe probe) { + this.probe = probe; + } + + @ManyToOne + @JoinColumn(name = "INFRA_ID", nullable = false) + public Infra getInfra() { + return infra; + } + + public void setInfra(Infra infra) { + this.infra = infra; + } + +}