sensor display item
This commit is contained in:
parent
9af262d02a
commit
994d5e2f69
|
@ -0,0 +1,19 @@
|
|||
package com.loafle.overflow.module.meta.dao;
|
||||
|
||||
import com.loafle.overflow.module.meta.model.MetaCrawler;
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorDisplayItem;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
@Repository
|
||||
public interface MetaSensorDisplayItemDAO extends JpaRepository<MetaSensorDisplayItem, Long> {
|
||||
|
||||
public List<MetaSensorDisplayItem> findAllByCrawler(MetaCrawler crawler);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.loafle.overflow.module.meta.dao;
|
||||
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorItemUnit;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
@Repository
|
||||
public interface MetaSensorItemUnitDAO extends JpaRepository<MetaSensorItemUnit, Short> {
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package com.loafle.overflow.module.meta.model;
|
||||
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "META_SENSOR_DISPLAY_ITEM", schema = "public")
|
||||
public class MetaSensorDisplayItem {
|
||||
|
||||
private long id;
|
||||
private String name;
|
||||
private MetaCrawler crawler;
|
||||
private MetaSensorItemUnit unit;
|
||||
private Date createDate;
|
||||
private MetaSensorItemType itemType;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(name = "NAME", nullable = false, length = 50)
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "CRAWLER_ID", nullable = false)
|
||||
public MetaCrawler getCrawler() {
|
||||
return crawler;
|
||||
}
|
||||
|
||||
public void setCrawler(MetaCrawler crawler) {
|
||||
this.crawler = crawler;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "UNIT_ID", nullable = true)
|
||||
public MetaSensorItemUnit getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void setUnit(MetaSensorItemUnit unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name="CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "TYPE_ID", nullable = false)
|
||||
public MetaSensorItemType getItemType() {
|
||||
return itemType;
|
||||
}
|
||||
|
||||
public void setItemType(MetaSensorItemType itemType) {
|
||||
this.itemType = itemType;
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ public class MetaSensorItemKey {
|
|||
private String option;
|
||||
private MetaCrawler crawler;
|
||||
private Date createDate;
|
||||
private MetaSensorItemUnit unit;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
|
@ -83,4 +84,14 @@ public class MetaSensorItemKey {
|
|||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "UNIT_ID", nullable = true)
|
||||
public MetaSensorItemUnit getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void setUnit(MetaSensorItemUnit unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package com.loafle.overflow.module.meta.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 19.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "META_SENSOR_ITEM_UNIT", schema = "public")
|
||||
public class MetaSensorItemUnit {
|
||||
private short id;
|
||||
private String unit;
|
||||
private Date createDate;
|
||||
private String mark;
|
||||
|
||||
@Id
|
||||
public short getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(short id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(name = "UNIT", nullable = false)
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void setUnit(String unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name="CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
@Column(name = "MARK", nullable = false)
|
||||
public String getMark() {
|
||||
return mark;
|
||||
}
|
||||
|
||||
public void setMark(String mark) {
|
||||
this.mark = mark;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.loafle.overflow.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.module.meta.dao.MetaSensorDisplayItemDAO;
|
||||
import com.loafle.overflow.module.meta.model.MetaCrawler;
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorDisplayItem;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
|
||||
@Service("MetaSensorDisplayItemService")
|
||||
public class MetaSensorDisplayItemService {
|
||||
@Autowired
|
||||
private MetaSensorDisplayItemDAO displayItemDAO;
|
||||
|
||||
public MetaSensorDisplayItem regist(MetaSensorDisplayItem item) {
|
||||
return this.displayItemDAO.save(item);
|
||||
}
|
||||
|
||||
public MetaSensorDisplayItem read(long id) {
|
||||
return this.displayItemDAO.findOne(id);
|
||||
}
|
||||
|
||||
public List<MetaSensorDisplayItem> readAllByCrawler(MetaCrawler crawler) {
|
||||
return this.displayItemDAO.findAllByCrawler(crawler);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.loafle.overflow.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.module.meta.dao.MetaSensorItemUnitDAO;
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorItemUnit;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
@Service("MetaSensorItemUnitService")
|
||||
public class MetaSensorItemUnitService {
|
||||
@Autowired
|
||||
private MetaSensorItemUnitDAO sensorItemUnitDAO;
|
||||
|
||||
public MetaSensorItemUnit regist(MetaSensorItemUnit sensorItemUnit) {
|
||||
return this.sensorItemUnitDAO.save(sensorItemUnit);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.loafle.overflow.module.sensor.dao;
|
||||
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorDisplayItem;
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorItemKey;
|
||||
import com.loafle.overflow.module.sensor.model.SensorItemDependency;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
@Repository
|
||||
public interface SensorItemDependencyDAO extends JpaRepository<SensorItemDependency, Long> {
|
||||
|
||||
List<MetaSensorItemKey> findAllByDisplayItem(MetaSensorDisplayItem displayItem);
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.loafle.overflow.module.sensor.model;
|
||||
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorDisplayItem;
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorItemKey;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "SENSOR_ITEM_DEPENDENCY", schema = "public")
|
||||
public class SensorItemDependency {
|
||||
private long id;
|
||||
private MetaSensorDisplayItem displayItem;
|
||||
private MetaSensorItemKey sensorItem;
|
||||
|
||||
@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 = "SENSOR_ITEM_ID", nullable = false)
|
||||
public MetaSensorItemKey getSensorItem() {
|
||||
return sensorItem;
|
||||
}
|
||||
|
||||
public void setSensorItem(MetaSensorItemKey sensorItem) {
|
||||
this.sensorItem = sensorItem;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.loafle.overflow.module.sensor.service;
|
||||
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorDisplayItem;
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorItemKey;
|
||||
import com.loafle.overflow.module.sensor.dao.SensorItemDependencyDAO;
|
||||
import com.loafle.overflow.module.sensor.model.SensorItemDependency;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
|
||||
@Service("SensorItemDependencyService")
|
||||
public class SensorItemDependencyService {
|
||||
|
||||
@Autowired
|
||||
private SensorItemDependencyDAO sensorItemDependencyDAO;
|
||||
|
||||
public SensorItemDependency regist(SensorItemDependency dependency) {
|
||||
return this.sensorItemDependencyDAO.save(dependency);
|
||||
}
|
||||
|
||||
public List<MetaSensorItemKey> readAllByDisplayItem(MetaSensorDisplayItem displayItem) {
|
||||
return this.sensorItemDependencyDAO.findAllByDisplayItem(displayItem);
|
||||
}
|
||||
}
|
|
@ -913,6 +913,27 @@ INSERT INTO public.meta_history_type (id,create_date,"name") VALUES (
|
|||
6,'2017-08-23 13:28:26.966','Sensor');
|
||||
|
||||
|
||||
INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES (
|
||||
1,'2017-09-20 14:16:26.213','%','Percentage');
|
||||
INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES (
|
||||
2,'2017-09-20 14:16:26.256','Bytes','Byte');
|
||||
INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES (
|
||||
3,'2017-09-20 14:16:26.272','KB','KByte');
|
||||
INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES (
|
||||
4,'2017-09-20 14:16:26.289','MB','MByte');
|
||||
INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES (
|
||||
5,'2017-09-20 14:16:26.305','GB','GByte');
|
||||
INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES (
|
||||
6,'2017-09-20 14:16:26.321','','Count');
|
||||
INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES (
|
||||
7,'2017-09-20 14:16:26.339','Jiffies','Jiffy');
|
||||
INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES (
|
||||
8,'2017-09-20 14:16:26.355','BPS','Byte Per Second');
|
||||
INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES (
|
||||
9,'2017-09-20 14:16:26.372','PPS','Packet Per Second');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package com.loafle.overflow.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.module.meta.model.MetaSensorItemUnit;
|
||||
import com.loafle.overflow.spring.AppConfigTest;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 7. 27.
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {AppConfigTest.class})
|
||||
public class MetaSensorItemUnitServiceTest {
|
||||
|
||||
@Autowired
|
||||
private MetaSensorItemUnitService service;
|
||||
|
||||
@Test
|
||||
public void regist() throws Exception {
|
||||
MetaSensorItemUnit unit1 = new MetaSensorItemUnit();
|
||||
unit1.setId((short)1);
|
||||
unit1.setUnit("Percentage");
|
||||
unit1.setMark("%");
|
||||
this.service.regist(unit1);
|
||||
|
||||
MetaSensorItemUnit unit2 = new MetaSensorItemUnit();
|
||||
unit2.setId((short)2);
|
||||
unit2.setUnit("Byte");
|
||||
unit2.setMark("Bytes");
|
||||
this.service.regist(unit2);
|
||||
|
||||
MetaSensorItemUnit unit3 = new MetaSensorItemUnit();
|
||||
unit3.setId((short)3);
|
||||
unit3.setUnit("KByte");
|
||||
unit3.setMark("KB");
|
||||
this.service.regist(unit3);
|
||||
|
||||
MetaSensorItemUnit unit4 = new MetaSensorItemUnit();
|
||||
unit4.setId((short)4);
|
||||
unit4.setUnit("MByte");
|
||||
unit4.setMark("MB");
|
||||
this.service.regist(unit4);
|
||||
|
||||
MetaSensorItemUnit unit5 = new MetaSensorItemUnit();
|
||||
unit5.setId((short)5);
|
||||
unit5.setUnit("GByte");
|
||||
unit5.setMark("GB");
|
||||
this.service.regist(unit5);
|
||||
|
||||
MetaSensorItemUnit unit6 = new MetaSensorItemUnit();
|
||||
unit6.setId((short)6);
|
||||
unit6.setUnit("Count");
|
||||
unit6.setMark("");
|
||||
this.service.regist(unit6);
|
||||
|
||||
MetaSensorItemUnit unit7 = new MetaSensorItemUnit();
|
||||
unit7.setId((short)7);
|
||||
unit7.setUnit("Jiffy");
|
||||
unit7.setMark("Jiffies");
|
||||
this.service.regist(unit7);
|
||||
|
||||
MetaSensorItemUnit unit8 = new MetaSensorItemUnit();
|
||||
unit8.setId((short)8);
|
||||
unit8.setUnit("Byte Per Second");
|
||||
unit8.setMark("BPS");
|
||||
this.service.regist(unit8);
|
||||
|
||||
MetaSensorItemUnit unit9 = new MetaSensorItemUnit();
|
||||
unit9.setId((short)9);
|
||||
unit9.setUnit("Packet Per Second");
|
||||
unit9.setMark("PPS");
|
||||
this.service.regist(unit9);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user