-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #277 from com-pas/add-websocket-support
Added Websocket support for creating and updating the SCL File
- Loading branch information
Showing
86 changed files
with
3,206 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...src/main/java/org/lfenergy/compas/scl/data/websocket/event/CompasSclDataEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// SPDX-FileCopyrightText: 2022 Alliander N.V. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.lfenergy.compas.scl.data.websocket.event; | ||
|
||
import io.quarkus.vertx.ConsumeEvent; | ||
import org.lfenergy.compas.core.websocket.WebsocketHandler; | ||
import org.lfenergy.compas.scl.data.service.CompasSclDataService; | ||
import org.lfenergy.compas.scl.data.websocket.event.model.CreateEventRequest; | ||
import org.lfenergy.compas.scl.data.websocket.event.model.GetEventRequest; | ||
import org.lfenergy.compas.scl.data.websocket.event.model.GetVersionEventRequest; | ||
import org.lfenergy.compas.scl.data.websocket.event.model.UpdateEventRequest; | ||
import org.lfenergy.compas.scl.data.websocket.v1.model.CreateWsResponse; | ||
import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsResponse; | ||
import org.lfenergy.compas.scl.data.websocket.v1.model.UpdateWsResponse; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
|
||
/** | ||
* Event Handler used to execute the validation asynchronized. | ||
*/ | ||
@ApplicationScoped | ||
public class CompasSclDataEventHandler { | ||
private final CompasSclDataService compasSclDataService; | ||
|
||
@Inject | ||
public CompasSclDataEventHandler(CompasSclDataService compasSclDataService) { | ||
this.compasSclDataService = compasSclDataService; | ||
} | ||
|
||
@ConsumeEvent(value = "create-ws", blocking = true) | ||
public void createWebsocketsEvent(CreateEventRequest request) { | ||
new WebsocketHandler<CreateWsResponse>().execute(request.getSession(), () -> { | ||
var response = new CreateWsResponse(); | ||
response.setSclData(compasSclDataService.create(request.getType(), request.getName(), request.getWho(), | ||
request.getComment(), request.getSclData())); | ||
return response; | ||
}); | ||
} | ||
|
||
@ConsumeEvent(value = "get-ws") | ||
public void getWebsocketsEvent(GetEventRequest request) { | ||
new WebsocketHandler<GetWsResponse>().execute(request.getSession(), () -> { | ||
var response = new GetWsResponse(); | ||
response.setSclData(compasSclDataService.findByUUID(request.getType(), request.getId())); | ||
return response; | ||
}); | ||
} | ||
|
||
@ConsumeEvent(value = "get-version-ws") | ||
public void getVersionWebsocketsEvent(GetVersionEventRequest request) { | ||
new WebsocketHandler<GetWsResponse>().execute(request.getSession(), () -> { | ||
var response = new GetWsResponse(); | ||
response.setSclData(compasSclDataService.findByUUID(request.getType(), request.getId(), request.getVersion())); | ||
return response; | ||
}); | ||
} | ||
|
||
@ConsumeEvent(value = "update-ws", blocking = true) | ||
public void updateWebsocketsEvent(UpdateEventRequest request) { | ||
new WebsocketHandler<UpdateWsResponse>().execute(request.getSession(), () -> { | ||
var response = new UpdateWsResponse(); | ||
response.setSclData(compasSclDataService.update(request.getType(), request.getId(), request.getChangeSetType(), | ||
request.getWho(), request.getComment(), request.getSclData())); | ||
return response; | ||
}); | ||
} | ||
} |
Oops, something went wrong.