Skip to content

Commit 735f35d

Browse files
author
Rob Tjalma
authored
Merge pull request #12 from com-pas/first-setup-sld
First version of SCL Auto Alignment Service
2 parents c0595f2 + aaa2591 commit 735f35d

File tree

70 files changed

+9149
-51
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+9149
-51
lines changed

.github/workflows/build-project.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ on:
88
push:
99
branches:
1010
- '**'
11-
- '!main'
12-
- '!develop'
1311
pull_request:
1412
branches:
1513
- 'main'

.github/workflows/release-project.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
push_to_registry:
1313
name: Build and publish
1414
runs-on: ubuntu-latest
15+
1516
steps:
1617
- name: Checkout
1718
uses: actions/checkout@v2

.github/workflows/reuse.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
test:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
14-
- name: REUSE Compliance Check
15-
uses: fsfe/reuse-action@v1
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: REUSE Compliance Check
16+
uses: fsfe/reuse-action@v1

.github/workflows/sonarcloud-analysis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,20 @@ on:
88
push:
99
branches:
1010
- '**'
11-
- '!main'
12-
- '!develop'
1311
pull_request:
1412
branches:
1513
- 'main'
1614
- 'develop'
1715

1816
jobs:
1917
build:
20-
name: Build
18+
name: SonarCloud
2119
runs-on: ubuntu-latest
2220
timeout-minutes: 15
2321

2422
steps:
25-
- uses: actions/checkout@v2
23+
- name: Checkout
24+
uses: actions/checkout@v2
2625
with:
2726
fetch-depth: 0
2827

app/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ SPDX-License-Identifier: Apache-2.0
3535

3636
<dependency>
3737
<groupId>org.lfenergy.compas.core</groupId>
38-
<artifactId>scl2007b4</artifactId>
38+
<artifactId>commons</artifactId>
3939
</dependency>
4040
<dependency>
4141
<groupId>org.lfenergy.compas.core</groupId>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-FileCopyrightText: 2021 Alliander N.V.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
package org.lfenergy.compas.scl.auto.alignment.rest;
5+
6+
import io.quarkus.runtime.annotations.RegisterForReflection;
7+
import org.lfenergy.compas.core.commons.ElementConverter;
8+
9+
import javax.enterprise.context.ApplicationScoped;
10+
import javax.enterprise.inject.Produces;
11+
12+
/**
13+
* Create Beans from other dependencies that are used in the application.
14+
*/
15+
@RegisterForReflection(targets = {com.powsybl.sld.library.Components.class,
16+
com.powsybl.sld.library.Component.class})
17+
public class CompasSclAutoAlignmentConfiguration {
18+
@Produces
19+
@ApplicationScoped
20+
public ElementConverter createElementConverter() {
21+
return new ElementConverter();
22+
}
23+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// SPDX-FileCopyrightText: 2021 Alliander N.V.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
package org.lfenergy.compas.scl.auto.alignment.rest;
5+
6+
import io.smallrye.config.ConfigMapping;
7+
import io.smallrye.config.WithName;
8+
9+
@ConfigMapping(prefix = "compas.userinfo")
10+
public interface UserInfoProperties {
11+
@WithName("who.claimname")
12+
String who();
13+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// SPDX-FileCopyrightText: 2021 Alliander N.V.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
package org.lfenergy.compas.scl.auto.alignment.rest.v1;
5+
6+
import io.quarkus.security.Authenticated;
7+
import org.eclipse.microprofile.jwt.JsonWebToken;
8+
import org.lfenergy.compas.scl.auto.alignment.rest.UserInfoProperties;
9+
import org.lfenergy.compas.scl.auto.alignment.rest.v1.model.SclAutoAlignRequest;
10+
import org.lfenergy.compas.scl.auto.alignment.rest.v1.model.SclAutoAlignResponse;
11+
import org.lfenergy.compas.scl.auto.alignment.service.SclAutoAlignmentService;
12+
import org.slf4j.Logger;
13+
import org.slf4j.LoggerFactory;
14+
15+
import javax.enterprise.context.RequestScoped;
16+
import javax.inject.Inject;
17+
import javax.validation.Valid;
18+
import javax.ws.rs.Consumes;
19+
import javax.ws.rs.POST;
20+
import javax.ws.rs.Path;
21+
import javax.ws.rs.Produces;
22+
import javax.ws.rs.core.MediaType;
23+
24+
@Authenticated
25+
@RequestScoped
26+
@Path("/auto/alignment/v1")
27+
public class SclAutoAlignmentResource {
28+
private static final Logger LOGGER = LoggerFactory.getLogger(SclAutoAlignmentResource.class);
29+
30+
private final SclAutoAlignmentService sclAutoAlignmentService;
31+
32+
@Inject
33+
JsonWebToken jsonWebToken;
34+
35+
@Inject
36+
UserInfoProperties userInfoProperties;
37+
38+
@Inject
39+
public SclAutoAlignmentResource(SclAutoAlignmentService compasCimMappingService) {
40+
this.sclAutoAlignmentService = compasCimMappingService;
41+
}
42+
43+
@POST
44+
@Consumes(MediaType.APPLICATION_XML)
45+
@Produces(MediaType.APPLICATION_XML)
46+
public SclAutoAlignResponse updateSCL(@Valid SclAutoAlignRequest request) {
47+
String who = jsonWebToken.getClaim(userInfoProperties.who());
48+
LOGGER.trace("Username used for Who {}", who);
49+
50+
var response = new SclAutoAlignResponse();
51+
response.setSclData(sclAutoAlignmentService.updateSCL(request.getSclData(), request.getSubstationName(), who));
52+
return response;
53+
}
54+
55+
@POST
56+
@Consumes(MediaType.APPLICATION_XML)
57+
@Produces(MediaType.APPLICATION_SVG_XML)
58+
@Path("/svg")
59+
public String getSVG(@Valid SclAutoAlignRequest request) {
60+
return sclAutoAlignmentService.getSVG(request.getSclData(), request.getSubstationName());
61+
}
62+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// SPDX-FileCopyrightText: 2021 Alliander N.V.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package org.lfenergy.compas.scl.auto.alignment.rest.v1.model;
6+
7+
import org.eclipse.microprofile.openapi.annotations.media.Schema;
8+
9+
import javax.validation.constraints.NotBlank;
10+
import javax.xml.bind.annotation.XmlAccessType;
11+
import javax.xml.bind.annotation.XmlAccessorType;
12+
import javax.xml.bind.annotation.XmlElement;
13+
import javax.xml.bind.annotation.XmlRootElement;
14+
15+
import static org.lfenergy.compas.scl.auto.alignment.SclAutoAlignmentConstants.SCL_AUTO_ALIGNMENT_SERVICE_V1_NS_URI;
16+
17+
@Schema(description = "")
18+
@XmlRootElement(name = "SclAutoAlignRequest", namespace = SCL_AUTO_ALIGNMENT_SERVICE_V1_NS_URI)
19+
@XmlAccessorType(XmlAccessType.FIELD)
20+
public class SclAutoAlignRequest {
21+
@Schema(description = "")
22+
@NotBlank
23+
@XmlElement(name = "SubstationName", namespace = SCL_AUTO_ALIGNMENT_SERVICE_V1_NS_URI)
24+
protected String substationName;
25+
26+
@Schema(description = "")
27+
@NotBlank
28+
@XmlElement(name = "SclData", namespace = SCL_AUTO_ALIGNMENT_SERVICE_V1_NS_URI)
29+
protected String sclData;
30+
31+
public String getSubstationName() {
32+
return substationName;
33+
}
34+
35+
public void setSubstationName(String substationName) {
36+
this.substationName = substationName;
37+
}
38+
39+
public String getSclData() {
40+
return sclData;
41+
}
42+
43+
public void setSclData(String sclData) {
44+
this.sclData = sclData;
45+
}
46+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-FileCopyrightText: 2021 Alliander N.V.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
package org.lfenergy.compas.scl.auto.alignment.rest.v1.model;
5+
6+
import org.eclipse.microprofile.openapi.annotations.media.Schema;
7+
8+
import javax.xml.bind.annotation.XmlAccessType;
9+
import javax.xml.bind.annotation.XmlAccessorType;
10+
import javax.xml.bind.annotation.XmlElement;
11+
import javax.xml.bind.annotation.XmlRootElement;
12+
13+
import static org.lfenergy.compas.scl.auto.alignment.SclAutoAlignmentConstants.SCL_AUTO_ALIGNMENT_SERVICE_V1_NS_URI;
14+
15+
@Schema(description = "")
16+
@XmlRootElement(name = "SclAutoAlignResponse", namespace = SCL_AUTO_ALIGNMENT_SERVICE_V1_NS_URI)
17+
@XmlAccessorType(XmlAccessType.FIELD)
18+
public class SclAutoAlignResponse {
19+
@Schema(description = "")
20+
@XmlElement(name = "SclData", namespace = SCL_AUTO_ALIGNMENT_SERVICE_V1_NS_URI)
21+
protected String sclData;
22+
23+
public String getSclData() {
24+
return sclData;
25+
}
26+
27+
public void setSclData(String sclData) {
28+
this.sclData = sclData;
29+
}
30+
}

0 commit comments

Comments
 (0)