Commit ef1dede7 authored by Sonja Happ's avatar Sonja Happ
Browse files

renaming: simulation model = component configuration

parent 5d63fc3e
......@@ -95,10 +95,10 @@ test:scenario:
variables:
TEST_FOLDER: routes/scenario
test:simulationmodel:
extends: test:scenario
test:component-configuration:
extends: test:database
variables:
TEST_FOLDER: routes/simulationmodel
TEST_FOLDER: routes/component-configuration
test:signal:
extends: test:database
......
......@@ -104,7 +104,7 @@ func GetDB() *gorm.DB {
func DropTables(db *gorm.DB) {
db.DropTableIfExists(&InfrastructureComponent{})
db.DropTableIfExists(&Signal{})
db.DropTableIfExists(&SimulationModel{})
db.DropTableIfExists(&ComponentConfiguration{})
db.DropTableIfExists(&File{})
db.DropTableIfExists(&Scenario{})
db.DropTableIfExists(&User{})
......@@ -118,7 +118,7 @@ func DropTables(db *gorm.DB) {
func MigrateModels(db *gorm.DB) {
db.AutoMigrate(&InfrastructureComponent{})
db.AutoMigrate(&Signal{})
db.AutoMigrate(&SimulationModel{})
db.AutoMigrate(&ComponentConfiguration{})
db.AutoMigrate(&File{})
db.AutoMigrate(&Scenario{})
db.AutoMigrate(&User{})
......
......@@ -107,8 +107,8 @@ func TestScenarioAssociations(t *testing.T) {
user0 := User0
userA := UserA
userB := UserB
modelA := SimulationModelA
modelB := SimulationModelB
configA := ConfigA
configB := ConfigB
dashboardA := DashboardA
dashboardB := DashboardB
......@@ -121,9 +121,9 @@ func TestScenarioAssociations(t *testing.T) {
assert.NoError(t, db.Create(&userA).Error) // Normal User
assert.NoError(t, db.Create(&userB).Error) // Normal User
// add simulation models to DB
assert.NoError(t, db.Create(&modelA).Error)
assert.NoError(t, db.Create(&modelB).Error)
// add component configurations to DB
assert.NoError(t, db.Create(&configA).Error)
assert.NoError(t, db.Create(&configB).Error)
// add dashboards to DB
assert.NoError(t, db.Create(&dashboardA).Error)
......@@ -136,9 +136,9 @@ func TestScenarioAssociations(t *testing.T) {
assert.NoError(t, db.Model(&scenarioB).Association("Users").Append(&userA).Error)
assert.NoError(t, db.Model(&scenarioB).Association("Users").Append(&userB).Error)
// add scenario has many simulation models associations
assert.NoError(t, db.Model(&scenarioA).Association("SimulationModels").Append(&modelA).Error)
assert.NoError(t, db.Model(&scenarioA).Association("SimulationModels").Append(&modelB).Error)
// add scenario has many component configurations associations
assert.NoError(t, db.Model(&scenarioA).Association("ComponentConfigurations").Append(&configA).Error)
assert.NoError(t, db.Model(&scenarioA).Association("ComponentConfigurations").Append(&configB).Error)
// Scenario HM Dashboards
assert.NoError(t, db.Model(&scenarioA).Association("Dashboards").Append(&dashboardA).Error)
......@@ -156,12 +156,12 @@ func TestScenarioAssociations(t *testing.T) {
"Expected to have %v Users. Has %v.", 2, len(users))
}
// Get simulation models of scenario1
var models []SimulationModel
assert.NoError(t, db.Model(&scenario1).Related(&models, "SimulationModels").Error)
if len(models) != 2 {
// Get component configurations of scenario1
var configs []ComponentConfiguration
assert.NoError(t, db.Model(&scenario1).Related(&configs, "ComponentConfigurations").Error)
if len(configs) != 2 {
assert.Fail(t, "Scenario Associations",
"Expected to have %v simulation models. Has %v.", 2, len(models))
"Expected to have %v component configs. Has %v.", 2, len(configs))
}
// Get dashboards of scenario1
......@@ -181,42 +181,42 @@ func TestICAssociations(t *testing.T) {
// create copies of global test data
icA := ICA
icB := ICB
modelA := SimulationModelA
modelB := SimulationModelB
configA := ConfigA
configB := ConfigB
// add ICs to DB
assert.NoError(t, db.Create(&icA).Error)
assert.NoError(t, db.Create(&icB).Error)
// add simulation models to DB
assert.NoError(t, db.Create(&modelA).Error)
assert.NoError(t, db.Create(&modelB).Error)
// add component configurations to DB
assert.NoError(t, db.Create(&configA).Error)
assert.NoError(t, db.Create(&configB).Error)
// add IC has many simulation models association to DB
assert.NoError(t, db.Model(&icA).Association("SimulationModels").Append(&modelA).Error)
assert.NoError(t, db.Model(&icA).Association("SimulationModels").Append(&modelB).Error)
// add IC has many component configurations association to DB
assert.NoError(t, db.Model(&icA).Association("ComponentConfigurations").Append(&configA).Error)
assert.NoError(t, db.Model(&icA).Association("ComponentConfigurations").Append(&configB).Error)
var ic1 InfrastructureComponent
assert.NoError(t, db.Find(&ic1, 1).Error, fmt.Sprintf("Find InfrastructureComponent with ID=1"))
assert.EqualValues(t, "Host_A", ic1.Host)
// Get simulation models of ic1
var models []SimulationModel
assert.NoError(t, db.Model(&ic1).Association("SimulationModels").Find(&models).Error)
if len(models) != 2 {
// Get Component Configurations of ic1
var configs []ComponentConfiguration
assert.NoError(t, db.Model(&ic1).Association("ComponentConfigurations").Find(&configs).Error)
if len(configs) != 2 {
assert.Fail(t, "InfrastructureComponent Associations",
"Expected to have %v SimulationModels. Has %v.", 2, len(models))
"Expected to have %v Component Configurations. Has %v.", 2, len(configs))
}
}
func TestSimulationModelAssociations(t *testing.T) {
func TestComponentConfigurationAssociations(t *testing.T) {
DropTables(db)
MigrateModels(db)
// create copies of global test data
modelA := SimulationModelA
modelB := SimulationModelB
configA := ConfigA
configB := ConfigB
outSignalA := OutSignalA
outSignalB := OutSignalB
inSignalA := InSignalA
......@@ -228,9 +228,9 @@ func TestSimulationModelAssociations(t *testing.T) {
icA := ICA
icB := ICB
// add simulation models to DB
assert.NoError(t, db.Create(&modelA).Error)
assert.NoError(t, db.Create(&modelB).Error)
// add Component Configurations to DB
assert.NoError(t, db.Create(&configA).Error)
assert.NoError(t, db.Create(&configB).Error)
// add signals to DB
assert.NoError(t, db.Create(&outSignalA).Error)
......@@ -248,42 +248,42 @@ func TestSimulationModelAssociations(t *testing.T) {
assert.NoError(t, db.Create(&icA).Error)
assert.NoError(t, db.Create(&icB).Error)
// add simulation model has many signals associations
assert.NoError(t, db.Model(&modelA).Association("InputMapping").Append(&inSignalA).Error)
assert.NoError(t, db.Model(&modelA).Association("InputMapping").Append(&inSignalB).Error)
assert.NoError(t, db.Model(&modelA).Association("OutputMapping").Append(&outSignalA).Error)
assert.NoError(t, db.Model(&modelA).Association("OutputMapping").Append(&outSignalB).Error)
// add Component Configuration has many signals associations
assert.NoError(t, db.Model(&configA).Association("InputMapping").Append(&inSignalA).Error)
assert.NoError(t, db.Model(&configA).Association("InputMapping").Append(&inSignalB).Error)
assert.NoError(t, db.Model(&configA).Association("OutputMapping").Append(&outSignalA).Error)
assert.NoError(t, db.Model(&configA).Association("OutputMapping").Append(&outSignalB).Error)
// add simulation model has many files associations
assert.NoError(t, db.Model(&modelA).Association("Files").Append(&fileC).Error)
assert.NoError(t, db.Model(&modelA).Association("Files").Append(&fileD).Error)
// add Component Configuration has many files associations
assert.NoError(t, db.Model(&configA).Association("Files").Append(&fileC).Error)
assert.NoError(t, db.Model(&configA).Association("Files").Append(&fileD).Error)
// associate simulation models with IC
assert.NoError(t, db.Model(&icA).Association("SimulationModels").Append(&modelA).Error)
assert.NoError(t, db.Model(&icA).Association("SimulationModels").Append(&modelB).Error)
// associate Component Configurations with IC
assert.NoError(t, db.Model(&icA).Association("ComponentConfigurations").Append(&configA).Error)
assert.NoError(t, db.Model(&icA).Association("ComponentConfigurations").Append(&configB).Error)
var model1 SimulationModel
assert.NoError(t, db.Find(&model1, 1).Error, fmt.Sprintf("Find SimulationModel with ID=1"))
assert.EqualValues(t, "SimulationModel_A", model1.Name)
var config1 ComponentConfiguration
assert.NoError(t, db.Find(&config1, 1).Error, fmt.Sprintf("Find ComponentConfiguration with ID=1"))
assert.EqualValues(t, ConfigA.Name, config1.Name)
// Check IC ID
if model1.ICID != 1 {
assert.Fail(t, "Simulation Model expected to have InfrastructureComponent ID 1, but is %v", model1.ICID)
if config1.ICID != 1 {
assert.Fail(t, "Component Configurations expected to have Infrastructure Component ID 1, but is %v", config1.ICID)
}
// Get OutputMapping signals of model1
// Get OutputMapping signals of config1
var signals []Signal
assert.NoError(t, db.Model(&model1).Where("Direction = ?", "out").Related(&signals, "OutputMapping").Error)
assert.NoError(t, db.Model(&config1).Where("Direction = ?", "out").Related(&signals, "OutputMapping").Error)
if len(signals) != 2 {
assert.Fail(t, "SimulationModel Associations",
assert.Fail(t, "ComponentConfiguration Associations",
"Expected to have %v Output Signals. Has %v.", 2, len(signals))
}
// Get files of model1
// Get files of config1
var files []File
assert.NoError(t, db.Model(&model1).Related(&files, "Files").Error)
assert.NoError(t, db.Model(&config1).Related(&files, "Files").Error)
if len(files) != 2 {
assert.Fail(t, "SimulationModel Associations",
assert.Fail(t, "ComponentConfiguration Associations",
"Expected to have %v Files. Has %v.", 2, len(files))
}
}
......
......@@ -65,35 +65,35 @@ type Scenario struct {
StartParameters postgres.Jsonb `json:"startParameters"`
// Users that have access to the scenario
Users []*User `json:"-" gorm:"many2many:user_scenarios;"`
// SimulationModels that belong to the scenario
SimulationModels []SimulationModel `json:"-" gorm:"foreignkey:ScenarioID" `
// ComponentConfigurations that belong to the scenario
ComponentConfigurations []ComponentConfiguration `json:"-" gorm:"foreignkey:ScenarioID" `
// Dashboards that belong to the Scenario
Dashboards []Dashboard `json:"-" gorm:"foreignkey:ScenarioID" `
}
// SimulationModel data model
type SimulationModel struct {
// ComponentConfiguration data model
type ComponentConfiguration struct {
Model
// Name of simulation model
// Name of Component Configuration
Name string `json:"name" gorm:"not null"`
// Number of output signals
OutputLength int `json:"outputLength" gorm:"default:0"`
// Number of input signals
InputLength int `json:"inputLength" gorm:"default:0"`
// Start parameters of simulation model as JSON
// Start parameters of Component Configuration as JSON
StartParameters postgres.Jsonb `json:"startParameters"`
// ID of Scenario to which simulation model belongs
// ID of Scenario to which Component Configuration belongs
ScenarioID uint `json:"scenarioID"`
// ID of IC associated with simulation model
// ID of IC associated with Component Configuration
ICID uint `json:"icID"`
// Mapping of output signals of the simulation model, order of signals is important
OutputMapping []Signal `json:"-" gorm:"foreignkey:SimulationModelID"`
// Mapping of input signals of the simulation model, order of signals is important
InputMapping []Signal `json:"-" gorm:"foreignkey:SimulationModelID"`
// Files of simulation model (can be CIM and other simulation model file formats)
Files []File `json:"-" gorm:"foreignkey:SimulationModelID"`
// Currently selected simulation model FileID
SelectedModelFileID uint `json:"selectedModelFileID" gorm:"default:0"`
// Mapping of output signals of the ComponentConfiguration, order of signals is important
OutputMapping []Signal `json:"-" gorm:"foreignkey:ConfigID"`
// Mapping of input signals of the Component Configuration, order of signals is important
InputMapping []Signal `json:"-" gorm:"foreignkey:ConfigID"`
// Files of Component Configuration (can be CIM and other ComponentConfiguration file formats)
Files []File `json:"-" gorm:"foreignkey:ConfigID"`
// Currently selected FileID
SelectedFileID uint `json:"selectedFileID" gorm:"default:0"`
}
// Signal data model
......@@ -107,8 +107,8 @@ type Signal struct {
Index uint `json:"index"`
// Direction of the signal (in or out)
Direction string `json:"direction"`
// ID of simulation model
SimulationModelID uint `json:"simulationModelID"`
// ID of Component Configuration
ConfigID uint `json:"configID"`
}
// InfrastructureComponent data model
......@@ -130,8 +130,8 @@ type InfrastructureComponent struct {
Properties postgres.Jsonb `json:"properties"`
// Raw properties of IC as JSON string
RawProperties postgres.Jsonb `json:"rawProperties"`
// SimulationModels in which the IC is used
SimulationModels []SimulationModel `json:"-" gorm:"foreignkey:ICID"`
// ComponentConfigurations in which the IC is used
ComponentConfigurations []ComponentConfiguration `json:"-" gorm:"foreignkey:ICID"`
}
// Dashboard data model
......@@ -195,8 +195,8 @@ type File struct {
ImageWidth uint `json:"imageWidth"`
// Last modification time of file
Date string `json:"date"`
// ID of model to which file belongs
SimulationModelID uint `json:"simulationModelID"`
// ID of Component Configuration to which file belongs
ConfigID uint `json:"configID"`
// ID of widget to which file belongs
WidgetID uint `json:"widgetID"`
// File itself
......
......@@ -42,7 +42,7 @@ const ModelInfrastructureComponent = ModelName("ic")
const ModelInfrastructureComponentAction = ModelName("icaction")
const ModelDashboard = ModelName("dashboard")
const ModelWidget = ModelName("widget")
const ModelSimulationModel = ModelName("simulationmodel")
const ModelComponentConfiguration = ModelName("component-configuration")
const ModelSignal = ModelName("signal")
const ModelFile = ModelName("file")
......@@ -76,7 +76,7 @@ var Roles = RoleActions{
ModelUser: crud,
ModelUsers: crud,
ModelScenario: crud,
ModelSimulationModel: crud,
ModelComponentConfiguration: crud,
ModelInfrastructureComponent: crud,
ModelInfrastructureComponentAction: crud,
ModelWidget: crud,
......@@ -88,7 +88,7 @@ var Roles = RoleActions{
ModelUser: _ru_,
ModelUsers: none,
ModelScenario: crud,
ModelSimulationModel: crud,
ModelComponentConfiguration: crud,
ModelInfrastructureComponent: _r__,
ModelInfrastructureComponentAction: _ru_,
ModelWidget: crud,
......@@ -98,7 +98,7 @@ var Roles = RoleActions{
},
"Guest": {
ModelScenario: _r__,
ModelSimulationModel: _r__,
ModelComponentConfiguration: _r__,
ModelDashboard: _r__,
ModelWidget: _r__,
ModelInfrastructureComponent: _r__,
......
......@@ -98,18 +98,18 @@ var ScenarioB = Scenario{
StartParameters: postgres.Jsonb{startParametersB},
}
// Simulation Models
// Component Configuration
var SimulationModelA = SimulationModel{
Name: "SimulationModel_A",
StartParameters: postgres.Jsonb{startParametersA},
SelectedModelFileID: 3,
var ConfigA = ComponentConfiguration{
Name: "Example simulation",
StartParameters: postgres.Jsonb{startParametersA},
SelectedFileID: 3,
}
var SimulationModelB = SimulationModel{
Name: "SimulationModel_B",
StartParameters: postgres.Jsonb{startParametersB},
SelectedModelFileID: 4,
var ConfigB = ComponentConfiguration{
Name: "VILLASnode gateway X",
StartParameters: postgres.Jsonb{startParametersB},
SelectedFileID: 4,
}
// Signals
......@@ -198,7 +198,7 @@ var customPropertiesLabel = json.RawMessage(`{"textSize" : "20", "fontColor" : 5
var customPropertiesButton = json.RawMessage(`{"toggle" : "Value1", "on_value" : "Value2", "off_value" : Value3}`)
var customPropertiesCustomActions = json.RawMessage(`{"actions" : "Value1", "icon" : "Value2"}`)
var customPropertiesGauge = json.RawMessage(`{ "valueMin": 0, "valueMax": 1}`)
var customPropertiesLamp = json.RawMessage(`{"simulationModel" : "null", "signal" : 0, "on_color" : 4, "off_color": 2 , "threshold" : 0.5}`)
var customPropertiesLamp = json.RawMessage(`{"signal" : 0, "on_color" : 4, "off_color": 2 , "threshold" : 0.5}`)
var WidgetA = Widget{
Name: "Label",
......@@ -327,8 +327,8 @@ func DBAddTestData(db *gorm.DB) error {
inSignalA := InSignalA
inSignalB := InSignalB
modelA := SimulationModelA
modelB := SimulationModelB
configA := ConfigA
configB := ConfigB
dashboardA := DashboardA
dashboardB := DashboardB
......@@ -368,9 +368,9 @@ func DBAddTestData(db *gorm.DB) error {
err = db.Create(&outSignalA).Error
err = db.Create(&outSignalB).Error
// Simulation Models
err = db.Create(&modelA).Error
err = db.Create(&modelB).Error
// Component Configuration
err = db.Create(&configA).Error
err = db.Create(&configB).Error
// Dashboards
err = db.Create(&dashboardA).Error
......@@ -400,9 +400,9 @@ func DBAddTestData(db *gorm.DB) error {
err = db.Model(&scenarioA).Association("Users").Append(&userC).Error
err = db.Model(&scenarioA).Association("Users").Append(&user0).Error
// Scenario HM SimulationModels
err = db.Model(&scenarioA).Association("SimulationModels").Append(&modelA).Error
err = db.Model(&scenarioA).Association("SimulationModels").Append(&modelB).Error
// Scenario HM Component Configurations
err = db.Model(&scenarioA).Association("ComponentConfigurations").Append(&configA).Error
err = db.Model(&scenarioA).Association("ComponentConfigurations").Append(&configB).Error
// Scenario HM Dashboards
err = db.Model(&scenarioA).Association("Dashboards").Append(&dashboardA).Error
......@@ -415,19 +415,19 @@ func DBAddTestData(db *gorm.DB) error {
err = db.Model(&dashboardA).Association("Widgets").Append(&widgetD).Error
err = db.Model(&dashboardA).Association("Widgets").Append(&widgetE).Error
// SimulationModel HM Signals
err = db.Model(&modelA).Association("InputMapping").Append(&inSignalA).Error
err = db.Model(&modelA).Association("InputMapping").Append(&inSignalB).Error
err = db.Model(&modelA).Association("InputMapping").Append(&outSignalA).Error
err = db.Model(&modelA).Association("InputMapping").Append(&outSignalB).Error
// ComponentConfiguration HM Signals
err = db.Model(&configA).Association("InputMapping").Append(&inSignalA).Error
err = db.Model(&configA).Association("InputMapping").Append(&inSignalB).Error
err = db.Model(&configA).Association("InputMapping").Append(&outSignalA).Error
err = db.Model(&configA).Association("InputMapping").Append(&outSignalB).Error
// SimulationModel HM Files
err = db.Model(&modelA).Association("Files").Append(&fileC).Error
err = db.Model(&modelA).Association("Files").Append(&fileD).Error
// ComponentConfiguration HM Files
err = db.Model(&configA).Association("Files").Append(&fileC).Error
err = db.Model(&configA).Association("Files").Append(&fileD).Error
// InfrastructureComponent HM SimulationModels
err = db.Model(&ICA).Association("SimulationModels").Append(&modelA).Error
err = db.Model(&ICA).Association("SimulationModels").Append(&modelB).Error
// InfrastructureComponent HM ComponentConfigurations
err = db.Model(&ICA).Association("ComponentConfigurations").Append(&configA).Error
err = db.Model(&ICA).Association("ComponentConfigurations").Append(&configB).Error
// Widget HM Files
err = db.Model(&widgetA).Association("Files").Append(&fileA).Error
......
This diff is collapsed.
......@@ -62,12 +62,12 @@ type ResponseScenario struct {
scenario database.Scenario
}
type ResponseSimulationModels struct {
simulationModels []database.SimulationModel
type ResponseConfigs struct {
configs []database.ComponentConfiguration
}
type ResponseSimulationModel struct {
simulationModel database.SimulationModel
type ResponseConfig struct {
config database.ComponentConfiguration
}
type ResponseDashboards struct {
......
This diff is collapsed.
This diff is collapsed.
/** Simulationmodel package, endpoints.
/** component_configuration package, endpoints.
*
* @author Sonja Happ <sonja.happ@eonerc.rwth-aachen.de>
* @copyright 2014-2019, Institute for Automation of Complex Power Systems, EONERC
......@@ -19,7 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
package simulationmodel
package component_configuration
import (
"git.rwth-aachen.de/acs/public/villas/web-backend-go/helper"
......@@ -31,27 +31,27 @@ import (
"git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/scenario"
)
func RegisterSimulationModelEndpoints(r *gin.RouterGroup) {
r.GET("", getSimulationModels)
r.POST("", addSimulationModel)
r.PUT("/:modelID", updateSimulationModel)
r.GET("/:modelID", getSimulationModel)
r.DELETE("/:modelID", deleteSimulationModel)
func RegisterComponentConfigurationEndpoints(r *gin.RouterGroup) {
r.GET("", getConfigs)
r.POST("", addConfig)
r.PUT("/:configID", updateConfig)
r.GET("/:configID", getConfig)
r.DELETE("/:configID", deleteConfig)
}
// getSimulationModels godoc
// @Summary Get all simulation models of scenario
// @ID getSimulationModels
// getConfigs godoc
// @Summary Get all component configurations of scenario
// @ID getConfigs
// @Produce json
// @Tags simulationModels
// @Success 200 {object} docs.ResponseSimulationModels "Simulation models which belong to scenario"
// @Tags component-configurations
// @Success 200 {object} docs.ResponseConfigs "Component configurations which belong to scenario"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param scenarioID query int true "Scenario ID"
// @Router /models [get]
func getSimulationModels(c *gin.Context) {
// @Router /configs [get]
func getConfigs(c *gin.Context) {
ok, so := scenario.CheckPermissions(c, database.Read, "query", -1)
if !ok {
......@@ -59,32 +59,32 @@ func getSimulationModels(c *gin.Context) {
}
db := database.GetDB()
var models []database.SimulationModel
err := db.Order("ID asc").Model(so).Related(&models, "Models").Error
var configs []database.ComponentConfiguration
err := db.Order("ID asc").Model(so).Related(&configs, "ComponentConfigurations").Error
if !helper.DBError(c, err) {
c.JSON(http.StatusOK, gin.H{"simulationModels": models})
c.JSON(http.StatusOK, gin.H{"configs": configs})
}
}
// addSimulationModel godoc
// @Summary Add a simulation model to a scenario
// @ID addSimulationModel
// addConfig godoc
// @Summary Add a component configuration to a scenario
// @ID addConfig
// @Accept json
// @Produce json
// @Tags simulationModels
// @Success 200 {object} docs.ResponseSimulationModel "simulation model that was added"
// @Tags component-configurations
// @Success 200 {object} docs.ResponseConfig "Component configuration that was added"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param inputSimulationModel body simulationmodel.addSimulationModelRequest true "Simulation model to be added incl. IDs of scenario and IC"
// @Router /models [post]
func addSimulationModel(c *gin.Context) {
// @Param inputConfig body component_configuration.addConfigRequest true "component configuration to be added incl. IDs of scenario and IC"
// @Router /configs [post]
func addConfig(c *gin.Context) {
// Bind the request to JSON
var req addSimulationModelRequest
var req addConfigRequest
err := c.ShouldBindJSON(&req)
if err != nil {
helper.BadRequestError(c, "Bad request. Error binding form data to JSON: "+err.Error())
......@@ -97,46 +97,46 @@ func addSimulationModel(c *gin.Context) {
return
}
// Create the new simulation model from the request
newSimulationModel := req.createSimulationModel()
// Create the new Component Configuration from the request
newConfig := req.createConfig()
// check access to the scenario
ok, _ := scenario.CheckPermissions(c, database.Update, "body", int(newSimulationModel.ScenarioID))
ok, _ := scenario.CheckPermissions(c, database.Update, "body", int(newConfig.ScenarioID))
if !ok {
return
}