diff options
Diffstat (limited to 'v3po/translate-impl')
3 files changed, 19 insertions, 9 deletions
diff --git a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeListReader.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeListReader.java index de32ee723..4c84c3afe 100644 --- a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeListReader.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/read/CompositeListReader.java @@ -133,9 +133,11 @@ public final class CompositeListReader<C extends DataObject & Identifiable<K>, K RWUtils.getCurrentIdItem(id, key); final InstanceIdentifier<C> keyedId = RWUtils.replaceLastInId(id, currentBdItem); final Optional<C> read = readCurrent(keyedId, ctx); - final DataObject singleItem = read.get(); - checkArgument(getManagedDataObjectType().getTargetType().isAssignableFrom(singleItem.getClass())); - allEntries.add(getManagedDataObjectType().getTargetType().cast(singleItem)); + if(read.isPresent()) { + final DataObject singleItem = read.get(); + checkArgument(getManagedDataObjectType().getTargetType().isAssignableFrom(singleItem.getClass())); + allEntries.add(getManagedDataObjectType().getTargetType().cast(singleItem)); + } } return allEntries; } diff --git a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/AbstractCompositeWriter.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/AbstractCompositeWriter.java index 1e4d1361a..603f2a868 100644 --- a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/AbstractCompositeWriter.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/AbstractCompositeWriter.java @@ -98,6 +98,7 @@ public abstract class AbstractCompositeWriter<D extends DataObject> implements W final WriteContext ctx) throws WriteFailedException { LOG.debug("{}: Updating current: {} dataBefore: {}, datAfter: {}", this, id, dataBefore, dataAfter); +/* FIXME: Equals does not work: LINK */ if (dataBefore.equals(dataAfter)) { LOG.debug("{}: Skipping current(no update): {}", this, id); // No change, ignore diff --git a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java index 512eb44d9..54a09f272 100644 --- a/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java +++ b/v3po/translate-impl/src/main/java/io/fd/honeycomb/v3po/translate/impl/write/CompositeChildWriter.java @@ -95,12 +95,12 @@ public class CompositeChildWriter<D extends DataObject> extends AbstractComposit @Override public void deleteChild(@Nonnull final InstanceIdentifier<? extends DataObject> parentId, - @Nonnull final DataObject parentData, + @Nonnull final DataObject parentDataBefore, @Nonnull final WriteContext ctx) throws WriteFailedException { final InstanceIdentifier<D> currentId = RWUtils.appendTypeToId(parentId, getManagedDataObjectType()); - final Optional<D> currentData = customizer.extract(currentId, parentData); - if(currentData.isPresent()) { - deleteCurrent(currentId, currentData.get(), ctx); + final Optional<D> dataBefore = customizer.extract(currentId, parentDataBefore); + if(dataBefore.isPresent()) { + deleteCurrent(currentId, dataBefore.get(), ctx); } } @@ -111,8 +111,15 @@ public class CompositeChildWriter<D extends DataObject> extends AbstractComposit final InstanceIdentifier<D> currentId = RWUtils.appendTypeToId(parentId, getManagedDataObjectType()); final Optional<D> before = customizer.extract(currentId, parentDataBefore); final Optional<D> after = customizer.extract(currentId, parentDataAfter); - if(before.isPresent() && after.isPresent()) { - updateCurrent(currentId, before.get(), after.get(), ctx); + + if(before.isPresent()) { + if(after.isPresent()) { + updateCurrent(currentId, before.get(), after.get(), ctx); + } else { + deleteCurrent(currentId, before.get(), ctx); + } + } else if (after.isPresent()){ + writeCurrent(currentId, after.get(), ctx); } } } |