Skip to content

Commit d2e250e

Browse files
author
Dennis Labordus
committed
Fixed sonar issues.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent f97582e commit d2e250e

File tree

3 files changed

+15
-60
lines changed

3 files changed

+15
-60
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import javax.xml.bind.annotation.XmlAccessorType;
99
import javax.xml.bind.annotation.XmlElement;
1010
import javax.xml.bind.annotation.XmlRootElement;
11-
import java.util.UUID;
1211

1312
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
1413

repository-basex/src/main/java/org/lfenergy/compas/scl/data/repository/CompasSclDataBaseXRepository.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public class CompasSclDataBaseXRepository implements CompasSclDataRepository {
6666
private static final String DECLARE_ID_VARIABLE = "declare variable $id := '%s';\n";
6767
private static final String DECLARE_PATH_VARIABLE = "declare variable $path := '%s';\n";
6868

69+
private static final String SCL_HEADER_ID_XPATH = "/scl:SCL/scl:Header/@id";
70+
private static final String SCL_HEADER_VERSION_XPATH = "/scl:SCL/scl:Header/@version";
71+
private static final String COMPAS_NAME_EXTENSION_XPATH = "/scl:SCL/scl:Private[@type='" + COMPAS_SCL_EXTENSION_TYPE + "']/compas:" + COMPAS_SCL_NAME_EXTENSION;
72+
6973
private final BaseXClientFactory baseXClientFactory;
7074
private final SclDataModelMarshaller sclDataMarshaller;
7175

@@ -93,11 +97,11 @@ public List<Item> list(SclType type) {
9397
DECLARE_LATEST_VERSION_FUNC +
9498
format(DECLARE_DB_VARIABLE, type) +
9599
"for $resource in db:open($db)\n" +
96-
" let $id := $resource/scl:SCL/scl:Header/@id\n" +
100+
" let $id := $resource" + SCL_HEADER_ID_XPATH + "\n" +
97101
" group by $id\n" +
98102
" let $latestScl := local:latest-version($db, $id)\n" +
99-
" let $version := $latestScl//scl:SCL/scl:Header/@version\n" +
100-
" let $name := $latestScl//scl:SCL/scl:Private[@type='" + COMPAS_SCL_EXTENSION_TYPE + "']/compas:" + COMPAS_SCL_NAME_EXTENSION + "\n" +
103+
" let $version := $latestScl" + SCL_HEADER_VERSION_XPATH + "\n" +
104+
" let $name := $latestScl" + COMPAS_NAME_EXTENSION_XPATH + "\n" +
101105
" order by fn:lower-case($name)\n" +
102106
" return '<Item xmlns=\"" + SCL_DATA_SERVICE_V1_NS_URI + "\"><Id>' || $id || '</Id><Name>' || $name || '</Name><Version>' || $version || '</Version></Item>'",
103107
sclDataMarshaller::unmarshalItem);
@@ -110,9 +114,9 @@ public List<Item> listVersionsByUUID(SclType type, UUID id) {
110114
format(DECLARE_DB_VARIABLE, type) +
111115
format(DECLARE_ID_VARIABLE, id) +
112116
"for $resource in db:open($db, $id)\n" +
113-
" let $id := $resource/scl:SCL/scl:Header/@id\n" +
114-
" let $name := $resource/scl:SCL/scl:Private[@type='" + COMPAS_SCL_EXTENSION_TYPE + "']/compas:" + COMPAS_SCL_NAME_EXTENSION + "\n" +
115-
" let $version := $resource/scl:SCL/scl:Header/@version\n" +
117+
" let $id := $resource" + SCL_HEADER_ID_XPATH + "\n" +
118+
" let $version := $resource" + SCL_HEADER_VERSION_XPATH + "\n" +
119+
" let $name := $resource" + COMPAS_NAME_EXTENSION_XPATH + "\n" +
116120
" let $parts := tokenize($version, '\\.')\n" +
117121
" let $majorVersion := xs:int($parts[1])\n" +
118122
" let $minorVersion := xs:int($parts[2])\n" +
@@ -170,9 +174,9 @@ public SclMetaInfo findMetaInfoByUUID(SclType type, UUID id) {
170174
"let $resource := local:latest-version($db, $id)" +
171175
"return if ($resource)\n" +
172176
"then (\n" +
173-
" let $id := $resource/scl:SCL/scl:Header/@id\n" +
174-
" let $name := $resource/scl:SCL/scl:Private[@type='" + COMPAS_SCL_EXTENSION_TYPE + "']/compas:" + COMPAS_SCL_NAME_EXTENSION + "\n" +
175-
" let $version := $resource/scl:SCL/scl:Header/@version\n" +
177+
" let $id := $resource" + SCL_HEADER_ID_XPATH + "\n" +
178+
" let $version := $resource" + SCL_HEADER_VERSION_XPATH + "\n" +
179+
" let $name := $resource" + COMPAS_NAME_EXTENSION_XPATH + "\n" +
176180
" return '<SclMetaInfo xmlns=\"" + SCL_DATA_SERVICE_V1_NS_URI + "\"><Id>' || $id || '</Id><Name>' || $name || '</Name><Version>' || $version || '</Version></SclMetaInfo>'\n" +
177181
")\n",
178182
sclDataMarshaller::unmarshalSclMetaInfo);

repository/src/main/java/org/lfenergy/compas/scl/data/model/SclMetaInfo.java

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,13 @@
55

66
import javax.xml.bind.annotation.XmlAccessType;
77
import javax.xml.bind.annotation.XmlAccessorType;
8-
import javax.xml.bind.annotation.XmlElement;
9-
10-
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
118

129
@XmlAccessorType(XmlAccessType.FIELD)
13-
public class SclMetaInfo {
14-
@XmlElement(
15-
name = "Id",
16-
namespace = SCL_DATA_SERVICE_V1_NS_URI,
17-
required = true
18-
)
19-
private String id;
20-
@XmlElement(
21-
name = "Name",
22-
namespace = SCL_DATA_SERVICE_V1_NS_URI,
23-
required = true
24-
)
25-
private String name;
26-
@XmlElement(
27-
name = "Version",
28-
namespace = SCL_DATA_SERVICE_V1_NS_URI,
29-
required = true
30-
)
31-
private String version;
32-
10+
public class SclMetaInfo extends Item {
3311
public SclMetaInfo() {
3412
}
3513

3614
public SclMetaInfo(String id, String name, String version) {
37-
this.id = id;
38-
this.name = name;
39-
this.version = version;
40-
}
41-
42-
public String getId() {
43-
return id;
44-
}
45-
46-
public void setId(String id) {
47-
this.id = id;
48-
}
49-
50-
public String getName() {
51-
return name;
52-
}
53-
54-
public void setName(String name) {
55-
this.name = name;
56-
}
57-
58-
public String getVersion() {
59-
return version;
60-
}
61-
62-
public void setVersion(String version) {
63-
this.version = version;
15+
super(id, name, version);
6416
}
6517
}

0 commit comments

Comments
 (0)