Merge branch 'master' into feature_target_filtering_supports_overdue
Conflicts: hawkbit-repository\hawkbit-repository-jpa\src\main\java\org\eclipse\hawkbit\repository\jpa\JpaDeploymentManagement.java hawkbit-repository\hawkbit-repository-jpa\src\main\java\org\eclipse\hawkbit\repository\jpa\JpaTargetManagement.java hawkbit-ui\src\main\java\org\eclipse\hawkbit\ui\management\targettable\TargetBeanQuery.java hawkbit-ui\src\main\java\org\eclipse\hawkbit\ui\management\targettable\TargetTable.java Signed-off-by: Marcel Mager (INST-IOT/ESB) <Marcel.Mager@bosch-si.com>
This commit is contained in:
@@ -187,13 +187,16 @@ public interface ArtifactManagement {
|
||||
void deleteExternalArtifact(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* Deletes a local artifact.
|
||||
* Garbage collects local artifact binary file if only referenced by given
|
||||
* {@link LocalArtifact} metadata object.
|
||||
*
|
||||
* @param existing
|
||||
* @param onlyByThisReferenced
|
||||
* the related local artifact
|
||||
*
|
||||
* @return <code>true</code> if an binary was actually garbage collected
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteLocalArtifact(@NotNull LocalArtifact existing);
|
||||
boolean clearLocalArtifactBinary(@NotNull LocalArtifact onlyByThisReferenced);
|
||||
|
||||
/**
|
||||
* Deletes {@link Artifact} based on given id.
|
||||
|
||||
@@ -255,7 +255,8 @@ public interface ControllerManagement {
|
||||
|
||||
/**
|
||||
* Refreshes the time of the last time the controller has been connected to
|
||||
* the server.
|
||||
* the server. Switches {@link TargetUpdateStatus#UNKNOWN} to
|
||||
* {@link TargetUpdateStatus#REGISTERED} if necessary.
|
||||
*
|
||||
* @param controllerId
|
||||
* of the target to to update
|
||||
|
||||
@@ -142,7 +142,7 @@ public interface RolloutGroupManagement {
|
||||
@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Get count of targets in different status in rollout group.
|
||||
* Get {@link RolloutGroup} by Id.
|
||||
*
|
||||
* @param rolloutGroupId
|
||||
* rollout group id
|
||||
|
||||
@@ -192,6 +192,15 @@ public interface TargetManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||
void deleteTargets(@NotEmpty Long... targetIDs);
|
||||
|
||||
/**
|
||||
* Deletes all targets with the given IDs.
|
||||
*
|
||||
* @param targetIDs
|
||||
* the technical IDs of the targets to be deleted
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||
void deleteTargets(@NotEmpty Collection<Long> targetIDs);
|
||||
|
||||
/**
|
||||
* finds all {@link Target#getControllerId()} which are currently in the
|
||||
* database.
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.eventbus.event;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* A abstract typesafe bulkevent which contains all changed base entities.
|
||||
*
|
||||
* @param <E>
|
||||
*/
|
||||
public abstract class AbstractEntityBulkEvent<E extends TenantAwareBaseEntity> implements EntityBulkEvent<E> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<E> entities;
|
||||
|
||||
private String tenant;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant
|
||||
* @param entities
|
||||
* the changed entities
|
||||
*/
|
||||
public AbstractEntityBulkEvent(final String tenant, final List<E> entities) {
|
||||
this.entities = entities;
|
||||
this.tenant = tenant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant
|
||||
* @param entitiy
|
||||
* the changed entity
|
||||
*/
|
||||
public AbstractEntityBulkEvent(final String tenant, final E entitiy) {
|
||||
this(tenant, Arrays.asList(entitiy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> getEntities() {
|
||||
return entities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRevision() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTenant() {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.event.Event;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
|
||||
/**
|
||||
* Event that gets sent when the assignment of a distribution set to a target
|
||||
* gets canceled.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class CancelTargetAssignmentEvent implements Event {
|
||||
|
||||
private final Target target;
|
||||
private final Long actionId;
|
||||
|
||||
/**
|
||||
* Creates a new {@link CancelTargetAssignmentEvent}.
|
||||
*
|
||||
* @param target
|
||||
* entity
|
||||
* @param actionId
|
||||
* the action id of the assignment
|
||||
*/
|
||||
public CancelTargetAssignmentEvent(final Target target, final Long actionId) {
|
||||
this.target = target;
|
||||
this.actionId = actionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the action id of the assignment
|
||||
*/
|
||||
public Long getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return target where the action got canceled
|
||||
*/
|
||||
public Target getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRevision() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTenant() {
|
||||
return target.getTenant();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,27 +8,43 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.event.Event;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||
|
||||
/**
|
||||
* A event for assignment target tag.
|
||||
*/
|
||||
public class DistributionSetTagAssigmentResultEvent {
|
||||
public class DistributionSetTagAssigmentResultEvent implements Event {
|
||||
|
||||
private final DistributionSetTagAssignmentResult assigmentResult;
|
||||
private final String tenant;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param assigmentResult
|
||||
* the assignment result-
|
||||
* the assignment result
|
||||
* @param tenant
|
||||
* current
|
||||
*/
|
||||
public DistributionSetTagAssigmentResultEvent(final DistributionSetTagAssignmentResult assigmentResult) {
|
||||
public DistributionSetTagAssigmentResultEvent(final DistributionSetTagAssignmentResult assigmentResult,
|
||||
final String tenant) {
|
||||
this.assigmentResult = assigmentResult;
|
||||
this.tenant = tenant;
|
||||
}
|
||||
|
||||
public DistributionSetTagAssignmentResult getAssigmentResult() {
|
||||
return assigmentResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRevision() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTenant() {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.eventbus.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
|
||||
/**
|
||||
* * A bulk event which contains one or many new ds tag after creating.
|
||||
*/
|
||||
public class DistributionSetTagCreatedBulkEvent extends AbstractEntityBulkEvent<DistributionSetTag> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant
|
||||
* @param entities
|
||||
* the new ds tags
|
||||
*/
|
||||
public DistributionSetTagCreatedBulkEvent(final String tenant, final List<DistributionSetTag> entities) {
|
||||
super(tenant, entities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant.
|
||||
* @param entity
|
||||
* the new ds tag
|
||||
*/
|
||||
public DistributionSetTagCreatedBulkEvent(final String tenant, final DistributionSetTag entity) {
|
||||
super(tenant, entity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
|
||||
/**
|
||||
* Defines the {@link AbstractBaseEntityEvent} for creation of a new
|
||||
* {@link DistributionSetTag}.
|
||||
*
|
||||
*/
|
||||
public class DistributionSetTagCreatedEvent extends AbstractBaseEntityEvent<DistributionSetTag> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tag
|
||||
* the tag which is updated
|
||||
*/
|
||||
public DistributionSetTagCreatedEvent(final DistributionSetTag tag) {
|
||||
super(tag);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.eventbus.event;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.event.Event;
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
|
||||
/**
|
||||
* An event interface which declares event types that an entities has been
|
||||
* changed.
|
||||
*
|
||||
* @param <E>
|
||||
* the entity type
|
||||
*/
|
||||
public interface EntityBulkEvent<E extends TenantAwareBaseEntity> extends Serializable, Event {
|
||||
|
||||
/**
|
||||
* A typesafe way to retrieve the the entities from the event, which might
|
||||
* be loaded lazy in case the event has been distributed from another node.
|
||||
*
|
||||
* @return the entities might be lazy loaded. Might be {@code null} in case
|
||||
* the entity e.g. is queried lazy on a different node and has been
|
||||
* already deleted from the database
|
||||
*/
|
||||
List<E> getEntities();
|
||||
}
|
||||
@@ -8,22 +8,27 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.event.Event;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||
|
||||
/**
|
||||
* A event for assignment target tag.
|
||||
*/
|
||||
public class TargetTagAssigmentResultEvent {
|
||||
public class TargetTagAssigmentResultEvent implements Event {
|
||||
|
||||
private final TargetTagAssignmentResult assigmentResult;
|
||||
private final String tenant;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param assigmentResult
|
||||
* the assignment result-
|
||||
* @param tenant
|
||||
* current
|
||||
*/
|
||||
public TargetTagAssigmentResultEvent(final TargetTagAssignmentResult assigmentResult) {
|
||||
public TargetTagAssigmentResultEvent(final TargetTagAssignmentResult assigmentResult, final String tenant) {
|
||||
this.tenant = tenant;
|
||||
this.assigmentResult = assigmentResult;
|
||||
}
|
||||
|
||||
@@ -31,4 +36,14 @@ public class TargetTagAssigmentResultEvent {
|
||||
return assigmentResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRevision() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTenant() {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.eventbus.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
|
||||
/**
|
||||
* A bulk event which contains one or many new target tags after creating.
|
||||
*/
|
||||
public class TargetTagCreatedBulkEvent extends AbstractEntityBulkEvent<TargetTag> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant
|
||||
* @param entities
|
||||
* the new targets
|
||||
*/
|
||||
public TargetTagCreatedBulkEvent(final String tenant, final List<TargetTag> entities) {
|
||||
super(tenant, entities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant
|
||||
* @param entity
|
||||
* one new target
|
||||
*/
|
||||
public TargetTagCreatedBulkEvent(final String tenant, final TargetTag entity) {
|
||||
super(tenant, entity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
|
||||
/**
|
||||
* Defines the {@link AbstractBaseEntityEvent} for creation of a new
|
||||
* {@link TargetTag}.
|
||||
*
|
||||
*/
|
||||
public class TargetTagCreatedEvent extends AbstractBaseEntityEvent<TargetTag> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tag
|
||||
* the tag which has been created
|
||||
*/
|
||||
public TargetTagCreatedEvent(final TargetTag tag) {
|
||||
super(tag);
|
||||
}
|
||||
}
|
||||
@@ -10,13 +10,16 @@ package org.eclipse.hawkbit.repository.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.event.Event;
|
||||
|
||||
/**
|
||||
* Result object for {@link DistributionSetTag} assignments.
|
||||
*
|
||||
*/
|
||||
public class DistributionSetTagAssignmentResult extends AssignmentResult<DistributionSet> {
|
||||
public class DistributionSetTagAssignmentResult extends AssignmentResult<DistributionSet> implements Event {
|
||||
|
||||
private final DistributionSetTag distributionSetTag;
|
||||
private final String tenant;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -36,14 +39,24 @@ public class DistributionSetTagAssignmentResult extends AssignmentResult<Distrib
|
||||
*/
|
||||
public DistributionSetTagAssignmentResult(final int alreadyAssigned, final int assigned, final int unassigned,
|
||||
final List<DistributionSet> assignedDs, final List<DistributionSet> unassignedDs,
|
||||
final DistributionSetTag distributionSetTag) {
|
||||
super(assigned, alreadyAssigned,unassigned, assignedDs, unassignedDs);
|
||||
final DistributionSetTag distributionSetTag, final String tenant) {
|
||||
super(assigned, alreadyAssigned, unassigned, assignedDs, unassignedDs);
|
||||
this.distributionSetTag = distributionSetTag;
|
||||
this.tenant = tenant;
|
||||
}
|
||||
|
||||
public DistributionSetTag getDistributionSetTag() {
|
||||
return distributionSetTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRevision() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTenant() {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -70,13 +70,13 @@ public interface Target extends NamedEntity {
|
||||
* @return <code>true</code> if tag could be added sucessfully (i.e. was not
|
||||
* already in the list).
|
||||
*/
|
||||
public boolean addTag(TargetTag tag);
|
||||
boolean addTag(TargetTag tag);
|
||||
|
||||
/**
|
||||
* @param tag
|
||||
* to remove
|
||||
* @return <code>true</code> if tag was in the list and removed
|
||||
*/
|
||||
public boolean removeTag(TargetTag tag);
|
||||
boolean removeTag(TargetTag tag);
|
||||
|
||||
}
|
||||
|
||||
@@ -207,15 +207,14 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
||||
@Override
|
||||
protected Map<String, Object> getVendorProperties() {
|
||||
|
||||
final Map<String, Object> properties = Maps.newHashMapWithExpectedSize(5);
|
||||
final Map<String, Object> properties = Maps.newHashMapWithExpectedSize(4);
|
||||
// Turn off dynamic weaving to disable LTW lookup in static weaving mode
|
||||
properties.put("eclipselink.weaving", "false");
|
||||
// needed for reports
|
||||
properties.put("eclipselink.jdbc.allow-native-sql-queries", "true");
|
||||
// flyway
|
||||
properties.put("eclipselink.ddl-generation", "none");
|
||||
|
||||
properties.put("eclipselink.persistence-context.flush-mode", "auto");
|
||||
// Embeed into hawkBit logging
|
||||
properties.put("eclipselink.logging.logger", "JavaLogger");
|
||||
|
||||
return properties;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
@@ -60,15 +59,4 @@ public class EclipseLinkTargetInfoRepository implements TargetInfoRepository {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
@CacheEvict(value = { "targetStatus", "distributionUsageInstalled", "targetsLastPoll" }, allEntries = true)
|
||||
public void deleteByTargetIdIn(final Collection<Long> targetIDs) {
|
||||
final javax.persistence.Query query = entityManager
|
||||
.createQuery("DELETE FROM JpaTargetInfo ti where ti.targetId IN :target");
|
||||
query.setParameter("target", targetIDs);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -150,28 +150,22 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public void deleteLocalArtifact(final LocalArtifact existing) {
|
||||
if (existing == null) {
|
||||
return;
|
||||
}
|
||||
public boolean clearLocalArtifactBinary(final LocalArtifact existing) {
|
||||
|
||||
boolean artifactIsOnlyUsedByOneSoftwareModule = true;
|
||||
for (final LocalArtifact lArtifact : localArtifactRepository
|
||||
.findByGridFsFileName(((JpaLocalArtifact) existing).getGridFsFileName())) {
|
||||
if (!lArtifact.getSoftwareModule().isDeleted()
|
||||
&& Long.compare(lArtifact.getSoftwareModule().getId(), existing.getSoftwareModule().getId()) != 0) {
|
||||
artifactIsOnlyUsedByOneSoftwareModule = false;
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (artifactIsOnlyUsedByOneSoftwareModule) {
|
||||
try {
|
||||
LOG.debug("deleting artifact from repository {}", ((JpaLocalArtifact) existing).getGridFsFileName());
|
||||
artifactRepository.deleteBySha1(((JpaLocalArtifact) existing).getGridFsFileName());
|
||||
} catch (final ArtifactStoreException e) {
|
||||
throw new ArtifactDeleteFailedException(e);
|
||||
}
|
||||
try {
|
||||
LOG.debug("deleting artifact from repository {}", ((JpaLocalArtifact) existing).getGridFsFileName());
|
||||
artifactRepository.deleteBySha1(((JpaLocalArtifact) existing).getGridFsFileName());
|
||||
return true;
|
||||
} catch (final ArtifactStoreException e) {
|
||||
throw new ArtifactDeleteFailedException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +179,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
return;
|
||||
}
|
||||
|
||||
deleteLocalArtifact(existing);
|
||||
clearLocalArtifactBinary(existing);
|
||||
|
||||
existing.getSoftwareModule().removeArtifact(existing);
|
||||
softwareModuleRepository.save((JpaSoftwareModule) existing.getSoftwareModule());
|
||||
|
||||
@@ -225,6 +225,11 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
if (address != null) {
|
||||
mtargetInfo.setAddress(address.toString());
|
||||
}
|
||||
|
||||
if (mtargetInfo.getUpdateStatus() == TargetUpdateStatus.UNKNOWN) {
|
||||
mtargetInfo.setUpdateStatus(TargetUpdateStatus.REGISTERED);
|
||||
}
|
||||
|
||||
return targetInfoRepository.save(mtargetInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,11 @@ import javax.persistence.criteria.ListJoin;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.event.CancelTargetAssignmentEvent;
|
||||
import org.eclipse.hawkbit.repository.ActionFields;
|
||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.CancelTargetAssignmentEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetAssignDistributionSetEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
|
||||
@@ -84,6 +84,7 @@ import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -357,17 +358,6 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
return actionForTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the {@link TargetAssignDistributionSetEvent} for a specific target
|
||||
* to the {@link EventBus}.
|
||||
*
|
||||
* @param target
|
||||
* the Target which has been assigned to a distribution set
|
||||
* @param actionId
|
||||
* the action id of the assignment
|
||||
* @param modules
|
||||
* the software modules which have been assigned
|
||||
*/
|
||||
private void assignDistributionSetEvent(final JpaTarget target, final Long actionId,
|
||||
final List<JpaSoftwareModule> modules) {
|
||||
((JpaTargetInfo) target.getTargetInfo()).setUpdateStatus(TargetUpdateStatus.PENDING);
|
||||
@@ -461,8 +451,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
* the action id of the assignment
|
||||
*/
|
||||
private void cancelAssignDistributionSetEvent(final Target target, final Long actionId) {
|
||||
afterCommit.afterCommit(() -> eventBus.post(new CancelTargetAssignmentEvent(target.getOptLockRevision(),
|
||||
target.getTenant(), target.getControllerId(), actionId, target.getTargetInfo().getAddress())));
|
||||
afterCommit.afterCommit(() -> eventBus.post(new CancelTargetAssignmentEvent(target, actionId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -521,7 +510,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
|
||||
public Action startScheduledAction(final Action action) {
|
||||
|
||||
final JpaAction mergedAction = (JpaAction) entityManager.merge(action);
|
||||
|
||||
@@ -146,15 +146,17 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
result = new DistributionSetTagAssignmentResult(dsIds.size() - toBeChangedDSs.size(), 0,
|
||||
toBeChangedDSs.size(), Collections.emptyList(),
|
||||
Collections.unmodifiableList(distributionSetRepository.save(toBeChangedDSs)), myTag);
|
||||
Collections.unmodifiableList(distributionSetRepository.save(toBeChangedDSs)), myTag,
|
||||
tenantAware.getCurrentTenant());
|
||||
} else {
|
||||
result = new DistributionSetTagAssignmentResult(dsIds.size() - toBeChangedDSs.size(), toBeChangedDSs.size(),
|
||||
0, Collections.unmodifiableList(distributionSetRepository.save(toBeChangedDSs)),
|
||||
Collections.emptyList(), myTag);
|
||||
Collections.emptyList(), myTag, tenantAware.getCurrentTenant());
|
||||
}
|
||||
|
||||
final DistributionSetTagAssignmentResult resultAssignment = result;
|
||||
afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment)));
|
||||
afterCommit.afterCommit(() -> eventBus
|
||||
.post(new DistributionSetTagAssigmentResultEvent(resultAssignment, tenantAware.getCurrentTenant())));
|
||||
|
||||
// no reason to persist the tag
|
||||
entityManager.detach(myTag);
|
||||
@@ -713,8 +715,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
afterCommit.afterCommit(() -> {
|
||||
|
||||
final DistributionSetTagAssignmentResult result = new DistributionSetTagAssignmentResult(0, save.size(), 0,
|
||||
save, Collections.emptyList(), tag);
|
||||
eventBus.post(new DistributionSetTagAssigmentResultEvent(result));
|
||||
save, Collections.emptyList(), tag, tenantAware.getCurrentTenant());
|
||||
eventBus.post(new DistributionSetTagAssigmentResultEvent(result, tenantAware.getCurrentTenant()));
|
||||
});
|
||||
|
||||
return save;
|
||||
|
||||
@@ -247,7 +247,7 @@ public class JpaSoftwareManagement implements SoftwareManagement {
|
||||
|
||||
private void deleteGridFsArtifacts(final JpaSoftwareModule swModule) {
|
||||
for (final LocalArtifact localArtifact : swModule.getLocalArtifacts()) {
|
||||
artifactManagement.deleteLocalArtifact(localArtifact);
|
||||
artifactManagement.clearLocalArtifactBinary(localArtifact);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@ import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.TagFields;
|
||||
import org.eclipse.hawkbit.repository.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedBulkEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
@@ -96,8 +96,7 @@ public class JpaTagManagement implements TagManagement {
|
||||
|
||||
final TargetTag save = targetTagRepository.save((JpaTargetTag) targetTag);
|
||||
|
||||
afterCommit
|
||||
.afterCommit(() -> eventBus.post(new TargetTagCreatedBulkEvent(tenantAware.getCurrentTenant(), save)));
|
||||
afterCommit.afterCommit(() -> eventBus.post(new TargetTagCreatedEvent(save)));
|
||||
|
||||
return save;
|
||||
}
|
||||
@@ -116,8 +115,7 @@ public class JpaTagManagement implements TagManagement {
|
||||
});
|
||||
|
||||
final List<TargetTag> save = Collections.unmodifiableList(targetTagRepository.save(targetTags));
|
||||
afterCommit
|
||||
.afterCommit(() -> eventBus.post(new TargetTagCreatedBulkEvent(tenantAware.getCurrentTenant(), save)));
|
||||
afterCommit.afterCommit(() -> save.forEach(tag -> eventBus.post(new TargetTagCreatedEvent(tag))));
|
||||
return save;
|
||||
}
|
||||
|
||||
@@ -199,8 +197,7 @@ public class JpaTagManagement implements TagManagement {
|
||||
|
||||
final DistributionSetTag save = distributionSetTagRepository.save((JpaDistributionSetTag) distributionSetTag);
|
||||
|
||||
afterCommit.afterCommit(
|
||||
() -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware.getCurrentTenant(), save)));
|
||||
afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagCreatedEvent(save)));
|
||||
return save;
|
||||
}
|
||||
|
||||
@@ -219,8 +216,7 @@ public class JpaTagManagement implements TagManagement {
|
||||
}
|
||||
final List<DistributionSetTag> save = Collections
|
||||
.unmodifiableList(distributionSetTagRepository.save(distributionSetTags));
|
||||
afterCommit.afterCommit(
|
||||
() -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware.getCurrentTenant(), save)));
|
||||
afterCommit.afterCommit(() -> save.forEach(tag -> eventBus.post(new DistributionSetTagCreatedEvent(tag))));
|
||||
|
||||
return save;
|
||||
}
|
||||
|
||||
@@ -209,19 +209,16 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public void deleteTargets(final Long... targetIDs) {
|
||||
// we need to select the target IDs first to check the if the targetIDs
|
||||
// belonging to the
|
||||
// tenant! Delete statement are not automatically enhanced with the
|
||||
// @FilterDef of the
|
||||
// hibernate session.
|
||||
final List<Long> targetsForCurrentTenant = targetRepository.findAll(Lists.newArrayList(targetIDs)).stream()
|
||||
.map(Target::getId).collect(Collectors.toList());
|
||||
if (!targetsForCurrentTenant.isEmpty()) {
|
||||
targetInfoRepository.deleteByTargetIdIn(targetsForCurrentTenant);
|
||||
targetRepository.deleteByIdIn(targetsForCurrentTenant);
|
||||
}
|
||||
targetsForCurrentTenant
|
||||
.forEach(targetId -> eventBus.post(new TargetDeletedEvent(tenantAware.getCurrentTenant(), targetId)));
|
||||
deleteTargets(Lists.newArrayList(targetIDs));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public void deleteTargets(final Collection<Long> targetIDs) {
|
||||
targetRepository.deleteByIdIn(targetIDs);
|
||||
|
||||
targetIDs.forEach(targetId -> eventBus.post(new TargetDeletedEvent(tenantAware.getCurrentTenant(), targetId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -371,7 +368,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
final TargetTagAssignmentResult result = new TargetTagAssignmentResult(0, 0, alreadyAssignedTargets.size(),
|
||||
Collections.emptyList(), alreadyAssignedTargets, tag);
|
||||
|
||||
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
|
||||
afterCommit.afterCommit(
|
||||
() -> eventBus.post(new TargetTagAssigmentResultEvent(result, tenantAware.getCurrentTenant())));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -382,7 +380,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
allTargets.size(), 0, Collections.unmodifiableList(targetRepository.save(allTargets)),
|
||||
Collections.emptyList(), tag);
|
||||
|
||||
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
|
||||
afterCommit.afterCommit(
|
||||
() -> eventBus.post(new TargetTagAssigmentResultEvent(result, tenantAware.getCurrentTenant())));
|
||||
|
||||
// no reason to persist the tag
|
||||
entityManager.detach(tag);
|
||||
@@ -392,9 +391,9 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public List<Target> assignTag(final Collection<String> targetIds, final TargetTag tag) {
|
||||
public List<Target> assignTag(final Collection<String> controllerIds, final TargetTag tag) {
|
||||
final List<JpaTarget> allTargets = targetRepository
|
||||
.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(targetIds));
|
||||
.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(controllerIds));
|
||||
|
||||
allTargets.forEach(target -> target.addTag(tag));
|
||||
final List<Target> save = Collections.unmodifiableList(targetRepository.save(allTargets));
|
||||
@@ -402,7 +401,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
afterCommit.afterCommit(() -> {
|
||||
final TargetTagAssignmentResult assigmentResult = new TargetTagAssignmentResult(0, save.size(), 0, save,
|
||||
Collections.emptyList(), tag);
|
||||
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
|
||||
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult, tenantAware.getCurrentTenant()));
|
||||
});
|
||||
|
||||
return save;
|
||||
@@ -418,7 +417,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
afterCommit.afterCommit(() -> {
|
||||
final TargetTagAssignmentResult assigmentResult = new TargetTagAssignmentResult(0, 0, save.size(),
|
||||
Collections.emptyList(), save, tag);
|
||||
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
|
||||
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult, tenantAware.getCurrentTenant()));
|
||||
});
|
||||
return save;
|
||||
}
|
||||
@@ -587,8 +586,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findAllTargetsByTargetFilterQueryAndNonDS(@NotNull Pageable pageRequest, Long distributionSetId,
|
||||
@NotNull TargetFilterQuery targetFilterQuery) {
|
||||
public Page<Target> findAllTargetsByTargetFilterQueryAndNonDS(@NotNull final Pageable pageRequest,
|
||||
final Long distributionSetId, @NotNull final TargetFilterQuery targetFilterQuery) {
|
||||
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class,
|
||||
virtualPropertyReplacer);
|
||||
@@ -602,10 +601,10 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countTargetsByTargetFilterQueryAndNonDS(Long distributionSetId,
|
||||
@NotNull TargetFilterQuery targetFilterQuery) {
|
||||
public Long countTargetsByTargetFilterQueryAndNonDS(final Long distributionSetId,
|
||||
@NotNull final TargetFilterQuery targetFilterQuery) {
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class,
|
||||
virtualPropertyReplacer);
|
||||
virtualPropertyReplacer);
|
||||
final List<Specification<JpaTarget>> specList = new ArrayList<>(2);
|
||||
specList.add(spec);
|
||||
specList.add(TargetSpecifications.hasNotDistributionSetInActions(distributionSetId));
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.hawkbit.repository.TenantStatsManagement;
|
||||
import org.eclipse.hawkbit.repository.report.model.TenantUsage;
|
||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||
@@ -46,15 +44,8 @@ public class JpaTenantStatsManagement implements TenantStatsManagement {
|
||||
final TenantUsage result = new TenantUsage(tenant);
|
||||
|
||||
result.setTargets(targetRepository.count());
|
||||
|
||||
final Long artifacts = artifactRepository.countBySoftwareModuleDeleted(false);
|
||||
result.setArtifacts(artifacts);
|
||||
|
||||
final Optional<Long> artifactsSize = artifactRepository.getSumOfUndeletedArtifactSize();
|
||||
if (artifactsSize.isPresent()) {
|
||||
result.setOverallArtifactVolumeInBytes(artifactsSize.get());
|
||||
}
|
||||
|
||||
result.setArtifacts(artifactRepository.countBySoftwareModuleDeleted(false));
|
||||
artifactRepository.getSumOfUndeletedArtifactSize().map(result::setOverallArtifactVolumeInBytes);
|
||||
result.setActions(actionRepository.count());
|
||||
|
||||
return result;
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
@@ -107,6 +108,20 @@ public interface RolloutGroupRepository
|
||||
*/
|
||||
List<JpaRolloutGroup> findByParentAndStatus(JpaRolloutGroup rolloutGroup, RolloutGroupStatus status);
|
||||
|
||||
/**
|
||||
* Updates all {@link RolloutGroup#getStatus()} of children for given
|
||||
* parent.
|
||||
*
|
||||
* @param parent
|
||||
* the parent rolloutgroup
|
||||
* @param status
|
||||
* the status of the rolloutgroups
|
||||
*/
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
@Query("UPDATE JpaRolloutGroup g SET g.status = :status WHERE g.parent = :parent")
|
||||
void setStatusForCildren(@Param("status") RolloutGroupStatus status, @Param("parent") RolloutGroup parent);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link RolloutGroup} for a specific rollout and status not
|
||||
* having ordered by ID DESC, latest top.
|
||||
|
||||
@@ -62,7 +62,10 @@ public interface RolloutRepository
|
||||
List<JpaRollout> findByLastCheckAndStatus(long lastCheck, RolloutStatus status);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link Rollout} for a specific {@code name}
|
||||
* Retrieves all {@link Rollout} for a specific {@code name}.
|
||||
*
|
||||
* @param pageable
|
||||
* for paging information
|
||||
*
|
||||
* @param name
|
||||
* the rollout name
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
@@ -56,15 +55,4 @@ public interface TargetInfoRepository {
|
||||
*/
|
||||
@CacheEvict(value = { "targetStatus", "distributionUsageInstalled", "targetsLastPoll" }, allEntries = true)
|
||||
<S extends JpaTargetInfo> S save(S entity);
|
||||
|
||||
/**
|
||||
* Deletes info entries by ID.
|
||||
*
|
||||
* @param targetIDs
|
||||
* to delete
|
||||
*/
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
@CacheEvict(value = { "targetStatus", "distributionUsageInstalled", "targetsLastPoll" }, allEntries = true)
|
||||
void deleteByTargetIdIn(final Collection<Long> targetIDs);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ public interface TargetRepository extends BaseEntityRepository<JpaTarget, Long>,
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477
|
||||
@Query("DELETE FROM JpaTarget t WHERE t.id IN ?1")
|
||||
@CacheEvict(value = { "targetStatus", "distributionUsageInstalled", "targetsLastPoll" }, allEntries = true)
|
||||
void deleteByIdIn(final Collection<Long> targetIDs);
|
||||
|
||||
/**
|
||||
|
||||
@@ -181,7 +181,8 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Action [distributionSet=" + distributionSet + ", getId()=" + getId() + "]";
|
||||
return "JpaAction [distributionSet=" + distributionSet.getId() + ", version=" + getOptLockRevision() + ", id="
|
||||
+ getId() + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -78,12 +78,14 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
||||
@Column(name = "required_migration_step")
|
||||
private boolean requiredMigrationStep;
|
||||
|
||||
@CascadeOnDelete
|
||||
@ManyToMany(targetEntity = JpaSoftwareModule.class, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "sp_ds_module", joinColumns = {
|
||||
@JoinColumn(name = "ds_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_ds")) }, inverseJoinColumns = {
|
||||
@JoinColumn(name = "module_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_module")) })
|
||||
private Set<SoftwareModule> modules;
|
||||
|
||||
@CascadeOnDelete
|
||||
@ManyToMany(targetEntity = JpaDistributionSetTag.class)
|
||||
@JoinTable(name = "sp_ds_dstag", joinColumns = {
|
||||
@JoinColumn(name = "ds", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_ds")) }, inverseJoinColumns = {
|
||||
@@ -276,9 +278,8 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
||||
.filter(module -> module.getType().getKey().equals(softwareModule.getType().getKey())).count();
|
||||
|
||||
if (allready >= softwareModule.getType().getMaxAssignments()) {
|
||||
final Optional<SoftwareModule> sameKey = modules.stream()
|
||||
.filter(module -> module.getType().getKey().equals(softwareModule.getType().getKey())).findFirst();
|
||||
modules.remove(sameKey.get());
|
||||
modules.stream().filter(module -> module.getType().getKey().equals(softwareModule.getType().getKey()))
|
||||
.findFirst().map(modules::remove);
|
||||
}
|
||||
|
||||
if (modules.add(softwareModule)) {
|
||||
@@ -326,14 +327,7 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
||||
return null;
|
||||
}
|
||||
|
||||
final Optional<SoftwareModule> result = modules.stream().filter(module -> module.getType().equals(type))
|
||||
.findFirst();
|
||||
|
||||
if (result.isPresent()) {
|
||||
return result.get();
|
||||
}
|
||||
|
||||
return null;
|
||||
return modules.stream().filter(module -> module.getType().equals(type)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -76,9 +76,11 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
|
||||
@Size(max = 256)
|
||||
private String vendor;
|
||||
|
||||
@CascadeOnDelete
|
||||
@OneToMany(mappedBy = "softwareModule", cascade = { CascadeType.ALL }, targetEntity = JpaLocalArtifact.class)
|
||||
private List<LocalArtifact> artifacts;
|
||||
|
||||
@CascadeOnDelete
|
||||
@OneToMany(mappedBy = "softwareModule", cascade = { CascadeType.ALL }, targetEntity = JpaExternalArtifact.class)
|
||||
private List<ExternalArtifact> externalArtifacts;
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Lon
|
||||
@Transient
|
||||
private boolean entityNew;
|
||||
|
||||
@CascadeOnDelete
|
||||
@ManyToMany(targetEntity = JpaTargetTag.class)
|
||||
@JoinTable(name = "sp_target_target_tag", joinColumns = {
|
||||
@JoinColumn(name = "target", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_target")) }, inverseJoinColumns = {
|
||||
|
||||
@@ -111,12 +111,12 @@ public class JpaTargetInfo implements Persistable<Long>, TargetInfo, EventAwareE
|
||||
/**
|
||||
* Read only on management API. Are commited by controller.
|
||||
*/
|
||||
@CascadeOnDelete
|
||||
@ElementCollection
|
||||
@Column(name = "attribute_value", length = 128)
|
||||
@MapKeyColumn(name = "attribute_key", nullable = false, length = 32)
|
||||
@CollectionTable(name = "sp_target_attributes", joinColumns = {
|
||||
@JoinColumn(name = "target_id") }, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_attrib_target"))
|
||||
|
||||
private final Map<String, String> controllerAttributes = Collections.synchronizedMap(new HashMap<String, String>());
|
||||
|
||||
// set default request controller attributes to true, because we want to
|
||||
|
||||
@@ -61,7 +61,9 @@ public class StartNextGroupRolloutGroupSuccessAction implements RolloutGroupActi
|
||||
rolloutGroup, Action.Status.SCHEDULED);
|
||||
logger.debug("{} Next actions to start for rollout {} and parent group {}", rolloutGroupActions.size(), rollout,
|
||||
rolloutGroup);
|
||||
rolloutGroupActions.forEach(action -> deploymentManagement.startScheduledAction(action));
|
||||
rolloutGroupActions.forEach(deploymentManagement::startScheduledAction);
|
||||
logger.debug("{} actions started for rollout {} and parent group {}", rolloutGroupActions.size(), rollout,
|
||||
rolloutGroup);
|
||||
if (!rolloutGroupActions.isEmpty()) {
|
||||
// get all next scheduled groups based on the found actions and set
|
||||
// them in state running
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
alter table sp_ds_module drop constraint fk_ds_module_ds;
|
||||
alter table sp_ds_module
|
||||
add constraint fk_ds_module_ds
|
||||
foreign key (ds_id)
|
||||
references sp_distribution_set (id)
|
||||
on delete cascade;
|
||||
|
||||
alter table sp_ds_module drop constraint fk_ds_module_module;
|
||||
alter table sp_ds_module
|
||||
add constraint fk_ds_module_module
|
||||
foreign key (module_id)
|
||||
references sp_base_software_module (id)
|
||||
on delete cascade;
|
||||
|
||||
alter table sp_external_artifact drop constraint fk_external_assigned_sm;
|
||||
alter table sp_external_artifact
|
||||
add constraint fk_external_assigned_sm
|
||||
foreign key (software_module)
|
||||
references sp_base_software_module (id)
|
||||
on delete cascade;
|
||||
|
||||
alter table sp_artifact drop constraint fk_assigned_sm;
|
||||
alter table sp_artifact
|
||||
add constraint fk_assigned_sm
|
||||
foreign key (software_module)
|
||||
references sp_base_software_module (id)
|
||||
on delete cascade;
|
||||
@@ -0,0 +1,27 @@
|
||||
alter table sp_ds_module drop FOREIGN KEY fk_ds_module_ds;
|
||||
alter table sp_ds_module
|
||||
add constraint fk_ds_module_ds
|
||||
foreign key (ds_id)
|
||||
references sp_distribution_set (id)
|
||||
on delete cascade;
|
||||
|
||||
alter table sp_ds_module drop FOREIGN KEY fk_ds_module_module;
|
||||
alter table sp_ds_module
|
||||
add constraint fk_ds_module_module
|
||||
foreign key (module_id)
|
||||
references sp_base_software_module (id)
|
||||
on delete cascade;
|
||||
|
||||
alter table sp_external_artifact drop FOREIGN KEY fk_external_assigned_sm;
|
||||
alter table sp_external_artifact
|
||||
add constraint fk_external_assigned_sm
|
||||
foreign key (software_module)
|
||||
references sp_base_software_module (id)
|
||||
on delete cascade;
|
||||
|
||||
alter table sp_artifact drop FOREIGN KEY fk_assigned_sm;
|
||||
alter table sp_artifact
|
||||
add constraint fk_assigned_sm
|
||||
foreign key (software_module)
|
||||
references sp_base_software_module (id)
|
||||
on delete cascade;
|
||||
@@ -21,9 +21,9 @@ import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.event.CancelTargetAssignmentEvent;
|
||||
import org.eclipse.hawkbit.repository.ActionStatusFields;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.CancelTargetAssignmentEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetAssignDistributionSetEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.ForceQuitActionNotAllowedException;
|
||||
import org.eclipse.hawkbit.repository.exception.IncompleteDistributionSetException;
|
||||
|
||||
Reference in New Issue
Block a user