Skip to content
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

Edg 33 certification info string to object #49

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,24 @@ protected void configure(final E epcisEvent, final List<EventIdentifierTracker>
epcisEvent.setSensorElementList(typeInfo.getSensorElementList());
}

// Add the certificationInfo
// Add the certificationInfo by formatting from UserExtension syntax
if (typeInfo.getCertificationInfo() != null && !typeInfo.getCertificationInfo().isEmpty()) {
epcisEvent.setCertificationInfo(typeInfo.getCertificationInfo());
final List<Object> formattedCertificationInfo = typeInfo.getCertificationInfo().stream()
.flatMap(root -> {
if (CollectionUtils.isNotEmpty(root.getChildren())) {
// Stream over children if present
return root.getChildren().stream().flatMap(c -> c.toMap().entrySet().stream());
} else if (root.getRawJsonld() instanceof Map) {
// Stream over rawJsonld if it's a Map
return root.toMap().entrySet().stream();
}
// Return an empty stream if neither are present
return Stream.empty();
}).collect(Collectors.toList());

if (!formattedCertificationInfo.isEmpty()) {
epcisEvent.setCertificationInfo(formattedCertificationInfo);
}
}

// User extensions addition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ public class EPCISEventType implements Serializable {
private @Valid String hashAlgorithm;

@Schema(
type = SchemaType.STRING,
description = "URL at which certification details can be found.")
private String certificationInfo;
type = SchemaType.ARRAY,
description = "Certification information associated with the event in GS1 Web Vocabulary or Raw JSON-LD format")
private List<@Valid UserExtensionSyntax> certificationInfo;

@Schema(
type = SchemaType.ARRAY,
Expand Down
Loading