Feature dmf target delete aware (#474)

* Implemented new function to create and send a thing created message if a
delete event is published

- added mock and integration tests 

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>

* Switched target address form URI to String and fixed test

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>

* Refactoring and removed TODOs

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>

* Fixed javadoc and description

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>

* Used Target from API instead from JpaTarget 

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>

* Refactoring after review

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>

* Small refactoring - fixed typos

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>

* Resolve Merge conflicts

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>
This commit is contained in:
Jonathan Knoblauch
2017-04-25 16:38:18 +02:00
committed by Michael Hirsch
parent a19364c635
commit 574fda1101
11 changed files with 222 additions and 51 deletions

View File

@@ -8,6 +8,7 @@
*/
package org.eclipse.hawkbit.repository.jpa;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -174,8 +175,10 @@ public class JpaTargetManagement implements TargetManagement {
targetRepository.deleteByIdIn(targetIDs);
targetIDs.forEach(targetId -> eventPublisher.publishEvent(new TargetDeletedEvent(tenantAware.getCurrentTenant(),
targetId, JpaTarget.class.getName(), applicationContext.getId())));
targets.forEach(target -> eventPublisher.publishEvent(
new TargetDeletedEvent(tenantAware.getCurrentTenant(), target.getId(), target.getControllerId(),
Optional.ofNullable(target.getAddress()).map(URI::toString).orElse(null),
JpaTarget.class.getName(), applicationContext.getId())));
}
@Override

View File

@@ -396,7 +396,8 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
@Override
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetDeletedEvent(getTenant(), getId(),
getClass().getName(), EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TargetDeletedEvent(getTenant(), getId(), getControllerId(), address,
getClass().getName(), EventPublisherHolder.getInstance().getApplicationId()));
}
}