-
Notifications
You must be signed in to change notification settings - Fork 3
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 #18 from com-pas/develop
Create first POC Version to test integration with all components
- Loading branch information
Showing
78 changed files
with
9,580 additions
and
405 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
...java/org/lfenergy/compas/scl/auto/alignment/rest/CompasSclAutoAlignmentConfiguration.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,23 @@ | ||
// SPDX-FileCopyrightText: 2021 Alliander N.V. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.lfenergy.compas.scl.auto.alignment.rest; | ||
|
||
import io.quarkus.runtime.annotations.RegisterForReflection; | ||
import org.lfenergy.compas.core.commons.ElementConverter; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.inject.Produces; | ||
|
||
/** | ||
* Create Beans from other dependencies that are used in the application. | ||
*/ | ||
@RegisterForReflection(targets = {com.powsybl.sld.library.Components.class, | ||
com.powsybl.sld.library.Component.class}) | ||
public class CompasSclAutoAlignmentConfiguration { | ||
@Produces | ||
@ApplicationScoped | ||
public ElementConverter createElementConverter() { | ||
return new ElementConverter(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/org/lfenergy/compas/scl/auto/alignment/rest/UserInfoProperties.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,13 @@ | ||
// SPDX-FileCopyrightText: 2021 Alliander N.V. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.lfenergy.compas.scl.auto.alignment.rest; | ||
|
||
import io.smallrye.config.ConfigMapping; | ||
import io.smallrye.config.WithName; | ||
|
||
@ConfigMapping(prefix = "compas.userinfo") | ||
public interface UserInfoProperties { | ||
@WithName("who.claimname") | ||
String who(); | ||
} |
63 changes: 63 additions & 0 deletions
63
...rc/main/java/org/lfenergy/compas/scl/auto/alignment/rest/v1/SclAutoAlignmentResource.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,63 @@ | ||
// SPDX-FileCopyrightText: 2021 Alliander N.V. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.lfenergy.compas.scl.auto.alignment.rest.v1; | ||
|
||
import io.quarkus.security.Authenticated; | ||
import org.eclipse.microprofile.jwt.JsonWebToken; | ||
import org.lfenergy.compas.scl.auto.alignment.rest.UserInfoProperties; | ||
import org.lfenergy.compas.scl.auto.alignment.rest.v1.model.SclAutoAlignRequest; | ||
import org.lfenergy.compas.scl.auto.alignment.rest.v1.model.SclAutoAlignResponse; | ||
import org.lfenergy.compas.scl.auto.alignment.rest.v1.model.SclAutoAlignSVGRequest; | ||
import org.lfenergy.compas.scl.auto.alignment.service.SclAutoAlignmentService; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.enterprise.context.RequestScoped; | ||
import javax.inject.Inject; | ||
import javax.validation.Valid; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
@Authenticated | ||
@RequestScoped | ||
@Path("/auto/alignment/v1") | ||
public class SclAutoAlignmentResource { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(SclAutoAlignmentResource.class); | ||
|
||
private final SclAutoAlignmentService sclAutoAlignmentService; | ||
|
||
@Inject | ||
JsonWebToken jsonWebToken; | ||
|
||
@Inject | ||
UserInfoProperties userInfoProperties; | ||
|
||
@Inject | ||
public SclAutoAlignmentResource(SclAutoAlignmentService compasCimMappingService) { | ||
this.sclAutoAlignmentService = compasCimMappingService; | ||
} | ||
|
||
@POST | ||
@Consumes(MediaType.APPLICATION_XML) | ||
@Produces(MediaType.APPLICATION_XML) | ||
public SclAutoAlignResponse updateSCL(@Valid SclAutoAlignRequest request) { | ||
String who = jsonWebToken.getClaim(userInfoProperties.who()); | ||
LOGGER.trace("Username used for Who {}", who); | ||
|
||
var response = new SclAutoAlignResponse(); | ||
response.setSclData(sclAutoAlignmentService.updateSCL(request.getSclData(), request.getSubstationNames(), who)); | ||
return response; | ||
} | ||
|
||
@POST | ||
@Consumes(MediaType.APPLICATION_XML) | ||
@Produces(MediaType.APPLICATION_SVG_XML) | ||
@Path("/svg") | ||
public String getSVG(@Valid SclAutoAlignSVGRequest request) { | ||
return sclAutoAlignmentService.getSVG(request.getSclData(), request.getSubstationName()); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...c/main/java/org/lfenergy/compas/scl/auto/alignment/rest/v1/model/SclAutoAlignRequest.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,49 @@ | ||
// SPDX-FileCopyrightText: 2021 Alliander N.V. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.scl.auto.alignment.rest.v1.model; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotEmpty; | ||
import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | ||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.lfenergy.compas.scl.auto.alignment.SclAutoAlignmentConstants.SCL_AUTO_ALIGNMENT_SERVICE_V1_NS_URI; | ||
|
||
@Schema(description = "") | ||
@XmlRootElement(name = "SclAutoAlignRequest", namespace = SCL_AUTO_ALIGNMENT_SERVICE_V1_NS_URI) | ||
@XmlAccessorType(XmlAccessType.FIELD) | ||
public class SclAutoAlignRequest { | ||
@Schema(description = "") | ||
@NotEmpty | ||
@XmlElement(name = "SubstationName", namespace = SCL_AUTO_ALIGNMENT_SERVICE_V1_NS_URI) | ||
protected List<String> substationNames = new ArrayList<>(); | ||
|
||
@Schema(description = "") | ||
@NotBlank | ||
@XmlElement(name = "SclData", namespace = SCL_AUTO_ALIGNMENT_SERVICE_V1_NS_URI) | ||
protected String sclData; | ||
|
||
public List<String> getSubstationNames() { | ||
return substationNames; | ||
} | ||
|
||
public void setSubstationNames(List<String> substationNames) { | ||
this.substationNames = substationNames; | ||
} | ||
|
||
public String getSclData() { | ||
return sclData; | ||
} | ||
|
||
public void setSclData(String sclData) { | ||
this.sclData = sclData; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
.../main/java/org/lfenergy/compas/scl/auto/alignment/rest/v1/model/SclAutoAlignResponse.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,30 @@ | ||
// SPDX-FileCopyrightText: 2021 Alliander N.V. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.lfenergy.compas.scl.auto.alignment.rest.v1.model; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
|
||
import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | ||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
|
||
import static org.lfenergy.compas.scl.auto.alignment.SclAutoAlignmentConstants.SCL_AUTO_ALIGNMENT_SERVICE_V1_NS_URI; | ||
|
||
@Schema(description = "") | ||
@XmlRootElement(name = "SclAutoAlignResponse", namespace = SCL_AUTO_ALIGNMENT_SERVICE_V1_NS_URI) | ||
@XmlAccessorType(XmlAccessType.FIELD) | ||
public class SclAutoAlignResponse { | ||
@Schema(description = "") | ||
@XmlElement(name = "SclData", namespace = SCL_AUTO_ALIGNMENT_SERVICE_V1_NS_URI) | ||
protected String sclData; | ||
|
||
public String getSclData() { | ||
return sclData; | ||
} | ||
|
||
public void setSclData(String sclData) { | ||
this.sclData = sclData; | ||
} | ||
} |
Oops, something went wrong.