|
|
@ -9,7 +9,6 @@ import (
|
|
|
|
"dsSupport/Utils/CommonUtil"
|
|
|
|
"dsSupport/Utils/CommonUtil"
|
|
|
|
"dsSupport/Utils/ES7Util"
|
|
|
|
"dsSupport/Utils/ES7Util"
|
|
|
|
"dsSupport/models"
|
|
|
|
"dsSupport/models"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"html"
|
|
|
|
"html"
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
@ -179,61 +178,59 @@ func RemoveMetadata(id string) (bool, string, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func CreateMetadataES(indexName string) (bool, string, error) {
|
|
|
|
func CreateMetadataES(indexName string) (bool, string, error) {
|
|
|
|
res, _, datasourceId, _ := DatasourceDAO.GetDatasourceIdByCode(indexName)
|
|
|
|
res, _, _, _ := DatasourceDAO.GetDatasourceIdByCode(indexName)
|
|
|
|
if res == true {
|
|
|
|
if res == true {
|
|
|
|
if MetadataDAO.IsMetadataExistsByDatasourceCode(indexName) == true {
|
|
|
|
r, _ := ES7Util.IndexExist(indexName)
|
|
|
|
MetadataDAO.DeleteMetadataByDatasourceCode(indexName)
|
|
|
|
if r == true {
|
|
|
|
}
|
|
|
|
if MetadataDAO.IsMetadataExistsByDatasourceCode(indexName) == true {
|
|
|
|
fmt.Println("datasourceId: ", datasourceId)
|
|
|
|
MetadataDAO.DeleteMetadataByDatasourceCode(indexName)
|
|
|
|
result := ES7Util.IndexDataContentMapping(indexName)
|
|
|
|
|
|
|
|
var itemType string
|
|
|
|
|
|
|
|
itemType = "string"
|
|
|
|
|
|
|
|
business := []models.TDataexMetadata{}
|
|
|
|
|
|
|
|
for k, v := range result {
|
|
|
|
|
|
|
|
fmt.Println(k, v)
|
|
|
|
|
|
|
|
fmt.Println("v: ", v.(map[string]interface{})["type"])
|
|
|
|
|
|
|
|
if v.(map[string]interface{})["type"] == "float" {
|
|
|
|
|
|
|
|
itemType = "float"
|
|
|
|
|
|
|
|
} else if v.(map[string]interface{})["type"] == "keyword" {
|
|
|
|
|
|
|
|
itemType = "string"
|
|
|
|
|
|
|
|
} else if v.(map[string]interface{})["type"] == "date" {
|
|
|
|
|
|
|
|
itemType = "datetime"
|
|
|
|
|
|
|
|
} else if v.(map[string]interface{})["type"] == "integer" {
|
|
|
|
|
|
|
|
itemType = "integer"
|
|
|
|
|
|
|
|
} else if v.(map[string]interface{})["type"] == "long" {
|
|
|
|
|
|
|
|
itemType = "text"
|
|
|
|
|
|
|
|
} else if v.(map[string]interface{})["type"] == "text" {
|
|
|
|
|
|
|
|
itemType = "text"
|
|
|
|
|
|
|
|
} else if v.(map[string]interface{})["type"] == "boolean" {
|
|
|
|
|
|
|
|
itemType = "boolean"
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
itemType = "string"
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
result := ES7Util.IndexDataContentMapping(indexName)
|
|
|
|
b := models.TDataexMetadata{}
|
|
|
|
var itemType string
|
|
|
|
b.Id = CommonUtil.GetUUID()
|
|
|
|
itemType = "string"
|
|
|
|
b.DatasourceId = html.EscapeString(indexName)
|
|
|
|
business := []models.TDataexMetadata{}
|
|
|
|
b.ItemName = html.EscapeString(k)
|
|
|
|
for k, v := range result {
|
|
|
|
//b.DicId = html.EscapeString("BA710E2E-895B-4563-9377-0CA5B3DE1CFD")
|
|
|
|
if v.(map[string]interface{})["type"] == "float" {
|
|
|
|
b.ItemType = itemType
|
|
|
|
itemType = "float"
|
|
|
|
b.ItemLength = -1
|
|
|
|
} else if v.(map[string]interface{})["type"] == "keyword" {
|
|
|
|
b.ItemPattern = html.EscapeString("")
|
|
|
|
itemType = "string"
|
|
|
|
b.ItemInfo = html.EscapeString("")
|
|
|
|
} else if v.(map[string]interface{})["type"] == "date" {
|
|
|
|
b.CheckName = -1
|
|
|
|
itemType = "datetime"
|
|
|
|
b.CheckDic = -1
|
|
|
|
} else if v.(map[string]interface{})["type"] == "integer" {
|
|
|
|
b.CheckType = -1
|
|
|
|
itemType = "integer"
|
|
|
|
b.CheckPattern = -1
|
|
|
|
} else if v.(map[string]interface{})["type"] == "long" {
|
|
|
|
b.CheckExist = -1
|
|
|
|
itemType = "text"
|
|
|
|
b.CreateTime = time.Now()
|
|
|
|
} else if v.(map[string]interface{})["type"] == "text" {
|
|
|
|
b.DeleteFlag = -1
|
|
|
|
itemType = "text"
|
|
|
|
|
|
|
|
} else if v.(map[string]interface{})["type"] == "boolean" {
|
|
|
|
business = append(business, b)
|
|
|
|
itemType = "boolean"
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
itemType = "string"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
b := models.TDataexMetadata{}
|
|
|
|
|
|
|
|
b.Id = CommonUtil.GetUUID()
|
|
|
|
|
|
|
|
b.DatasourceId = html.EscapeString(indexName)
|
|
|
|
|
|
|
|
b.ItemName = html.EscapeString(k)
|
|
|
|
|
|
|
|
b.ItemType = itemType
|
|
|
|
|
|
|
|
b.ItemLength = -1
|
|
|
|
|
|
|
|
b.ItemPattern = html.EscapeString("")
|
|
|
|
|
|
|
|
b.ItemInfo = html.EscapeString("")
|
|
|
|
|
|
|
|
b.CheckName = -1
|
|
|
|
|
|
|
|
b.CheckDic = -1
|
|
|
|
|
|
|
|
b.CheckType = -1
|
|
|
|
|
|
|
|
b.CheckPattern = -1
|
|
|
|
|
|
|
|
b.CheckExist = -1
|
|
|
|
|
|
|
|
b.CreateTime = time.Now()
|
|
|
|
|
|
|
|
b.DeleteFlag = -1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
business = append(business, b)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
result1, message, error := MetadataDAO.CreateMetadataBatch(business)
|
|
|
|
|
|
|
|
return result1, message, error
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return false, "", nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Println(business)
|
|
|
|
|
|
|
|
result1, message, error := MetadataDAO.CreateMetadataBatch(business)
|
|
|
|
|
|
|
|
return result1, message, error
|
|
|
|
|
|
|
|
//return true, "ok", nil
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return false, "", nil
|
|
|
|
return false, "", nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|