Skip to content

Commit

Permalink
Merge pull request #18 from com-pas/develop
Browse files Browse the repository at this point in the history
Create first POC Version to test integration with all components
  • Loading branch information
Dennis Labordus authored Dec 8, 2021
2 parents 8c80642 + c7eafbf commit b61b85a
Show file tree
Hide file tree
Showing 78 changed files with 9,580 additions and 405 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/automate-projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
if: github.event_name == 'issues' && github.event.action == 'opened'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PROJECT_URL: https://github.com/com-pas/compas-scl-auto-alignment/projects/2
GITHUB_PROJECT_URL: https://github.com/com-pas/compas-scl-auto-alignment/projects/1
GITHUB_PROJECT_COLUMN_NAME: To do
- name: add-new-pull-request-to-repository-based-project-column
uses: docker://takanabe/github-actions-automate-projects:v0.0.1
if: github.event_name == 'pull_request' && github.event.action == 'opened'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PROJECT_URL: https://github.com/com-pas/compas-scl-auto-alignment/projects/2
GITHUB_PROJECT_URL: https://github.com/com-pas/compas-scl-auto-alignment/projects/1
GITHUB_PROJECT_COLUMN_NAME: To do
- name: add-new-issues-to-organization-based-project-column
uses: docker://takanabe/github-actions-automate-projects:v0.0.1
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/build-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ on:
push:
branches:
- '**'
- '!main'
- '!develop'
pull_request:
branches:
- 'main'
Expand Down Expand Up @@ -40,7 +38,7 @@ jobs:
restore-keys: ${{ runner.os }}-m2

- name: Set up JDK 1.11
uses: actions/setup-java@v2.3.1
uses: actions/setup-java@v2.4.0
with:
distribution: 'zulu'
java-version: '11'
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
push_to_registry:
name: Build and publish
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -41,7 +42,7 @@ jobs:
# Extra the tagname form the git reference, value of GITHUB_REF will be something like refs/tags/<tag_name>.
run: echo "##[set-output name=tagname;]$(echo ${GITHUB_REF##*/})"
- name: Set up JDK 1.11
uses: actions/setup-java@v2.3.1
uses: actions/setup-java@v2.4.0
with:
distribution: 'zulu'
java-version: '11'
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/reuse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1
- name: Checkout
uses: actions/checkout@v2
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1
9 changes: 4 additions & 5 deletions .github/workflows/sonarcloud-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,25 @@ on:
push:
branches:
- '**'
- '!main'
- '!develop'
pull_request:
branches:
- 'main'
- 'develop'

jobs:
build:
name: Build
name: SonarCloud
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up JDK 1.11
uses: actions/setup-java@v2.3.1
uses: actions/setup-java@v2.4.0
with:
distribution: 'zulu'
java-version: '11'
Expand Down
11 changes: 1 addition & 10 deletions app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,12 @@ SPDX-License-Identifier: Apache-2.0
<packaging>jar</packaging>

<properties>
<quarkus.platform.version>2.4.1.Final</quarkus.platform.version>

<quarkus.container-image.group>lfenergy</quarkus.container-image.group>
<quarkus.container-image.name>compas-scl-auto-alignment</quarkus.container-image.name>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-universe-bom</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -44,7 +35,7 @@ SPDX-License-Identifier: Apache-2.0

<dependency>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl2007b4</artifactId>
<artifactId>commons</artifactId>
</dependency>
<dependency>
<groupId>org.lfenergy.compas.core</groupId>
Expand Down
51 changes: 0 additions & 51 deletions app/src/main/docker/Dockerfile.legacy-jar

This file was deleted.

23 changes: 0 additions & 23 deletions app/src/main/docker/Dockerfile.native-distroless

This file was deleted.

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();
}
}
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();
}
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());
}
}
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;
}
}
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;
}
}
Loading

0 comments on commit b61b85a

Please sign in to comment.