model's arranging
This commit is contained in:
parent
29e337c9ed
commit
e266f5dc8a
|
@ -62,5 +62,4 @@ public class SensorConfigGenerator {
|
|||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.loafle.overflow.module.infra.model.Infra;
|
|||
import com.loafle.overflow.module.probe.exception.ProbeNotFoundException;
|
||||
import com.loafle.overflow.module.probe.model.Probe;
|
||||
import com.loafle.overflow.module.probe.service.ProbeService;
|
||||
import com.loafle.overflow.module.sensor.dao.SensorDAO;
|
||||
import com.loafle.overflow.module.target.model.Target;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
@ -25,6 +26,9 @@ public class InfraService {
|
|||
@Autowired
|
||||
InfraDAO infraDAO;
|
||||
|
||||
@Autowired
|
||||
SensorDAO sensorDAO;
|
||||
|
||||
@Autowired
|
||||
private ProbeService probeService;
|
||||
|
||||
|
@ -33,7 +37,9 @@ public class InfraService {
|
|||
}
|
||||
|
||||
public Infra read(long id) {
|
||||
return this.infraDAO.findOne(id);
|
||||
Infra infra = this.infraDAO.findOne(id);
|
||||
infra.getTarget().setSensors(this.sensorDAO.findAllByTarget(infra.getTarget()));
|
||||
return infra;
|
||||
}
|
||||
|
||||
public Page<Infra> readAllByProbe(Probe probe, PageParams pageParams) {
|
||||
|
@ -47,12 +53,13 @@ public class InfraService {
|
|||
throw new ProbeNotFoundException();
|
||||
}
|
||||
|
||||
return this.infraDAO.findAllByProbeList(probeList, PageUtil.getPageRequest(pageParams));
|
||||
Page<Infra> infraList = this.infraDAO.findAllByProbeList(probeList, PageUtil.getPageRequest(pageParams));
|
||||
for (Infra infra: infraList) {
|
||||
infra.getTarget().setSensors(this.sensorDAO.findAllByTarget(infra.getTarget()));
|
||||
}
|
||||
return infraList;
|
||||
}
|
||||
|
||||
// public List<Infra> readAllByProbeList(List<Probe> probeList) {
|
||||
// return this.infraDAO.findAllByProbeList(probeList);
|
||||
// }
|
||||
|
||||
public List<Target> readAllTargetByDomain(Domain domain) {
|
||||
|
||||
|
@ -74,5 +81,4 @@ public class InfraService {
|
|||
return this.infraDAO.findByTarget(target);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.loafle.overflow.module.noauthprobe.service;
|
||||
|
||||
import com.loafle.overflow.commons.service.MessagePublisher;
|
||||
import com.loafle.overflow.module.apikey.model.ApiKey;
|
||||
import com.loafle.overflow.module.apikey.service.ApiKeyService;
|
||||
import com.loafle.overflow.module.domain.model.Domain;
|
||||
|
@ -10,7 +11,6 @@ import com.loafle.overflow.module.noauthprobe.dao.NoAuthProbeDAO;
|
|||
import com.loafle.overflow.module.noauthprobe.model.NoAuthProbe;
|
||||
import com.loafle.overflow.module.probe.model.Probe;
|
||||
import com.loafle.overflow.module.probe.service.ProbeService;
|
||||
import com.loafle.overflow.commons.service.MessagePublisher;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.codehaus.jackson.type.TypeReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -81,8 +81,6 @@ public class NoAuthProbeService {
|
|||
probe.setDomain(new Domain(1));
|
||||
probe.setAuthorizeMember(new Member(1));
|
||||
probe.setStatus(new MetaProbeStatus((short)1));
|
||||
probe.setTargetCount(0);
|
||||
probe.setSensorCount(0);
|
||||
|
||||
Map<String, Object> objMap = this.objectMapper.readValue(noAuthProbe.getDescription(), new TypeReference<HashMap<String,Object>>() {});
|
||||
Map<String, String> hostMap = (Map<String, String>)objMap.get("host");
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.loafle.overflow.module.probe.model;
|
||||
|
||||
import com.loafle.overflow.module.domain.model.Domain;
|
||||
import com.loafle.overflow.module.infra.model.Infra;
|
||||
import com.loafle.overflow.module.member.model.Member;
|
||||
import com.loafle.overflow.module.meta.model.MetaProbeStatus;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
|
@ -21,13 +23,16 @@ public class Probe {
|
|||
private Domain domain;
|
||||
private String probeKey;
|
||||
private String encryptionKey;
|
||||
private int targetCount;
|
||||
private int sensorCount;
|
||||
private String displayName;
|
||||
private String cidr;
|
||||
private Date authorizeDate;
|
||||
private Member authorizeMember;
|
||||
|
||||
private List<Infra> targets;
|
||||
|
||||
// private InfraHost host;
|
||||
// private int targetCount;
|
||||
// private int sensorCount;
|
||||
|
||||
public Probe() {
|
||||
|
||||
|
@ -107,23 +112,33 @@ public class Probe {
|
|||
this.encryptionKey = encryptionKey;
|
||||
}
|
||||
|
||||
@Column(name = "TARGET_COUNT", nullable = false)
|
||||
public int getTargetCount() {
|
||||
return targetCount;
|
||||
|
||||
@Transient
|
||||
public List<Infra> getTargets() {
|
||||
return targets;
|
||||
}
|
||||
|
||||
public void setTargetCount(int targetCount) {
|
||||
this.targetCount = targetCount;
|
||||
public void setTargets(List<Infra> targets) {
|
||||
this.targets = targets;
|
||||
}
|
||||
|
||||
@Column(name = "SENSOR_COUNT", nullable = false)
|
||||
public int getSensorCount() {
|
||||
return sensorCount;
|
||||
}
|
||||
|
||||
public void setSensorCount(int sensorCount) {
|
||||
this.sensorCount = sensorCount;
|
||||
}
|
||||
// @Column(name = "TARGET_COUNT", nullable = false)
|
||||
// public int getTargetCount() {
|
||||
// return targetCount;
|
||||
// }
|
||||
//
|
||||
// public void setTargetCount(int targetCount) {
|
||||
// this.targetCount = targetCount;
|
||||
// }
|
||||
//
|
||||
// @Column(name = "SENSOR_COUNT", nullable = false)
|
||||
// public int getSensorCount() {
|
||||
// return sensorCount;
|
||||
// }
|
||||
//
|
||||
// public void setSensorCount(int sensorCount) {
|
||||
// this.sensorCount = sensorCount;
|
||||
// }
|
||||
|
||||
@Column(name = "DISPLAY_NAME")
|
||||
public String getDisplayName() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.loafle.overflow.module.probe.service;
|
||||
|
||||
import com.loafle.overflow.module.domain.model.Domain;
|
||||
import com.loafle.overflow.module.infra.dao.InfraDAO;
|
||||
import com.loafle.overflow.module.probe.dao.ProbeDAO;
|
||||
import com.loafle.overflow.module.probe.model.Probe;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -16,6 +17,8 @@ public class ProbeService {
|
|||
|
||||
@Autowired
|
||||
private ProbeDAO probeDAO;
|
||||
@Autowired
|
||||
private InfraDAO infraDAO;
|
||||
|
||||
public Probe regist(Probe probe) {
|
||||
return this.probeDAO.save(probe);
|
||||
|
@ -26,11 +29,17 @@ public class ProbeService {
|
|||
}
|
||||
|
||||
public List<Probe> readAllByDomain(Domain domain) {
|
||||
return this.probeDAO.findAllByDomainOrderByIdDesc(domain);
|
||||
List<Probe> probes = this.probeDAO.findAllByDomainOrderByIdDesc(domain);
|
||||
for(Probe probe : probes) {
|
||||
probe.setTargets(this.infraDAO.findAllByProbe(probe));
|
||||
}
|
||||
return probes;
|
||||
}
|
||||
|
||||
public Probe read(long id) {
|
||||
return this.probeDAO.findOne(id);
|
||||
Probe probe = this.probeDAO.findOne(id);
|
||||
probe.setTargets(this.infraDAO.findAllByProbe(probe));
|
||||
return probe;
|
||||
}
|
||||
|
||||
public Probe readByProbeKey(String probeKey) {
|
||||
|
|
|
@ -20,6 +20,7 @@ public interface SensorDAO extends JpaRepository<Sensor, Long> {
|
|||
|
||||
|
||||
Page<Sensor> findAllByTarget(Target target, Pageable pageable);
|
||||
List<Sensor> findAllByTarget(Target target);
|
||||
|
||||
@Query("SELECT s from Sensor s WHERE s.target in (:targetList)")
|
||||
Page<Sensor> findAllByTargetList(@Param("targetList") List<Target> targetList, Pageable pageable);
|
||||
|
|
|
@ -22,6 +22,7 @@ public class Sensor {
|
|||
private Target target;
|
||||
private MetaCrawler crawler;
|
||||
private String crawlerInputItems;
|
||||
private short itemCount = 0;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
|
@ -92,4 +93,12 @@ public class Sensor {
|
|||
this.crawlerInputItems = crawlerInputItems;
|
||||
}
|
||||
|
||||
@Column(name = "ITEM_COUNT", nullable = false)
|
||||
public short getItemCount() {
|
||||
return itemCount;
|
||||
}
|
||||
|
||||
public void setItemCount(short itemCount) {
|
||||
this.itemCount = itemCount;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.loafle.overflow.module.target.model;
|
||||
|
||||
import com.loafle.overflow.module.sensor.model.Sensor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
|
@ -15,6 +18,8 @@ public class Target {
|
|||
private String displayName;
|
||||
private String description;
|
||||
|
||||
private List<Sensor> sensors;
|
||||
|
||||
/*
|
||||
private long id;
|
||||
private Date createDate;
|
||||
|
@ -82,4 +87,12 @@ public class Target {
|
|||
// this.infra = infra;
|
||||
// }
|
||||
|
||||
@Transient
|
||||
public List<Sensor> getSensors() {
|
||||
return sensors;
|
||||
}
|
||||
|
||||
public void setSensors(List<Sensor> sensors) {
|
||||
this.sensors = sensors;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1309,11 +1309,11 @@ INSERT INTO public.domain_member (create_date,domain_id,member_id) VALUES (
|
|||
INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES (
|
||||
'52abd6fd57e511e7ac52080027658d13','2017-06-26 13:02:28.347',1);
|
||||
|
||||
INSERT INTO public.probe (authorize_date,cidr,create_date,description,display_name,encryption_key,probe_key,sensor_count,target_count,authorize_member_id,domain_id,status) VALUES (
|
||||
'2017-08-21 14:48:31.563','192.168.1.0/24','2017-08-21 14:48:31.563','snoop probe','test probe 111111','8c51fa9c5bcc11e7980a080027658d13','899fdd145bcc11e7b611080027658d13',0,0,1,1,1);
|
||||
INSERT INTO public.probe (authorize_date,cidr,create_date,description,display_name,encryption_key,probe_key,authorize_member_id,domain_id,status) VALUES (
|
||||
'2017-08-21 14:48:31.563','192.168.1.0/24','2017-08-21 14:48:31.563','snoop probe','test probe 111111','8c51fa9c5bcc11e7980a080027658d13','899fdd145bcc11e7b611080027658d13',1,1,1);
|
||||
|
||||
INSERT INTO public.probe (authorize_date,cidr,create_date,description,display_name,encryption_key,probe_key,sensor_count,target_count,authorize_member_id,domain_id,status) VALUES (
|
||||
'2017-08-21 15:00:09.691','192.168.2.0/24','2017-08-21 15:00:09.691','insanity probe','test probe 22222','f1f72c8d2a814580bb7c4615ec43a6a8','95d8bcdc739741dca74c4a0e489e0774',0,0,1,1,1);
|
||||
INSERT INTO public.probe (authorize_date,cidr,create_date,description,display_name,encryption_key,probe_key,authorize_member_id,domain_id,status) VALUES (
|
||||
'2017-08-21 15:00:09.691','192.168.2.0/24','2017-08-21 15:00:09.691','insanity probe','test probe 22222','f1f72c8d2a814580bb7c4615ec43a6a8','95d8bcdc739741dca74c4a0e489e0774',1,1,1);
|
||||
|
||||
INSERT INTO public.target (create_date,description,display_name) VALUES (
|
||||
'2017-07-27 20:18:09.555','Machine Target','ghost target');
|
||||
|
@ -1369,16 +1369,16 @@ INSERT INTO public.infra_os_daemon ("name",id,os_id) VALUES (
|
|||
insert into public.PROBE_INFRAHOST (HOST_ID, PROBE_ID) values (3, 1);
|
||||
|
||||
|
||||
INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id) VALUES (
|
||||
NULL,'2017-06-26 20:19:07.009','My sensor 11111',1,1,1);
|
||||
INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id) VALUES (
|
||||
NULL,'2017-06-26 20:19:07.074','My sensor 22222',1,2,1);
|
||||
INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id) VALUES (
|
||||
NULL,'2017-08-28 16:17:05.506','OS_SERVICE-MYSQL_CRAWLER',11,1,4);
|
||||
INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id) VALUES (
|
||||
NULL,'2017-09-05 12:26:02.738','HOST-WMI_CRAWLER',23,1,3);
|
||||
INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id) VALUES (
|
||||
NULL,'2017-09-11 12:26:02.738','SERVICE-JMX_CRAWLER',17,1,4);
|
||||
INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id,item_count) VALUES (
|
||||
NULL,'2017-06-26 20:19:07.009','My sensor 11111',1,1,1,3);
|
||||
INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id,item_count) VALUES (
|
||||
NULL,'2017-06-26 20:19:07.074','My sensor 22222',1,2,1,1);
|
||||
INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id,item_count) VALUES (
|
||||
NULL,'2017-08-28 16:17:05.506','OS_SERVICE-MYSQL_CRAWLER',11,1,4,2);
|
||||
INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id,item_count) VALUES (
|
||||
NULL,'2017-09-05 12:26:02.738','HOST-WMI_CRAWLER',23,1,3,1);
|
||||
INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id,item_count) VALUES (
|
||||
NULL,'2017-09-11 12:26:02.738','SERVICE-JMX_CRAWLER',17,1,4,4);
|
||||
|
||||
--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES (
|
||||
--'2017-06-26 20:21:16.626',1,1);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.loafle.overflow.module.probe.service;
|
||||
|
||||
import com.loafle.overflow.module.domain.model.Domain;
|
||||
import com.loafle.overflow.module.infra.model.InfraHost;
|
||||
import com.loafle.overflow.module.member.model.Member;
|
||||
import com.loafle.overflow.module.meta.model.MetaProbeStatus;
|
||||
import com.loafle.overflow.module.probe.model.Probe;
|
||||
|
@ -49,8 +48,6 @@ public class ProbeServiceTest {
|
|||
|
||||
probe.setStatus(status);
|
||||
|
||||
probe.setTargetCount(0);
|
||||
probe.setSensorCount(0);
|
||||
probe.setDisplayName("test probe 22222");
|
||||
probe.setCidr("192.168.1.0/24");
|
||||
// probe.setAuthorizedDate(new Date());
|
||||
|
|
Loading…
Reference in New Issue
Block a user