Skip to content
Open
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</developers>

<properties>
<revision>1.6.2-SNAPSHOT</revision>
<revision>1.0.0-RC1</revision>
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,20 @@ private void processNestedEntityComposition(
return;
}

// Get the actual key field names from the entity instead of hardcoding "ID"
List<String> keyElementNames = getKeyElementNames(nestedDraftEntity.get());

Result nestedRecords =
persistenceService.run(
Select.from(nestedDraftEntity.get())
.columns("ID")
.where(e -> e.get("IsActiveEntity").eq(false)));
Select.from(nestedDraftEntity.get()).where(e -> e.get("IsActiveEntity").eq(false)));

for (Row nestedRecord : nestedRecords) {
Object nestedEntityId = nestedRecord.get("ID");

Map<String, Object> nestedEntityKeys = new HashMap<>();
nestedEntityKeys.put("ID", nestedEntityId);

// Populate the key map with all actual key field names and values
for (String keyName : keyElementNames) {
nestedEntityKeys.put(keyName, nestedRecord.get(keyName));
}
nestedEntityKeys.put("IsActiveEntity", false);

for (Map.Entry<String, String> entry : nestedAttachmentMapping.entrySet()) {
Expand Down Expand Up @@ -429,6 +432,18 @@ private String getUpIdKey(CdsEntity attachmentDraftEntity) {
return upIdKey;
}

/**
* Retrieves the key element names from a CdsEntity. This method extracts the names of all key
* fields defined in the entity, allowing for dynamic key field handling instead of hardcoding
* "ID".
*
* @param entity the CdsEntity to extract key element names from
* @return a list of key element names
*/
private List<String> getKeyElementNames(CdsEntity entity) {
return entity.elements().filter(CdsElement::isKey).map(CdsElement::getName).toList();
}

private void checkAttachmentConstraints(
EventContext context, CdsEntity attachmentDraftEntity, String upID, String upIdKey)
throws ServiceException {
Expand Down
Loading