Skip to content

Commit

Permalink
Merge pull request #10 from com-pas/Fetch_IED_Data
Browse files Browse the repository at this point in the history
Fetch ied data
  • Loading branch information
pascalwilbrink authored May 9, 2023
2 parents 33401cb + 0548672 commit a526fdf
Show file tree
Hide file tree
Showing 44 changed files with 1,824 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ public Uni<BayTypicalResponse> getAssignedBayTypicals() {
return Uni.createFrom().item(response);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package org.lfenergy.compas.sitipe.rest.v1.model;

import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.lfenergy.compas.sitipe.data.entity.BayTypical;
import org.lfenergy.compas.sitipe.dto.BayTypicalDTO;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
Expand Down Expand Up @@ -38,164 +38,116 @@ public static class BayTypicalItem {

@Schema(description = "Id of the BayTypical.", example = "1")
@XmlElement(name = "Id", namespace = SITIPE_SERVICE_V1_NS_URI)
private Integer id;
private final Integer id;

@Schema(description = "Access Id of the BayTypical.", example = "c50b3276-81f6-4bc3-82ab-b8adef829136")
@XmlElement(name = "AccessId", namespace = SITIPE_SERVICE_V1_NS_URI)
private String accessId;
private final String accessId;

@Schema(description = "Name of the BayTypical.", example = "BT1")
@XmlElement(name = "Name", namespace = SITIPE_SERVICE_V1_NS_URI)
private String name;
private final String name;

@Schema(description = "Version of the BayTypical.", example = "1")
@XmlElement(name = "Version", namespace = SITIPE_SERVICE_V1_NS_URI)
private String version;
private final String version;

@Schema(description = "Description of the BayTypical.")
@XmlElement(name = "Description", namespace = SITIPE_SERVICE_V1_NS_URI)
private String description;
private final String description;

@Schema(description = "Released flag of the BayTypical.", example = "1")
@XmlElement(name = "Released", namespace = SITIPE_SERVICE_V1_NS_URI)
private int released;
private final int released;

@Schema(description = "Flag if the BayTypical is locked by someone.", example = "1")
@XmlElement(name = "LockedBy", namespace = SITIPE_SERVICE_V1_NS_URI)
private String lockedBy;
private final String lockedBy;

@Schema(description = "Timestamp of when the BayTypical is locked.", example = "18129347234")
@XmlElement(name = "LockedOn", namespace = SITIPE_SERVICE_V1_NS_URI)
private Long lockedOn;
private final Long lockedOn;

@Schema(description = "Timestamp of when the BayTypical is modified.", example = "18129347234")
@XmlElement(name = "ModifiedOn", namespace = SITIPE_SERVICE_V1_NS_URI)
private Long modifiedOn;
private final Long modifiedOn;

@Schema(description = "Name of the SMR File of the BayTypical.", example = "SMR_1_BT_Foo - Amsterdam.smr")
@XmlElement(name = "SmrFile", namespace = SITIPE_SERVICE_V1_NS_URI)
private String smrFile;
private final String smrFile;

@Schema(description = "Content Version of the BayTypical.", example = "2.0")
@XmlElement(name = "ContentVersion", namespace = SITIPE_SERVICE_V1_NS_URI)
private String contentVersion;
private final String contentVersion;

@Schema(description = "Reference Access Id of the BayTypical.", example = "d7b0ad3a-c0ae-4b8b-8321-71eaf8970ed7")
@XmlElement(name = "ReferenceAccessId", namespace = SITIPE_SERVICE_V1_NS_URI)
private String referenceAccessId;
private final String referenceAccessId;

public BayTypicalItem(
final BayTypical bt
final BayTypicalDTO dto
) {
this.id = bt.getId();
this.accessId = bt.getAccessId();
this.name = bt.getName();
this.version = bt.getVersion();
this.description = bt.getDescription();
this.released = bt.getReleased();
this.lockedBy = bt.getLockedBy();
this.lockedOn = bt.getLockedOn();
this.modifiedOn = bt.getModifiedOn();
this.smrFile = bt.getSmrFile();
this.contentVersion = bt.getContentVersion();
this.referenceAccessId = bt.getReferenceAccessId();
this.id = dto.getId();
this.accessId = dto.getAccessId();
this.name = dto.getName();
this.version = dto.getVersion();
this.description = dto.getDescription();
this.released = dto.getReleased();
this.lockedBy = dto.getLockedBy();
this.lockedOn = dto.getLockedOn();
this.modifiedOn = dto.getModifiedOn();
this.smrFile = dto.getSmrFile();
this.contentVersion = dto.getContentVersion();
this.referenceAccessId = dto.getReferenceAccessId();
}
public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getAccessId() {
return accessId;
}

public void setAccessId(String accessId) {
this.accessId = accessId;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public int getReleased() {
return released;
}

public void setReleased(int released) {
this.released = released;
}

public String getLockedBy() {
return lockedBy;
}

public void setLockedBy(String lockedBy) {
this.lockedBy = lockedBy;
}

public Long getLockedOn() {
return lockedOn;
}

public void setLockedOn(Long lockedOn) {
this.lockedOn = lockedOn;
}

public Long getModifiedOn() {
return modifiedOn;
}

public void setModifiedOn(Long modifiedOn) {
this.modifiedOn = modifiedOn;
}

public String getSmrFile() {
return smrFile;
}

public void setSmrFile(String smrFile) {
this.smrFile = smrFile;
}

public String getContentVersion() {
return contentVersion;
}

public void setContentVersion(String contentVersion) {
this.contentVersion = contentVersion;
}

public String getReferenceAccessId() {
return referenceAccessId;
}

public void setReferenceAccessId(String referenceAccessId) {
this.referenceAccessId = referenceAccessId;
}

}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// SPDX-FileCopyrightText: 2023 Alliander N.V.
//
// SPDX-License-Identifier: Apache-2.0

package org.lfenergy.compas.sitipe.rest.v2;

import io.quarkus.security.Authenticated;
import io.smallrye.common.annotation.Blocking;
import io.smallrye.mutiny.Uni;
import org.lfenergy.compas.sitipe.dto.ImportedComponentDTO;
import org.lfenergy.compas.sitipe.service.ImportedComponentService;
import org.lfenergy.compas.sitipe.dto.ImportedDataDTO;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.List;

@Authenticated
@RequestScoped
@Path("/v2/btcomponents")
public class BTComponentResource {

private final ImportedComponentService importedComponentService;

@Inject
public BTComponentResource(
final ImportedComponentService importedComponentService
) {
this.importedComponentService = importedComponentService;
}

@GET
@Path("/{accessId}/imported")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Blocking
public Uni<List<ImportedComponentDTO>> getImportedComponents(
@PathParam("accessId") final String accessId
) {
return Uni.createFrom().item(this.importedComponentService.getByAccessId(accessId));
}

@GET
@Path("/imported/{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Blocking
public Uni<ImportedDataDTO> getImportedComponentData(
@PathParam("id") final Integer id
) {
final ImportedDataDTO data = this.importedComponentService.getImportedComponentData(id);

return Uni.createFrom().item(data);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
import io.quarkus.security.Authenticated;
import io.smallrye.common.annotation.Blocking;
import io.smallrye.mutiny.Uni;
import org.lfenergy.compas.sitipe.data.entity.BayTypical;
import org.lfenergy.compas.sitipe.dto.BTComponentDTO;
import org.lfenergy.compas.sitipe.service.BTComponentService;
import org.lfenergy.compas.sitipe.dto.BayTypicalDTO;
import org.lfenergy.compas.sitipe.service.BayTypicalService;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.List;

Expand All @@ -25,18 +24,30 @@
public class BayTypicalResource {

private final BayTypicalService bayTypicalService;
private final BTComponentService btComponentService;

@Inject
public BayTypicalResource(final BayTypicalService bayTypicalService) {
public BayTypicalResource(final BayTypicalService bayTypicalService, final BTComponentService btComponentService) {
this.bayTypicalService = bayTypicalService;
this.btComponentService = btComponentService;
}

@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Blocking
public Uni<List<BayTypical>> getAssignedBayTypicals() {
public Uni<List<BayTypicalDTO>> getAssignedBayTypicals() {
return Uni.createFrom().item(this.bayTypicalService.getAssignedBayTypicals());
}

@GET
@Path("/{accessId}/components")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Blocking
public Uni<List<BTComponentDTO>> getBayTypicalComponentsByAccessId(
@PathParam("accessId") final String accessId
) {
return Uni.createFrom().item(this.btComponentService.getBTComponentsByBayTypicalAccessId(accessId));
}
}
2 changes: 1 addition & 1 deletion app/src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# SPDX-License-Identifier: Apache-2.0

quarkus.http.cors = true
quarkus.http.cors.origins = http://localhost:8081
quarkus.http.cors.origins = http://localhost:8081, http://localhost:8080
3 changes: 1 addition & 2 deletions app/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mp.jwt.verify.audiences = ${JWT_VERIFY_CLIENT_ID:sitipe-service}
smallrye.jwt.path.groups = ${JWT_GROUPS_PATH:resource_access/sitipe-service/roles}

quarkus.http.auth.permission.deny-default.paths=/*
quarkus.http.auth.permission.deny-default.policy=deny
quarkus.http.auth.permission.deny-default.policy=permit

quarkus.http.auth.permission.allow-quarkus-services.paths=/compas-sitipe-service/q/health/live,/compas-sitipe-service/q/health/ready,/compas-sitipe-service/q/openapi
quarkus.http.auth.permission.allow-quarkus-services.policy=permit
Expand All @@ -54,6 +54,5 @@ quarkus.datasource.jdbc.url=${SITIPE_MSSQL_URL:jdbc:sqlserver://localhost:1433;d
quarkus.datasource.jdbc.max-size=16
#quarkus.hibernate-orm.dialect=org.hibernate.dialect.SQLServer2012Dialect


quarkus.hibernate-orm.physical-naming-strategy=org.lfenergy.compas.sitipe.data.table.SitipeFrameworkIdNamingStrategy

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-FileCopyrightText: 2023 Alliander N.V.
//
// SPDX-License-Identifier: Apache-2.0

package org.lfenergy.compas.sitipe.helper;

import javax.enterprise.context.ApplicationScoped;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.DeflaterOutputStream;

@ApplicationScoped
public class CompressionUtils {

public byte[] compress(byte[] bArray) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (DeflaterOutputStream dos = new DeflaterOutputStream(baos)) {
dos.write(bArray);
}
return baos.toByteArray();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

package org.lfenergy.compas.sitipe.helper;

import org.lfenergy.compas.sitipe.data.repository.BTComponentRepository;
import org.lfenergy.compas.sitipe.data.repository.BayTypicalRepository;
import org.lfenergy.compas.sitipe.data.repository.ImportedComponentRepository;
import org.lfenergy.compas.sitipe.data.repository.SystemVersionRepository;

import javax.enterprise.context.ApplicationScoped;
Expand All @@ -20,9 +22,17 @@ public class DatabaseCleaner {
@Inject
BayTypicalRepository bayTypicalRepository;

@Inject
BTComponentRepository btComponentRepository;

@Inject
ImportedComponentRepository importedComponentRepository;

@Transactional
public void cleanUp() {
bayTypicalRepository.deleteAll();
systemVersionRepository.deleteAll();
btComponentRepository.deleteAll();
importedComponentRepository.deleteAll();
}
}
Loading

0 comments on commit a526fdf

Please sign in to comment.