Skip to content

Commit 804aee1

Browse files
Dennis LabordusRob Tjalma
authored andcommitted
Change package for extension and improvement of code.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent b83c058 commit 804aee1

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public JAXBContext getContext(Class<?> type) {
2020
org.lfenergy.compas.scl.data.rest.model.ObjectFactory.class,
2121
org.lfenergy.compas.scl.data.model.ObjectFactory.class,
2222
org.lfenergy.compas.scl.ObjectFactory.class,
23-
org.lfenergy.compas.extensions.ObjectFactory.class);
23+
org.lfenergy.compas.scl.extensions.ObjectFactory.class);
2424
} catch (JAXBException exp) {
2525
throw new SclDataException(exp);
2626
}

service/src/main/java/org/lfenergy/compas/scl/data/service/CompasSclDataService.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
package org.lfenergy.compas.scl.data.service;
66

7-
import org.lfenergy.compas.extensions.ObjectFactory;
8-
import org.lfenergy.compas.extensions.TSclFileType;
97
import org.lfenergy.compas.scl.SCL;
108
import org.lfenergy.compas.scl.TAnyContentFromOtherNamespace;
119
import org.lfenergy.compas.scl.TPrivate;
@@ -14,6 +12,8 @@
1412
import org.lfenergy.compas.scl.data.model.SclType;
1513
import org.lfenergy.compas.scl.data.model.Version;
1614
import org.lfenergy.compas.scl.data.repository.CompasSclDataRepository;
15+
import org.lfenergy.compas.scl.extensions.ObjectFactory;
16+
import org.lfenergy.compas.scl.extensions.TSclFileType;
1717

1818
import javax.enterprise.context.ApplicationScoped;
1919
import javax.inject.Inject;
@@ -70,14 +70,8 @@ public void update(SclType type, UUID id, ChangeSetType changeSetType, SCL scl)
7070
scl.getHeader().setId(id.toString());
7171
scl.getHeader().setVersion(version.toString());
7272

73-
// Retrieve name from original SCL.
74-
var name = getCompasElement(scl, "SclFilename")
75-
.stream()
76-
.map(JAXBElement::getValue)
77-
.map(Object::toString)
78-
.findFirst();
7973
// Add name and type to SCL before storing the SCL.
80-
setSclCompasPrivateElement(scl, name, type);
74+
setSclCompasPrivateElement(scl, Optional.empty(), type);
8175

8276
repository.create(type, id, scl, version);
8377
}
@@ -101,7 +95,7 @@ private Optional<JAXBElement> getCompasElement(SCL scl, String name) {
10195
return getCompasPrivate(scl).stream()
10296
.map(TAnyContentFromOtherNamespace::getContent)
10397
.flatMap(List::stream)
104-
.filter(element -> element.getClass().equals(JAXBElement.class))
98+
.filter(element -> element instanceof JAXBElement)
10599
.map(element -> (JAXBElement) element)
106100
.filter(element -> element.getName().equals(new QName("https://www.lfenergy.org/compas/v1", name)))
107101
.findFirst();
@@ -131,11 +125,8 @@ private void setSclCompasPrivateElement(SCL scl, Optional<String> filename, SclT
131125
filename.ifPresent(value ->
132126
getCompasElement(scl, "SclFilename")
133127
.ifPresentOrElse(
134-
element -> {
135-
},
136-
() -> compasPrivate.getContent().add(compasPrivateElementFactory.createSclFilename(value)
137-
)
138-
)
128+
element -> element.setValue(value),
129+
() -> compasPrivate.getContent().add(compasPrivateElementFactory.createSclFilename(value)))
139130
);
140131

141132
TSclFileType sclFileType = TSclFileType.valueOf(fileType.toString());

0 commit comments

Comments
 (0)