mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
allow to set optional properties of IC to empty strings
This commit is contained in:
parent
e383df74ab
commit
71e69688a6
1 changed files with 15 additions and 39 deletions
|
@ -107,30 +107,20 @@ func (r *AddICRequest) createIC(receivedViaAMQP bool) (InfrastructureComponent,
|
||||||
*action.Properties.Category = r.InfrastructureComponent.Category
|
*action.Properties.Category = r.InfrastructureComponent.Category
|
||||||
|
|
||||||
// set optional properties
|
// set optional properties
|
||||||
if r.InfrastructureComponent.Description != "" {
|
action.Properties.Description = new(string)
|
||||||
action.Properties.Description = new(string)
|
*action.Properties.Description = r.InfrastructureComponent.Description
|
||||||
*action.Properties.Description = r.InfrastructureComponent.Description
|
|
||||||
}
|
|
||||||
|
|
||||||
if r.InfrastructureComponent.Location != "" {
|
action.Properties.Location = new(string)
|
||||||
action.Properties.Location = new(string)
|
*action.Properties.Location = r.InfrastructureComponent.Location
|
||||||
*action.Properties.Location = r.InfrastructureComponent.Location
|
|
||||||
}
|
|
||||||
|
|
||||||
if r.InfrastructureComponent.APIURL != "" {
|
action.Properties.API_url = new(string)
|
||||||
action.Properties.API_url = new(string)
|
*action.Properties.API_url = r.InfrastructureComponent.APIURL
|
||||||
*action.Properties.API_url = r.InfrastructureComponent.APIURL
|
|
||||||
}
|
|
||||||
|
|
||||||
if r.InfrastructureComponent.WebsocketURL != "" {
|
action.Properties.WS_url = new(string)
|
||||||
action.Properties.WS_url = new(string)
|
*action.Properties.WS_url = r.InfrastructureComponent.WebsocketURL
|
||||||
*action.Properties.WS_url = r.InfrastructureComponent.WebsocketURL
|
|
||||||
}
|
|
||||||
|
|
||||||
if r.InfrastructureComponent.UUID != "" {
|
action.Properties.UUID = new(string)
|
||||||
action.Properties.UUID = new(string)
|
*action.Properties.UUID = r.InfrastructureComponent.UUID
|
||||||
*action.Properties.UUID = r.InfrastructureComponent.UUID
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Println("AMQP: Sending request to create new IC")
|
log.Println("AMQP: Sending request to create new IC")
|
||||||
err = sendActionAMQP(action)
|
err = sendActionAMQP(action)
|
||||||
|
@ -162,18 +152,6 @@ func (r *UpdateICRequest) updatedIC(oldIC InfrastructureComponent) Infrastructur
|
||||||
// Use the old InfrastructureComponent as a basis for the updated InfrastructureComponent `s`
|
// Use the old InfrastructureComponent as a basis for the updated InfrastructureComponent `s`
|
||||||
s := oldIC
|
s := oldIC
|
||||||
|
|
||||||
if r.InfrastructureComponent.UUID != "" {
|
|
||||||
s.UUID = r.InfrastructureComponent.UUID
|
|
||||||
}
|
|
||||||
|
|
||||||
if r.InfrastructureComponent.WebsocketURL != "" {
|
|
||||||
s.WebsocketURL = r.InfrastructureComponent.WebsocketURL
|
|
||||||
}
|
|
||||||
|
|
||||||
if r.InfrastructureComponent.APIURL != "" {
|
|
||||||
s.APIURL = r.InfrastructureComponent.APIURL
|
|
||||||
}
|
|
||||||
|
|
||||||
if r.InfrastructureComponent.Type != "" {
|
if r.InfrastructureComponent.Type != "" {
|
||||||
s.Type = r.InfrastructureComponent.Type
|
s.Type = r.InfrastructureComponent.Type
|
||||||
}
|
}
|
||||||
|
@ -190,13 +168,11 @@ func (r *UpdateICRequest) updatedIC(oldIC InfrastructureComponent) Infrastructur
|
||||||
s.State = r.InfrastructureComponent.State
|
s.State = r.InfrastructureComponent.State
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.InfrastructureComponent.Location != "" {
|
s.UUID = r.InfrastructureComponent.UUID
|
||||||
s.Location = r.InfrastructureComponent.Location
|
s.WebsocketURL = r.InfrastructureComponent.WebsocketURL
|
||||||
}
|
s.APIURL = r.InfrastructureComponent.APIURL
|
||||||
|
s.Location = r.InfrastructureComponent.Location
|
||||||
if r.InfrastructureComponent.Description != "" {
|
s.Description = r.InfrastructureComponent.Description
|
||||||
s.Description = r.InfrastructureComponent.Description
|
|
||||||
}
|
|
||||||
|
|
||||||
// set last update time
|
// set last update time
|
||||||
s.StateUpdateAt = time.Now().Format(time.RFC1123)
|
s.StateUpdateAt = time.Now().Format(time.RFC1123)
|
||||||
|
|
Loading…
Add table
Reference in a new issue