Skip to content

Commit c724b0b

Browse files
committed
Added SDK notice subtype entity and repository
1 parent 5e3f420 commit c724b0b

5 files changed

Lines changed: 107 additions & 1 deletion

File tree

src/main/java/eu/europa/ted/eforms/sdk/SdkConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public class SdkConstants {
77
public static final String FIELDS_JSON_XML_STRUCTURE_KEY = "xmlStructure";
88
public static final String FIELDS_JSON_FIELDS_KEY = "fields";
99

10+
public static final String NOTICE_TYPES_JSON_SUBTYPES_KEY = "noticeSubTypes";
1011
public static final String NOTICE_TYPES_JSON_DOCUMENT_TYPES_KEY = "documentTypes";
1112
public static final String NOTICE_TYPES_JSON_DOCUMENT_TYPE_KEY = "documentType";
1213
public static final String NOTICE_TYPES_JSON_NAMESPACE_KEY = "namespace";

src/main/java/eu/europa/ted/eforms/sdk/component/SdkComponentType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
* Enumeration of component types that can be registered with the SDK component factory.
55
*/
66
public enum SdkComponentType {
7-
FIELD, NODE, CODELIST, EFX_EXPRESSION_TRANSLATOR, EFX_TEMPLATE_TRANSLATOR, EFX_RULES_TRANSLATOR, SYMBOL_RESOLVER, SCRIPT_GENERATOR, MARKUP_GENERATOR;
7+
FIELD, NODE, CODELIST, NOTICE_TYPE, EFX_EXPRESSION_TRANSLATOR, EFX_TEMPLATE_TRANSLATOR, EFX_RULES_TRANSLATOR, SYMBOL_RESOLVER, SCRIPT_GENERATOR, MARKUP_GENERATOR;
88
}

src/main/java/eu/europa/ted/eforms/sdk/entity/SdkEntityFactory.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,10 @@ public static SdkNode getSdkNode(String sdkVersion, JsonNode node) throws Instan
3030
return SdkEntityFactory.INSTANCE.getComponentImpl(sdkVersion, SdkComponentType.NODE,
3131
SdkNode.class, node);
3232
}
33+
34+
public static SdkNoticeSubtype getSdkNoticeType(final String sdkVersion, final JsonNode json)
35+
throws InstantiationException {
36+
return SdkEntityFactory.INSTANCE.getComponentImpl(sdkVersion, SdkComponentType.NOTICE_TYPE,
37+
SdkNoticeSubtype.class, json);
38+
}
3339
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package eu.europa.ted.eforms.sdk.entity;
2+
3+
import java.util.Objects;
4+
import com.fasterxml.jackson.databind.JsonNode;
5+
6+
/**
7+
* Represents a notice subtype from the SDK's notice-types.json file.
8+
*/
9+
public abstract class SdkNoticeSubtype {
10+
private final String subTypeId;
11+
private final String documentType;
12+
private final String type;
13+
14+
protected SdkNoticeSubtype(String subTypeId, String documentType, String type) {
15+
this.subTypeId = subTypeId;
16+
this.documentType = documentType;
17+
this.type = type;
18+
}
19+
20+
protected SdkNoticeSubtype(JsonNode json) {
21+
this.subTypeId = json.get("subTypeId").asText();
22+
this.documentType = json.get("documentType").asText();
23+
this.type = json.get("type").asText();
24+
}
25+
26+
/**
27+
* Returns the notice subtype ID (e.g., "1", "3", "CEI", "E1", "X01").
28+
* This is the primary identifier used for phase generation.
29+
*/
30+
public String getId() {
31+
return subTypeId;
32+
}
33+
34+
public String getSubTypeId() {
35+
return subTypeId;
36+
}
37+
38+
public String getDocumentType() {
39+
return documentType;
40+
}
41+
42+
public String getType() {
43+
return type;
44+
}
45+
46+
@Override
47+
public boolean equals(Object obj) {
48+
if (this == obj) {
49+
return true;
50+
}
51+
if (obj == null) {
52+
return false;
53+
}
54+
if (getClass() != obj.getClass()) {
55+
return false;
56+
}
57+
SdkNoticeSubtype other = (SdkNoticeSubtype) obj;
58+
return Objects.equals(subTypeId, other.subTypeId);
59+
}
60+
61+
@Override
62+
public int hashCode() {
63+
return Objects.hash(subTypeId);
64+
}
65+
66+
@Override
67+
public String toString() {
68+
return subTypeId;
69+
}
70+
}
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.repository;
2+
3+
import java.nio.file.Path;
4+
import com.fasterxml.jackson.databind.JsonNode;
5+
import com.fasterxml.jackson.databind.node.ArrayNode;
6+
import eu.europa.ted.eforms.sdk.SdkConstants;
7+
import eu.europa.ted.eforms.sdk.entity.SdkEntityFactory;
8+
import eu.europa.ted.eforms.sdk.entity.SdkNoticeSubtype;
9+
10+
/**
11+
* Repository for SDK notice types loaded from notice-types.json.
12+
* Maps notice subtype IDs (e.g., "1", "3", "CEI", "E1", "X01") to SdkNoticeSubtype objects.
13+
*/
14+
public class SdkNoticeTypeRepository extends MapFromJson<SdkNoticeSubtype> {
15+
private static final long serialVersionUID = 1L;
16+
17+
public SdkNoticeTypeRepository(String sdkVersion, Path jsonPath) throws InstantiationException {
18+
super(sdkVersion, jsonPath);
19+
}
20+
21+
@Override
22+
protected void populateMap(final JsonNode json) throws InstantiationException {
23+
final ArrayNode noticeTypes = (ArrayNode) json.get(SdkConstants.NOTICE_TYPES_JSON_SUBTYPES_KEY);
24+
for (final JsonNode noticeType : noticeTypes) {
25+
final SdkNoticeSubtype sdkNoticeType = SdkEntityFactory.getSdkNoticeType(sdkVersion, noticeType);
26+
put(sdkNoticeType.getId(), sdkNoticeType);
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)