Skip to content

Commit a526fdf

Browse files
Merge pull request #10 from com-pas/Fetch_IED_Data
Fetch ied data
2 parents 33401cb + 0548672 commit a526fdf

File tree

44 files changed

+1824
-136
lines changed

Some content is hidden

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

44 files changed

+1824
-136
lines changed

app/src/main/java/org/lfenergy/compas/sitipe/rest/v1/BayTypicalResource.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,4 @@ public Uni<BayTypicalResponse> getAssignedBayTypicals() {
4848
return Uni.createFrom().item(response);
4949
}
5050

51-
5251
}

app/src/main/java/org/lfenergy/compas/sitipe/rest/v1/model/BayTypicalResponse.java

Lines changed: 26 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package org.lfenergy.compas.sitipe.rest.v1.model;
66

77
import org.eclipse.microprofile.openapi.annotations.media.Schema;
8-
import org.lfenergy.compas.sitipe.data.entity.BayTypical;
8+
import org.lfenergy.compas.sitipe.dto.BayTypicalDTO;
99

1010
import javax.xml.bind.annotation.XmlAccessType;
1111
import javax.xml.bind.annotation.XmlAccessorType;
@@ -38,164 +38,116 @@ public static class BayTypicalItem {
3838

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

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

4747
@Schema(description = "Name of the BayTypical.", example = "BT1")
4848
@XmlElement(name = "Name", namespace = SITIPE_SERVICE_V1_NS_URI)
49-
private String name;
49+
private final String name;
5050

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

5555
@Schema(description = "Description of the BayTypical.")
5656
@XmlElement(name = "Description", namespace = SITIPE_SERVICE_V1_NS_URI)
57-
private String description;
57+
private final String description;
5858

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

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

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

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

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

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

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

8787
public BayTypicalItem(
88-
final BayTypical bt
88+
final BayTypicalDTO dto
8989
) {
90-
this.id = bt.getId();
91-
this.accessId = bt.getAccessId();
92-
this.name = bt.getName();
93-
this.version = bt.getVersion();
94-
this.description = bt.getDescription();
95-
this.released = bt.getReleased();
96-
this.lockedBy = bt.getLockedBy();
97-
this.lockedOn = bt.getLockedOn();
98-
this.modifiedOn = bt.getModifiedOn();
99-
this.smrFile = bt.getSmrFile();
100-
this.contentVersion = bt.getContentVersion();
101-
this.referenceAccessId = bt.getReferenceAccessId();
90+
this.id = dto.getId();
91+
this.accessId = dto.getAccessId();
92+
this.name = dto.getName();
93+
this.version = dto.getVersion();
94+
this.description = dto.getDescription();
95+
this.released = dto.getReleased();
96+
this.lockedBy = dto.getLockedBy();
97+
this.lockedOn = dto.getLockedOn();
98+
this.modifiedOn = dto.getModifiedOn();
99+
this.smrFile = dto.getSmrFile();
100+
this.contentVersion = dto.getContentVersion();
101+
this.referenceAccessId = dto.getReferenceAccessId();
102102
}
103103
public Integer getId() {
104104
return id;
105105
}
106106

107-
public void setId(Integer id) {
108-
this.id = id;
109-
}
110-
111107
public String getAccessId() {
112108
return accessId;
113109
}
114110

115-
public void setAccessId(String accessId) {
116-
this.accessId = accessId;
117-
}
118-
119111
public String getName() {
120112
return name;
121113
}
122114

123-
public void setName(String name) {
124-
this.name = name;
125-
}
126-
127115
public String getVersion() {
128116
return version;
129117
}
130118

131-
public void setVersion(String version) {
132-
this.version = version;
133-
}
134-
135119
public String getDescription() {
136120
return description;
137121
}
138122

139-
public void setDescription(String description) {
140-
this.description = description;
141-
}
142-
143123
public int getReleased() {
144124
return released;
145125
}
146126

147-
public void setReleased(int released) {
148-
this.released = released;
149-
}
150-
151127
public String getLockedBy() {
152128
return lockedBy;
153129
}
154130

155-
public void setLockedBy(String lockedBy) {
156-
this.lockedBy = lockedBy;
157-
}
158-
159131
public Long getLockedOn() {
160132
return lockedOn;
161133
}
162134

163-
public void setLockedOn(Long lockedOn) {
164-
this.lockedOn = lockedOn;
165-
}
166-
167135
public Long getModifiedOn() {
168136
return modifiedOn;
169137
}
170138

171-
public void setModifiedOn(Long modifiedOn) {
172-
this.modifiedOn = modifiedOn;
173-
}
174-
175139
public String getSmrFile() {
176140
return smrFile;
177141
}
178142

179-
public void setSmrFile(String smrFile) {
180-
this.smrFile = smrFile;
181-
}
182-
183143
public String getContentVersion() {
184144
return contentVersion;
185145
}
186146

187-
public void setContentVersion(String contentVersion) {
188-
this.contentVersion = contentVersion;
189-
}
190-
191147
public String getReferenceAccessId() {
192148
return referenceAccessId;
193149
}
194150

195-
public void setReferenceAccessId(String referenceAccessId) {
196-
this.referenceAccessId = referenceAccessId;
197-
}
198-
199151
}
200152

201153

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// SPDX-FileCopyrightText: 2023 Alliander N.V.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package org.lfenergy.compas.sitipe.rest.v2;
6+
7+
import io.quarkus.security.Authenticated;
8+
import io.smallrye.common.annotation.Blocking;
9+
import io.smallrye.mutiny.Uni;
10+
import org.lfenergy.compas.sitipe.dto.ImportedComponentDTO;
11+
import org.lfenergy.compas.sitipe.service.ImportedComponentService;
12+
import org.lfenergy.compas.sitipe.dto.ImportedDataDTO;
13+
14+
import javax.enterprise.context.RequestScoped;
15+
import javax.inject.Inject;
16+
import javax.ws.rs.*;
17+
import javax.ws.rs.core.MediaType;
18+
import java.util.List;
19+
20+
@Authenticated
21+
@RequestScoped
22+
@Path("/v2/btcomponents")
23+
public class BTComponentResource {
24+
25+
private final ImportedComponentService importedComponentService;
26+
27+
@Inject
28+
public BTComponentResource(
29+
final ImportedComponentService importedComponentService
30+
) {
31+
this.importedComponentService = importedComponentService;
32+
}
33+
34+
@GET
35+
@Path("/{accessId}/imported")
36+
@Consumes(MediaType.APPLICATION_JSON)
37+
@Produces(MediaType.APPLICATION_JSON)
38+
@Blocking
39+
public Uni<List<ImportedComponentDTO>> getImportedComponents(
40+
@PathParam("accessId") final String accessId
41+
) {
42+
return Uni.createFrom().item(this.importedComponentService.getByAccessId(accessId));
43+
}
44+
45+
@GET
46+
@Path("/imported/{id}")
47+
@Consumes(MediaType.APPLICATION_JSON)
48+
@Produces(MediaType.APPLICATION_JSON)
49+
@Blocking
50+
public Uni<ImportedDataDTO> getImportedComponentData(
51+
@PathParam("id") final Integer id
52+
) {
53+
final ImportedDataDTO data = this.importedComponentService.getImportedComponentData(id);
54+
55+
return Uni.createFrom().item(data);
56+
}
57+
}

app/src/main/java/org/lfenergy/compas/sitipe/rest/v2/BayTypicalResource.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
import io.quarkus.security.Authenticated;
88
import io.smallrye.common.annotation.Blocking;
99
import io.smallrye.mutiny.Uni;
10-
import org.lfenergy.compas.sitipe.data.entity.BayTypical;
10+
import org.lfenergy.compas.sitipe.dto.BTComponentDTO;
11+
import org.lfenergy.compas.sitipe.service.BTComponentService;
12+
import org.lfenergy.compas.sitipe.dto.BayTypicalDTO;
1113
import org.lfenergy.compas.sitipe.service.BayTypicalService;
1214

1315
import javax.enterprise.context.RequestScoped;
1416
import javax.inject.Inject;
15-
import javax.ws.rs.GET;
16-
import javax.ws.rs.Path;
17-
import javax.ws.rs.Consumes;
18-
import javax.ws.rs.Produces;
17+
import javax.ws.rs.*;
1918
import javax.ws.rs.core.MediaType;
2019
import java.util.List;
2120

@@ -25,18 +24,30 @@
2524
public class BayTypicalResource {
2625

2726
private final BayTypicalService bayTypicalService;
27+
private final BTComponentService btComponentService;
2828

2929
@Inject
30-
public BayTypicalResource(final BayTypicalService bayTypicalService) {
30+
public BayTypicalResource(final BayTypicalService bayTypicalService, final BTComponentService btComponentService) {
3131
this.bayTypicalService = bayTypicalService;
32+
this.btComponentService = btComponentService;
3233
}
3334

3435
@GET
3536
@Consumes(MediaType.APPLICATION_JSON)
3637
@Produces(MediaType.APPLICATION_JSON)
3738
@Blocking
38-
public Uni<List<BayTypical>> getAssignedBayTypicals() {
39+
public Uni<List<BayTypicalDTO>> getAssignedBayTypicals() {
3940
return Uni.createFrom().item(this.bayTypicalService.getAssignedBayTypicals());
4041
}
4142

43+
@GET
44+
@Path("/{accessId}/components")
45+
@Consumes(MediaType.APPLICATION_JSON)
46+
@Produces(MediaType.APPLICATION_JSON)
47+
@Blocking
48+
public Uni<List<BTComponentDTO>> getBayTypicalComponentsByAccessId(
49+
@PathParam("accessId") final String accessId
50+
) {
51+
return Uni.createFrom().item(this.btComponentService.getBTComponentsByBayTypicalAccessId(accessId));
52+
}
4253
}

app/src/main/resources/application-dev.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
quarkus.http.cors = true
6-
quarkus.http.cors.origins = http://localhost:8081
6+
quarkus.http.cors.origins = http://localhost:8081, http://localhost:8080

app/src/main/resources/application.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ mp.jwt.verify.audiences = ${JWT_VERIFY_CLIENT_ID:sitipe-service}
3434
smallrye.jwt.path.groups = ${JWT_GROUPS_PATH:resource_access/sitipe-service/roles}
3535

3636
quarkus.http.auth.permission.deny-default.paths=/*
37-
quarkus.http.auth.permission.deny-default.policy=deny
37+
quarkus.http.auth.permission.deny-default.policy=permit
3838

3939
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
4040
quarkus.http.auth.permission.allow-quarkus-services.policy=permit
@@ -54,6 +54,5 @@ quarkus.datasource.jdbc.url=${SITIPE_MSSQL_URL:jdbc:sqlserver://localhost:1433;d
5454
quarkus.datasource.jdbc.max-size=16
5555
#quarkus.hibernate-orm.dialect=org.hibernate.dialect.SQLServer2012Dialect
5656

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-FileCopyrightText: 2023 Alliander N.V.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package org.lfenergy.compas.sitipe.helper;
6+
7+
import javax.enterprise.context.ApplicationScoped;
8+
import java.io.ByteArrayOutputStream;
9+
import java.io.IOException;
10+
import java.util.zip.DeflaterOutputStream;
11+
12+
@ApplicationScoped
13+
public class CompressionUtils {
14+
15+
public byte[] compress(byte[] bArray) throws IOException {
16+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
17+
try (DeflaterOutputStream dos = new DeflaterOutputStream(baos)) {
18+
dos.write(bArray);
19+
}
20+
return baos.toByteArray();
21+
}
22+
23+
}

app/src/test/java/org/lfenergy/compas/sitipe/helper/DatabaseCleaner.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
package org.lfenergy.compas.sitipe.helper;
66

7+
import org.lfenergy.compas.sitipe.data.repository.BTComponentRepository;
78
import org.lfenergy.compas.sitipe.data.repository.BayTypicalRepository;
9+
import org.lfenergy.compas.sitipe.data.repository.ImportedComponentRepository;
810
import org.lfenergy.compas.sitipe.data.repository.SystemVersionRepository;
911

1012
import javax.enterprise.context.ApplicationScoped;
@@ -20,9 +22,17 @@ public class DatabaseCleaner {
2022
@Inject
2123
BayTypicalRepository bayTypicalRepository;
2224

25+
@Inject
26+
BTComponentRepository btComponentRepository;
27+
28+
@Inject
29+
ImportedComponentRepository importedComponentRepository;
30+
2331
@Transactional
2432
public void cleanUp() {
2533
bayTypicalRepository.deleteAll();
2634
systemVersionRepository.deleteAll();
35+
btComponentRepository.deleteAll();
36+
importedComponentRepository.deleteAll();
2737
}
2838
}

0 commit comments

Comments
 (0)