mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
Transform Properties into StartParameterScheme
This commit is contained in:
parent
1f0455d901
commit
adabfc8e9c
9 changed files with 177 additions and 177 deletions
|
@ -138,8 +138,8 @@ type InfrastructureComponent struct {
|
||||||
Location string `json:"location" gorm:"default:''"`
|
Location string `json:"location" gorm:"default:''"`
|
||||||
// Description of the IC
|
// Description of the IC
|
||||||
Description string `json:"description" gorm:"default:''"`
|
Description string `json:"description" gorm:"default:''"`
|
||||||
// Properties of IC as JSON string
|
// JSON scheme of start parameters for IC
|
||||||
Properties postgres.Jsonb `json:"properties"`
|
StartParameterScheme postgres.Jsonb `json:"startparameterscheme"`
|
||||||
// ComponentConfigurations in which the IC is used
|
// ComponentConfigurations in which the IC is used
|
||||||
ComponentConfigurations []ComponentConfiguration `json:"-" gorm:"foreignkey:ICID"`
|
ComponentConfigurations []ComponentConfiguration `json:"-" gorm:"foreignkey:ICID"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
||||||
// This file was generated by swaggo/swag at
|
// This file was generated by swaggo/swag at
|
||||||
// 2020-10-20 12:56:57.842992188 +0200 CEST m=+0.084567298
|
// 2020-10-20 15:23:51.266197121 +0200 CEST m=+0.098130845
|
||||||
|
|
||||||
package docs
|
package docs
|
||||||
|
|
||||||
|
@ -3000,8 +3000,8 @@ var doc = `{
|
||||||
"description": "Name of the IC",
|
"description": "Name of the IC",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"properties": {
|
"startparameterscheme": {
|
||||||
"description": "Properties of IC as JSON string",
|
"description": "JSON scheme of start parameters for IC",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"state": {
|
"state": {
|
||||||
|
@ -3397,7 +3397,7 @@ var doc = `{
|
||||||
"Name": {
|
"Name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"Properties": {
|
"StartParameterScheme": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"State": {
|
"State": {
|
||||||
|
@ -3432,7 +3432,7 @@ var doc = `{
|
||||||
"Name": {
|
"Name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"Properties": {
|
"StartParameterScheme": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"State": {
|
"State": {
|
||||||
|
|
|
@ -2983,8 +2983,8 @@
|
||||||
"description": "Name of the IC",
|
"description": "Name of the IC",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"properties": {
|
"startparameterscheme": {
|
||||||
"description": "Properties of IC as JSON string",
|
"description": "JSON scheme of start parameters for IC",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"state": {
|
"state": {
|
||||||
|
@ -3380,7 +3380,7 @@
|
||||||
"Name": {
|
"Name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"Properties": {
|
"StartParameterScheme": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"State": {
|
"State": {
|
||||||
|
@ -3415,7 +3415,7 @@
|
||||||
"Name": {
|
"Name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"Properties": {
|
"StartParameterScheme": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"State": {
|
"State": {
|
||||||
|
|
|
@ -163,8 +163,8 @@ definitions:
|
||||||
name:
|
name:
|
||||||
description: Name of the IC
|
description: Name of the IC
|
||||||
type: string
|
type: string
|
||||||
properties:
|
startparameterscheme:
|
||||||
description: Properties of IC as JSON string
|
description: JSON scheme of start parameters for IC
|
||||||
type: string
|
type: string
|
||||||
state:
|
state:
|
||||||
description: State of the IC
|
description: State of the IC
|
||||||
|
@ -431,7 +431,7 @@ definitions:
|
||||||
type: string
|
type: string
|
||||||
Name:
|
Name:
|
||||||
type: string
|
type: string
|
||||||
Properties:
|
StartParameterScheme:
|
||||||
type: string
|
type: string
|
||||||
State:
|
State:
|
||||||
type: string
|
type: string
|
||||||
|
@ -459,7 +459,7 @@ definitions:
|
||||||
type: string
|
type: string
|
||||||
Name:
|
Name:
|
||||||
type: string
|
type: string
|
||||||
Properties:
|
StartParameterScheme:
|
||||||
type: string
|
type: string
|
||||||
State:
|
State:
|
||||||
type: string
|
type: string
|
||||||
|
|
|
@ -102,7 +102,7 @@ var ICA = database.InfrastructureComponent{
|
||||||
Location: "ACS Laboratory",
|
Location: "ACS Laboratory",
|
||||||
Description: "This is a test description",
|
Description: "This is a test description",
|
||||||
//StateUpdateAt: time.Now().Format(time.RFC1123),
|
//StateUpdateAt: time.Now().Format(time.RFC1123),
|
||||||
Properties: postgres.Jsonb{propertiesA},
|
StartParameterScheme: postgres.Jsonb{propertiesA},
|
||||||
}
|
}
|
||||||
|
|
||||||
var ICB = database.InfrastructureComponent{
|
var ICB = database.InfrastructureComponent{
|
||||||
|
@ -117,7 +117,7 @@ var ICB = database.InfrastructureComponent{
|
||||||
Location: "k8s",
|
Location: "k8s",
|
||||||
Description: "A signal generator for testing purposes",
|
Description: "A signal generator for testing purposes",
|
||||||
//StateUpdateAt: time.Now().Format(time.RFC1123),
|
//StateUpdateAt: time.Now().Format(time.RFC1123),
|
||||||
Properties: postgres.Jsonb{propertiesB},
|
StartParameterScheme: postgres.Jsonb{propertiesB},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scenarios
|
// Scenarios
|
||||||
|
|
|
@ -57,7 +57,7 @@ type ICRequest struct {
|
||||||
State string `json:"state,omitempty"`
|
State string `json:"state,omitempty"`
|
||||||
Location string `json:"location,omitempty"`
|
Location string `json:"location,omitempty"`
|
||||||
Description string `json:"description,omitempty"`
|
Description string `json:"description,omitempty"`
|
||||||
Properties postgres.Jsonb `json:"properties,omitempty"`
|
StartParameterScheme postgres.Jsonb `json:"startparameterscheme,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ScenarioRequest struct {
|
type ScenarioRequest struct {
|
||||||
|
@ -82,7 +82,7 @@ func addScenarioAndIC() (scenarioID uint, ICID uint) {
|
||||||
State: helper.ICA.State,
|
State: helper.ICA.State,
|
||||||
Location: helper.ICA.Location,
|
Location: helper.ICA.Location,
|
||||||
Description: helper.ICA.Description,
|
Description: helper.ICA.Description,
|
||||||
Properties: helper.ICA.Properties,
|
StartParameterScheme: helper.ICA.StartParameterScheme,
|
||||||
}
|
}
|
||||||
_, resp, _ := helper.TestEndpoint(router, token,
|
_, resp, _ := helper.TestEndpoint(router, token,
|
||||||
"/api/ic", "POST", helper.KeyModels{"ic": newICA})
|
"/api/ic", "POST", helper.KeyModels{"ic": newICA})
|
||||||
|
@ -100,7 +100,7 @@ func addScenarioAndIC() (scenarioID uint, ICID uint) {
|
||||||
State: helper.ICB.State,
|
State: helper.ICB.State,
|
||||||
Location: helper.ICB.Location,
|
Location: helper.ICB.Location,
|
||||||
Description: helper.ICB.Description,
|
Description: helper.ICB.Description,
|
||||||
Properties: helper.ICB.Properties,
|
StartParameterScheme: helper.ICB.StartParameterScheme,
|
||||||
}
|
}
|
||||||
_, resp, _ = helper.TestEndpoint(router, token,
|
_, resp, _ = helper.TestEndpoint(router, token,
|
||||||
"/api/ic", "POST", helper.KeyModels{"ic": newICB})
|
"/api/ic", "POST", helper.KeyModels{"ic": newICB})
|
||||||
|
|
|
@ -48,7 +48,7 @@ type ICRequest struct {
|
||||||
State string `json:"state,omitempty"`
|
State string `json:"state,omitempty"`
|
||||||
Location string `json:"location,omitempty"`
|
Location string `json:"location,omitempty"`
|
||||||
Description string `json:"description,omitempty"`
|
Description string `json:"description,omitempty"`
|
||||||
Properties postgres.Jsonb `json:"properties,omitempty"`
|
StartParameterScheme postgres.Jsonb `json:"startparameterscheme,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
@ -111,7 +111,7 @@ func TestAddICAsAdmin(t *testing.T) {
|
||||||
State: helper.ICA.State,
|
State: helper.ICA.State,
|
||||||
Location: helper.ICA.Location,
|
Location: helper.ICA.Location,
|
||||||
Description: helper.ICA.Description,
|
Description: helper.ICA.Description,
|
||||||
Properties: helper.ICA.Properties,
|
StartParameterScheme: helper.ICA.StartParameterScheme,
|
||||||
}
|
}
|
||||||
code, resp, err = helper.TestEndpoint(router, token,
|
code, resp, err = helper.TestEndpoint(router, token,
|
||||||
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
|
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
|
||||||
|
@ -165,7 +165,7 @@ func TestAddICAsUser(t *testing.T) {
|
||||||
State: helper.ICA.State,
|
State: helper.ICA.State,
|
||||||
Location: helper.ICA.Location,
|
Location: helper.ICA.Location,
|
||||||
Description: helper.ICA.Description,
|
Description: helper.ICA.Description,
|
||||||
Properties: helper.ICA.Properties,
|
StartParameterScheme: helper.ICA.StartParameterScheme,
|
||||||
}
|
}
|
||||||
|
|
||||||
// This should fail with unprocessable entity 422 error code
|
// This should fail with unprocessable entity 422 error code
|
||||||
|
@ -196,7 +196,7 @@ func TestUpdateICAsAdmin(t *testing.T) {
|
||||||
State: helper.ICA.State,
|
State: helper.ICA.State,
|
||||||
Location: helper.ICA.Location,
|
Location: helper.ICA.Location,
|
||||||
Description: helper.ICA.Description,
|
Description: helper.ICA.Description,
|
||||||
Properties: helper.ICA.Properties,
|
StartParameterScheme: helper.ICA.StartParameterScheme,
|
||||||
}
|
}
|
||||||
code, resp, err := helper.TestEndpoint(router, token,
|
code, resp, err := helper.TestEndpoint(router, token,
|
||||||
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
|
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
|
||||||
|
@ -262,7 +262,7 @@ func TestUpdateICAsUser(t *testing.T) {
|
||||||
State: helper.ICA.State,
|
State: helper.ICA.State,
|
||||||
Location: helper.ICA.Location,
|
Location: helper.ICA.Location,
|
||||||
Description: helper.ICA.Description,
|
Description: helper.ICA.Description,
|
||||||
Properties: helper.ICA.Properties,
|
StartParameterScheme: helper.ICA.StartParameterScheme,
|
||||||
}
|
}
|
||||||
code, resp, err := helper.TestEndpoint(router, token,
|
code, resp, err := helper.TestEndpoint(router, token,
|
||||||
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
|
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
|
||||||
|
@ -308,7 +308,7 @@ func TestDeleteICAsAdmin(t *testing.T) {
|
||||||
State: helper.ICA.State,
|
State: helper.ICA.State,
|
||||||
Location: helper.ICA.Location,
|
Location: helper.ICA.Location,
|
||||||
Description: helper.ICA.Description,
|
Description: helper.ICA.Description,
|
||||||
Properties: helper.ICA.Properties,
|
StartParameterScheme: helper.ICA.StartParameterScheme,
|
||||||
}
|
}
|
||||||
code, resp, err := helper.TestEndpoint(router, token,
|
code, resp, err := helper.TestEndpoint(router, token,
|
||||||
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
|
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
|
||||||
|
@ -362,7 +362,7 @@ func TestDeleteICAsUser(t *testing.T) {
|
||||||
State: helper.ICA.State,
|
State: helper.ICA.State,
|
||||||
Location: helper.ICA.Location,
|
Location: helper.ICA.Location,
|
||||||
Description: helper.ICA.Description,
|
Description: helper.ICA.Description,
|
||||||
Properties: helper.ICA.Properties,
|
StartParameterScheme: helper.ICA.StartParameterScheme,
|
||||||
}
|
}
|
||||||
code, resp, err := helper.TestEndpoint(router, token,
|
code, resp, err := helper.TestEndpoint(router, token,
|
||||||
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
|
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
|
||||||
|
@ -412,7 +412,7 @@ func TestGetAllICs(t *testing.T) {
|
||||||
State: helper.ICA.State,
|
State: helper.ICA.State,
|
||||||
Location: helper.ICA.Location,
|
Location: helper.ICA.Location,
|
||||||
Description: helper.ICA.Description,
|
Description: helper.ICA.Description,
|
||||||
Properties: helper.ICA.Properties,
|
StartParameterScheme: helper.ICA.StartParameterScheme,
|
||||||
}
|
}
|
||||||
code, resp, err := helper.TestEndpoint(router, token,
|
code, resp, err := helper.TestEndpoint(router, token,
|
||||||
"/api/ic", "POST", helper.KeyModels{"ic": newICA})
|
"/api/ic", "POST", helper.KeyModels{"ic": newICA})
|
||||||
|
@ -429,7 +429,7 @@ func TestGetAllICs(t *testing.T) {
|
||||||
State: helper.ICB.State,
|
State: helper.ICB.State,
|
||||||
Location: helper.ICB.Location,
|
Location: helper.ICB.Location,
|
||||||
Description: helper.ICB.Description,
|
Description: helper.ICB.Description,
|
||||||
Properties: helper.ICB.Properties,
|
StartParameterScheme: helper.ICB.StartParameterScheme,
|
||||||
}
|
}
|
||||||
code, resp, err = helper.TestEndpoint(router, token,
|
code, resp, err = helper.TestEndpoint(router, token,
|
||||||
"/api/ic", "POST", helper.KeyModels{"ic": newICB})
|
"/api/ic", "POST", helper.KeyModels{"ic": newICB})
|
||||||
|
@ -476,7 +476,7 @@ func TestGetConfigsOfIC(t *testing.T) {
|
||||||
State: helper.ICA.State,
|
State: helper.ICA.State,
|
||||||
Location: helper.ICA.Location,
|
Location: helper.ICA.Location,
|
||||||
Description: helper.ICA.Description,
|
Description: helper.ICA.Description,
|
||||||
Properties: helper.ICA.Properties,
|
StartParameterScheme: helper.ICA.StartParameterScheme,
|
||||||
}
|
}
|
||||||
code, resp, err := helper.TestEndpoint(router, token,
|
code, resp, err := helper.TestEndpoint(router, token,
|
||||||
"/api/ic", "POST", helper.KeyModels{"ic": newICA})
|
"/api/ic", "POST", helper.KeyModels{"ic": newICA})
|
||||||
|
|
|
@ -38,7 +38,7 @@ type validNewIC struct {
|
||||||
Type string `form:"Type" validate:"required"`
|
Type string `form:"Type" validate:"required"`
|
||||||
Name string `form:"Name" validate:"required"`
|
Name string `form:"Name" validate:"required"`
|
||||||
Category string `form:"Category" validate:"required"`
|
Category string `form:"Category" validate:"required"`
|
||||||
Properties postgres.Jsonb `form:"Properties" validate:"omitempty"`
|
StartParameterScheme postgres.Jsonb `form:"StartParameterScheme" validate:"omitempty"`
|
||||||
State string `form:"State" validate:"omitempty"`
|
State string `form:"State" validate:"omitempty"`
|
||||||
Location string `form:"Location" validate:"omitempty"`
|
Location string `form:"Location" validate:"omitempty"`
|
||||||
Description string `form:"Description" validate:"omitempty"`
|
Description string `form:"Description" validate:"omitempty"`
|
||||||
|
@ -51,7 +51,7 @@ type validUpdatedIC struct {
|
||||||
Type string `form:"Type" validate:"omitempty"`
|
Type string `form:"Type" validate:"omitempty"`
|
||||||
Name string `form:"Name" validate:"omitempty"`
|
Name string `form:"Name" validate:"omitempty"`
|
||||||
Category string `form:"Category" validate:"omitempty"`
|
Category string `form:"Category" validate:"omitempty"`
|
||||||
Properties postgres.Jsonb `form:"Properties" validate:"omitempty"`
|
StartParameterScheme postgres.Jsonb `form:"StartParameterScheme" validate:"omitempty"`
|
||||||
State string `form:"State" validate:"omitempty"`
|
State string `form:"State" validate:"omitempty"`
|
||||||
Location string `form:"Location" validate:"omitempty"`
|
Location string `form:"Location" validate:"omitempty"`
|
||||||
Description string `form:"Description" validate:"omitempty"`
|
Description string `form:"Description" validate:"omitempty"`
|
||||||
|
@ -88,7 +88,7 @@ func (r *AddICRequest) CreateIC() InfrastructureComponent {
|
||||||
s.Category = r.InfrastructureComponent.Category
|
s.Category = r.InfrastructureComponent.Category
|
||||||
s.Location = r.InfrastructureComponent.Location
|
s.Location = r.InfrastructureComponent.Location
|
||||||
s.Description = r.InfrastructureComponent.Description
|
s.Description = r.InfrastructureComponent.Description
|
||||||
s.Properties = r.InfrastructureComponent.Properties
|
s.StartParameterScheme = r.InfrastructureComponent.StartParameterScheme
|
||||||
if r.InfrastructureComponent.State != "" {
|
if r.InfrastructureComponent.State != "" {
|
||||||
s.State = r.InfrastructureComponent.State
|
s.State = r.InfrastructureComponent.State
|
||||||
} else {
|
} else {
|
||||||
|
@ -147,11 +147,11 @@ func (r *UpdateICRequest) UpdatedIC(oldIC InfrastructureComponent) Infrastructur
|
||||||
var emptyJson postgres.Jsonb
|
var emptyJson postgres.Jsonb
|
||||||
// Serialize empty json and params
|
// Serialize empty json and params
|
||||||
emptyJson_ser, _ := json.Marshal(emptyJson)
|
emptyJson_ser, _ := json.Marshal(emptyJson)
|
||||||
startParams_ser, _ := json.Marshal(r.InfrastructureComponent.Properties)
|
startParams_ser, _ := json.Marshal(r.InfrastructureComponent.StartParameterScheme)
|
||||||
opts := jsondiff.DefaultConsoleOptions()
|
opts := jsondiff.DefaultConsoleOptions()
|
||||||
diff, _ := jsondiff.Compare(emptyJson_ser, startParams_ser, &opts)
|
diff, _ := jsondiff.Compare(emptyJson_ser, startParams_ser, &opts)
|
||||||
if diff.String() != "FullMatch" {
|
if diff.String() != "FullMatch" {
|
||||||
s.Properties = r.InfrastructureComponent.Properties
|
s.StartParameterScheme = r.InfrastructureComponent.StartParameterScheme
|
||||||
}
|
}
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
|
@ -64,7 +64,7 @@ type ICRequest struct {
|
||||||
State string `json:"state,omitempty"`
|
State string `json:"state,omitempty"`
|
||||||
Location string `json:"location,omitempty"`
|
Location string `json:"location,omitempty"`
|
||||||
Description string `json:"description,omitempty"`
|
Description string `json:"description,omitempty"`
|
||||||
Properties postgres.Jsonb `json:"properties,omitempty"`
|
StartParameterScheme postgres.Jsonb `json:"startparameterscheme,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ScenarioRequest struct {
|
type ScenarioRequest struct {
|
||||||
|
@ -89,7 +89,7 @@ func addScenarioAndICAndConfig() (scenarioID uint, ICID uint, configID uint) {
|
||||||
State: helper.ICA.State,
|
State: helper.ICA.State,
|
||||||
Location: helper.ICA.Location,
|
Location: helper.ICA.Location,
|
||||||
Description: helper.ICA.Description,
|
Description: helper.ICA.Description,
|
||||||
Properties: helper.ICA.Properties,
|
StartParameterScheme: helper.ICA.StartParameterScheme,
|
||||||
}
|
}
|
||||||
_, resp, _ := helper.TestEndpoint(router, token,
|
_, resp, _ := helper.TestEndpoint(router, token,
|
||||||
"/api/ic", "POST", helper.KeyModels{"ic": newICA})
|
"/api/ic", "POST", helper.KeyModels{"ic": newICA})
|
||||||
|
|
Loading…
Add table
Reference in a new issue