Skip to content

Commit 61d9329

Browse files
authored
Merge pull request #18 from OP-TED/release/1.0.5
Release/1.0.5
2 parents 4abec11 + 7b5e715 commit 61d9329

13 files changed

Lines changed: 773 additions & 162 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
# eForms Core Library 1.0.4 Release Notes
1+
# eForms Core Library 1.0.5 Release Notes
22

33
_The library is a collection of utilities that are used by our sample applications as well as the EFX Toolkit for Java Developers._
44

55
## In this release:
6-
This patch includes code optimizations and bug fixes.
6+
This patch
7+
- improves performance by lazy-loading codelists,
8+
- improves handling of SemVer 2.0 version numbers.
79

810
## Download
911

pom.xml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>eu.europa.ted.eforms</groupId>
55
<artifactId>eforms-core-java</artifactId>
6-
<version>1.0.4</version>
6+
<version>1.0.5</version>
77

88
<name>eForms Core Library</name>
99
<description>API and tools for eForms applications.</description>
@@ -44,7 +44,7 @@
4444
</distributionManagement>
4545

4646
<properties>
47-
<project.build.outputTimestamp>2023-05-10T15:13:30Z</project.build.outputTimestamp>
47+
<project.build.outputTimestamp>2023-05-10T15:47:46Z</project.build.outputTimestamp>
4848
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4949

5050
<sonatype.server.url>s01.oss.sonatype.org</sonatype.server.url>
@@ -58,8 +58,7 @@
5858
<version.commons-collections>3.2.2</version.commons-collections>
5959
<version.commons-io>2.11.0</version.commons-io>
6060
<version.commons-lang3>3.12.0</version.commons-lang3>
61-
<version.jackson>2.13.4</version.jackson>
62-
<version.jackson-databind>2.13.4.2</version.jackson-databind>
61+
<version.jackson>2.15.1</version.jackson>
6362
<version.jool>0.9.15</version.jool>
6463
<version.jsr305>3.0.2</version.jsr305>
6564
<version.junit>5.7.2</version.junit>
@@ -69,6 +68,7 @@
6968
<version.ph-genericode>6.2.0</version.ph-genericode>
7069
<version.reflections>0.10.2</version.reflections>
7170
<version.resolver>1.8.2</version.resolver>
71+
<version.semver4j>3.1.0</version.semver4j>
7272
<version.slf4j>2.0.3</version.slf4j>
7373

7474
<!-- Versions - Plugins -->
@@ -103,7 +103,7 @@
103103
<dependency>
104104
<groupId>com.fasterxml.jackson.core</groupId>
105105
<artifactId>jackson-databind</artifactId>
106-
<version>${version.jackson-databind}</version>
106+
<version>${version.jackson}</version>
107107
</dependency>
108108

109109
<!-- Apache Commons -->
@@ -221,6 +221,11 @@
221221
<artifactId>junit-jupiter-api</artifactId>
222222
<version>${version.junit}</version>
223223
</dependency>
224+
<dependency>
225+
<groupId>com.vdurmont</groupId>
226+
<artifactId>semver4j</artifactId>
227+
<version>${version.semver4j}</version>
228+
</dependency>
224229
</dependencies>
225230
</dependencyManagement>
226231

@@ -342,6 +347,10 @@
342347
<artifactId>junit-jupiter-api</artifactId>
343348
<scope>test</scope>
344349
</dependency>
350+
<dependency>
351+
<groupId>com.vdurmont</groupId>
352+
<artifactId>semver4j</artifactId>
353+
</dependency>
345354
</dependencies>
346355

347356
<build>
Lines changed: 21 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,60 @@
11
package eu.europa.ted.eforms.sdk;
22

3-
import java.text.MessageFormat;
43
import java.util.ArrayList;
54
import java.util.List;
65
import java.util.Objects;
7-
import java.util.Optional;
86
import org.apache.commons.lang3.StringUtils;
97
import org.apache.commons.lang3.Validate;
108

11-
public class SdkVersion implements Comparable<SdkVersion> {
12-
private static final String FORMAT_PATTERN = "{0}.{1}.{2}";
13-
14-
private String major = "0";
15-
16-
private String minor = "0";
9+
import com.vdurmont.semver4j.Semver;
10+
import com.vdurmont.semver4j.Semver.SemverType;
1711

18-
private String patch = "0";
19-
20-
private boolean isPatch = false;
12+
public class SdkVersion implements Comparable<SdkVersion> {
2113

22-
@SuppressWarnings("unused")
23-
private SdkVersion() {}
14+
private final Semver version;
2415

2516
public SdkVersion(final String version) {
2617
Validate.notBlank(version, "Undefined version");
27-
Validate.matchesPattern(version, "[0-9]+(\\.[0-9]+)*(-SNAPSHOT)?", "Invalid version format");
28-
29-
String[] versionParts = version.split("\\.");
3018

31-
this.major = versionParts[0];
19+
// LOOSE because we need to accept MAJOR.MINOR
20+
this.version = new Semver(version, SemverType.LOOSE);
3221

33-
if (versionParts.length > 1) {
34-
this.minor = versionParts[1];
35-
}
36-
37-
if (versionParts.length > 2) {
38-
this.isPatch = true;
39-
this.patch = versionParts[2];
40-
}
22+
// Check that we did get a MINOR part
23+
Validate.notNull(this.version.getMinor());
4124
}
4225

4326
public String getMajor() {
44-
return major;
27+
return version.getMajor().toString();
4528
}
4629

4730
public String getMinor() {
48-
return minor;
31+
return version.getMinor().toString();
4932
}
5033

5134
public String getPatch() {
52-
return patch;
35+
return version.getPatch() == null ? "0" : version.getPatch().toString();
5336
}
5437

5538
public String getNextMajor() {
56-
return new SdkVersion(MessageFormat.format(FORMAT_PATTERN, getAsInt(major) + 1, minor, patch))
57-
.toString();
39+
return version.withIncMajor().toString();
5840
}
5941

6042
public String getNextMinor() {
61-
return new SdkVersion(MessageFormat.format(FORMAT_PATTERN, major, getAsInt(minor) + 1, patch))
62-
.toString();
43+
return version.withIncMinor().toString();
6344
}
6445

6546
public boolean isPatch() {
66-
return isPatch;
47+
return version.getPatch() != null;
6748
}
6849

6950
public String toNormalisedString(boolean withPatch) {
7051
List<String> parts = new ArrayList<>();
7152

72-
parts.add(major);
73-
parts.add(minor);
53+
parts.add(getMajor());
54+
parts.add(getMinor());
7455

7556
if (withPatch) {
76-
parts.add(patch);
57+
parts.add(getPatch());
7758
}
7859

7960
return StringUtils.join(parts, ".");
@@ -85,7 +66,7 @@ public String toStringWithoutPatch() {
8566

8667
@Override
8768
public String toString() {
88-
return toNormalisedString(true);
69+
return version.toString();
8970
}
9071

9172
@Override
@@ -98,24 +79,12 @@ public int compareTo(SdkVersion that) {
9879
return 0;
9980
}
10081

101-
if (getAsInt(this.getMajor()) == getAsInt(that.getMajor())) {
102-
if (getAsInt(this.getMinor()) == getAsInt(that.getMinor())) {
103-
return getAsInt(this.getPatch()) < getAsInt(that.getPatch()) ? -1 : 1;
104-
} else {
105-
return getAsInt(this.getMinor()) < getAsInt(that.getMinor()) ? -1 : 1;
106-
}
107-
} else {
108-
return getAsInt(this.getMajor()) < getAsInt(that.getMajor()) ? -1 : 1;
109-
}
110-
}
111-
112-
private int getAsInt(String versionPart) {
113-
return Integer.parseInt(Optional.ofNullable(versionPart).orElse("0").replace("-SNAPSHOT", ""));
82+
return version.compareTo(that.version);
11483
}
11584

11685
@Override
11786
public int hashCode() {
118-
return Objects.hash(major, minor, patch);
87+
return Objects.hash(version);
11988
}
12089

12190
@Override
@@ -127,7 +96,6 @@ public boolean equals(Object obj) {
12796
if (getClass() != obj.getClass())
12897
return false;
12998
SdkVersion other = (SdkVersion) obj;
130-
return Objects.equals(major, other.major) && Objects.equals(minor, other.minor)
131-
&& Objects.equals(patch, other.patch);
99+
return Objects.equals(version, other.version);
132100
}
133101
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package eu.europa.ted.eforms.sdk.domain.codelist;
2+
3+
import java.io.Serializable;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
public class CodelistForIndex implements Serializable {
7+
private static final long serialVersionUID = 4221672498810948002L;
8+
9+
private String id;
10+
private String parentId;
11+
private String filename;
12+
private String description;
13+
14+
@JsonProperty("_label")
15+
private String labelId;
16+
17+
public String getId() {
18+
return id;
19+
}
20+
21+
public String getParentId() {
22+
return parentId;
23+
}
24+
25+
public String getFilename() {
26+
return filename;
27+
}
28+
29+
public String getDescription() {
30+
return description;
31+
}
32+
33+
@JsonProperty("_label")
34+
public String getLabel() {
35+
return labelId;
36+
}
37+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package eu.europa.ted.eforms.sdk.domain.codelist;
2+
3+
import java.io.Serializable;
4+
import java.util.List;
5+
6+
public class CodelistsIndex implements Serializable {
7+
private static final long serialVersionUID = -6549217565224309697L;
8+
9+
private List<CodelistForIndex> codelists;
10+
11+
public List<CodelistForIndex> getCodelists() {
12+
return codelists;
13+
}
14+
}

0 commit comments

Comments
 (0)