SensorDisplayItem ing
This commit is contained in:
parent
c02f035623
commit
04609401ef
src
main
java/com/loafle/overflow/module/meta
dao
model
service
resources/local
test/java/com/loafle/overflow/module/meta/service
@ -12,8 +12,6 @@ import java.util.List;
|
||||
*/
|
||||
@Repository
|
||||
public interface MetaSensorDisplayItemDAO extends JpaRepository<MetaSensorDisplayItem, Long> {
|
||||
|
||||
public List<MetaSensorDisplayItem> findAllByCrawler(MetaCrawler crawler);
|
||||
|
||||
|
||||
}
|
||||
|
15
src/main/java/com/loafle/overflow/module/meta/dao/MetaSensorDisplayItemMappingDAO.java
Normal file
15
src/main/java/com/loafle/overflow/module/meta/dao/MetaSensorDisplayItemMappingDAO.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com.loafle.overflow.module.meta.dao;
|
||||
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorDisplayMapping;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 11. 7.
|
||||
*/
|
||||
@Repository
|
||||
public interface MetaSensorDisplayItemMappingDAO extends JpaRepository<MetaSensorDisplayMapping, Short> {
|
||||
public List<MetaSensorDisplayMapping> findAllByDisplayItem(MetaSensorDisplayMapping mapping);
|
||||
}
|
@ -14,6 +14,14 @@ public class MetaCrawler {
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
public MetaCrawler(short id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public MetaCrawler() {
|
||||
|
||||
}
|
||||
|
||||
@Id
|
||||
public short getId() {
|
||||
return id;
|
||||
|
@ -12,14 +12,14 @@ import java.util.Date;
|
||||
public class MetaSensorDisplayItem {
|
||||
|
||||
private long id;
|
||||
private String name;
|
||||
private String key;
|
||||
private String displayName;
|
||||
private String description;
|
||||
private MetaCrawler crawler;
|
||||
private MetaSensorItemUnit unit;
|
||||
private Date createDate;
|
||||
private MetaSensorItemType itemType;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
@ -28,15 +28,34 @@ public class MetaSensorDisplayItem {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(name = "NAME", nullable = false, length = 50)
|
||||
public String getName() {
|
||||
return name;
|
||||
@Column(name = "KEY", nullable = false)
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Column(name = "DISPLAY_NAME", nullable = false)
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@Column(name = "DESCRIPTION", nullable = false)
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "CRAWLER_ID", nullable = false)
|
||||
public MetaCrawler getCrawler() {
|
||||
@ -67,14 +86,4 @@ public class MetaSensorDisplayItem {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "TYPE_ID", nullable = false)
|
||||
public MetaSensorItemType getItemType() {
|
||||
return itemType;
|
||||
}
|
||||
|
||||
public void setItemType(MetaSensorItemType itemType) {
|
||||
this.itemType = itemType;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
package com.loafle.overflow.module.meta.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 11. 7.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "META_SENSOR_DISPLAY_MAPPING", schema = "public")
|
||||
public class MetaSensorDisplayMapping {
|
||||
|
||||
private long id;
|
||||
private MetaSensorDisplayItem displayItem;
|
||||
private MetaSensorItemKey itemKey;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "DISPLAY_ITEM_ID", nullable = false)
|
||||
public MetaSensorDisplayItem getDisplayItem() {
|
||||
return displayItem;
|
||||
}
|
||||
|
||||
public void setDisplayItem(MetaSensorDisplayItem displayItem) {
|
||||
this.displayItem = displayItem;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "ITEM_KEY_ID", nullable = false)
|
||||
public MetaSensorItemKey getItemKey() {
|
||||
return itemKey;
|
||||
}
|
||||
|
||||
public void setItemKey(MetaSensorItemKey itemKey) {
|
||||
this.itemKey = itemKey;
|
||||
}
|
||||
}
|
@ -14,6 +14,14 @@ public class MetaSensorItemUnit {
|
||||
private Date createDate;
|
||||
private String mark;
|
||||
|
||||
public MetaSensorItemUnit(short id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public MetaSensorItemUnit() {
|
||||
|
||||
}
|
||||
|
||||
@Id
|
||||
public short getId() {
|
||||
return id;
|
||||
|
25
src/main/java/com/loafle/overflow/module/meta/service/MetaSensorDisplayItemMappingService.java
Normal file
25
src/main/java/com/loafle/overflow/module/meta/service/MetaSensorDisplayItemMappingService.java
Normal file
@ -0,0 +1,25 @@
|
||||
package com.loafle.overflow.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.module.meta.dao.MetaSensorDisplayItemMappingDAO;
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorDisplayMapping;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 11. 7.
|
||||
*/
|
||||
@Service("MetaSensorDisplayItemMappingService")
|
||||
public class MetaSensorDisplayItemMappingService {
|
||||
@Autowired
|
||||
private MetaSensorDisplayItemMappingDAO mappingDAO;
|
||||
|
||||
public MetaSensorDisplayMapping regist(MetaSensorDisplayMapping m) {
|
||||
return this.mappingDAO.save(m);
|
||||
}
|
||||
|
||||
public List<MetaSensorDisplayMapping> findAllByDisplayItem(MetaSensorDisplayMapping mapping) {
|
||||
return this.mappingDAO.findAllByDisplayItem(mapping);
|
||||
}
|
||||
}
|
@ -925,6 +925,38 @@ INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler
|
||||
INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES (
|
||||
'146','2017-06-26 19:49:04','Win32_OperatingSystem ','FreeSpaceInPagingFiles','','23','146','3');
|
||||
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'1','2017-11-07 16:08:59','','CPU Total usage (%)','ssh.cpu.usage.total','21','1');
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'2','2017-11-07 16:08:59','','CPU User (%)','ssh.cpu.usage.user','21','1');
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'3','2017-11-07 16:08:59','','CPU Nice (%)','ssh.cpu.usage.nice','21','1');
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'4','2017-11-07 16:08:59','','CPU System (%)','ssh.cpu.usage.system','21','1');
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'5','2017-11-07 16:08:59','','CPU Idle (%)','ssh.cpu.usage.idle','21','1');
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'6','2017-11-07 16:08:59','','CPU IO wait (%)','ssh.cpu.usage.iowait','21','1');
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'7','2017-11-07 16:08:59','','CPU IRQ (%)','ssh.cpu.usage.irq','21','1');
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'8','2017-11-07 16:08:59','','CPU Soft IRQ (%)','ssh.cpu.usage.softirq','21','1');
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'9','2017-11-07 16:08:59','','CPU Steal (%)','ssh.cpu.usage.steal','21','1');
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'10','2017-11-07 16:08:59','','CPU Guest (%)','ssh.cpu.usage.guest','21','1');
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'11','2017-11-07 16:08:59','','CPU Guest Nice (%)','ssh.cpu.usage.gnice','21','1');
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'12','2017-11-07 16:08:59','','CPU Total usage (%)','wmi.cpu.usage.total','23','1');
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'13','2017-11-07 16:08:59','','CPU Idle (%)','wmi.cpu.usage.idle','23','1');
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'14','2017-11-07 16:08:59','','CPU Processor (%)','wmi.cpu.usage.processor','23','1');
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'15','2017-11-07 16:08:59','','CPU User (%)','wmi.cpu.usage.user','23','1');
|
||||
INSERT INTO meta_sensor_display_item (id,create_date,description,display_name,"key",crawler_id,unit_id) VALUES (
|
||||
'16','2017-11-07 16:08:59','','CPU Privilege (%)','wmi.cpu.usage.privilege','23','1');
|
||||
|
||||
INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES (
|
||||
1,'2017-07-27 15:29:48.634',23,26);
|
||||
|
39
src/test/java/com/loafle/overflow/module/meta/service/MetaSensorDisplayItemServiceTest.java
Normal file
39
src/test/java/com/loafle/overflow/module/meta/service/MetaSensorDisplayItemServiceTest.java
Normal file
@ -0,0 +1,39 @@
|
||||
package com.loafle.overflow.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.module.meta.model.MetaCrawler;
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorDisplayItem;
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorItemUnit;
|
||||
import com.loafle.overflow.spring.AppConfigTest;
|
||||
import org.junit.Ignore;
|
||||
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 java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 11. 7.
|
||||
*/
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {AppConfigTest.class})
|
||||
public class MetaSensorDisplayItemServiceTest {
|
||||
@Autowired
|
||||
MetaSensorDisplayItemService service;
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void regist() throws Exception {
|
||||
MetaSensorDisplayItem cpuTotal = new MetaSensorDisplayItem();
|
||||
cpuTotal.setId(1);
|
||||
cpuTotal.setCrawler(new MetaCrawler((short)21));
|
||||
cpuTotal.setCreateDate(new Date());
|
||||
cpuTotal.setKey("CPU_TOTAL");
|
||||
cpuTotal.setDisplayName("CPU Total Usage (%)");
|
||||
cpuTotal.setDescription("");
|
||||
cpuTotal.setUnit(new MetaSensorItemUnit((short)1));
|
||||
service.regist(cpuTotal);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user