Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFS
controller
Commits
b4ef3fe7
Commit
b4ef3fe7
authored
1 year ago
by
Vasilis Katopodis
Browse files
Options
Downloads
Patches
Plain Diff
fix: remove duplicate subscription in automation service
parent
8cd8e0d9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/automation/src/main/java/eu/teraflow/automation/AutomationServiceImpl.java
+40
-42
40 additions, 42 deletions
...in/java/eu/teraflow/automation/AutomationServiceImpl.java
with
40 additions
and
42 deletions
src/automation/src/main/java/eu/teraflow/automation/AutomationServiceImpl.java
+
40
−
42
View file @
b4ef3fe7
...
@@ -42,53 +42,51 @@ public class AutomationServiceImpl implements AutomationService {
...
@@ -42,53 +42,51 @@ public class AutomationServiceImpl implements AutomationService {
@Override
@Override
public
Uni
<
Device
>
addDevice
(
String
deviceId
)
{
public
Uni
<
Device
>
addDevice
(
String
deviceId
)
{
final
var
deserializedDeviceUni
=
contextService
.
getDevice
(
deviceId
);
final
var
deserializedDeviceUni
=
contextService
.
getDevice
(
deviceId
);
deserializedDeviceUni
deserializedDeviceUni
.
onFailure
()
.
onFailure
()
.
recoverWithNull
()
.
recoverWithNull
()
.
subscribe
()
.
invoke
(
device
->
processDevice
(
device
,
deviceId
));
.
with
(
device
->
{
final
var
id
=
deviceId
;
if
(
device
==
null
)
{
LOGGER
.
warnf
(
"%s is null. Ignoring..."
,
device
);
return
;
}
if
(
device
.
isEnabled
())
{
LOGGER
.
warnf
(
"%s has already been enabled. Ignoring..."
,
device
);
return
;
}
// LOGGER.infof(MESSAGE, device);
final
var
initialConfiguration
=
deviceService
.
getInitialConfiguration
(
device
.
getDeviceId
());
device
.
enableDevice
();
LOGGER
.
infof
(
"Enabled device [%s]"
,
id
);
initialConfiguration
.
subscribe
()
.
with
(
deviceConfig
->
{
device
.
setDeviceConfiguration
(
deviceConfig
);
final
var
configuredDeviceIdUni
=
deviceService
.
configureDevice
(
device
);
configuredDeviceIdUni
.
subscribe
()
.
with
(
configuredDeviceId
->
LOGGER
.
infof
(
"Device [%s] has been successfully enabled and configured with %s.\n"
,
id
,
deviceConfig
));
});
});
return
deserializedDeviceUni
;
return
deserializedDeviceUni
;
}
}
private
void
processDevice
(
Device
device
,
String
deviceId
)
{
if
(
device
==
null
)
{
LOGGER
.
warnf
(
"%s is null. Ignoring..."
,
device
);
return
;
}
if
(
device
.
isEnabled
())
{
LOGGER
.
warnf
(
"%s has already been enabled. Ignoring..."
,
device
);
return
;
}
enableAndConfigureDevice
(
device
,
deviceId
);
}
private
void
enableAndConfigureDevice
(
Device
device
,
String
deviceId
)
{
final
var
initialConfiguration
=
deviceService
.
getInitialConfiguration
(
device
.
getDeviceId
());
device
.
enableDevice
();
LOGGER
.
infof
(
"Enabled device [%s]"
,
deviceId
);
initialConfiguration
.
subscribe
()
.
with
(
deviceConfig
->
setDeviceConfiguration
(
device
,
deviceId
,
deviceConfig
));
}
private
void
setDeviceConfiguration
(
Device
device
,
String
deviceId
,
DeviceConfig
deviceConfig
)
{
device
.
setDeviceConfiguration
(
deviceConfig
);
final
var
configuredDeviceIdUni
=
deviceService
.
configureDevice
(
device
);
configuredDeviceIdUni
.
subscribe
()
.
with
(
configuredDeviceId
->
LOGGER
.
infof
(
"Device [%s] has been successfully enabled and configured with %s.\n"
,
deviceId
,
deviceConfig
));
}
@Override
@Override
public
Uni
<
Device
>
deleteDevice
(
String
deviceId
)
{
public
Uni
<
Device
>
deleteDevice
(
String
deviceId
)
{
final
var
deserializedDeviceUni
=
contextService
.
getDevice
(
deviceId
);
final
var
deserializedDeviceUni
=
contextService
.
getDevice
(
deviceId
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment