diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetFilter.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetFilter.java index 203fcb289..e341fa142 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetFilter.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetFilter.java @@ -28,6 +28,4 @@ public final class DistributionSetFilter { private final String searchText; private final Boolean selectDSWithNoTag; private final Collection tagNames; - private final String assignedTargetId; - private final String installedTargetId; } \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDeploymentManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDeploymentManagement.java index f4fcf8782..d98895362 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDeploymentManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDeploymentManagement.java @@ -934,15 +934,16 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl @Override public Optional getAssignedDistributionSet(final String controllerId) { - // target access checked in assertTargetReadAllowed - assertTargetReadAllowed(controllerId); - return distributionSetRepository.findAssignedToTarget(controllerId); + return targetRepository + .findOne(TargetSpecifications.hasControllerId(controllerId)) + .map(JpaTarget::getAssignedDistributionSet); } @Override public Optional getInstalledDistributionSet(final String controllerId) { - assertTargetReadAllowed(controllerId); - return distributionSetRepository.findInstalledAtTarget(controllerId); + return targetRepository + .findOne(TargetSpecifications.hasControllerId(controllerId)) + .map(JpaTarget::getInstalledDistributionSet); } @Override diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java index 2dc708812..29a9a7292 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java @@ -574,7 +574,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { throw new InsufficientPermissionException("Target not accessible (or not found)!"); } return distributionSetRepository - .findOne(DistributionSetSpecification.byActionId(actionId)) + .findOne(DistributionSetSpecification.byId(action.getDistributionSet().getId())) .orElseThrow(() -> new InsufficientPermissionException("DistributionSet not accessible (or not found)!")); }) @@ -630,14 +630,6 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { distributionSetFilter.getSelectDSWithNoTag()); specList.add(spec); } - if (distributionSetFilter.getInstalledTargetId() != null) { - spec = DistributionSetSpecification.installedTarget(distributionSetFilter.getInstalledTargetId()); - specList.add(spec); - } - if (distributionSetFilter.getAssignedTargetId() != null) { - spec = DistributionSetSpecification.assignedTarget(distributionSetFilter.getAssignedTargetId()); - specList.add(spec); - } return specList; } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java index c70717756..fe1d7f6ea 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java @@ -35,7 +35,6 @@ import jakarta.persistence.Table; import jakarta.persistence.UniqueConstraint; import jakarta.validation.constraints.NotNull; -import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; @@ -46,13 +45,11 @@ import org.eclipse.hawkbit.repository.exception.DistributionSetTypeUndefinedExce import org.eclipse.hawkbit.repository.exception.IncompleteDistributionSetException; import org.eclipse.hawkbit.repository.exception.LockedException; import org.eclipse.hawkbit.repository.exception.UnsupportedSoftwareModuleForThisDistributionSetException; -import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetMetadata; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModule; -import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder; import org.eclipse.persistence.annotations.CascadeOnDelete; import org.eclipse.persistence.descriptors.DescriptorEvent; @@ -123,26 +120,6 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen @Column(name = "required_migration_step") private boolean requiredMigrationStep; - @ToString.Exclude - @Getter(AccessLevel.NONE) - @OneToMany(mappedBy = "autoAssignDistributionSet", targetEntity = JpaTargetFilterQuery.class, fetch = FetchType.LAZY) - private List autoAssignFilters; - - @ToString.Exclude - @Getter(AccessLevel.NONE) - @OneToMany(mappedBy = "assignedDistributionSet", targetEntity = JpaTarget.class, fetch = FetchType.LAZY) - private List assignedToTargets; - - @ToString.Exclude - @Getter(AccessLevel.NONE) - @OneToMany(mappedBy = "installedDistributionSet", targetEntity = JpaTarget.class, fetch = FetchType.LAZY) - private List installedAtTargets; - - @ToString.Exclude - @Getter(AccessLevel.NONE) - @OneToMany(mappedBy = "distributionSet", targetEntity = JpaAction.class, fetch = FetchType.LAZY) - private List actions; - /** * Parameterized constructor. */ @@ -284,14 +261,6 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen requiredMigrationStep = isRequiredMigrationStep; } - public List getActions() { - if (actions == null) { - return Collections.emptyList(); - } - - return Collections.unmodifiableList(actions); - } - @Override public void fireCreateEvent(final DescriptorEvent descriptorEvent) { publishEventWithEventPublisher( diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/DistributionSetRepository.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/DistributionSetRepository.java index af7bbd1f9..645bc9245 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/DistributionSetRepository.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/DistributionSetRepository.java @@ -121,12 +121,6 @@ public interface DistributionSetRepository @Query("select ra.distributionSet.id from JpaRollout ra where ra.distributionSet.id in :ids") List findAssignedToRolloutDistributionSetsById(@Param("ids") Collection ids); - @Query("select DISTINCT ds from JpaDistributionSet ds join fetch ds.modules join ds.assignedToTargets t where t.controllerId = :controllerId") - Optional findAssignedToTarget(@Param("controllerId") String controllerId); - - @Query("select DISTINCT ds from JpaDistributionSet ds join fetch ds.modules join ds.installedAtTargets t where t.controllerId = :controllerId") - Optional findInstalledAtTarget(@Param("controllerId") String controllerId); - /** * Counts {@link DistributionSet} instances of given type in the repository. *

diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/DistributionSetSpecification.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/DistributionSetSpecification.java index e38c7b7ed..cc0241703 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/DistributionSetSpecification.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/DistributionSetSpecification.java @@ -117,15 +117,6 @@ public final class DistributionSetSpecification { }; } - public static Specification byActionId(final Long actionId) { - return (dsRoot, query, cb) -> { - final ListJoin join = dsRoot.join(JpaDistributionSet_.actions, - JoinType.LEFT); - query.distinct(true); - return cb.equal(join.get(JpaAction_.id), actionId); - }; - } - /** * {@link Specification} for retrieving {@link DistributionSet} with given * {@link DistributionSet#getId()}s. @@ -250,36 +241,6 @@ public final class DistributionSetSpecification { return (dsRoot, query, cb) -> dsRoot.get(JpaDistributionSet_.type).get(JpaDistributionSetType_.id).in(typeIds); } - /** - * @param installedTargetId - * the targetID which is installed to a distribution set to search - * for. - * @return the specification to search for a distribution set which is installed - * to the given targetId - */ - public static Specification installedTarget(final String installedTargetId) { - return (dsRoot, query, cb) -> { - final ListJoin installedTargetJoin = dsRoot - .join(JpaDistributionSet_.installedAtTargets, JoinType.INNER); - return cb.equal(installedTargetJoin.get(JpaTarget_.controllerId), installedTargetId); - }; - } - - /** - * @param assignedTargetId - * the targetID which is assigned to a distribution set to search - * for. - * @return the specification to search for a distribution set which is assigned - * to the given targetId - */ - public static Specification assignedTarget(final String assignedTargetId) { - return (dsRoot, query, cb) -> { - final ListJoin assignedTargetJoin = dsRoot - .join(JpaDistributionSet_.assignedToTargets, JoinType.INNER); - return cb.equal(assignedTargetJoin.get(JpaTarget_.controllerId), assignedTargetId); - }; - } - /** * {@link Specification} for retrieving {@link DistributionSet}s by tag. *