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

@ -49,15 +49,15 @@ type ConfigRequest struct {
}
type ICRequest struct {
UUID string `json:"uuid,omitempty"`
WebsocketURL string `json:"websocketurl,omitempty"`
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Category string `json:"category,omitempty"`
State string `json:"state,omitempty"`
Location string `json:"location,omitempty"`
Description string `json:"description,omitempty"`
Properties postgres.Jsonb `json:"properties,omitempty"`
UUID string `json:"uuid,omitempty"`
WebsocketURL string `json:"websocketurl,omitempty"`
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Category string `json:"category,omitempty"`
State string `json:"state,omitempty"`
Location string `json:"location,omitempty"`
Description string `json:"description,omitempty"`
StartParameterScheme postgres.Jsonb `json:"startparameterscheme,omitempty"`
}
type ScenarioRequest struct {
@ -74,15 +74,15 @@ func addScenarioAndIC() (scenarioID uint, ICID uint) {
// POST $newICA
newICA := ICRequest{
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
_, resp, _ := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newICA})
@ -92,15 +92,15 @@ func addScenarioAndIC() (scenarioID uint, ICID uint) {
// POST a second IC to change to that IC during testing
newICB := ICRequest{
UUID: helper.ICB.UUID,
WebsocketURL: helper.ICB.WebsocketURL,
Type: helper.ICB.Type,
Name: helper.ICB.Name,
Category: helper.ICB.Category,
State: helper.ICB.State,
Location: helper.ICB.Location,
Description: helper.ICB.Description,
Properties: helper.ICB.Properties,
UUID: helper.ICB.UUID,
WebsocketURL: helper.ICB.WebsocketURL,
Type: helper.ICB.Type,
Name: helper.ICB.Name,
Category: helper.ICB.Category,
State: helper.ICB.State,
Location: helper.ICB.Location,
Description: helper.ICB.Description,
StartParameterScheme: helper.ICB.StartParameterScheme,
}
_, resp, _ = helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newICB})

View file

@ -39,16 +39,16 @@ import (
var router *gin.Engine
type ICRequest struct {
UUID string `json:"uuid,omitempty"`
WebsocketURL string `json:"websocketurl,omitempty"`
APIURL string `json:"apiurl,omitempty"`
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Category string `json:"category,omitempty"`
State string `json:"state,omitempty"`
Location string `json:"location,omitempty"`
Description string `json:"description,omitempty"`
Properties postgres.Jsonb `json:"properties,omitempty"`
UUID string `json:"uuid,omitempty"`
WebsocketURL string `json:"websocketurl,omitempty"`
APIURL string `json:"apiurl,omitempty"`
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Category string `json:"category,omitempty"`
State string `json:"state,omitempty"`
Location string `json:"location,omitempty"`
Description string `json:"description,omitempty"`
StartParameterScheme postgres.Jsonb `json:"startparameterscheme,omitempty"`
}
func TestMain(m *testing.M) {
@ -102,16 +102,16 @@ func TestAddICAsAdmin(t *testing.T) {
// test POST ic/ $newIC
newIC := ICRequest{
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
APIURL: helper.ICB.APIURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
APIURL: helper.ICB.APIURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
code, resp, err = helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
@ -157,15 +157,15 @@ func TestAddICAsUser(t *testing.T) {
// test POST ic/ $newIC
newIC := ICRequest{
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
// This should fail with unprocessable entity 422 error code
@ -188,15 +188,15 @@ func TestUpdateICAsAdmin(t *testing.T) {
// test POST ic/ $newIC
newIC := ICRequest{
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
code, resp, err := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
@ -254,15 +254,15 @@ func TestUpdateICAsUser(t *testing.T) {
// test POST ic/ $newIC
newIC := ICRequest{
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
code, resp, err := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
@ -300,15 +300,15 @@ func TestDeleteICAsAdmin(t *testing.T) {
// test POST ic/ $newIC
newIC := ICRequest{
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
code, resp, err := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
@ -354,15 +354,15 @@ func TestDeleteICAsUser(t *testing.T) {
// test POST ic/ $newIC
newIC := ICRequest{
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
code, resp, err := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newIC})
@ -404,15 +404,15 @@ func TestGetAllICs(t *testing.T) {
// test POST ic/ $newICA
newICA := ICRequest{
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
code, resp, err := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newICA})
@ -421,15 +421,15 @@ func TestGetAllICs(t *testing.T) {
// test POST ic/ $newICB
newICB := ICRequest{
UUID: helper.ICB.UUID,
WebsocketURL: helper.ICB.WebsocketURL,
Type: helper.ICB.Type,
Name: helper.ICB.Name,
Category: helper.ICB.Category,
State: helper.ICB.State,
Location: helper.ICB.Location,
Description: helper.ICB.Description,
Properties: helper.ICB.Properties,
UUID: helper.ICB.UUID,
WebsocketURL: helper.ICB.WebsocketURL,
Type: helper.ICB.Type,
Name: helper.ICB.Name,
Category: helper.ICB.Category,
State: helper.ICB.State,
Location: helper.ICB.Location,
Description: helper.ICB.Description,
StartParameterScheme: helper.ICB.StartParameterScheme,
}
code, resp, err = helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newICB})
@ -468,15 +468,15 @@ func TestGetConfigsOfIC(t *testing.T) {
// test POST ic/ $newICA
newICA := ICRequest{
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
code, resp, err := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newICA})

View file

@ -32,29 +32,29 @@ import (
var validate *validator.Validate
type validNewIC struct {
UUID string `form:"UUID" validate:"required"`
WebsocketURL string `form:"WebsocketURL" validate:"omitempty"`
APIURL string `form:"APIURL" validate:"omitempty"`
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"`
State string `form:"State" validate:"omitempty"`
Location string `form:"Location" validate:"omitempty"`
Description string `form:"Description" validate:"omitempty"`
UUID string `form:"UUID" validate:"required"`
WebsocketURL string `form:"WebsocketURL" validate:"omitempty"`
APIURL string `form:"APIURL" validate:"omitempty"`
Type string `form:"Type" validate:"required"`
Name string `form:"Name" validate:"required"`
Category string `form:"Category" validate:"required"`
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"`
}
type validUpdatedIC struct {
UUID string `form:"UUID" validate:"omitempty"`
WebsocketURL string `form:"WebsocketURL" validate:"omitempty"`
APIURL string `form:"APIURL" validate:"omitempty"`
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"`
State string `form:"State" validate:"omitempty"`
Location string `form:"Location" validate:"omitempty"`
Description string `form:"Description" validate:"omitempty"`
UUID string `form:"UUID" validate:"omitempty"`
WebsocketURL string `form:"WebsocketURL" validate:"omitempty"`
APIURL string `form:"APIURL" validate:"omitempty"`
Type string `form:"Type" validate:"omitempty"`
Name string `form:"Name" validate:"omitempty"`
Category string `form:"Category" 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"`
}
type AddICRequest struct {
@ -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

@ -56,15 +56,15 @@ type ConfigRequest struct {
}
type ICRequest struct {
UUID string `json:"uuid,omitempty"`
WebsocketURL string `json:"websocketurl,omitempty"`
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Category string `json:"category,omitempty"`
State string `json:"state,omitempty"`
Location string `json:"location,omitempty"`
Description string `json:"description,omitempty"`
Properties postgres.Jsonb `json:"properties,omitempty"`
UUID string `json:"uuid,omitempty"`
WebsocketURL string `json:"websocketurl,omitempty"`
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Category string `json:"category,omitempty"`
State string `json:"state,omitempty"`
Location string `json:"location,omitempty"`
Description string `json:"description,omitempty"`
StartParameterScheme postgres.Jsonb `json:"startparameterscheme,omitempty"`
}
type ScenarioRequest struct {
@ -81,15 +81,15 @@ func addScenarioAndICAndConfig() (scenarioID uint, ICID uint, configID uint) {
// POST $newICA
newICA := ICRequest{
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
Properties: helper.ICA.Properties,
UUID: helper.ICA.UUID,
WebsocketURL: helper.ICA.WebsocketURL,
Type: helper.ICA.Type,
Name: helper.ICA.Name,
Category: helper.ICA.Category,
State: helper.ICA.State,
Location: helper.ICA.Location,
Description: helper.ICA.Description,
StartParameterScheme: helper.ICA.StartParameterScheme,
}
_, resp, _ := helper.TestEndpoint(router, token,
"/api/ic", "POST", helper.KeyModels{"ic": newICA})