Transform Properties into StartParameterScheme

This commit is contained in:
Sonja Happ 2020-10-20 15:27:36 +02:00
parent 1f0455d901
commit adabfc8e9c
9 changed files with 177 additions and 177 deletions

View file

@ -138,8 +138,8 @@ type InfrastructureComponent struct {
Location string `json:"location" gorm:"default:''"`
// Description of the IC
Description string `json:"description" gorm:"default:''"`
// Properties of IC as JSON string
Properties postgres.Jsonb `json:"properties"`
// JSON scheme of start parameters for IC
StartParameterScheme postgres.Jsonb `json:"startparameterscheme"`
// ComponentConfigurations in which the IC is used
ComponentConfigurations []ComponentConfiguration `json:"-" gorm:"foreignkey:ICID"`
}

View file

@ -1,6 +1,6 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// 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
@ -3000,8 +3000,8 @@ var doc = `{
"description": "Name of the IC",
"type": "string"
},
"properties": {
"description": "Properties of IC as JSON string",
"startparameterscheme": {
"description": "JSON scheme of start parameters for IC",
"type": "string"
},
"state": {
@ -3397,7 +3397,7 @@ var doc = `{
"Name": {
"type": "string"
},
"Properties": {
"StartParameterScheme": {
"type": "string"
},
"State": {
@ -3432,7 +3432,7 @@ var doc = `{
"Name": {
"type": "string"
},
"Properties": {
"StartParameterScheme": {
"type": "string"
},
"State": {

View file

@ -2983,8 +2983,8 @@
"description": "Name of the IC",
"type": "string"
},
"properties": {
"description": "Properties of IC as JSON string",
"startparameterscheme": {
"description": "JSON scheme of start parameters for IC",
"type": "string"
},
"state": {
@ -3380,7 +3380,7 @@
"Name": {
"type": "string"
},
"Properties": {
"StartParameterScheme": {
"type": "string"
},
"State": {
@ -3415,7 +3415,7 @@
"Name": {
"type": "string"
},
"Properties": {
"StartParameterScheme": {
"type": "string"
},
"State": {

View file

@ -163,8 +163,8 @@ definitions:
name:
description: Name of the IC
type: string
properties:
description: Properties of IC as JSON string
startparameterscheme:
description: JSON scheme of start parameters for IC
type: string
state:
description: State of the IC
@ -431,7 +431,7 @@ definitions:
type: string
Name:
type: string
Properties:
StartParameterScheme:
type: string
State:
type: string
@ -459,7 +459,7 @@ definitions:
type: string
Name:
type: string
Properties:
StartParameterScheme:
type: string
State:
type: string

View file

@ -102,7 +102,7 @@ var ICA = database.InfrastructureComponent{
Location: "ACS Laboratory",
Description: "This is a test description",
//StateUpdateAt: time.Now().Format(time.RFC1123),
Properties: postgres.Jsonb{propertiesA},
StartParameterScheme: postgres.Jsonb{propertiesA},
}
var ICB = database.InfrastructureComponent{
@ -117,7 +117,7 @@ var ICB = database.InfrastructureComponent{
Location: "k8s",
Description: "A signal generator for testing purposes",
//StateUpdateAt: time.Now().Format(time.RFC1123),
Properties: postgres.Jsonb{propertiesB},
StartParameterScheme: postgres.Jsonb{propertiesB},
}
// Scenarios

View file

@ -57,7 +57,7 @@ type ICRequest struct {
State string `json:"state,omitempty"`
Location string `json:"location,omitempty"`
Description string `json:"description,omitempty"`
Properties postgres.Jsonb `json:"properties,omitempty"`
StartParameterScheme postgres.Jsonb `json:"startparameterscheme,omitempty"`
}
type ScenarioRequest struct {
@ -82,7 +82,7 @@ func addScenarioAndIC() (scenarioID uint, ICID uint) {
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
_, resp, _ := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newICA})
@ -100,7 +100,7 @@ func addScenarioAndIC() (scenarioID uint, ICID uint) {
State: helper.ICB.State,
Location: helper.ICB.Location,
Description: helper.ICB.Description,
Properties: helper.ICB.Properties,
StartParameterScheme: helper.ICB.StartParameterScheme,
}
_, resp, _ = helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newICB})

View file

@ -48,7 +48,7 @@ type ICRequest struct {
State string `json:"state,omitempty"`
Location string `json:"location,omitempty"`
Description string `json:"description,omitempty"`
Properties postgres.Jsonb `json:"properties,omitempty"`
StartParameterScheme postgres.Jsonb `json:"startparameterscheme,omitempty"`
}
func TestMain(m *testing.M) {
@ -111,7 +111,7 @@ func TestAddICAsAdmin(t *testing.T) {
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
code, resp, err = helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
@ -165,7 +165,7 @@ func TestAddICAsUser(t *testing.T) {
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
// This should fail with unprocessable entity 422 error code
@ -196,7 +196,7 @@ func TestUpdateICAsAdmin(t *testing.T) {
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
code, resp, err := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
@ -262,7 +262,7 @@ func TestUpdateICAsUser(t *testing.T) {
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
code, resp, err := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
@ -308,7 +308,7 @@ func TestDeleteICAsAdmin(t *testing.T) {
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
code, resp, err := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
@ -362,7 +362,7 @@ func TestDeleteICAsUser(t *testing.T) {
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
code, resp, err := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
@ -412,7 +412,7 @@ func TestGetAllICs(t *testing.T) {
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
code, resp, err := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newICA})
@ -429,7 +429,7 @@ func TestGetAllICs(t *testing.T) {
State: helper.ICB.State,
Location: helper.ICB.Location,
Description: helper.ICB.Description,
Properties: helper.ICB.Properties,
StartParameterScheme: helper.ICB.StartParameterScheme,
}
code, resp, err = helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newICB})
@ -476,7 +476,7 @@ func TestGetConfigsOfIC(t *testing.T) {
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
code, resp, err := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newICA})

View file

@ -38,7 +38,7 @@ type validNewIC struct {
Type string `form:"Type" validate:"required"`
Name string `form:"Name" 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"`
Location string `form:"Location" validate:"omitempty"`
Description string `form:"Description" validate:"omitempty"`
@ -51,7 +51,7 @@ type validUpdatedIC struct {
Type string `form:"Type" validate:"omitempty"`
Name string `form:"Name" 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"`
Location string `form:"Location" validate:"omitempty"`
Description string `form:"Description" validate:"omitempty"`
@ -88,7 +88,7 @@ func (r *AddICRequest) CreateIC() InfrastructureComponent {
s.Category = r.InfrastructureComponent.Category
s.Location = r.InfrastructureComponent.Location
s.Description = r.InfrastructureComponent.Description
s.Properties = r.InfrastructureComponent.Properties
s.StartParameterScheme = r.InfrastructureComponent.StartParameterScheme
if r.InfrastructureComponent.State != "" {
s.State = r.InfrastructureComponent.State
} else {
@ -147,11 +147,11 @@ func (r *UpdateICRequest) UpdatedIC(oldIC InfrastructureComponent) Infrastructur
var emptyJson postgres.Jsonb
// Serialize empty json and params
emptyJson_ser, _ := json.Marshal(emptyJson)
startParams_ser, _ := json.Marshal(r.InfrastructureComponent.Properties)
startParams_ser, _ := json.Marshal(r.InfrastructureComponent.StartParameterScheme)
opts := jsondiff.DefaultConsoleOptions()
diff, _ := jsondiff.Compare(emptyJson_ser, startParams_ser, &opts)
if diff.String() != "FullMatch" {
s.Properties = r.InfrastructureComponent.Properties
s.StartParameterScheme = r.InfrastructureComponent.StartParameterScheme
}
return s

View file

@ -64,7 +64,7 @@ type ICRequest struct {
State string `json:"state,omitempty"`
Location string `json:"location,omitempty"`
Description string `json:"description,omitempty"`
Properties postgres.Jsonb `json:"properties,omitempty"`
StartParameterScheme postgres.Jsonb `json:"startparameterscheme,omitempty"`
}
type ScenarioRequest struct {
@ -89,7 +89,7 @@ func addScenarioAndICAndConfig() (scenarioID uint, ICID uint, configID uint) {
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
_, resp, _ := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newICA})