Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
VILLASframework
VILLASweb-backend-go
Commits
bff9efa0
Commit
bff9efa0
authored
Mar 04, 2020
by
Sonja Happ
Browse files
WIP: start renaming of simulaton model to component configuration in IC endpoints
parent
11a0c53b
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
routes/infrastructure-component/ic_endpoints.go
View file @
bff9efa0
...
...
@@ -35,7 +35,7 @@ func RegisterICEndpoints(r *gin.RouterGroup) {
r
.
PUT
(
"/:ICID"
,
updateIC
)
r
.
GET
(
"/:ICID"
,
getIC
)
r
.
DELETE
(
"/:ICID"
,
deleteIC
)
r
.
GET
(
"/:ICID/
model
s"
,
getConfigsOfIC
)
r
.
GET
(
"/:ICID/
config
s"
,
getConfigsOfIC
)
}
// getICs godoc
...
...
@@ -216,7 +216,7 @@ func deleteIC(c *gin.Context) {
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Param Authorization header string true "Authorization token"
// @Param ICID path int true "Infrastructure Component ID"
// @Router /ic/{ICID}/
model
s [get]
// @Router /ic/{ICID}/
config
s [get]
func
getConfigsOfIC
(
c
*
gin
.
Context
)
{
ok
,
s
:=
CheckPermissions
(
c
,
database
.
ModelInfrastructureComponent
,
database
.
Read
,
true
)
...
...
@@ -224,10 +224,10 @@ func getConfigsOfIC(c *gin.Context) {
return
}
// get all associated
simulation model
s
all
Model
s
,
_
,
err
:=
s
.
get
Model
s
()
// get all associated
configuration
s
all
Config
s
,
_
,
err
:=
s
.
get
Config
s
()
if
!
helper
.
DBError
(
c
,
err
)
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"
simulationModel
s"
:
all
Model
s
})
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"
config
s"
:
all
Config
s
})
}
}
routes/infrastructure-component/ic_methods.go
View file @
bff9efa0
...
...
@@ -54,10 +54,10 @@ func (s *InfrastructureComponent) update(updatedIC InfrastructureComponent) erro
func
(
s
*
InfrastructureComponent
)
delete
()
error
{
db
:=
database
.
GetDB
()
no_
simulationmodel
s
:=
db
.
Model
(
s
)
.
Association
(
"SimulationModels"
)
.
Count
()
no_
config
s
:=
db
.
Model
(
s
)
.
Association
(
"SimulationModels"
)
.
Count
()
if
no_
simulationmodel
s
>
0
{
return
fmt
.
Errorf
(
"InfrastructureComponent cannot be deleted as it is still used in
SimulationModel
s (active or dangling)"
)
if
no_
config
s
>
0
{
return
fmt
.
Errorf
(
"InfrastructureComponent cannot be deleted as it is still used in
configuration
s (active or dangling)"
)
}
// delete InfrastructureComponent from DB (does NOT remain as dangling)
...
...
@@ -65,9 +65,9 @@ func (s *InfrastructureComponent) delete() error {
return
err
}
func
(
s
*
InfrastructureComponent
)
get
Model
s
()
([]
database
.
SimulationModel
,
int
,
error
)
{
func
(
s
*
InfrastructureComponent
)
get
Config
s
()
([]
database
.
SimulationModel
,
int
,
error
)
{
db
:=
database
.
GetDB
()
var
model
s
[]
database
.
SimulationModel
err
:=
db
.
Order
(
"ID asc"
)
.
Model
(
s
)
.
Related
(
&
model
s
,
"SimulationModels"
)
.
Error
return
model
s
,
len
(
model
s
),
err
var
config
s
[]
database
.
SimulationModel
err
:=
db
.
Order
(
"ID asc"
)
.
Model
(
s
)
.
Related
(
&
config
s
,
"SimulationModels"
)
.
Error
return
config
s
,
len
(
config
s
),
err
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment