Skip to content

Commit

Permalink
Merge pull request #434 from eclipse/thomas/dev-factory-fix
Browse files Browse the repository at this point in the history
Mark metadata DTOs with NullAction.IGNORE
  • Loading branch information
tcalmant authored Jul 29, 2024
2 parents 9ce35b1 + 5dfb831 commit aa33a6c
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.eclipse.sensinact.core.annotation.dto.NullAction;
import org.eclipse.sensinact.core.push.DataUpdate;
import org.eclipse.sensinact.core.push.DataUpdateException;
import org.eclipse.sensinact.core.push.FailedUpdatesException;
Expand Down Expand Up @@ -388,16 +389,6 @@ private List<GenericDto> handleRecord(final DeviceMappingConfigurationDTO config
}
}

// Add metadata updates
for (Entry<String, Map<String, Map<String, Object>>> svcEntry : allMetadata.entrySet()) {
final String svcName = svcEntry.getKey();
for (Entry<String, Map<String, Object>> rcEntry : svcEntry.getValue().entrySet()) {
logger.warn("ADDING METADATA TO {}/{}/{} -> {}", provider, svcName, rcEntry.getKey(), rcEntry.getValue());
bulk.add(makeMetadataDto(modelPackageUri, model, provider, svcName, rcEntry.getKey(),
rcEntry.getValue()));
}
}

// Remove null entries
bulk.removeIf(Objects::isNull);

Expand All @@ -406,6 +397,15 @@ private List<GenericDto> handleRecord(final DeviceMappingConfigurationDTO config
dto.nullAction = options.nullAction;
});

// Add metadata updates afterwards, to avoid the null action to be overwritten
for (Entry<String, Map<String, Map<String, Object>>> svcEntry : allMetadata.entrySet()) {
final String svcName = svcEntry.getKey();
for (Entry<String, Map<String, Object>> rcEntry : svcEntry.getValue().entrySet()) {
bulk.add(makeMetadataDto(modelPackageUri, model, provider, svcName, rcEntry.getKey(),
rcEntry.getValue()));
}
}

return bulk;
}

Expand Down Expand Up @@ -456,6 +456,7 @@ private GenericDto makeMetadataDto(final String modelPackageUri, final String mo
dto.service = service;
dto.resource = resource;
dto.metadata = metadata;
dto.nullAction = NullAction.IGNORE;
return dto;
}

Expand Down

0 comments on commit aa33a6c

Please sign in to comment.