-
Notifications
You must be signed in to change notification settings - Fork 189
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
Remove TargetInfo entity #453
Remove TargetInfo entity #453
Conversation
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Conflicts: hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TargetManagementTest.java
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
.publishEvent(new TargetUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId())); | ||
final ObjectChangeSet objectChanges = ((UpdateObjectQuery) descriptorEvent.getQuery()).getObjectChangeSet(); | ||
|
||
if (objectChanges.getChangedAttributeNames().stream() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move logic into caller
// through JQL | ||
final JpaTarget target = (JpaTarget) action.getTarget(); | ||
target.setUpdateStatus(TargetUpdateStatus.PENDING); | ||
entityManager.detach(target); | ||
|
||
afterCommit.afterCommit(() -> eventPublisher | ||
.publishEvent(new TargetUpdatedEvent(action.getTarget(), applicationContext.getId()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use target reference for readability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ignore event sending logic based on ignore changed fields can be moved to the caller EntityPropertyChangeListener
then every entity class profits from it.
I would extend the EventAwareEntity
with a method getIgnoreFields()
or something.
* the parent rollout group the actions should reference. null | ||
* references the first group | ||
* @return the amount of started actions | ||
*/ | ||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) | ||
long startScheduledActionsByRolloutGroupParent(@NotNull Rollout rollout, RolloutGroup rolloutGroupParent); | ||
long startScheduledActionsByRolloutGroupParent(@NotNull Long rolloutId, Long rolloutGroupParentId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
// check if we need to override running update actions | ||
final Set<Long> overrideObsoleteUpdateActions = overrideObsoleteUpdateActions( | ||
Collections.singletonList(action.getTarget().getId())); | ||
|
||
if (action.getTarget().getAssignedDistributionSet() != null && action.getDistributionSet().getId() | ||
.equals(action.getTarget().getAssignedDistributionSet().getId())) { | ||
if (((JpaTarget) action.getTarget()).getAssignedDistributionSet() != null && action.getDistributionSet().getId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better reagability use a variable for the cast (JpaTarget) action.getTarget()
. Then you have only 1 instead of 2 cast
Conflicts: hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
TargetInfo was historically there to allow a fork on the spring audit listener. The idea was that devices should not trigger an audit log write (only users). So TargetInfo contained all properties that are set by a device (controller). However, our security is much more evolved these days. So we can merge Target and TargetInfo back together and instead create a condition that ensures that audit data is not changed if data is written by a controller.