From 00f7c96744e5ec711e40b3e582ed9dc7dc3e8a75 Mon Sep 17 00:00:00 2001 From: "insanity@loafle.com" Date: Tue, 27 Jun 2017 11:57:22 +0900 Subject: [PATCH] old sensor-relative classes are removed --- proxy/sensor/sensor_service_test.go | 5 +- proxy/sensorItem/sensorItem.go | 47 -------------- proxy/sensorItem/sensorItem_test.go | 18 ----- .../sensorItemCategory/sensorItemCategory.go | 30 --------- .../sensorItemCategory_test.go | 1 - proxy/sensorItemMapping/sensorItemMapping.go | 65 ------------------- .../sensorItemMapping_test.go | 56 ---------------- 7 files changed, 1 insertion(+), 221 deletions(-) delete mode 100644 proxy/sensorItem/sensorItem.go delete mode 100644 proxy/sensorItem/sensorItem_test.go delete mode 100644 proxy/sensorItemCategory/sensorItemCategory.go delete mode 100644 proxy/sensorItemCategory/sensorItemCategory_test.go delete mode 100644 proxy/sensorItemMapping/sensorItemMapping.go delete mode 100644 proxy/sensorItemMapping/sensorItemMapping_test.go diff --git a/proxy/sensor/sensor_service_test.go b/proxy/sensor/sensor_service_test.go index f3e5fbc..e00ac37 100644 --- a/proxy/sensor/sensor_service_test.go +++ b/proxy/sensor/sensor_service_test.go @@ -17,9 +17,6 @@ func TestSensorRegist(t *testing.T) { p.Id = json.Number("1") i := &infra.Infra{} i.Id = json.Number("1") - status := &meta.MetaSensorStatus{ - Id: "2", - } target := &target.Target{ Id: "1", } @@ -29,7 +26,7 @@ func TestSensorRegist(t *testing.T) { sensor := &Sensor{ CreateDate: timestamp.Now(), Description: "This is a Sensor", - MetaSensorStatus: status, + MetaSensorStatus: meta.NewMetaSensorStatus(meta.SENSOR_STATUS_RUNNING), Target: target, Crawler: crawler, } diff --git a/proxy/sensorItem/sensorItem.go b/proxy/sensorItem/sensorItem.go deleted file mode 100644 index 85890c3..0000000 --- a/proxy/sensorItem/sensorItem.go +++ /dev/null @@ -1,47 +0,0 @@ -package sensorItem - -import ( - "encoding/json" - "git.loafle.net/overflow/commons_go/model/timestamp" - "git.loafle.net/overflow/overflow_service/proxy/crawler" - "git.loafle.net/overflow/overflow_service/proxy/sensorItemCategory" - "git.loafle.net/overflow/overflow_service/proxy/utils" -) - -type SensorItem struct { - Id json.Number `json:"id,Number,omitempty"` - Crawler crawler.Crawler `json:"crawler,omitempty"` - SensorItemCategory sensorItemCategory.SensorItemCategory `json:"sensorItemCategory,omitempty"` - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - DataType string `json:"dataType,omitempty"` - CreateDate timestamp.Timestamp `json:"createDate,omitempty"` -} - -type SensorItemService struct { -} - -func NewSensorItemService() *SensorItemService { - return &SensorItemService{} -} - -func (sis *SensorItemService) Create(si *SensorItem) (string, error) { - out, err := utils.InvokeDBByModel("sensorItem", "create", si, "com.loafle.overflow.sensor.model.SensorItem") - - if err != nil { - return "", err - } - return out, nil -} - -func (ss *SensorItemService) List(cr *crawler.Crawler) (string, error) { - - out, err := utils.InvokeDBByModel("sensorItem", "findAllByCrawlerId", cr, "com.loafle.overflow.crawler.model.Crawler") - - if err != nil { - return "", err - } - - return out, nil - -} diff --git a/proxy/sensorItem/sensorItem_test.go b/proxy/sensorItem/sensorItem_test.go deleted file mode 100644 index 7405662..0000000 --- a/proxy/sensorItem/sensorItem_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package sensorItem - -import ( - "encoding/json" - "git.loafle.net/overflow/overflow_service/proxy/crawler" - "testing" -) - -func TestSensorItemService_List(t *testing.T) { - - cr := &crawler.Crawler{} - cr.Id = json.Number("1") - sis := NewSensorItemService() - - res, _ := sis.List(cr) - - t.Log(res) -} diff --git a/proxy/sensorItemCategory/sensorItemCategory.go b/proxy/sensorItemCategory/sensorItemCategory.go deleted file mode 100644 index 304b588..0000000 --- a/proxy/sensorItemCategory/sensorItemCategory.go +++ /dev/null @@ -1,30 +0,0 @@ -package sensorItemCategory - -import ( - "encoding/json" - "git.loafle.net/overflow/commons_go/model/timestamp" - "git.loafle.net/overflow/overflow_service/proxy/utils" -) - -type SensorItemCategory struct { - Id json.Number `json:"id,Number,omitempty"` - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - CreateDate timestamp.Timestamp `json:"createDate,omitempty"` -} - -type SensorItemCategoryService struct { -} - -func NewSensorItemCategoryService() *SensorItemCategoryService { - return &SensorItemCategoryService{} -} - -func (sics *SensorItemCategoryService) Create(sic *SensorItemCategory) (string, error) { - out, err := utils.InvokeDBByModel("sensorItemCategory", "create", sic, "com.loafle.overflow.sensor.model.SensorItemCategory") - - if err != nil { - return "", err - } - return out, nil -} diff --git a/proxy/sensorItemCategory/sensorItemCategory_test.go b/proxy/sensorItemCategory/sensorItemCategory_test.go deleted file mode 100644 index ad759f2..0000000 --- a/proxy/sensorItemCategory/sensorItemCategory_test.go +++ /dev/null @@ -1 +0,0 @@ -package sensorItemCategory diff --git a/proxy/sensorItemMapping/sensorItemMapping.go b/proxy/sensorItemMapping/sensorItemMapping.go deleted file mode 100644 index a85ccb3..0000000 --- a/proxy/sensorItemMapping/sensorItemMapping.go +++ /dev/null @@ -1,65 +0,0 @@ -package sensorItemMapping - -import ( - "encoding/json" - "git.loafle.net/overflow/commons_go/model/timestamp" - "git.loafle.net/overflow/overflow_service/proxy/sensor" - "git.loafle.net/overflow/overflow_service/proxy/sensorItem" - "git.loafle.net/overflow/overflow_service/proxy/utils" -) - -type SensorItemMapping struct { - Id json.Number `json:"id,Number,omitempty"` - Sensor sensor.Sensor `json:"sensor,omitempty"` - SensorItem sensorItem.SensorItem `json:"sensorItem,omitempty"` - CreateDate timestamp.Timestamp `json:"createDate,omitempty"` -} - -type SensorItemMappingService struct { -} - -func NewSensorItemMappingService() *SensorItemMappingService { - return &SensorItemMappingService{} -} - -func (sims *SensorItemMappingService) Create(sim *SensorItemMapping) (string, error) { - out, err := utils.InvokeDBByModel("sensorItemMapping", "create", sim, "com.loafle.overflow.sensor.model.SensorItemMapping") - - if err != nil { - return "", err - } - return out, nil -} - -func (sims *SensorItemMappingService) CreateAll(siml *[]*SensorItemMapping) (string, error) { - - outlist := make([]string, 0) - for _, sim := range *siml { - out, err := sims.Create(sim) - if err != nil { - return "", err - } - outlist = append(outlist, out) - } - - bytes, err := json.Marshal(outlist) - - if err != nil { - return "", err - } - - return string(bytes), nil - -} - -func (ss *SensorItemMappingService) List(s *sensor.Sensor) (string, error) { - - out, err := utils.InvokeDBByModel("sensorItemMapping", "findAllBySensorId", s, "com.loafle.overflow.sensor.model.Sensor") - - if err != nil { - return "", err - } - - return out, nil - -} diff --git a/proxy/sensorItemMapping/sensorItemMapping_test.go b/proxy/sensorItemMapping/sensorItemMapping_test.go deleted file mode 100644 index c8526ca..0000000 --- a/proxy/sensorItemMapping/sensorItemMapping_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package sensorItemMapping - -import ( - "encoding/json" - "fmt" - "git.loafle.net/overflow/overflow_service/proxy/sensor" - "strconv" - "sync" - "testing" -) - -func TestSensorItemMappingService_List(t *testing.T) { - s := &sensor.Sensor{} - s.Id = json.Number("1") - - sims := NewSensorItemMappingService() - res, _ := sims.List(s) - - t.Log(res) -} - -func TestSensorItemMappingService_List_GoRutine(t *testing.T) { - //s := &sensor.Sensor{} - //s.Id = json.Number("14") - - sims := NewSensorItemMappingService() - - il := make([]int, 0) - - il = append(il, 1) - il = append(il, 2) - il = append(il, 3) - il = append(il, 13) - il = append(il, 14) - - for _, ii := range il { - - go func(i int) { - s := &sensor.Sensor{} - s.Id = json.Number(strconv.Itoa(ii)) - res, _ := sims.List(s) - fmt.Print(res) - }(ii) - - } - - wg := sync.WaitGroup{} - - wg.Add(1) - - wg.Wait() - - //res, _ := sims.List(s) - // - //t.Log(res) -}