Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/eu/europa/ted/eforms/sdk/SdkConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class SdkConstants {
public static final String FIELDS_JSON_XML_STRUCTURE_KEY = "xmlStructure";
public static final String FIELDS_JSON_FIELDS_KEY = "fields";

public static final String NOTICE_TYPES_JSON_SUBTYPES_KEY = "noticeSubTypes";
public static final String NOTICE_TYPES_JSON_DOCUMENT_TYPES_KEY = "documentTypes";
public static final String NOTICE_TYPES_JSON_DOCUMENT_TYPE_KEY = "documentType";
public static final String NOTICE_TYPES_JSON_NAMESPACE_KEY = "namespace";
Expand Down
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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value name "NOTICE_TYPE" is inconsistent with the corresponding class SdkNoticeSubtype, but it corresponds to the folder named "notice-types" in the SDK.
So I'm not sure which is the best name here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure either... We will have a name finalisation debate before we release the SDK. The subtypes are a common naming problem but there are others like for example the fact that we interchangeably use the terms "string" and "text" in the grammar. We will deal with any such remaining naming issues when all else i ready.

SYMBOL_RESOLVER, SCRIPT_GENERATOR, MARKUP_GENERATOR, VALIDATOR_GENERATOR;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@ public static SdkNode getSdkNode(String sdkVersion, JsonNode node) throws Instan
return SdkEntityFactory.INSTANCE.getComponentImpl(sdkVersion, SdkComponentType.NODE,
SdkNode.class, node);
}

public static SdkNoticeSubtype getSdkNoticeType(final String sdkVersion, final JsonNode json)
Comment thread
rousso marked this conversation as resolved.
Outdated
throws InstantiationException {
return SdkEntityFactory.INSTANCE.getComponentImpl(sdkVersion, SdkComponentType.NOTICE_TYPE,
SdkNoticeSubtype.class, json);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar classes in this folder are described in the README file in the folder. So this new class should also be described in this README, for consistency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please address this remark by adding an adequate reference to this class in the respected README file.

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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 {
Comment thread
rousso marked this conversation as resolved.
Outdated
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();
this.documentType = json.get("documentType").asText();
this.type = json.get("type").asText();
Comment thread
rousso marked this conversation as resolved.
Outdated
}

/**
* 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
Copy link

Copilot AI Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getId() method returns subTypeId which can be null (set via asText(null) in the JsonNode constructor at line 21). This could cause NullPointerException in callers who expect a non-null value, such as in SdkNoticeTypeRepository.java:26 where it's used as a map key, and in the compareTo method. Consider validating that critical fields like subTypeId are non-null after construction, or document that null is a valid return value.

Copilot uses AI. Check for mistakes.

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 hashCode() {
return Objects.hash(subTypeId);
}

@Override
public String toString() {
return subTypeId;
Comment thread
rousso marked this conversation as resolved.
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar classes in this folder are described in the README file in the folder. So this new class should also be described in this README, for consistency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please address this remark by adding an adequate reference to this class in the respected README file.

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 noticeTypes = (ArrayNode) json.get(SdkConstants.NOTICE_TYPES_JSON_SUBTYPES_KEY);
for (final JsonNode noticeType : noticeTypes) {
final SdkNoticeSubtype sdkNoticeType = SdkEntityFactory.getSdkNoticeType(sdkVersion, noticeType);
Comment thread
rousso marked this conversation as resolved.
Outdated
put(sdkNoticeType.getId(), sdkNoticeType);
Comment thread
rousso marked this conversation as resolved.
Outdated
}
}
}
Loading