Skip to content

Commit c39d5ab

Browse files
author
Dennis Labordus
authored
Merge pull request #122 from com-pas/develop
New Release
2 parents 68ee484 + 234734f commit c39d5ab

File tree

31 files changed

+637
-573
lines changed

31 files changed

+637
-573
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,4 @@ configured as needed.
137137
- SED_DELETE
138138
- SED_READ
139139
- SED_UPDATE
140+

app/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SPDX-License-Identifier: Apache-2.0
1818
<packaging>jar</packaging>
1919

2020
<properties>
21-
<quarkus.platform.version>2.2.3.Final</quarkus.platform.version>
21+
<quarkus.platform.version>2.3.0.Final</quarkus.platform.version>
2222

2323
<quarkus.container-image.group>lfenergycompas</quarkus.container-image.group>
2424
<quarkus.container-image.name>compas-scl-data-service</quarkus.container-image.name>

app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/CompasSclDataResource.java

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import io.quarkus.security.Authenticated;
77
import org.eclipse.microprofile.jwt.JsonWebToken;
8-
import org.lfenergy.compas.core.commons.ElementConverter;
98
import org.lfenergy.compas.scl.data.model.SclType;
109
import org.lfenergy.compas.scl.data.model.Version;
1110
import org.lfenergy.compas.scl.data.rest.UserInfoProperties;
@@ -30,7 +29,6 @@ public class CompasSclDataResource {
3029
private static final Logger LOGGER = LoggerFactory.getLogger(CompasSclDataResource.class);
3130

3231
private final CompasSclDataService compasSclDataService;
33-
private final ElementConverter converter;
3432

3533
@Inject
3634
JsonWebToken jsonWebToken;
@@ -39,10 +37,8 @@ public class CompasSclDataResource {
3937
UserInfoProperties userInfoProperties;
4038

4139
@Inject
42-
public CompasSclDataResource(CompasSclDataService compasSclDataService,
43-
ElementConverter converter) {
40+
public CompasSclDataResource(CompasSclDataService compasSclDataService) {
4441
this.compasSclDataService = compasSclDataService;
45-
this.converter = converter;
4642
}
4743

4844
@POST
@@ -54,7 +50,8 @@ public CreateResponse create(@PathParam(TYPE_PATH_PARAM) SclType type,
5450
LOGGER.trace("Username used for Who {}", who);
5551

5652
var response = new CreateResponse();
57-
response.setId(compasSclDataService.create(type, request.getName(), who, request.getComment(), request.getElements().get(0)));
53+
response.setSclData(compasSclDataService.create(type, request.getName(), who, request.getComment(),
54+
request.getSclData()));
5855
return response;
5956
}
6057

@@ -83,7 +80,7 @@ public VersionsResponse listVersionsByUUID(@PathParam(TYPE_PATH_PARAM) SclType t
8380
public GetResponse findByUUID(@PathParam(TYPE_PATH_PARAM) SclType type,
8481
@PathParam(ID_PATH_PARAM) UUID id) {
8582
var response = new GetResponse();
86-
response.setScl(compasSclDataService.findByUUID(type, id));
83+
response.setSclData(compasSclDataService.findByUUID(type, id));
8784
return response;
8885
}
8986

@@ -94,40 +91,24 @@ public GetResponse findByUUIDAndVersion(@PathParam(TYPE_PATH_PARAM) SclType type
9491
@PathParam(ID_PATH_PARAM) UUID id,
9592
@PathParam(VERSION_PATH_PARAM) Version version) {
9693
var response = new GetResponse();
97-
response.setScl(compasSclDataService.findByUUID(type, id, version));
94+
response.setSclData(compasSclDataService.findByUUID(type, id, version));
9895
return response;
9996
}
10097

101-
@GET
102-
@Path("/{" + ID_PATH_PARAM + "}/scl")
103-
@Produces(MediaType.APPLICATION_XML)
104-
public String findRawSCLByUUID(@PathParam(TYPE_PATH_PARAM) SclType type,
105-
@PathParam(ID_PATH_PARAM) UUID id) {
106-
var scl = compasSclDataService.findByUUID(type, id);
107-
return converter.convertToString(scl, false);
108-
}
109-
110-
@GET
111-
@Path("/{" + ID_PATH_PARAM + "}/{" + VERSION_PATH_PARAM + "}/scl")
112-
@Produces(MediaType.APPLICATION_XML)
113-
public String findRawSCLByUUIDAndVersion(@PathParam(TYPE_PATH_PARAM) SclType type,
114-
@PathParam(ID_PATH_PARAM) UUID id,
115-
@PathParam(VERSION_PATH_PARAM) Version version) {
116-
var scl = compasSclDataService.findByUUID(type, id, version);
117-
return converter.convertToString(scl, false);
118-
}
119-
12098
@PUT
12199
@Path("/{" + ID_PATH_PARAM + "}")
122100
@Consumes(MediaType.APPLICATION_XML)
123101
@Produces(MediaType.APPLICATION_XML)
124-
public void update(@PathParam(TYPE_PATH_PARAM) SclType type,
125-
@PathParam(ID_PATH_PARAM) UUID id,
126-
@Valid UpdateRequest request) {
102+
public UpdateResponse update(@PathParam(TYPE_PATH_PARAM) SclType type,
103+
@PathParam(ID_PATH_PARAM) UUID id,
104+
@Valid UpdateRequest request) {
127105
String who = jsonWebToken.getClaim(userInfoProperties.who());
128106
LOGGER.trace("Username used for Who {}", who);
129107

130-
compasSclDataService.update(type, id, request.getChangeSetType(), who, request.getComment(), request.getElements().get(0));
108+
var response = new UpdateResponse();
109+
response.setSclData(compasSclDataService.update(type, id, request.getChangeSetType(), who, request.getComment(),
110+
request.getSclData()));
111+
return response;
131112
}
132113

133114
@DELETE

app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/model/CreateRequest.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66

77
import org.eclipse.microprofile.openapi.annotations.media.Schema;
88
import org.lfenergy.compas.core.commons.constraint.FilenameValid;
9-
import org.lfenergy.compas.core.commons.constraint.XmlAnyElementValid;
10-
import org.w3c.dom.Element;
119

12-
import javax.validation.constraints.Size;
13-
import javax.xml.bind.annotation.*;
14-
import java.util.List;
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;
1514

1615
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
17-
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_NS_URI;
1816

1917
@Schema(description = "A request to create a new entry in the database containing the SCL Element content.")
2018
@XmlRootElement(name = "CreateRequest", namespace = SCL_DATA_SERVICE_V1_NS_URI)
@@ -30,11 +28,8 @@ public class CreateRequest {
3028
@XmlElement(name = "Comment", namespace = SCL_DATA_SERVICE_V1_NS_URI)
3129
private String comment;
3230

33-
@Size(min = 1, max = 1, message = "{org.lfenergy.compas.XmlAnyElementValid.moreElements.message}")
34-
@XmlAnyElementValid(elementName = "SCL", elementNamespace = SCL_NS_URI)
35-
@Schema(description = "Can contain one element, named 'SCL', containing a SCL XML Definition")
36-
@XmlAnyElement
37-
private List<Element> elements;
31+
@XmlElement(name = "SclData", namespace = SCL_DATA_SERVICE_V1_NS_URI)
32+
private String sclData;
3833

3934
public String getName() {
4035
return name;
@@ -52,12 +47,12 @@ public void setComment(String comment) {
5247
this.comment = comment;
5348
}
5449

55-
public List<Element> getElements() {
56-
return elements;
50+
public String getSclData() {
51+
return sclData;
5752
}
5853

59-
public void setElements(List<Element> elements) {
60-
this.elements = elements;
54+
public void setSclData(String sclData) {
55+
this.sclData = sclData;
6156
}
6257
}
6358

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
// SPDX-FileCopyrightText: 2021 Alliander N.V.
22
//
33
// SPDX-License-Identifier: Apache-2.0
4-
54
package org.lfenergy.compas.scl.data.rest.v1.model;
65

76
import javax.xml.bind.annotation.XmlAccessType;
87
import javax.xml.bind.annotation.XmlAccessorType;
98
import javax.xml.bind.annotation.XmlElement;
109
import javax.xml.bind.annotation.XmlRootElement;
11-
import java.util.UUID;
1210

1311
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
1412

1513
@XmlRootElement(name = "CreateResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
1614
@XmlAccessorType(XmlAccessType.FIELD)
1715
public class CreateResponse {
18-
@XmlElement(name = "Id", namespace = SCL_DATA_SERVICE_V1_NS_URI, required = true)
19-
private UUID id;
16+
@XmlElement(name = "SclData", namespace = SCL_DATA_SERVICE_V1_NS_URI, required = true)
17+
private String sclData;
2018

21-
public UUID getId() {
22-
return id;
19+
public String getSclData() {
20+
return sclData;
2321
}
2422

25-
public void setId(UUID id) {
26-
this.id = id;
23+
public void setSclData(String sclData) {
24+
this.sclData = sclData;
2725
}
2826
}

app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/model/GetResponse.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,24 @@
44

55
package org.lfenergy.compas.scl.data.rest.v1.model;
66

7-
import org.eclipse.microprofile.openapi.annotations.media.Schema;
8-
import org.w3c.dom.Element;
9-
107
import javax.xml.bind.annotation.XmlAccessType;
118
import javax.xml.bind.annotation.XmlAccessorType;
12-
import javax.xml.bind.annotation.XmlAnyElement;
9+
import javax.xml.bind.annotation.XmlElement;
1310
import javax.xml.bind.annotation.XmlRootElement;
1411

1512
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
1613

1714
@XmlRootElement(name = "GetResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
1815
@XmlAccessorType(XmlAccessType.FIELD)
1916
public class GetResponse {
20-
@Schema(example = "SCL XML...")
21-
@XmlAnyElement
22-
protected Element scl;
17+
@XmlElement(name = "SclData", namespace = SCL_DATA_SERVICE_V1_NS_URI, required = true)
18+
private String sclData;
2319

24-
public Element getScl() {
25-
return scl;
20+
public String getSclData() {
21+
return sclData;
2622
}
2723

28-
public void setScl(Element scl) {
29-
this.scl = scl;
24+
public void setSclData(String sclData) {
25+
this.sclData = sclData;
3026
}
3127
}

app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/model/UpdateRequest.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55
package org.lfenergy.compas.scl.data.rest.v1.model;
66

77
import org.eclipse.microprofile.openapi.annotations.media.Schema;
8-
import org.lfenergy.compas.core.commons.constraint.XmlAnyElementValid;
98
import org.lfenergy.compas.scl.data.model.ChangeSetType;
10-
import org.w3c.dom.Element;
119

1210
import javax.validation.constraints.NotNull;
13-
import javax.validation.constraints.Size;
14-
import javax.xml.bind.annotation.*;
15-
import java.util.List;
11+
import javax.xml.bind.annotation.XmlAccessType;
12+
import javax.xml.bind.annotation.XmlAccessorType;
13+
import javax.xml.bind.annotation.XmlElement;
14+
import javax.xml.bind.annotation.XmlRootElement;
1615

1716
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
18-
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_NS_URI;
1917

2018
@Schema(description = "A request to update an existing entry in the database containing the SCL Element content. " +
2119
"A new version is created and the old version is also kept.")
@@ -32,11 +30,8 @@ public class UpdateRequest {
3230
@XmlElement(name = "Comment", namespace = SCL_DATA_SERVICE_V1_NS_URI)
3331
private String comment;
3432

35-
@XmlAnyElement
36-
@Size(min = 1, max = 1, message = "{org.lfenergy.compas.XmlAnyElementValid.moreElements.message}")
37-
@Schema(description = "Can contain one element, named 'SCL', containing a SCL XML Definition")
38-
@XmlAnyElementValid(elementName = "SCL", elementNamespace = SCL_NS_URI)
39-
protected List<Element> elements;
33+
@XmlElement(name = "SclData", namespace = SCL_DATA_SERVICE_V1_NS_URI)
34+
private String sclData;
4035

4136
public ChangeSetType getChangeSetType() {
4237
return changeSetType;
@@ -54,11 +49,11 @@ public void setComment(String comment) {
5449
this.comment = comment;
5550
}
5651

57-
public List<Element> getElements() {
58-
return elements;
52+
public String getSclData() {
53+
return sclData;
5954
}
6055

61-
public void setElements(List<Element> elements) {
62-
this.elements = elements;
56+
public void setSclData(String sclData) {
57+
this.sclData = sclData;
6358
}
6459
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// SPDX-FileCopyrightText: 2021 Alliander N.V.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package org.lfenergy.compas.scl.data.rest.v1.model;
6+
7+
import javax.xml.bind.annotation.XmlAccessType;
8+
import javax.xml.bind.annotation.XmlAccessorType;
9+
import javax.xml.bind.annotation.XmlElement;
10+
import javax.xml.bind.annotation.XmlRootElement;
11+
12+
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
13+
14+
@XmlRootElement(name = "UpdateResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
15+
@XmlAccessorType(XmlAccessType.FIELD)
16+
public class UpdateResponse {
17+
@XmlElement(name = "SclData", namespace = SCL_DATA_SERVICE_V1_NS_URI, required = true)
18+
private String sclData;
19+
20+
public String getSclData() {
21+
return sclData;
22+
}
23+
24+
public void setSclData(String sclData) {
25+
this.sclData = sclData;
26+
}
27+
}

0 commit comments

Comments
 (0)