-
Notifications
You must be signed in to change notification settings - Fork 1
Tedefo 4805 efx rules translator #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
5e3f420
c724b0b
0331b91
7d77eff
dd51af2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| package eu.europa.ted.eforms.sdk.component; | ||
|
|
||
| /** | ||
| * Enumeration of component types that can be registered with the SDK component factory. | ||
| * Enumeration of component types that can be registered with the SDK component | ||
| * factory. | ||
| */ | ||
| public enum SdkComponentType { | ||
| FIELD, NODE, CODELIST, EFX_EXPRESSION_TRANSLATOR, EFX_TEMPLATE_TRANSLATOR, SYMBOL_RESOLVER, SCRIPT_GENERATOR, MARKUP_GENERATOR; | ||
| FIELD, NODE, CODELIST, NOTICE_TYPE, EFX_EXPRESSION_TRANSLATOR, EFX_TEMPLATE_TRANSLATOR, EFX_RULES_TRANSLATOR, | ||
| SYMBOL_RESOLVER, SCRIPT_GENERATOR, MARKUP_GENERATOR, VALIDATOR_GENERATOR; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| package eu.europa.ted.eforms.sdk.entity; | ||
|
|
||
| import java.util.Objects; | ||
| import com.fasterxml.jackson.databind.JsonNode; | ||
|
|
||
| /** | ||
| * Represents a notice subtype from the SDK's notice-types.json file. | ||
| */ | ||
| public abstract class SdkNoticeSubtype implements Comparable<SdkNoticeSubtype> { | ||
| private final String subTypeId; | ||
| private final String documentType; | ||
| private final String type; | ||
|
|
||
| protected SdkNoticeSubtype(String subTypeId, String documentType, String type) { | ||
| this.subTypeId = subTypeId; | ||
| this.documentType = documentType; | ||
| this.type = type; | ||
| } | ||
|
|
||
| protected SdkNoticeSubtype(JsonNode json) { | ||
| this.subTypeId = json.get("subTypeId").asText(null); | ||
| this.documentType = json.get("documentType").asText(null); | ||
| this.type = json.get("type").asText(null); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the notice subtype ID (e.g., "1", "3", "CEI", "E1", "X01"). | ||
| * This is the primary identifier used for phase generation. | ||
| */ | ||
| public String getId() { | ||
| return subTypeId; | ||
| } | ||
|
Comment on lines
+30
to
+32
|
||
|
|
||
| public String getSubTypeId() { | ||
| return subTypeId; | ||
| } | ||
|
|
||
| public String getDocumentType() { | ||
| return documentType; | ||
| } | ||
|
|
||
| public String getType() { | ||
| return type; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object obj) { | ||
| if (this == obj) { | ||
| return true; | ||
| } | ||
| if (obj == null) { | ||
| return false; | ||
| } | ||
| if (getClass() != obj.getClass()) { | ||
| return false; | ||
| } | ||
| SdkNoticeSubtype other = (SdkNoticeSubtype) obj; | ||
| return Objects.equals(subTypeId, other.subTypeId); | ||
| } | ||
|
|
||
| @Override | ||
| public int compareTo(SdkNoticeSubtype o) { | ||
| return this.subTypeId.compareTo(o.subTypeId); | ||
| } | ||
|
Comment on lines
+62
to
+64
|
||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(subTypeId); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return subTypeId; | ||
rousso marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package eu.europa.ted.eforms.sdk.repository; | ||
|
|
||
| import java.nio.file.Path; | ||
| import com.fasterxml.jackson.databind.JsonNode; | ||
| import com.fasterxml.jackson.databind.node.ArrayNode; | ||
| import eu.europa.ted.eforms.sdk.SdkConstants; | ||
| import eu.europa.ted.eforms.sdk.entity.SdkEntityFactory; | ||
| import eu.europa.ted.eforms.sdk.entity.SdkNoticeSubtype; | ||
|
|
||
| /** | ||
| * Repository for SDK notice types loaded from notice-types.json. | ||
| * Maps notice subtype IDs (e.g., "1", "3", "CEI", "E1", "X01") to SdkNoticeSubtype objects. | ||
| */ | ||
| public class SdkNoticeTypeRepository extends MapFromJson<SdkNoticeSubtype> { | ||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| public SdkNoticeTypeRepository(String sdkVersion, Path jsonPath) throws InstantiationException { | ||
| super(sdkVersion, jsonPath); | ||
| } | ||
|
|
||
| @Override | ||
| protected void populateMap(final JsonNode json) throws InstantiationException { | ||
| final ArrayNode noticeSubtypes = (ArrayNode) json.get(SdkConstants.NOTICE_TYPES_JSON_SUBTYPES_KEY); | ||
| for (final JsonNode noticeSubtype : noticeSubtypes) { | ||
| final SdkNoticeSubtype sdkNoticeSubtype = SdkEntityFactory.getSdkNoticeSubtype(sdkVersion, noticeSubtype); | ||
| put(sdkNoticeSubtype.getId(), sdkNoticeSubtype); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JsonNode constructor does not validate that required JSON fields (subTypeId, documentType, type) exist before accessing them. If json.get("subTypeId") returns null, calling asText(null) on it will throw a NullPointerException. Consider adding null checks or using safer accessor methods like json.has("subTypeId") before accessing, consistent with how SdkNode handles optional fields (see SdkNode.java:27).