Skip to content

Commit 57087ca

Browse files
committed
TEDEFO-2129: Move versioned SDK entity classes from EXT to ECL
1 parent a58966b commit 57087ca

8 files changed

Lines changed: 258 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package eu.europa.ted.eforms.sdk.entity.v1;
2+
3+
import java.util.List;
4+
import java.util.Optional;
5+
import eu.europa.ted.eforms.sdk.component.SdkComponent;
6+
import eu.europa.ted.eforms.sdk.component.SdkComponentType;
7+
import eu.europa.ted.eforms.sdk.entity.SdkCodelist;
8+
9+
/**
10+
* Representation of an SdkCodelist for usage in the symbols map.
11+
*
12+
* @author rouschr
13+
*/
14+
@SdkComponent(versions = {"1"}, componentType = SdkComponentType.CODELIST)
15+
public class SdkCodelistV1 extends SdkCodelist {
16+
17+
public SdkCodelistV1(final String codelistId, final String codelistVersion,
18+
final List<String> codes, final Optional<String> parentId) {
19+
super(codelistId, codelistVersion, codes, parentId);
20+
}
21+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package eu.europa.ted.eforms.sdk.entity.v1;
2+
3+
import java.util.Map;
4+
import com.fasterxml.jackson.annotation.JsonCreator;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import com.fasterxml.jackson.databind.JsonNode;
7+
import eu.europa.ted.eforms.sdk.component.SdkComponent;
8+
import eu.europa.ted.eforms.sdk.component.SdkComponentType;
9+
import eu.europa.ted.eforms.sdk.entity.SdkField;
10+
11+
@SdkComponent(versions = {"1"}, componentType = SdkComponentType.FIELD)
12+
public class SdkFieldV1 extends SdkField {
13+
14+
public SdkFieldV1(final String id, final String type, final String parentNodeId,
15+
final String xpathAbsolute, final String xpathRelative, final String codelistId,
16+
final boolean repeatable) {
17+
super(id, type, parentNodeId, xpathAbsolute, xpathRelative, codelistId, repeatable);
18+
}
19+
20+
public SdkFieldV1(final JsonNode field) {
21+
super(field);
22+
}
23+
24+
@JsonCreator
25+
public SdkFieldV1(
26+
@JsonProperty("id") final String id,
27+
@JsonProperty("type") final String type,
28+
@JsonProperty("parentNodeId") final String parentNodeId,
29+
@JsonProperty("xpathAbsolute") final String xpathAbsolute,
30+
@JsonProperty("xpathRelative") final String xpathRelative,
31+
@JsonProperty("codeList") final Map<String, Map<String, String>> codelist,
32+
@JsonProperty("repeatable") final Map<String, Object> repeatable) {
33+
this(id, type, parentNodeId, xpathAbsolute, xpathRelative, getCodelistId(codelist),
34+
getRepeatable(repeatable));
35+
}
36+
37+
protected static String getCodelistId(Map<String, Map<String, String>> codelist) {
38+
if (codelist == null) {
39+
return null;
40+
}
41+
42+
Map<String, String> value = codelist.get("value");
43+
if (value == null) {
44+
return null;
45+
}
46+
47+
return value.get("id");
48+
}
49+
50+
protected static boolean getRepeatable(Map<String, Object> repeatable) {
51+
if (repeatable == null) {
52+
return false;
53+
}
54+
55+
// If there are constraints, the field may repeat conditionally - treat as repeatable
56+
Object constraints = repeatable.get("constraints");
57+
if (constraints != null) {
58+
return true;
59+
}
60+
61+
// Otherwise check the default value
62+
Object value = repeatable.get("value");
63+
return Boolean.TRUE.equals(value);
64+
}
65+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package eu.europa.ted.eforms.sdk.entity.v1;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import com.fasterxml.jackson.databind.JsonNode;
6+
import eu.europa.ted.eforms.sdk.component.SdkComponent;
7+
import eu.europa.ted.eforms.sdk.component.SdkComponentType;
8+
import eu.europa.ted.eforms.sdk.entity.SdkNode;
9+
10+
/**
11+
* A node is something like a section. Nodes can be parents of other nodes or parents of fields.
12+
*/
13+
@SdkComponent(versions = {"1"}, componentType = SdkComponentType.NODE)
14+
public class SdkNodeV1 extends SdkNode {
15+
16+
@JsonCreator
17+
public SdkNodeV1(
18+
@JsonProperty("id") String id,
19+
@JsonProperty("parentId") String parentId,
20+
@JsonProperty("xpathAbsolute") String xpathAbsolute,
21+
@JsonProperty("xpathRelative") String xpathRelative,
22+
@JsonProperty("repeatable") boolean repeatable) {
23+
super(id, parentId, xpathAbsolute, xpathRelative, repeatable);
24+
}
25+
26+
public SdkNodeV1(JsonNode node) {
27+
super(node);
28+
}
29+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package eu.europa.ted.eforms.sdk.entity.v1;
2+
3+
import com.fasterxml.jackson.databind.JsonNode;
4+
import eu.europa.ted.eforms.sdk.component.SdkComponent;
5+
import eu.europa.ted.eforms.sdk.component.SdkComponentType;
6+
import eu.europa.ted.eforms.sdk.entity.SdkNoticeSubtype;
7+
8+
/**
9+
* Represents a notice subtype from the SDK's notice-types.json file.
10+
*/
11+
@SdkComponent(versions = {"1"}, componentType = SdkComponentType.NOTICE_TYPE)
12+
public class SdkNoticeSubtypeV1 extends SdkNoticeSubtype {
13+
14+
public SdkNoticeSubtypeV1(String subTypeId, String documentType, String type) {
15+
super(subTypeId, documentType, type);
16+
}
17+
18+
public SdkNoticeSubtypeV1(JsonNode json) {
19+
super(json);
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package eu.europa.ted.eforms.sdk.entity.v2;
2+
3+
import java.util.List;
4+
import java.util.Optional;
5+
import eu.europa.ted.eforms.sdk.component.SdkComponent;
6+
import eu.europa.ted.eforms.sdk.component.SdkComponentType;
7+
import eu.europa.ted.eforms.sdk.entity.v1.SdkCodelistV1;
8+
9+
/**
10+
* Representation of an SdkCodelist for usage in the symbols map.
11+
*
12+
* @author rouschr
13+
*/
14+
@SdkComponent(versions = {"2"}, componentType = SdkComponentType.CODELIST)
15+
public class SdkCodelistV2 extends SdkCodelistV1 {
16+
17+
public SdkCodelistV2(final String codelistId, final String codelistVersion,
18+
final List<String> codes, final Optional<String> parentId) {
19+
super(codelistId, codelistVersion, codes, parentId);
20+
}
21+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package eu.europa.ted.eforms.sdk.entity.v2;
2+
3+
import java.util.Map;
4+
import com.fasterxml.jackson.annotation.JsonCreator;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import com.fasterxml.jackson.databind.JsonNode;
7+
import eu.europa.ted.eforms.sdk.component.SdkComponent;
8+
import eu.europa.ted.eforms.sdk.component.SdkComponentType;
9+
import eu.europa.ted.eforms.sdk.entity.v1.SdkFieldV1;
10+
11+
@SdkComponent(versions = {"2"}, componentType = SdkComponentType.FIELD)
12+
public class SdkFieldV2 extends SdkFieldV1 {
13+
private final String alias;
14+
15+
public SdkFieldV2(String id, String type, String parentNodeId, String xpathAbsolute,
16+
String xpathRelative, String rootCodelistId, boolean repeatable, String alias) {
17+
super(id, type, parentNodeId, xpathAbsolute, xpathRelative, rootCodelistId, repeatable);
18+
this.alias = alias;
19+
}
20+
21+
public SdkFieldV2(JsonNode fieldNode) {
22+
super(fieldNode);
23+
this.alias = fieldNode.has("alias") ? fieldNode.get("alias").asText(null) : null;
24+
}
25+
26+
@JsonCreator
27+
public SdkFieldV2(
28+
@JsonProperty("id") final String id,
29+
@JsonProperty("type") final String type,
30+
@JsonProperty("parentNodeId") final String parentNodeId,
31+
@JsonProperty("xpathAbsolute") final String xpathAbsolute,
32+
@JsonProperty("xpathRelative") final String xpathRelative,
33+
@JsonProperty("codeList") final Map<String, Map<String, String>> codelist,
34+
@JsonProperty("repeatable") final Map<String, Object> repeatable,
35+
@JsonProperty("alias") final String alias) {
36+
this(id, type, parentNodeId, xpathAbsolute, xpathRelative, getCodelistId(codelist),
37+
getRepeatable(repeatable), alias);
38+
}
39+
40+
public String getAlias() {
41+
return alias;
42+
}
43+
}
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.entity.v2;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import com.fasterxml.jackson.databind.JsonNode;
6+
import eu.europa.ted.eforms.sdk.component.SdkComponent;
7+
import eu.europa.ted.eforms.sdk.component.SdkComponentType;
8+
import eu.europa.ted.eforms.sdk.entity.v1.SdkNodeV1;
9+
10+
/**
11+
* A node is something like a section. Nodes can be parents of other nodes or parents of fields.
12+
*/
13+
@SdkComponent(versions = {"2"}, componentType = SdkComponentType.NODE)
14+
public class SdkNodeV2 extends SdkNodeV1 {
15+
private final String alias;
16+
17+
@JsonCreator
18+
public SdkNodeV2(
19+
@JsonProperty("id") String id,
20+
@JsonProperty("parentId") String parentId,
21+
@JsonProperty("xpathAbsolute") String xpathAbsolute,
22+
@JsonProperty("xpathRelative") String xpathRelative,
23+
@JsonProperty("repeatable") boolean repeatable,
24+
@JsonProperty("alias") String alias) {
25+
super(id, parentId, xpathAbsolute, xpathRelative, repeatable);
26+
this.alias = alias;
27+
}
28+
29+
public SdkNodeV2(JsonNode node) {
30+
super(node);
31+
this.alias = node.has("alias") ? node.get("alias").asText(null) : null;
32+
}
33+
34+
public String getAlias() {
35+
return alias;
36+
}
37+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package eu.europa.ted.eforms.sdk.entity.v2;
2+
3+
import com.fasterxml.jackson.databind.JsonNode;
4+
import eu.europa.ted.eforms.sdk.component.SdkComponent;
5+
import eu.europa.ted.eforms.sdk.component.SdkComponentType;
6+
import eu.europa.ted.eforms.sdk.entity.v1.SdkNoticeSubtypeV1;
7+
8+
/**
9+
* Represents a notice subtype from the SDK's notice-types.json file.
10+
*/
11+
@SdkComponent(versions = {"2"}, componentType = SdkComponentType.NOTICE_TYPE)
12+
public class SdkNoticeSubtypeV2 extends SdkNoticeSubtypeV1 {
13+
14+
public SdkNoticeSubtypeV2(String subTypeId, String documentType, String type) {
15+
super(subTypeId, documentType, type);
16+
}
17+
18+
public SdkNoticeSubtypeV2(JsonNode json) {
19+
super(json);
20+
}
21+
}

0 commit comments

Comments
 (0)