diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/RolloutChangeEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/RolloutChangeEvent.java index 8f15602b5..576a6b99c 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/RolloutChangeEvent.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/RolloutChangeEvent.java @@ -8,8 +8,6 @@ */ package org.eclipse.hawkbit.eventbus.event; -import org.eclipse.hawkbit.eventbus.event.AbstractEvent; - /** * Event declaration for the UI to notify the UI that a rollout has been * changed. diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java index 47ff3c49f..dd91ee07a 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java @@ -9,6 +9,7 @@ package org.eclipse.hawkbit.repository; import java.net.URI; +import java.util.Collection; import java.util.List; import java.util.Map; @@ -275,4 +276,11 @@ public interface ControllerManagement { */ ActionStatus generateActionStatus(); + ActionStatus generateActionStatus(Action action, Status status, Long occurredAt, final String message); + + ActionStatus generateActionStatus(Action action, final Status status, Long occurredAt, + final Collection messages); + + ActionStatus generateActionStatus(Action action, Status status, Long occurredAt); + } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java index 070594d4e..f58af4ca6 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -322,8 +322,10 @@ public interface DeploymentManagement { * @return the corresponding {@link Page} of {@link ActionStatus} */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findActionStatusByAction(@NotNull Pageable pageReq, @NotNull Action action, - boolean withMessages); + Page findActionStatusByAction(@NotNull Pageable pageReq, @NotNull Action action); + + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Page findActionStatusByActionWithMessages(@NotNull Pageable pageReq, @NotNull Action action); /** * Retrieves all {@link Action}s of a specific target ordered by action ID. @@ -445,4 +447,7 @@ public interface DeploymentManagement { * @return {@link Action} object */ Action generateAction(); + + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Page findActionStatusAll(@NotNull Pageable pageable); } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java index 2574230b3..9b4dcb8c7 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java @@ -83,6 +83,15 @@ public interface DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) Long countDistributionSetsAll(); + /** + * Count all {@link DistributionSet}s in the repository that are not marked + * as deleted. + * + * @return number of {@link DistributionSet}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Long countDistributionSetsByType(@NotNull DistributionSetType type); + /** * @return number of {@link DistributionSetType}s in the repository. */ @@ -261,20 +270,6 @@ public interface DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) DistributionSet findDistributionSetByNameAndVersion(@NotEmpty String distributionName, @NotEmpty String version); - /** - * Retrieves {@link DistributionSet} List for overview purposes (no - * {@link SoftwareModule}s and {@link DistributionSetTag}s). - * - * Please use {@link #findDistributionSetListWithDetails(Iterable)} if - * details are required. - * - * @param dist - * List of {@link DistributionSet} IDs to be found - * @return the found {@link DistributionSet}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - List findDistributionSetsAll(Collection dist); - /** * finds all meta data by the given distribution set id. * @@ -305,6 +300,20 @@ public interface DistributionSetManagement { Page findDistributionSetMetadataByDistributionSetId(@NotNull Long distributionSetId, @NotNull String rsqlParam, @NotNull Pageable pageable); + /** + * Retrieves {@link DistributionSet} List for overview purposes (no + * {@link SoftwareModule}s and {@link DistributionSetTag}s). + * + * Please use {@link #findDistributionSetListWithDetails(Iterable)} if + * details are required. + * + * @param dist + * List of {@link DistributionSet} IDs to be found + * @return the found {@link DistributionSet}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + List findDistributionSetsAll(Collection dist); + // TODO discuss: use enum instead of the true,false,null switch ? /** * finds all {@link DistributionSet}s. @@ -328,7 +337,8 @@ public interface DistributionSetManagement { * @return all found {@link DistributionSet}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Page findDistributionSetsAll(@NotNull Pageable pageReq, Boolean deleted, Boolean complete); + Page findDistributionSetsByDeletedAndOrCompleted(@NotNull Pageable pageReq, Boolean deleted, + Boolean complete); /** * finds all {@link DistributionSet}s. @@ -445,6 +455,26 @@ public interface DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) DistributionSetMetadata findOne(@NotNull DsMetadataCompositeKey id); + /** + * Generates an empty {@link DistributionSet} without persisting it. + * + * @return {@link DistributionSet} object + */ + DistributionSet generateDistributionSet(); + + DistributionSetMetadata generateDistributionSetMetadata(); + + DistributionSetMetadata generateDistributionSetMetadata(DistributionSet distributionSet, String key, String value); + + /** + * Generates an empty {@link DistributionSetType} without persisting it. + * + * @return {@link DistributionSetType} object + */ + DistributionSetType generateDistributionSetType(); + + DistributionSetType generateDistributionSetType(String key, String name, String description); + /** * Checks if a {@link DistributionSet} is currently in use by a target in * the repository. @@ -567,17 +597,7 @@ public interface DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) DistributionSetType updateDistributionSetType(@NotNull DistributionSetType dsType); - /** - * Generates an empty {@link DistributionSetType} without persisting it. - * - * @return {@link DistributionSetType} object - */ - DistributionSetType generateDistributionSetType(); + DistributionSet generateDistributionSet(String name, String version, String description, DistributionSetType type, + Collection moduleList); - /** - * Generates an empty {@link DistributionSet} without persisting it. - * - * @return {@link DistributionSet} object - */ - DistributionSet generateDistributionSet(); } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/OffsetBasedPageRequest.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/OffsetBasedPageRequest.java similarity index 87% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/OffsetBasedPageRequest.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/OffsetBasedPageRequest.java index 80bb85461..f28047666 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/OffsetBasedPageRequest.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/OffsetBasedPageRequest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.repository.jpa; +package org.eclipse.hawkbit.repository; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; @@ -14,13 +14,9 @@ import org.springframework.data.domain.Sort; /** * An implementation of the {@link PageRequest} which is offset based by means * the offset is given and not the page number as in the original - * {@link PageRequest} implemntation where the offset is generated. Due that the - * REST-API is working with {@code offset} and {@code limit} parameter we need - * an offset based page request for JPA. - * - * @author Michael Hirsch - * @since 0.2.2 - * + * {@link PageRequest} implementation where the offset is generated. Due that + * the REST-API is working with {@code offset} and {@code limit} parameter we + * need an offset based page request. */ public final class OffsetBasedPageRequest extends PageRequest { diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java index efad0100c..bf58e3053 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java @@ -33,12 +33,12 @@ public interface RolloutGroupManagement { * * @param rolloutId * the ID of the rollout to filter the {@link RolloutGroup}s - * @param page + * @param pageable * the page request to sort and limit the result * @return a page of found {@link RolloutGroup}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findAllRolloutGroupsWithDetailedStatus(@NotNull Long rolloutId, @NotNull Pageable page); + Page findAllRolloutGroupsWithDetailedStatus(@NotNull Long rolloutId, @NotNull Pageable pageable); // TODO discuss: target read perm missing? /** @@ -79,13 +79,13 @@ public interface RolloutGroupManagement { * @param specification * the specification to filter the result set based on attributes * of the {@link RolloutGroup} - * @param page + * @param pageable * the page request to sort and limit the result * @return a page of found {@link RolloutGroup}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) Page findRolloutGroupsAll(@NotNull Rollout rollout, @NotNull String rsqlParam, - @NotNull Pageable page); + @NotNull Pageable pageable); /** * Retrieves a page of {@link RolloutGroup}s filtered by a given @@ -93,12 +93,12 @@ public interface RolloutGroupManagement { * * @param rolloutId * the ID of the rollout to filter the {@link RolloutGroup}s - * @param page + * @param pageable * the page request to sort and limit the result * @return a page of found {@link RolloutGroup}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findRolloutGroupsByRolloutId(@NotNull Long rolloutId, @NotNull Pageable page); + Page findRolloutGroupsByRolloutId(@NotNull Long rolloutId, @NotNull Pageable pageable); // TODO discuss: target read perm missing? /** @@ -122,14 +122,14 @@ public interface RolloutGroupManagement { * rollout group * @param specification * the specification for filtering the targets of a rollout group - * @param page + * @param pageable * the page request to sort and limit the result * * @return Page list of targets of a rollout group */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) Page findRolloutGroupTargets(@NotNull RolloutGroup rolloutGroup, @NotNull String rsqlParam, - @NotNull Pageable page); + @NotNull Pageable pageable); /** * Get count of targets in different status in rollout group. diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java index 140273439..f75ff545b 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java @@ -13,11 +13,11 @@ import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.eventbus.event.RolloutGroupCreatedEvent; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.repository.exception.RolloutIllegalStateException; -import org.eclipse.hawkbit.repository.jpa.model.JpaRollout.RolloutStatus; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupConditions; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupStatus; import org.eclipse.hawkbit.repository.model.Rollout; +import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus; import org.eclipse.hawkbit.repository.model.RolloutGroup; +import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus; +import org.eclipse.hawkbit.repository.model.RolloutGroupConditions; import org.hibernate.validator.constraints.NotEmpty; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -149,36 +149,36 @@ public interface RolloutManagement { /** * Retrieves all rollouts. * - * @param page + * @param pageable * the page request to sort and limit the result * @return a page of found rollouts */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findAll(@NotNull Pageable page); + Page findAll(@NotNull Pageable pageable); /** * Get count of targets in different status in rollout. * - * @param page + * @param pageable * the page request to sort and limit the result * @return a list of rollouts with details of targets count for different * statuses * */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findAllRolloutsWithDetailedStatus(@NotNull Pageable page); + Page findAllRolloutsWithDetailedStatus(@NotNull Pageable pageable); /** * Retrieves all rollouts found by the given specification. * * @param specification * the specification to filter rollouts - * @param page + * @param pageable * the page request to sort and limit the result * @return a page of found rollouts */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findAllWithDetailedStatusByPredicate(@NotNull String rsqlParam, @NotNull Pageable page); + Page findAllWithDetailedStatusByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable); /** * Finds rollouts by given text in name or description. diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java index 1802b1dcc..a586c0bfb 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java @@ -259,7 +259,7 @@ public interface SoftwareManagement { * in case the meta data does not exists for the given key */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - SoftwareModuleMetadata findSoftwareModuleMetadata(@NotNull SwMetadataCompositeKey id); + SoftwareModuleMetadata findSoftwareModuleMetadata(@NotNull SoftwareModule softwareModule, @NotEmpty String key); /** * finds all meta data by the given software module id. @@ -409,7 +409,7 @@ public interface SoftwareManagement { * @return the found {@link SoftwareModuleType}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Page findSoftwareModuleTypesByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable); + Page findSoftwareModuleTypesAll(@NotNull String rsqlParam, @NotNull Pageable pageable); /** * Retrieves software module including details ( @@ -478,4 +478,37 @@ public interface SoftwareManagement { * @return {@link SoftwareModule} object */ SoftwareModule generateSoftwareModule(); + + /** + * Generates a {@link SoftwareModule} without persisting it. + * + * @param type + * of the {@link SoftwareModule} + * @param name + * abstract name of the {@link SoftwareModule} + * @param version + * of the {@link SoftwareModule} + * @param description + * of the {@link SoftwareModule} + * @param vendor + * of the {@link SoftwareModule} + * + * @return {@link SoftwareModule} object + */ + SoftwareModule generateSoftwareModule(SoftwareModuleType type, String name, String version, String description, + String vendor); + + /** + * Generates an empty {@link SoftwareModuleMetadata} pair without persisting + * it. + * + * @return {@link SoftwareModuleMetadata} object + */ + SoftwareModuleMetadata generateSoftwareModuleMetadata(); + + SoftwareModuleMetadata generateSoftwareModuleMetadata(SoftwareModule softwareModule, String key, String value); + + SoftwareModuleType generateSoftwareModuleType(final String key, final String name, final String description, + final int maxAssignments); + } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java index fa38e318b..786308e70 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java @@ -148,13 +148,13 @@ public interface TagManagement { /** * returns all {@link TargetTag}s. * - * @param pageReq + * @param pageable * page parameter * * @return all {@link TargetTag}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findAllTargetTags(@NotNull Pageable pageReq); + Page findAllTargetTags(@NotNull Pageable pageable); /** * Retrieves all target tags based on the given specification. @@ -245,4 +245,12 @@ public interface TagManagement { */ DistributionSetTag generateDistributionSetTag(); + TargetTag generateTargetTag(String name, String description, String colour); + + TargetTag generateTargetTag(String name); + + DistributionSetTag generateDistributionSetTag(String name, String description, String colour); + + DistributionSetTag generateDistributionSetTag(String name); + } \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java index caf045c93..127e22e63 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java @@ -96,4 +96,10 @@ public interface TargetFilterQueryManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) TargetFilterQuery updateTargetFilterQuery(@NotNull TargetFilterQuery targetFilterQuery); + /** + * Generates an empty {@link TargetFilterQuery} without persisting it. + * + * @return {@link TargetFilterQuery} object + */ + TargetFilterQuery generateTargetFilterQuery(); } \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/BaseEntityRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/BaseEntityRepository.java index 92bec68a2..0d9f72b37 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/BaseEntityRepository.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/BaseEntityRepository.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.repository.jpa; import java.io.Serializable; -import org.eclipse.hawkbit.repository.jpa.model.JpaTenantAwareBaseEntity; +import org.eclipse.hawkbit.repository.jpa.model.AbstractJpaTenantAwareBaseEntity; import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.repository.NoRepositoryBean; @@ -28,7 +28,7 @@ import org.springframework.transaction.annotation.Transactional; */ @NoRepositoryBean @Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED) -public interface BaseEntityRepository +public interface BaseEntityRepository extends PagingAndSortingRepository { /** diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java index c7a229bf0..09283f67c 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java @@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.jpa; import java.net.URI; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Map; @@ -286,7 +287,7 @@ public class JpaControllerManagement implements ControllerManagement { return actionRepository.save(mergedAction); } - private void handleErrorOnAction(final Action mergedAction, final Target mergedTarget) { + private void handleErrorOnAction(final JpaAction mergedAction, final Target mergedTarget) { mergedAction.setActive(false); mergedAction.setStatus(Status.ERROR); mergedTarget.setAssignedDistributionSet(null); @@ -437,4 +438,28 @@ public class JpaControllerManagement implements ControllerManagement { public ActionStatus generateActionStatus() { return new JpaActionStatus(); } + + @Override + @Transactional(propagation = Propagation.SUPPORTS) + public ActionStatus generateActionStatus(final Action action, final Status status, final Long occurredAt, + final String message) { + return new JpaActionStatus((JpaAction) action, status, occurredAt, message); + } + + @Override + @Transactional(propagation = Propagation.SUPPORTS) + public ActionStatus generateActionStatus(final Action action, final Status status, final Long occurredAt, + final Collection messages) { + + final ActionStatus result = new JpaActionStatus((JpaAction) action, status, occurredAt, null); + messages.forEach(result::addMessage); + + return result; + } + + @Override + @Transactional(propagation = Propagation.SUPPORTS) + public ActionStatus generateActionStatus(final Action action, final Status status, final Long occurredAt) { + return new JpaActionStatus(action, status, occurredAt); + } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java index 3dea0e549..e0ace822d 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java @@ -598,11 +598,11 @@ public class JpaDeploymentManagement implements DeploymentManagement { return convertAcPage(actionRepository.findAll((Specification) (root, query, cb) -> cb .and(specification.toPredicate(root, query, cb), cb.equal(root.get(JpaAction_.target), target)), - pageable)); + pageable), pageable); } - private static Page convertAcPage(final Page findAll) { - return new PageImpl<>(new ArrayList<>(findAll.getContent())); + private static Page convertAcPage(final Page findAll, final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements()); } @Override @@ -656,13 +656,13 @@ public class JpaDeploymentManagement implements DeploymentManagement { } @Override - public Page findActionStatusByAction(final Pageable pageReq, final Action action, - final boolean withMessages) { - if (withMessages) { - return actionStatusRepository.getByAction(pageReq, (JpaAction) action); - } else { - return actionStatusRepository.findByAction(pageReq, (JpaAction) action); - } + public Page findActionStatusByAction(final Pageable pageReq, final Action action) { + return actionStatusRepository.findByAction(pageReq, (JpaAction) action); + } + + @Override + public Page findActionStatusByActionWithMessages(final Pageable pageReq, final Action action) { + return actionStatusRepository.getByAction(pageReq, (JpaAction) action); } @Override @@ -682,4 +682,13 @@ public class JpaDeploymentManagement implements DeploymentManagement { public Action generateAction() { return new JpaAction(); } + + @Override + public Page findActionStatusAll(final Pageable pageable) { + return convertAcSPage(actionStatusRepository.findAll(pageable), pageable); + } + + private static Page convertAcSPage(final Page findAll, final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements()); + } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java index 4e33d4960..e17c737e7 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java @@ -298,11 +298,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { final DistributionSetFilter distributionSetFilter) { final List> specList = buildDistributionSetSpecifications( distributionSetFilter); - return convertDsPage(findByCriteriaAPI(pageable, specList)); + return convertDsPage(findByCriteriaAPI(pageable, specList), pageable); } - private static Page convertDsPage(final Page findAll) { - return new PageImpl<>(new ArrayList<>(findAll.getContent())); + private static Page convertDsPage(final Page findAll, + final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements()); } /** @@ -323,8 +324,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { } @Override - public Page findDistributionSetsAll(final Pageable pageReq, final Boolean deleted, - final Boolean complete) { + public Page findDistributionSetsByDeletedAndOrCompleted(final Pageable pageReq, + final Boolean deleted, final Boolean complete) { final List> specList = new ArrayList<>(); if (deleted != null) { @@ -337,7 +338,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { specList.add(spec); } - return convertDsPage(findByCriteriaAPI(pageReq, specList)); + return convertDsPage(findByCriteriaAPI(pageReq, specList), pageReq); } @Override @@ -351,7 +352,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { specList.add(DistributionSetSpecification.isDeleted(deleted)); } specList.add(spec); - return convertDsPage(findByCriteriaAPI(pageReq, specList)); + return convertDsPage(findByCriteriaAPI(pageReq, specList), pageReq); } @Override @@ -528,7 +529,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { return convertMdPage(distributionSetMetadataRepository .findAll((Specification) (root, query, cb) -> cb.equal( root.get(JpaDistributionSetMetadata_.distributionSet).get(JpaDistributionSet_.id), - distributionSetId), pageable)); + distributionSetId), pageable), + pageable); } @Override @@ -543,11 +545,13 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { .findAll((Specification) (root, query, cb) -> cb.and( cb.equal(root.get(JpaDistributionSetMetadata_.distributionSet) .get(JpaDistributionSet_.id), distributionSetId), - spec.toPredicate(root, query, cb)), pageable)); + spec.toPredicate(root, query, cb)), pageable), + pageable); } - private static Page convertMdPage(final Page findAll) { - return new PageImpl<>(new ArrayList<>(findAll.getContent())); + private static Page convertMdPage(final Page findAll, + final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements()); } @Override @@ -745,4 +749,36 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { public DistributionSet generateDistributionSet() { return new JpaDistributionSet(); } + + @Override + @Transactional(propagation = Propagation.SUPPORTS) + public DistributionSetMetadata generateDistributionSetMetadata() { + return new JpaDistributionSetMetadata(); + } + + @Override + @Transactional(propagation = Propagation.SUPPORTS) + public DistributionSetMetadata generateDistributionSetMetadata(final DistributionSet distributionSet, + final String key, final String value) { + return new JpaDistributionSetMetadata(key, distributionSet, value); + } + + @Override + @Transactional(propagation = Propagation.SUPPORTS) + public DistributionSetType generateDistributionSetType(final String key, final String name, + final String description) { + return new JpaDistributionSetType(key, name, description); + } + + @Override + @Transactional(propagation = Propagation.SUPPORTS) + public DistributionSet generateDistributionSet(final String name, final String version, final String description, + final DistributionSetType type, final Collection moduleList) { + return new JpaDistributionSet(name, version, description, type, moduleList); + } + + @Override + public Long countDistributionSetsByType(final DistributionSetType type) { + return distributionSetRepository.countByType((JpaDistributionSetType) type); + } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java index b3ea8fb74..cde2a0a15 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java @@ -26,7 +26,6 @@ import org.eclipse.hawkbit.repository.RolloutGroupManagement; import org.eclipse.hawkbit.repository.TargetFields; import org.eclipse.hawkbit.repository.jpa.model.JpaAction; import org.eclipse.hawkbit.repository.jpa.model.JpaAction_; -import org.eclipse.hawkbit.repository.jpa.model.JpaRollout.RolloutStatus; import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup; import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup_; import org.eclipse.hawkbit.repository.jpa.model.JpaTarget; @@ -35,6 +34,7 @@ import org.eclipse.hawkbit.repository.jpa.model.RolloutTargetGroup; import org.eclipse.hawkbit.repository.jpa.model.RolloutTargetGroup_; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Rollout; +import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus; import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetWithActionStatus; @@ -46,7 +46,6 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Slice; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; @@ -80,20 +79,21 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { } @Override - public Page findRolloutGroupsByRolloutId(final Long rolloutId, final Pageable page) { - return convertPage(rolloutGroupRepository.findByRolloutId(rolloutId, page)); + public Page findRolloutGroupsByRolloutId(final Long rolloutId, final Pageable pageable) { + return convertPage(rolloutGroupRepository.findByRolloutId(rolloutId, pageable), pageable); } - private static Page convertPage(final Slice findAll) { - return new PageImpl<>(new ArrayList<>(findAll.getContent())); + private static Page convertPage(final Page findAll, final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements()); } - private static Page convertTPage(final Page findAll) { - return new PageImpl<>(new ArrayList<>(findAll.getContent())); + private static Page convertTPage(final Page findAll, final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements()); } @Override - public Page findRolloutGroupsAll(final Rollout rollout, final String rsqlParam, final Pageable page) { + public Page findRolloutGroupsAll(final Rollout rollout, final String rsqlParam, + final Pageable pageable) { final Specification specification = RSQLUtility.parse(rsqlParam, RolloutGroupFields.class); @@ -103,12 +103,13 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { (root, query, criteriaBuilder) -> criteriaBuilder.and( criteriaBuilder.equal(root.get(JpaRolloutGroup_.rollout), rollout), specification.toPredicate(root, query, criteriaBuilder)), - page)); + pageable), + pageable); } @Override - public Page findAllRolloutGroupsWithDetailedStatus(final Long rolloutId, final Pageable page) { - final Page rolloutGroups = rolloutGroupRepository.findByRolloutId(rolloutId, page); + public Page findAllRolloutGroupsWithDetailedStatus(final Long rolloutId, final Pageable pageable) { + final Page rolloutGroups = rolloutGroupRepository.findByRolloutId(rolloutId, pageable); final List rolloutGroupIds = rolloutGroups.getContent().stream().map(rollout -> rollout.getId()) .collect(Collectors.toList()); final Map> allStatesForRollout = getStatusCountItemForRolloutGroup( @@ -120,7 +121,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { rolloutGroup.setTotalTargetCountStatus(totalTargetCountStatus); } - return convertPage(rolloutGroups); + return convertPage(rolloutGroups, pageable); } @Override @@ -145,7 +146,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { @Override public Page findRolloutGroupTargets(final RolloutGroup rolloutGroup, final String rsqlParam, - final Pageable page) { + final Pageable pageable) { final Specification rsqlSpecification = RSQLUtility.parse(rsqlParam, TargetFields.class); @@ -153,7 +154,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { final ListJoin rolloutTargetJoin = root.join(JpaTarget_.rolloutTargetGroup); return criteriaBuilder.and(rsqlSpecification.toPredicate(root, query, criteriaBuilder), criteriaBuilder.equal(rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup), rolloutGroup)); - }, page)); + }, pageable), pageable); } @Override diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java index ec13c4f29..744c863ba 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java @@ -20,24 +20,25 @@ import javax.persistence.EntityManager; import org.eclipse.hawkbit.cache.CacheWriteNotify; import org.eclipse.hawkbit.repository.DeploymentManagement; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.RolloutFields; import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.exception.RolloutIllegalStateException; import org.eclipse.hawkbit.repository.jpa.model.JpaRollout; -import org.eclipse.hawkbit.repository.jpa.model.JpaRollout.RolloutStatus; import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupConditions; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupErrorCondition; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupStatus; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupSuccessCondition; import org.eclipse.hawkbit.repository.jpa.model.JpaRollout_; import org.eclipse.hawkbit.repository.jpa.model.RolloutTargetGroup; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.Rollout; +import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus; import org.eclipse.hawkbit.repository.model.RolloutGroup; +import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondition; +import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus; +import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition; +import org.eclipse.hawkbit.repository.model.RolloutGroupConditions; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TotalTargetCountActionStatus; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; @@ -137,22 +138,26 @@ public class JpaRolloutManagement implements RolloutManagement { private static final Set startingRollouts = ConcurrentHashMap.newKeySet(); @Override - public Page findAll(final Pageable page) { - return convertPage(rolloutRepository.findAll(page)); + public Page findAll(final Pageable pageable) { + return convertPage(rolloutRepository.findAll(pageable), pageable); } - private static Page convertPage(final Slice findAll) { - return new PageImpl<>(new ArrayList<>(findAll.getContent())); + private static Page convertPage(final Page findAll, final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements()); + } + + private static Slice convertPage(final Slice findAll, final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, 0); } @Override - public Page findAllWithDetailedStatusByPredicate(final String rsqlParam, final Pageable page) { + public Page findAllWithDetailedStatusByPredicate(final String rsqlParam, final Pageable pageable) { final Specification specification = RSQLUtility.parse(rsqlParam, RolloutFields.class); - final Page findAll = rolloutRepository.findAll(specification, page); + final Page findAll = rolloutRepository.findAll(specification, pageable); setRolloutStatusDetails(findAll); - return convertPage(findAll); + return convertPage(findAll, pageable); } @Override @@ -570,7 +575,7 @@ public class JpaRolloutManagement implements RolloutManagement { final Specification specs = likeNameOrDescription(searchText); final Slice findAll = criteriaNoCountDao.findAll(specs, pageable, JpaRollout.class); setRolloutStatusDetails(findAll); - return convertPage(findAll); + return convertPage(findAll, pageable); } @Override @@ -604,10 +609,10 @@ public class JpaRolloutManagement implements RolloutManagement { * */ @Override - public Page findAllRolloutsWithDetailedStatus(final Pageable page) { - final Page rollouts = rolloutRepository.findAll(page); + public Page findAllRolloutsWithDetailedStatus(final Pageable pageable) { + final Page rollouts = rolloutRepository.findAll(pageable); setRolloutStatusDetails(rollouts); - return convertPage(rollouts); + return convertPage(rollouts, pageable); } @@ -618,7 +623,7 @@ public class JpaRolloutManagement implements RolloutManagement { .getStatusCountByRolloutId(rolloutId); final TotalTargetCountStatus totalTargetCountStatus = new TotalTargetCountStatus(rolloutStatusCountItems, rollout.getTotalTargets()); - rollout.setTotalTargetCountStatus(totalTargetCountStatus); + ((JpaRollout) rollout).setTotalTargetCountStatus(totalTargetCountStatus); return rollout; } @@ -636,7 +641,7 @@ public class JpaRolloutManagement implements RolloutManagement { for (final Rollout rollout : rollouts) { final TotalTargetCountStatus totalTargetCountStatus = new TotalTargetCountStatus( allStatesForRollout.get(rollout.getId()), rollout.getTotalTargets()); - rollout.setTotalTargetCountStatus(totalTargetCountStatus); + ((JpaRollout) rollout).setTotalTargetCountStatus(totalTargetCountStatus); } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareManagement.java index 7ea7e46be..b98ff0754 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareManagement.java @@ -183,15 +183,21 @@ public class JpaSoftwareManagement implements SoftwareManagement { spec = SoftwareModuleSpecification.isDeletedFalse(); specList.add(spec); - return convertSmPage(findSwModuleByCriteriaAPI(pageable, specList)); + return convertSmPage(findSwModuleByCriteriaAPI(pageable, specList), pageable); } - private static Page convertSmPage(final Slice findAll) { - return new PageImpl<>(new ArrayList<>(findAll.getContent())); + private static Slice convertSmPage(final Slice findAll, + final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, 0); } - private static Page convertSmMdPage(final Slice findAll) { - return new PageImpl<>(new ArrayList<>(findAll.getContent())); + private static Page convertSmPage(final Page findAll, final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements()); + } + + private static Page convertSmMdPage(final Page findAll, + final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements()); } @Override @@ -288,7 +294,7 @@ public class JpaSoftwareManagement implements SoftwareManagement { specList.add(spec); - return convertSmPage(findSwModuleByCriteriaAPI(pageable, specList)); + return convertSmPage(findSwModuleByCriteriaAPI(pageable, specList), pageable); } @Override @@ -311,20 +317,20 @@ public class JpaSoftwareManagement implements SoftwareManagement { public Page findSoftwareModulesByPredicate(final String rsqlParam, final Pageable pageable) { final Specification spec = RSQLUtility.parse(rsqlParam, SoftwareModuleFields.class); - return convertSmPage(softwareModuleRepository.findAll(spec, pageable)); + return convertSmPage(softwareModuleRepository.findAll(spec, pageable), pageable); } @Override - public Page findSoftwareModuleTypesByPredicate(final String rsqlParam, - final Pageable pageable) { + public Page findSoftwareModuleTypesAll(final String rsqlParam, final Pageable pageable) { final Specification spec = RSQLUtility.parse(rsqlParam, SoftwareModuleTypeFields.class); - return convertSmTPage(softwareModuleTypeRepository.findAll(spec, pageable)); + return convertSmTPage(softwareModuleTypeRepository.findAll(spec, pageable), pageable); } - private static Page convertSmTPage(final Slice findAll) { - return new PageImpl<>(new ArrayList<>(findAll.getContent())); + private static Page convertSmTPage(final Page findAll, + final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements()); } @Override @@ -361,7 +367,7 @@ public class JpaSoftwareManagement implements SoftwareManagement { specList.add(spec); - return convertSmPage(findSwModuleByCriteriaAPI(pageable, specList)); + return convertSmPage(findSwModuleByCriteriaAPI(pageable, specList), pageable); } @Override @@ -614,11 +620,16 @@ public class JpaSoftwareManagement implements SoftwareManagement { cb.equal(root.get(JpaSoftwareModuleMetadata_.softwareModule) .get(JpaSoftwareModule_.id), softwareModuleId), spec.toPredicate(root, query, cb)), - pageable)); + pageable), + pageable); } @Override - public SoftwareModuleMetadata findSoftwareModuleMetadata(final SwMetadataCompositeKey id) { + public SoftwareModuleMetadata findSoftwareModuleMetadata(final SoftwareModule softwareModule, final String key) { + return findSoftwareModuleMetadata(new SwMetadataCompositeKey(softwareModule, key)); + } + + private SoftwareModuleMetadata findSoftwareModuleMetadata(final SwMetadataCompositeKey id) { final SoftwareModuleMetadata findOne = softwareModuleMetadataRepository.findOne(id); if (findOne == null) { throw new EntityNotFoundException("Metadata with key '" + id.getKey() + "' does not exist"); @@ -664,4 +675,32 @@ public class JpaSoftwareManagement implements SoftwareManagement { return new JpaSoftwareModule(); } + @Override + @Transactional(propagation = Propagation.SUPPORTS) + public SoftwareModule generateSoftwareModule(final SoftwareModuleType type, final String name, final String version, + final String description, final String vendor) { + + return new JpaSoftwareModule(type, name, version, description, vendor); + } + + @Override + @Transactional(propagation = Propagation.SUPPORTS) + public SoftwareModuleMetadata generateSoftwareModuleMetadata() { + return new JpaSoftwareModuleMetadata(); + } + + @Override + @Transactional(propagation = Propagation.SUPPORTS) + public SoftwareModuleMetadata generateSoftwareModuleMetadata(final SoftwareModule softwareModule, final String key, + final String value) { + return new JpaSoftwareModuleMetadata(key, softwareModule, value); + } + + @Override + @Transactional(propagation = Propagation.SUPPORTS) + public SoftwareModuleType generateSoftwareModuleType(final String key, final String name, final String description, + final int maxAssignments) { + return new JpaSoftwareModuleType(key, name, description, maxAssignments); + } + } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTagManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTagManagement.java index 4ff9c6e2b..c8358b7ec 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTagManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTagManagement.java @@ -151,15 +151,16 @@ public class JpaTagManagement implements TagManagement { public Page findAllTargetTags(final String rsqlParam, final Pageable pageable) { final Specification spec = RSQLUtility.parse(rsqlParam, TagFields.class); - return convertTPage(targetTagRepository.findAll(spec, pageable)); + return convertTPage(targetTagRepository.findAll(spec, pageable), pageable); } - private static Page convertTPage(final Page findAll) { - return new PageImpl<>(new ArrayList<>(findAll.getContent())); + private static Page convertTPage(final Page findAll, final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements()); } - private static Page convertDsPage(final Page findAll) { - return new PageImpl<>(new ArrayList<>(findAll.getContent())); + private static Page convertDsPage(final Page findAll, + final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements()); } @Override @@ -270,20 +271,20 @@ public class JpaTagManagement implements TagManagement { } @Override - public Page findAllTargetTags(final Pageable pageReq) { - return convertTPage(targetTagRepository.findAll(pageReq)); + public Page findAllTargetTags(final Pageable pageable) { + return convertTPage(targetTagRepository.findAll(pageable), pageable); } @Override - public Page findAllDistributionSetTags(final Pageable pageReq) { - return convertDsPage(distributionSetTagRepository.findAll(pageReq)); + public Page findAllDistributionSetTags(final Pageable pageable) { + return convertDsPage(distributionSetTagRepository.findAll(pageable), pageable); } @Override public Page findAllDistributionSetTags(final String rsqlParam, final Pageable pageable) { final Specification spec = RSQLUtility.parse(rsqlParam, TagFields.class); - return convertDsPage(distributionSetTagRepository.findAll(spec, pageable)); + return convertDsPage(distributionSetTagRepository.findAll(spec, pageable), pageable); } @Override @@ -298,4 +299,29 @@ public class JpaTagManagement implements TagManagement { return new JpaDistributionSetTag(); } + @Override + @Transactional(propagation = Propagation.SUPPORTS) + public TargetTag generateTargetTag(final String name, final String description, final String colour) { + return new JpaTargetTag(name, description, colour); + } + + @Override + @Transactional(propagation = Propagation.SUPPORTS) + public DistributionSetTag generateDistributionSetTag(final String name, final String description, + final String colour) { + return new JpaDistributionSetTag(name, description, colour); + } + + @Override + @Transactional(propagation = Propagation.SUPPORTS) + public TargetTag generateTargetTag(final String name) { + return new JpaTargetTag(name); + } + + @Override + @Transactional(propagation = Propagation.SUPPORTS) + public DistributionSetTag generateDistributionSetTag(final String name) { + return new JpaDistributionSetTag(name); + } + } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetFilterQueryManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetFilterQueryManagement.java index 5dd33b762..8bc4a0833 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetFilterQueryManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetFilterQueryManagement.java @@ -64,11 +64,12 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme @Override public Page findAllTargetFilterQuery(final Pageable pageable) { - return convertPage(targetFilterQueryRepository.findAll(pageable)); + return convertPage(targetFilterQueryRepository.findAll(pageable), pageable); } - private static Page convertPage(final Page findAll) { - return new PageImpl<>(new ArrayList<>(findAll.getContent())); + private static Page convertPage(final Page findAll, + final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements()); } @Override @@ -77,7 +78,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme if (!Strings.isNullOrEmpty(name)) { specList.add(TargetFilterQuerySpecification.likeName(name)); } - return convertPage(findTargetFilterQueryByCriteriaAPI(pageable, specList)); + return convertPage(findTargetFilterQueryByCriteriaAPI(pageable, specList), pageable); } private Page findTargetFilterQueryByCriteriaAPI(final Pageable pageable, @@ -108,4 +109,9 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme return targetFilterQueryRepository.save((JpaTargetFilterQuery) targetFilterQuery); } + @Override + public TargetFilterQuery generateTargetFilterQuery() { + return new JpaTargetFilterQuery(); + } + } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java index 0e900e655..d73a9ae5f 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java @@ -145,7 +145,7 @@ public class JpaTargetManagement implements TargetManagement { } return cb.conjunction(); }; - return convertPage(criteriaNoCountDao.findAll(spec, pageable, JpaTarget.class)); + return convertPage(criteriaNoCountDao.findAll(spec, pageable, JpaTarget.class), pageable); } @Override @@ -159,7 +159,7 @@ public class JpaTargetManagement implements TargetManagement { } private Page findTargetsBySpec(final Specification spec, final Pageable pageable) { - return convertPage(targetRepository.findAll(spec, pageable)); + return convertPage(targetRepository.findAll(spec, pageable), pageable); } @Override @@ -222,17 +222,21 @@ public class JpaTargetManagement implements TargetManagement { final Specification spec = RSQLUtility.parse(rsqlParam, TargetFields.class); - return convertPage(targetRepository.findAll((Specification) (root, query, cb) -> cb.and( - TargetSpecifications.hasAssignedDistributionSet(distributionSetID).toPredicate(root, query, cb), - spec.toPredicate(root, query, cb)), pageReq)); + return convertPage( + targetRepository + .findAll((Specification) (root, query, + cb) -> cb.and(TargetSpecifications.hasAssignedDistributionSet(distributionSetID) + .toPredicate(root, query, cb), spec.toPredicate(root, query, cb)), + pageReq), + pageReq); } - private static Page convertPage(final Page findAll) { - return new PageImpl<>(new ArrayList<>(findAll.getContent())); + private static Page convertPage(final Page findAll, final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements()); } - private static Slice convertPage(final Slice findAll) { - return new PageImpl<>(new ArrayList<>(findAll.getContent())); + private static Slice convertPage(final Slice findAll, final Pageable pageable) { + return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, 0); } @Override @@ -246,9 +250,13 @@ public class JpaTargetManagement implements TargetManagement { final Specification spec = RSQLUtility.parse(rsqlParam, TargetFields.class); - return convertPage(targetRepository.findAll((Specification) (root, query, cb) -> cb.and( - TargetSpecifications.hasInstalledDistributionSet(distributionSetId).toPredicate(root, query, cb), - spec.toPredicate(root, query, cb)), pageable)); + return convertPage( + targetRepository + .findAll((Specification) (root, query, + cb) -> cb.and(TargetSpecifications.hasInstalledDistributionSet(distributionSetId) + .toPredicate(root, query, cb), spec.toPredicate(root, query, cb)), + pageable), + pageable); } @Override @@ -296,10 +304,11 @@ public class JpaTargetManagement implements TargetManagement { private Slice findByCriteriaAPI(final Pageable pageable, final List> specList) { if (specList == null || specList.isEmpty()) { - return convertPage(criteriaNoCountDao.findAll(pageable, JpaTarget.class)); + return convertPage(criteriaNoCountDao.findAll(pageable, JpaTarget.class), pageable); } return convertPage( - criteriaNoCountDao.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable, JpaTarget.class)); + criteriaNoCountDao.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable, JpaTarget.class), + pageable); } private Long countByCriteriaAPI(final List> specList) { diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/RolloutGroupRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/RolloutGroupRepository.java index 0eaa237aa..134f7b18d 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/RolloutGroupRepository.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/RolloutGroupRepository.java @@ -12,9 +12,9 @@ import java.util.List; import org.eclipse.hawkbit.repository.jpa.model.JpaRollout; import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupStatus; import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.RolloutGroup; +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; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/RolloutRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/RolloutRepository.java index e73c12952..74d47d99a 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/RolloutRepository.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/RolloutRepository.java @@ -11,8 +11,8 @@ package org.eclipse.hawkbit.repository.jpa; import java.util.List; import org.eclipse.hawkbit.repository.jpa.model.JpaRollout; -import org.eclipse.hawkbit.repository.jpa.model.JpaRollout.RolloutStatus; import org.eclipse.hawkbit.repository.model.Rollout; +import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaArtifact.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaArtifact.java similarity index 93% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaArtifact.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaArtifact.java index be0b5e1ac..7a5bea6b7 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaArtifact.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaArtifact.java @@ -19,7 +19,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule; * {@link SoftwareModule}. */ @MappedSuperclass -public abstract class JpaArtifact extends JpaTenantAwareBaseEntity implements Artifact { +public abstract class AbstractJpaArtifact extends AbstractJpaTenantAwareBaseEntity implements Artifact { private static final long serialVersionUID = 1L; @Column(name = "sha1_hash", length = 40, nullable = true) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaBaseEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaBaseEntity.java similarity index 96% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaBaseEntity.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaBaseEntity.java index cfe4ada52..b7e340085 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaBaseEntity.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaBaseEntity.java @@ -34,7 +34,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; @MappedSuperclass @Access(AccessType.FIELD) @EntityListeners({ AuditingEntityListener.class, CacheFieldEntityListener.class, EntityPropertyChangeListener.class }) -public abstract class JpaBaseEntity implements BaseEntity { +public abstract class AbstractJpaBaseEntity implements BaseEntity { private static final long serialVersionUID = 1L; @Id @@ -54,7 +54,7 @@ public abstract class JpaBaseEntity implements BaseEntity { /** * Default constructor needed for JPA entities. */ - public JpaBaseEntity() { + public AbstractJpaBaseEntity() { // Default constructor needed for JPA entities. } @@ -167,7 +167,7 @@ public abstract class JpaBaseEntity implements BaseEntity { if (!(this.getClass().isInstance(obj))) { return false; } - final JpaBaseEntity other = (JpaBaseEntity) obj; + final AbstractJpaBaseEntity other = (AbstractJpaBaseEntity) obj; if (id == null) { if (other.id != null) { return false; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaMetaData.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaMetaData.java similarity index 90% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaMetaData.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaMetaData.java index f2d905d89..5a3f23ac3 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaMetaData.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaMetaData.java @@ -20,7 +20,7 @@ import org.eclipse.hawkbit.repository.model.MetaData; * */ @MappedSuperclass -public abstract class JpaMetaData implements MetaData { +public abstract class AbstractJpaMetaData implements MetaData { private static final long serialVersionUID = 1L; @Id @@ -31,13 +31,13 @@ public abstract class JpaMetaData implements MetaData { @Basic private String value; - public JpaMetaData(final String key, final String value) { + public AbstractJpaMetaData(final String key, final String value) { super(); this.key = key; this.value = value; } - public JpaMetaData() { + public AbstractJpaMetaData() { // Default constructor needed for JPA entities } @@ -81,7 +81,7 @@ public abstract class JpaMetaData implements MetaData { if (!(this.getClass().isInstance(obj))) { return false; } - final JpaMetaData other = (JpaMetaData) obj; + final AbstractJpaMetaData other = (AbstractJpaMetaData) obj; if (key == null) { if (other.key != null) { return false; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaNamedEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaNamedEntity.java similarity index 87% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaNamedEntity.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaNamedEntity.java index e4e48ac36..196e636d9 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaNamedEntity.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaNamedEntity.java @@ -19,7 +19,7 @@ import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity; * addition to their technical ID. */ @MappedSuperclass -public abstract class JpaNamedEntity extends JpaTenantAwareBaseEntity implements NamedEntity { +public abstract class AbstractJpaNamedEntity extends AbstractJpaTenantAwareBaseEntity implements NamedEntity { private static final long serialVersionUID = 1L; @Column(name = "name", nullable = false, length = 64) @@ -31,7 +31,7 @@ public abstract class JpaNamedEntity extends JpaTenantAwareBaseEntity implements /** * Default constructor. */ - public JpaNamedEntity() { + public AbstractJpaNamedEntity() { super(); } @@ -43,7 +43,7 @@ public abstract class JpaNamedEntity extends JpaTenantAwareBaseEntity implements * @param description * of the {@link NamedEntity} */ - public JpaNamedEntity(final String name, final String description) { + public AbstractJpaNamedEntity(final String name, final String description) { this.name = name; this.description = description; } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaNamedVersionedEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaNamedVersionedEntity.java similarity index 82% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaNamedVersionedEntity.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaNamedVersionedEntity.java index 33a7036d5..785666b67 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaNamedVersionedEntity.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaNamedVersionedEntity.java @@ -19,7 +19,7 @@ import org.eclipse.hawkbit.repository.model.NamedVersionedEntity; * */ @MappedSuperclass -public abstract class JpaNamedVersionedEntity extends JpaNamedEntity implements NamedVersionedEntity { +public abstract class AbstractJpaNamedVersionedEntity extends AbstractJpaNamedEntity implements NamedVersionedEntity { private static final long serialVersionUID = 1L; @Column(name = "version", nullable = false, length = 64) @@ -34,12 +34,12 @@ public abstract class JpaNamedVersionedEntity extends JpaNamedEntity implements * of the entity * @param description */ - public JpaNamedVersionedEntity(final String name, final String version, final String description) { + public AbstractJpaNamedVersionedEntity(final String name, final String version, final String description) { super(name, description); this.version = version; } - JpaNamedVersionedEntity() { + AbstractJpaNamedVersionedEntity() { super(); } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTag.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaTag.java similarity index 86% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTag.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaTag.java index ee4da0824..653b678bc 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTag.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaTag.java @@ -19,13 +19,13 @@ import org.eclipse.hawkbit.repository.model.Tag; * */ @MappedSuperclass -public abstract class JpaTag extends JpaNamedEntity implements Tag { +public abstract class AbstractJpaTag extends AbstractJpaNamedEntity implements Tag { private static final long serialVersionUID = 1L; @Column(name = "colour", nullable = true, length = 16) private String colour; - protected JpaTag() { + protected AbstractJpaTag() { super(); } @@ -39,7 +39,7 @@ public abstract class JpaTag extends JpaNamedEntity implements Tag { * @param colour * of tag in UI */ - public JpaTag(final String name, final String description, final String colour) { + public AbstractJpaTag(final String name, final String description, final String colour) { super(name, description); this.colour = colour; } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantAwareBaseEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaTenantAwareBaseEntity.java similarity index 93% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantAwareBaseEntity.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaTenantAwareBaseEntity.java index e921e6915..134d0c788 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantAwareBaseEntity.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaTenantAwareBaseEntity.java @@ -27,7 +27,7 @@ import org.eclipse.persistence.annotations.TenantDiscriminatorColumn; @MappedSuperclass @TenantDiscriminatorColumn(name = "tenant", length = 40) @Multitenant(MultitenantType.SINGLE_TABLE) -public abstract class JpaTenantAwareBaseEntity extends JpaBaseEntity implements TenantAwareBaseEntity { +public abstract class AbstractJpaTenantAwareBaseEntity extends AbstractJpaBaseEntity implements TenantAwareBaseEntity { private static final long serialVersionUID = 1L; @Column(name = "tenant", nullable = false, insertable = false, updatable = false, length = 40) @@ -36,7 +36,7 @@ public abstract class JpaTenantAwareBaseEntity extends JpaBaseEntity implements /** * Default constructor needed for JPA entities. */ - public JpaTenantAwareBaseEntity() { + public AbstractJpaTenantAwareBaseEntity() { // Default constructor needed for JPA entities. } @@ -101,7 +101,7 @@ public abstract class JpaTenantAwareBaseEntity extends JpaBaseEntity implements if (!super.equals(obj)) { return false; } - final JpaTenantAwareBaseEntity other = (JpaTenantAwareBaseEntity) obj; + final AbstractJpaTenantAwareBaseEntity other = (AbstractJpaTenantAwareBaseEntity) obj; if (tenant == null) { if (other.tenant != null) { return false; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAction.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAction.java index 1080b35fd..7ad7d7a60 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAction.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAction.java @@ -36,21 +36,11 @@ import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.RolloutGroup; -import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.persistence.annotations.CascadeOnDelete; /** - *

- * Applicable transition changes of the {@link SoftwareModule}s state of a - * {@link Target}, e.g. install, uninstall, update and preparations for the - * transition change, i.e. download. - *

- * - *

- * Actions are managed by the SP server and applied to the targets by the - * client. - *

+ * JPA implementation of {@link Action}. */ @Table(name = "sp_action", indexes = { @Index(name = "sp_idx_action_01", columnList = "tenant,distribution_set"), @Index(name = "sp_idx_action_02", columnList = "tenant,target,active"), @@ -59,12 +49,9 @@ import org.eclipse.persistence.annotations.CascadeOnDelete; @NamedEntityGraph(name = "Action.all", attributeNodes = { @NamedAttributeNode("distributionSet"), @NamedAttributeNode(value = "target", subgraph = "target.ds") }, subgraphs = @NamedSubgraph(name = "target.ds", attributeNodes = @NamedAttributeNode("assignedDistributionSet"))) }) @Entity -public class JpaAction extends JpaTenantAwareBaseEntity implements Action { +public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Action { private static final long serialVersionUID = 1L; - /** - * the {@link DistributionSet} which should be installed by this action. - */ @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "distribution_set", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_ds")) private JpaDistributionSet distributionSet; @@ -106,33 +93,16 @@ public class JpaAction extends JpaTenantAwareBaseEntity implements Action { @CacheField(key = CacheKeys.DOWNLOAD_PROGRESS_PERCENT) private int downloadProgressPercent; - /** - * @return the distributionSet - */ @Override public DistributionSet getDistributionSet() { return distributionSet; } - /** - * @param distributionSet - * the distributionSet to set - */ @Override public void setDistributionSet(final DistributionSet distributionSet) { this.distributionSet = (JpaDistributionSet) distributionSet; } - /** - * @return true when action is in state {@link Status#CANCELING} or - * {@link Status#CANCELED}, false otherwise - */ - @Override - public boolean isCancelingOrCanceled() { - return status == Status.CANCELING || status == Status.CANCELED; - } - - @Override public void setActive(final boolean active) { this.active = active; } @@ -152,7 +122,6 @@ public class JpaAction extends JpaTenantAwareBaseEntity implements Action { return downloadProgressPercent; } - @Override public void setDownloadProgressPercent(final int downloadProgressPercent) { this.downloadProgressPercent = downloadProgressPercent; } @@ -162,14 +131,10 @@ public class JpaAction extends JpaTenantAwareBaseEntity implements Action { return active; } - @Override public void setActionType(final ActionType actionType) { this.actionType = actionType; } - /** - * @return the actionType - */ @Override public ActionType getActionType() { return actionType; @@ -195,7 +160,6 @@ public class JpaAction extends JpaTenantAwareBaseEntity implements Action { return forcedTime; } - @Override public void setForcedTime(final long forcedTime) { this.forcedTime = forcedTime; } @@ -205,7 +169,6 @@ public class JpaAction extends JpaTenantAwareBaseEntity implements Action { return rolloutGroup; } - @Override public void setRolloutGroup(final RolloutGroup rolloutGroup) { this.rolloutGroup = (JpaRolloutGroup) rolloutGroup; } @@ -215,57 +178,10 @@ public class JpaAction extends JpaTenantAwareBaseEntity implements Action { return rollout; } - @Override public void setRollout(final Rollout rollout) { this.rollout = (JpaRollout) rollout; } - /** - * checks if the {@link #forcedTime} is hit by the given - * {@code hitTimeMillis}, by means if the given milliseconds are greater - * than the forcedTime. - * - * @param hitTimeMillis - * the milliseconds, mostly the - * {@link System#currentTimeMillis()} - * @return {@code true} if this {@link #type} is in - * {@link ActionType#TIMEFORCED} and the given {@code hitTimeMillis} - * is greater than the {@link #forcedTime} otherwise {@code false} - */ - @Override - public boolean isHitAutoForceTime(final long hitTimeMillis) { - if (actionType == ActionType.TIMEFORCED) { - return hitTimeMillis >= forcedTime; - } - return false; - } - - /** - * @return {@code true} if either the {@link #type} is - * {@link ActionType#FORCED} or {@link ActionType#TIMEFORCED} but - * then if the {@link #forcedTime} has been exceeded otherwise - * always {@code false} - */ - @Override - public boolean isForce() { - switch (actionType) { - case FORCED: - return true; - case TIMEFORCED: - return isHitAutoForceTime(System.currentTimeMillis()); - default: - return false; - } - } - - /** - * @return true when action is forced, false otherwise - */ - @Override - public boolean isForced() { - return actionType == ActionType.FORCED; - } - @Override public String toString() { return "Action [distributionSet=" + distributionSet + ", getId()=" + getId() + "]"; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaActionStatus.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaActionStatus.java index 94f76cae7..cf146651d 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaActionStatus.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaActionStatus.java @@ -40,7 +40,7 @@ import com.google.common.base.Splitter; @Index(name = "sp_idx_action_status_prim", columnList = "tenant,id") }) @NamedEntityGraph(name = "ActionStatus.withMessages", attributeNodes = { @NamedAttributeNode("messages") }) @Entity -public class JpaActionStatus extends JpaTenantAwareBaseEntity implements ActionStatus { +public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements ActionStatus { private static final long serialVersionUID = 1L; @Column(name = "target_occurred_at") @@ -88,14 +88,11 @@ public class JpaActionStatus extends JpaTenantAwareBaseEntity implements ActionS * @param messages * the messages which should be added to this action status */ - public JpaActionStatus(final JpaAction action, final Status status, final Long occurredAt, - final String... messages) { + public JpaActionStatus(final JpaAction action, final Status status, final Long occurredAt, final String message) { this.action = action; this.status = status; this.occurredAt = occurredAt; - for (final String msg : messages) { - addMessage(msg); - } + addMessage(message); } /** @@ -115,15 +112,11 @@ public class JpaActionStatus extends JpaTenantAwareBaseEntity implements ActionS this.occurredAt = occurredAt; } - /** - * Adds message including splitting in case it exceeds 512 length. - * - * @param message - * to add - */ @Override public final void addMessage(final String message) { - Splitter.fixedLength(512).split(message).forEach(messages::add); + if (message != null) { + Splitter.fixedLength(512).split(message).forEach(messages::add); + } } @Override diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java index 201d4d657..d01cf3f4c 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java @@ -9,6 +9,7 @@ package org.eclipse.hawkbit.repository.jpa.model; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -47,14 +48,7 @@ import org.eclipse.hawkbit.repository.model.TargetInfo; import org.eclipse.persistence.annotations.CascadeOnDelete; /** - *

- * The {@link DistributionSet} is defined in the SP repository and contains at - * least an OS and an Agent Hub. - *

- * - *

- * A {@link Target} has exactly one target {@link DistributionSet} assigned. - *

+ * Jpa implementation of {@link DistributionSet}. * */ @Entity @@ -65,11 +59,11 @@ import org.eclipse.persistence.annotations.CascadeOnDelete; @Index(name = "sp_idx_distribution_set_prim", columnList = "tenant,id") }) @NamedEntityGraph(name = "DistributionSet.detail", attributeNodes = { @NamedAttributeNode("modules"), @NamedAttributeNode("tags"), @NamedAttributeNode("type") }) -public class JpaDistributionSet extends JpaNamedVersionedEntity implements DistributionSet { +public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implements DistributionSet { private static final long serialVersionUID = 1L; @Column(name = "required_migration_step") - private boolean requiredMigrationStep = false; + private boolean requiredMigrationStep; @ManyToMany(targetEntity = JpaSoftwareModule.class, fetch = FetchType.LAZY) @JoinTable(name = "sp_ds_module", joinColumns = { @@ -84,7 +78,7 @@ public class JpaDistributionSet extends JpaNamedVersionedEntity implements Distr private Set tags = new HashSet<>(); @Column(name = "deleted") - private boolean deleted = false; + private boolean deleted; @OneToMany(mappedBy = "assignedDistributionSet", targetEntity = JpaTarget.class, fetch = FetchType.LAZY) private List assignedToTargets; @@ -106,7 +100,7 @@ public class JpaDistributionSet extends JpaNamedVersionedEntity implements Distr private DistributionSetType type; @Column(name = "complete") - private boolean complete = false; + private boolean complete; /** * Default constructor. @@ -130,7 +124,7 @@ public class JpaDistributionSet extends JpaNamedVersionedEntity implements Distr * {@link SoftwareModule}s of the {@link DistributionSet} */ public JpaDistributionSet(final String name, final String version, final String description, - final DistributionSetType type, final Iterable moduleList) { + final DistributionSetType type, final Collection moduleList) { super(name, version, description); this.type = type; @@ -152,15 +146,11 @@ public class JpaDistributionSet extends JpaNamedVersionedEntity implements Distr return deleted; } - /** - * @return immutable list of meta data elements. - */ @Override public List getMetadata() { return Collections.unmodifiableList(metadata); } - @Override public List getActions() { return actions; } @@ -182,23 +172,16 @@ public class JpaDistributionSet extends JpaNamedVersionedEntity implements Distr return this; } - @Override public DistributionSet setTags(final Set tags) { this.tags = tags; return this; } - /** - * @return the assignedTargets - */ @Override public List getAssignedTargets() { return assignedToTargets; } - /** - * @return the installedTargets - */ @Override public List getInstalledTargets() { return installedAtTargets; @@ -210,10 +193,6 @@ public class JpaDistributionSet extends JpaNamedVersionedEntity implements Distr + ", getId()=" + getId() + "]"; } - /** - * - * @return unmodifiableSet of {@link SoftwareModule}. - */ @Override public Set getModules() { return Collections.unmodifiableSet(modules); @@ -224,12 +203,6 @@ public class JpaDistributionSet extends JpaNamedVersionedEntity implements Distr return new DistributionSetIdName(getId(), getName(), getVersion()); } - /** - * @param softwareModule - * @return true if the module was added and false - * if it already existed in the set - * - */ @Override public boolean addModule(final SoftwareModule softwareModule) { @@ -267,13 +240,6 @@ public class JpaDistributionSet extends JpaNamedVersionedEntity implements Distr return false; } - /** - * Removed given {@link SoftwareModule} from this DS instance. - * - * @param softwareModule - * to remove - * @return true if element was found and removed - */ @Override public boolean removeModule(final SoftwareModule softwareModule) { final Optional found = modules.stream() @@ -289,14 +255,6 @@ public class JpaDistributionSet extends JpaNamedVersionedEntity implements Distr } - /** - * Searches through modules for the given type. - * - * @param type - * to search for - * @return SoftwareModule of given type or null if not in the - * list. - */ @Override public SoftwareModule findFirstModuleByType(final SoftwareModuleType type) { final Optional result = modules.stream().filter(module -> module.getType().equals(type)) @@ -323,4 +281,5 @@ public class JpaDistributionSet extends JpaNamedVersionedEntity implements Distr public boolean isComplete() { return complete; } + } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetMetadata.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetMetadata.java index b73e3c72e..5d176b4a9 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetMetadata.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetMetadata.java @@ -28,7 +28,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetMetadata; @IdClass(DsMetadataCompositeKey.class) @Entity @Table(name = "sp_ds_metadata") -public class JpaDistributionSetMetadata extends JpaMetaData implements DistributionSetMetadata { +public class JpaDistributionSetMetadata extends AbstractJpaMetaData implements DistributionSetMetadata { private static final long serialVersionUID = 1L; @Id @@ -49,7 +49,6 @@ public class JpaDistributionSetMetadata extends JpaMetaData implements Distribut return new DsMetadataCompositeKey(distributionSet, getKey()); } - @Override public void setDistributionSet(final DistributionSet distributionSet) { this.distributionSet = (JpaDistributionSet) distributionSet; } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetTag.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetTag.java index 4b6e67135..c4b55fe03 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetTag.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetTag.java @@ -29,7 +29,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTag; @Table(name = "sp_distributionset_tag", indexes = { @Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_ds_tag")) -public class JpaDistributionSetTag extends JpaTag implements DistributionSetTag { +public class JpaDistributionSetTag extends AbstractJpaTag implements DistributionSetTag { private static final long serialVersionUID = 1L; @ManyToMany(mappedBy = "tags", targetEntity = JpaDistributionSet.class, fetch = FetchType.LAZY) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetType.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetType.java index d8edd4dcc..fa5d57642 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetType.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetType.java @@ -38,7 +38,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType; @Index(name = "sp_idx_distribution_set_type_prim", columnList = "tenant,id") }, uniqueConstraints = { @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_dst_name"), @UniqueConstraint(columnNames = { "type_key", "tenant" }, name = "uk_dst_key") }) -public class JpaDistributionSetType extends JpaNamedEntity implements DistributionSetType { +public class JpaDistributionSetType extends AbstractJpaNamedEntity implements DistributionSetType { private static final long serialVersionUID = 1L; @OneToMany(targetEntity = DistributionSetTypeElement.class, cascade = { @@ -53,7 +53,7 @@ public class JpaDistributionSetType extends JpaNamedEntity implements Distributi private String colour; @Column(name = "deleted") - private boolean deleted = false; + private boolean deleted; public JpaDistributionSetType() { // default public constructor for JPA @@ -91,19 +91,11 @@ public class JpaDistributionSetType extends JpaNamedEntity implements Distributi colour = color; } - /** - * @return the deleted - */ @Override public boolean isDeleted() { return deleted; } - /** - * @param deleted - * the deleted to set - */ - @Override public void setDeleted(final boolean deleted) { this.deleted = deleted; } @@ -120,14 +112,6 @@ public class JpaDistributionSetType extends JpaNamedEntity implements Distributi .collect(Collectors.toSet()); } - /** - * Checks if the given {@link SoftwareModuleType} is in this - * {@link DistributionSetType}. - * - * @param softwareModuleType - * search for - * @return true if found - */ @Override public boolean containsModuleType(final SoftwareModuleType softwareModuleType) { for (final DistributionSetTypeElement distributionSetTypeElement : elements) { @@ -139,15 +123,6 @@ public class JpaDistributionSetType extends JpaNamedEntity implements Distributi return false; } - /** - * Checks if the given {@link SoftwareModuleType} is in this - * {@link DistributionSetType} and defined as - * {@link DistributionSetTypeElement#isMandatory()}. - * - * @param softwareModuleType - * search for - * @return true if found - */ @Override public boolean containsMandatoryModuleType(final SoftwareModuleType softwareModuleType) { return elements.stream().filter(element -> element.isMandatory()) @@ -155,15 +130,6 @@ public class JpaDistributionSetType extends JpaNamedEntity implements Distributi } - /** - * Checks if the given {@link SoftwareModuleType} is in this - * {@link DistributionSetType} and defined as - * {@link DistributionSetTypeElement#isMandatory()}. - * - * @param softwareModuleType - * search for by {@link SoftwareModuleType#getId()} - * @return true if found - */ @Override public boolean containsMandatoryModuleType(final Long softwareModuleTypeId) { return elements.stream().filter(element -> element.isMandatory()) @@ -171,15 +137,6 @@ public class JpaDistributionSetType extends JpaNamedEntity implements Distributi } - /** - * Checks if the given {@link SoftwareModuleType} is in this - * {@link DistributionSetType} and NOT defined as - * {@link DistributionSetTypeElement#isMandatory()}. - * - * @param softwareModuleType - * search for - * @return true if found - */ @Override public boolean containsOptionalModuleType(final SoftwareModuleType softwareModuleType) { return elements.stream().filter(element -> !element.isMandatory()) @@ -187,15 +144,6 @@ public class JpaDistributionSetType extends JpaNamedEntity implements Distributi } - /** - * Checks if the given {@link SoftwareModuleType} is in this - * {@link DistributionSetType} and NOT defined as - * {@link DistributionSetTypeElement#isMandatory()}. - * - * @param softwareModuleTypeId - * search by {@link SoftwareModuleType#getId()} - * @return true if found - */ @Override public boolean containsOptionalModuleType(final Long softwareModuleTypeId) { return elements.stream().filter(element -> !element.isMandatory()) @@ -203,27 +151,11 @@ public class JpaDistributionSetType extends JpaNamedEntity implements Distributi } - /** - * Compares the modules of this {@link DistributionSetType} and the given - * one. - * - * @param dsType - * to compare with - * @return true if the lists are identical. - */ @Override public boolean areModuleEntriesIdentical(final DistributionSetType dsType) { return new HashSet(((JpaDistributionSetType) dsType).elements).equals(elements); } - /** - * Adds {@link SoftwareModuleType} that is optional for the - * {@link DistributionSet}. - * - * @param smType - * to add - * @return updated instance - */ @Override public DistributionSetType addOptionalModuleType(final SoftwareModuleType smType) { elements.add(new DistributionSetTypeElement(this, (JpaSoftwareModuleType) smType, false)); @@ -231,14 +163,6 @@ public class JpaDistributionSetType extends JpaNamedEntity implements Distributi return this; } - /** - * Adds {@link SoftwareModuleType} that is mandatory for the - * {@link DistributionSet}. - * - * @param smType - * to add - * @return updated instance - */ @Override public DistributionSetType addMandatoryModuleType(final SoftwareModuleType smType) { elements.add(new DistributionSetTypeElement(this, (JpaSoftwareModuleType) smType, true)); @@ -246,13 +170,6 @@ public class JpaDistributionSetType extends JpaNamedEntity implements Distributi return this; } - /** - * Removes {@link SoftwareModuleType} from the list. - * - * @param smTypeId - * to remove - * @return updated instance - */ @Override public DistributionSetType removeModuleType(final Long smTypeId) { // we search by id (standard equals compares also revison) @@ -276,12 +193,6 @@ public class JpaDistributionSetType extends JpaNamedEntity implements Distributi this.key = key; } - /** - * @param distributionSet - * to check for completeness - * @return true if the all mandatory software module types are - * in the system. - */ @Override public boolean checkComplete(final DistributionSet distributionSet) { return distributionSet.getModules().stream().map(module -> module.getType()).collect(Collectors.toList()) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaExternalArtifact.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaExternalArtifact.java index ab55bf307..91f3df598 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaExternalArtifact.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaExternalArtifact.java @@ -33,7 +33,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule; @Table(name = "sp_external_artifact", indexes = { @Index(name = "sp_idx_external_artifact_prim", columnList = "id,tenant") }) @Entity -public class JpaExternalArtifact extends JpaArtifact implements ExternalArtifact { +public class JpaExternalArtifact extends AbstractJpaArtifact implements ExternalArtifact { private static final long serialVersionUID = 1L; @ManyToOne @@ -85,7 +85,6 @@ public class JpaExternalArtifact extends JpaArtifact implements ExternalArtifact return softwareModule; } - @Override public final void setSoftwareModule(final SoftwareModule softwareModule) { this.softwareModule = (JpaSoftwareModule) softwareModule; this.softwareModule.addArtifact(this); @@ -106,9 +105,8 @@ public class JpaExternalArtifact extends JpaArtifact implements ExternalArtifact return urlSuffix; } - @Override - public void setExternalArtifactProvider(final ExternalArtifactProvider externalArtifactProvider) { - this.externalArtifactProvider = (JpaExternalArtifactProvider) externalArtifactProvider; + public void setExternalArtifactProvider(final JpaExternalArtifactProvider externalArtifactProvider) { + this.externalArtifactProvider = externalArtifactProvider; } /** diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaExternalArtifactProvider.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaExternalArtifactProvider.java index 527a90510..06e572d57 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaExternalArtifactProvider.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaExternalArtifactProvider.java @@ -17,15 +17,13 @@ import org.eclipse.hawkbit.repository.model.ExternalArtifact; import org.eclipse.hawkbit.repository.model.ExternalArtifactProvider; /** - * External repositories for artifact storage. The SP server provides URLs for - * the targets to download from these external resources but does not access - * them itself. + * JPA implementation of {@link ExternalArtifactProvider}. * */ @Table(name = "sp_external_provider", indexes = { @Index(name = "sp_idx_external_provider_prim", columnList = "tenant,id") }) @Entity -public class JpaExternalArtifactProvider extends JpaNamedEntity implements ExternalArtifactProvider { +public class JpaExternalArtifactProvider extends AbstractJpaNamedEntity implements ExternalArtifactProvider { private static final long serialVersionUID = 1L; @Column(name = "base_url", length = 512, nullable = false) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaLocalArtifact.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaLocalArtifact.java index 7c6de6c0d..4348a3a7d 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaLocalArtifact.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaLocalArtifact.java @@ -26,18 +26,13 @@ import com.mongodb.gridfs.GridFS; import com.mongodb.gridfs.GridFSFile; /** - * Tenant specific locally stored artifact representation that is used by - * {@link SoftwareModule} . It contains all information that is provided by the - * user while all SP server generated information related to the artifact (hash, - * length) is stored directly with the binary itself. - * - * + * JPA implementation of {@link LocalArtifact}. * */ @Table(name = "sp_artifact", indexes = { @Index(name = "sp_idx_artifact_01", columnList = "tenant,software_module"), @Index(name = "sp_idx_artifact_prim", columnList = "tenant,id") }) @Entity -public class JpaLocalArtifact extends JpaArtifact implements LocalArtifact { +public class JpaLocalArtifact extends AbstractJpaArtifact implements LocalArtifact { private static final long serialVersionUID = 1L; @NotNull @@ -101,7 +96,6 @@ public class JpaLocalArtifact extends JpaArtifact implements LocalArtifact { return softwareModule; } - @Override public final void setSoftwareModule(final SoftwareModule softwareModule) { this.softwareModule = (JpaSoftwareModule) softwareModule; this.softwareModule.addArtifact(this); diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRollout.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRollout.java index 25e1a3a93..38dadc1c4 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRollout.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRollout.java @@ -34,14 +34,14 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; /** - * @author Michael Hirsch + * JPA implementation of a {@link Rollout}. * */ @Entity @Table(name = "sp_rollout", indexes = { @Index(name = "sp_idx_rollout_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_rollout")) -public class JpaRollout extends JpaNamedEntity implements Rollout { +public class JpaRollout extends AbstractJpaNamedEntity implements Rollout { private static final long serialVersionUID = 1L; @@ -60,7 +60,7 @@ public class JpaRollout extends JpaNamedEntity implements Rollout { private RolloutStatus status = RolloutStatus.CREATING; @Column(name = "last_check") - private long lastCheck = 0L; + private long lastCheck; @Column(name = "action_type", nullable = false) @Enumerated(EnumType.STRING) @@ -74,11 +74,11 @@ public class JpaRollout extends JpaNamedEntity implements Rollout { @Transient @CacheField(key = CacheKeys.ROLLOUT_GROUP_TOTAL) - private int rolloutGroupsTotal = 0; + private int rolloutGroupsTotal; @Transient @CacheField(key = CacheKeys.ROLLOUT_GROUP_CREATED) - private int rolloutGroupsCreated = 0; + private int rolloutGroupsCreated; @Transient private transient TotalTargetCountStatus totalTargetCountStatus; @@ -98,7 +98,6 @@ public class JpaRollout extends JpaNamedEntity implements Rollout { return rolloutGroups; } - @Override public void setRolloutGroups(final List rolloutGroups) { this.rolloutGroups = rolloutGroups; } @@ -118,17 +117,14 @@ public class JpaRollout extends JpaNamedEntity implements Rollout { return status; } - @Override public void setStatus(final RolloutStatus status) { this.status = status; } - @Override public long getLastCheck() { return lastCheck; } - @Override public void setLastCheck(final long lastCheck) { this.lastCheck = lastCheck; } @@ -158,7 +154,6 @@ public class JpaRollout extends JpaNamedEntity implements Rollout { return totalTargets; } - @Override public void setTotalTargets(final long totalTargets) { this.totalTargets = totalTargets; } @@ -168,7 +163,6 @@ public class JpaRollout extends JpaNamedEntity implements Rollout { return rolloutGroupsTotal; } - @Override public void setRolloutGroupsTotal(final int rolloutGroupsTotal) { this.rolloutGroupsTotal = rolloutGroupsTotal; } @@ -178,7 +172,6 @@ public class JpaRollout extends JpaNamedEntity implements Rollout { return rolloutGroupsCreated; } - @Override public void setRolloutGroupsCreated(final int rolloutGroupsCreated) { this.rolloutGroupsCreated = rolloutGroupsCreated; } @@ -191,7 +184,6 @@ public class JpaRollout extends JpaNamedEntity implements Rollout { return totalTargetCountStatus; } - @Override public void setTotalTargetCountStatus(final TotalTargetCountStatus totalTargetCountStatus) { this.totalTargetCountStatus = totalTargetCountStatus; } @@ -203,58 +195,4 @@ public class JpaRollout extends JpaNamedEntity implements Rollout { + ", getName()=" + getName() + ", getId()=" + getId() + "]"; } - /** - * - * State machine for rollout. - * - */ - public enum RolloutStatus { - - /** - * Rollouts is beeing created. - */ - CREATING, - - /** - * Rollout is ready to start. - */ - READY, - - /** - * Rollout is paused. - */ - PAUSED, - - /** - * Rollout is starting. - */ - STARTING, - - /** - * Rollout is stopped. - */ - STOPPED, - - /** - * Rollout is running. - */ - RUNNING, - - /** - * Rollout is finished. - */ - FINISHED, - - /** - * Rollout could not created due errors, might be database problem due - * asynchronous creating. - */ - ERROR_CREATING, - - /** - * Rollout could not started due errors, might be database problem due - * asynchronous starting. - */ - ERROR_STARTING; - } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRolloutGroup.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRolloutGroup.java index f167d89fd..ed2620ae6 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRolloutGroup.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRolloutGroup.java @@ -32,14 +32,12 @@ import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; /** * JPA entity definition of persisting a group of an rollout. * - * @author Michael Hirsch - * */ @Entity @Table(name = "sp_rolloutgroup", indexes = { @Index(name = "sp_idx_rolloutgroup_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = { "name", "rollout", "tenant" }, name = "uk_rolloutgroup")) -public class JpaRolloutGroup extends JpaNamedEntity implements RolloutGroup { +public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGroup { private static final long serialVersionUID = 1L; @@ -61,25 +59,25 @@ public class JpaRolloutGroup extends JpaNamedEntity implements RolloutGroup { private RolloutGroupSuccessCondition successCondition = RolloutGroupSuccessCondition.THRESHOLD; @Column(name = "success_condition_exp", length = 512, nullable = false) - private String successConditionExp = null; + private String successConditionExp; @Column(name = "success_action", nullable = false) private RolloutGroupSuccessAction successAction = RolloutGroupSuccessAction.NEXTGROUP; @Column(name = "success_action_exp", length = 512, nullable = false) - private String successActionExp = null; + private String successActionExp; @Column(name = "error_condition") - private RolloutGroupErrorCondition errorCondition = null; + private RolloutGroupErrorCondition errorCondition; @Column(name = "error_condition_exp", length = 512) - private String errorConditionExp = null; + private String errorConditionExp; @Column(name = "error_action") - private RolloutGroupErrorAction errorAction = null; + private RolloutGroupErrorAction errorAction; @Column(name = "error_action_exp", length = 512) - private String errorActionExp = null; + private String errorActionExp; @Column(name = "total_targets") private long totalTargets; @@ -239,271 +237,4 @@ public class JpaRolloutGroup extends JpaNamedEntity implements RolloutGroup { + ", getId()=" + getId() + "]"; } - /** - * Rollout goup state machine. - * - */ - public enum RolloutGroupStatus { - - /** - * Ready to start the group. - */ - READY, - - /** - * Group is scheduled and started sometime, e.g. trigger of group - * before. - */ - SCHEDULED, - - /** - * Group is finished. - */ - FINISHED, - - /** - * Group is finished and has errors. - */ - ERROR, - - /** - * Group is running. - */ - RUNNING; - } - - /** - * The condition to evaluate if an group is success state. - */ - public enum RolloutGroupSuccessCondition { - THRESHOLD("thresholdRolloutGroupSuccessCondition"); - - private final String beanName; - - private RolloutGroupSuccessCondition(final String beanName) { - this.beanName = beanName; - } - - /** - * @return the beanName - */ - public String getBeanName() { - return beanName; - } - } - - /** - * The condition to evaluate if an group is in error state. - */ - public enum RolloutGroupErrorCondition { - THRESHOLD("thresholdRolloutGroupErrorCondition"); - - private final String beanName; - - private RolloutGroupErrorCondition(final String beanName) { - this.beanName = beanName; - } - - /** - * @return the beanName - */ - public String getBeanName() { - return beanName; - } - } - - /** - * The actions executed when the {@link RolloutGroup#errorCondition} is hit. - */ - public enum RolloutGroupErrorAction { - PAUSE("pauseRolloutGroupAction"); - - private final String beanName; - - private RolloutGroupErrorAction(final String beanName) { - this.beanName = beanName; - } - - /** - * @return the beanName - */ - public String getBeanName() { - return beanName; - } - } - - /** - * The actions executed when the {@link RolloutGroup#successCondition} is - * hit. - */ - public enum RolloutGroupSuccessAction { - NEXTGROUP("startNextRolloutGroupAction"); - - private final String beanName; - - private RolloutGroupSuccessAction(final String beanName) { - this.beanName = beanName; - } - - /** - * @return the beanName - */ - public String getBeanName() { - return beanName; - } - } - - /** - * Object which holds all {@link RolloutGroup} conditions together which can - * easily built. - */ - public static class RolloutGroupConditions { - private RolloutGroupSuccessCondition successCondition = null; - private String successConditionExp = null; - private RolloutGroupSuccessAction successAction = null; - private String successActionExp = null; - private RolloutGroupErrorCondition errorCondition = null; - private String errorConditionExp = null; - private RolloutGroupErrorAction errorAction = null; - private String errorActionExp = null; - - public RolloutGroupSuccessCondition getSuccessCondition() { - return successCondition; - } - - public void setSuccessCondition(final RolloutGroupSuccessCondition finishCondition) { - successCondition = finishCondition; - } - - public String getSuccessConditionExp() { - return successConditionExp; - } - - public void setSuccessConditionExp(final String finishConditionExp) { - successConditionExp = finishConditionExp; - } - - public RolloutGroupSuccessAction getSuccessAction() { - return successAction; - } - - public void setSuccessAction(final RolloutGroupSuccessAction successAction) { - this.successAction = successAction; - } - - public String getSuccessActionExp() { - return successActionExp; - } - - public void setSuccessActionExp(final String successActionExp) { - this.successActionExp = successActionExp; - } - - public RolloutGroupErrorCondition getErrorCondition() { - return errorCondition; - } - - public void setErrorCondition(final RolloutGroupErrorCondition errorCondition) { - this.errorCondition = errorCondition; - } - - public String getErrorConditionExp() { - return errorConditionExp; - } - - public void setErrorConditionExp(final String errorConditionExp) { - this.errorConditionExp = errorConditionExp; - } - - public RolloutGroupErrorAction getErrorAction() { - return errorAction; - } - - public void setErrorAction(final RolloutGroupErrorAction errorAction) { - this.errorAction = errorAction; - } - - public String getErrorActionExp() { - return errorActionExp; - } - - public void setErrorActionExp(final String errorActionExp) { - this.errorActionExp = errorActionExp; - } - } - - /** - * Builder to build easily the {@link RolloutGroupConditions}. - * - */ - public static class RolloutGroupConditionBuilder { - private final RolloutGroupConditions conditions = new RolloutGroupConditions(); - - public RolloutGroupConditions build() { - return conditions; - } - - /** - * Sets the finish condition and expression on the builder. - * - * @param condition - * the finish condition - * @param expression - * the finish expression - * @return the builder itself - */ - public RolloutGroupConditionBuilder successCondition(final RolloutGroupSuccessCondition condition, - final String expression) { - conditions.setSuccessCondition(condition); - conditions.setSuccessConditionExp(expression); - return this; - } - - /** - * Sets the success action and expression on the builder. - * - * @param action - * the success action - * @param expression - * the error expression - * @return the builder itself - */ - public RolloutGroupConditionBuilder successAction(final RolloutGroupSuccessAction action, - final String expression) { - conditions.setSuccessAction(action); - conditions.setSuccessActionExp(expression); - return this; - } - - /** - * Sets the error condition and expression on the builder. - * - * @param condition - * the error condition - * @param expression - * the error expression - * @return the builder itself - */ - public RolloutGroupConditionBuilder errorCondition(final RolloutGroupErrorCondition condition, - final String expression) { - conditions.setErrorCondition(condition); - conditions.setErrorConditionExp(expression); - return this; - } - - /** - * Sets the error action and expression on the builder. - * - * @param action - * the error action - * @param expression - * the error expression - * @return the builder itself - */ - public RolloutGroupConditionBuilder errorAction(final RolloutGroupErrorAction action, final String expression) { - conditions.setErrorAction(action); - conditions.setErrorActionExp(expression); - return this; - } - } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModule.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModule.java index 306b6980b..6465e135a 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModule.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModule.java @@ -50,7 +50,7 @@ import org.eclipse.persistence.annotations.CascadeOnDelete; @Index(name = "sp_idx_base_sw_module_02", columnList = "tenant,deleted,module_type"), @Index(name = "sp_idx_base_sw_module_prim", columnList = "tenant,id") }) @NamedEntityGraph(name = "SoftwareModule.artifacts", attributeNodes = { @NamedAttributeNode("artifacts") }) -public class JpaSoftwareModule extends JpaNamedVersionedEntity implements SoftwareModule { +public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implements SoftwareModule { private static final long serialVersionUID = 1L; @ManyToOne @@ -61,7 +61,7 @@ public class JpaSoftwareModule extends JpaNamedVersionedEntity implements Softwa private final List assignedTo = new ArrayList<>(); @Column(name = "deleted") - private boolean deleted = false; + private boolean deleted; @Column(name = "vendor", nullable = true, length = 256) private String vendor; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModuleMetadata.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModuleMetadata.java index aba08f0ed..53ce08ca9 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModuleMetadata.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModuleMetadata.java @@ -28,7 +28,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; @IdClass(SwMetadataCompositeKey.class) @Entity @Table(name = "sp_sw_metadata") -public class JpaSoftwareModuleMetadata extends JpaMetaData implements SoftwareModuleMetadata { +public class JpaSoftwareModuleMetadata extends AbstractJpaMetaData implements SoftwareModuleMetadata { private static final long serialVersionUID = 1L; @Id diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModuleType.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModuleType.java index 9948a7cde..a943b08a4 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModuleType.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModuleType.java @@ -26,12 +26,16 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType; @Index(name = "sp_idx_software_module_type_prim", columnList = "tenant,id") }, uniqueConstraints = { @UniqueConstraint(columnNames = { "type_key", "tenant" }, name = "uk_smt_type_key"), @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_smt_name") }) -public class JpaSoftwareModuleType extends JpaNamedEntity implements SoftwareModuleType { +public class JpaSoftwareModuleType extends AbstractJpaNamedEntity implements SoftwareModuleType { private static final long serialVersionUID = 1L; @Column(name = "type_key", nullable = false, length = 64) private String key; + public void setMaxAssignments(final int maxAssignments) { + this.maxAssignments = maxAssignments; + } + @Column(name = "max_ds_assignments", nullable = false) private int maxAssignments; @@ -39,7 +43,7 @@ public class JpaSoftwareModuleType extends JpaNamedEntity implements SoftwareMod private String colour; @Column(name = "deleted") - private boolean deleted = false; + private boolean deleted; /** * Constructor. @@ -53,7 +57,8 @@ public class JpaSoftwareModuleType extends JpaNamedEntity implements SoftwareMod * @param maxAssignments * assignments to a DS */ - public JpaSoftwareModuleType(final String key, final String name, final String description, final int maxAssignments) { + public JpaSoftwareModuleType(final String key, final String name, final String description, + final int maxAssignments) { this(key, name, description, maxAssignments, null); } @@ -71,8 +76,8 @@ public class JpaSoftwareModuleType extends JpaNamedEntity implements SoftwareMod * @param colour * of the type. It will be null by default */ - public JpaSoftwareModuleType(final String key, final String name, final String description, final int maxAssignments, - final String colour) { + public JpaSoftwareModuleType(final String key, final String name, final String description, + final int maxAssignments, final String colour) { super(); this.key = key; this.maxAssignments = maxAssignments; @@ -122,4 +127,9 @@ public class JpaSoftwareModuleType extends JpaNamedEntity implements SoftwareMod public String toString() { return "SoftwareModuleType [key=" + key + ", getName()=" + getName() + ", getId()=" + getId() + "]"; } + + @Override + public void setKey(final String key) { + this.key = key; + } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java index 08a66a9b3..229ef1a42 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java @@ -73,7 +73,7 @@ import org.springframework.data.domain.Persistable; "controller_id", "tenant" }, name = "uk_tenant_controller_id")) @NamedEntityGraph(name = "Target.detail", attributeNodes = { @NamedAttributeNode("tags"), @NamedAttributeNode(value = "assignedDistributionSet"), @NamedAttributeNode(value = "targetInfo") }) -public class JpaTarget extends JpaNamedEntity implements Persistable, Target { +public class JpaTarget extends AbstractJpaNamedEntity implements Persistable, Target { private static final long serialVersionUID = 1L; @Column(name = "controller_id", length = 64) @@ -82,7 +82,7 @@ public class JpaTarget extends JpaNamedEntity implements Persistable, Targ private String controllerId; @Transient - private boolean entityNew = false; + private boolean entityNew; @ManyToMany(targetEntity = JpaTargetTag.class) @JoinTable(name = "sp_target_target_tag", joinColumns = { @@ -103,14 +103,14 @@ public class JpaTarget extends JpaNamedEntity implements Persistable, Targ @CascadeOnDelete @OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, targetEntity = JpaTargetInfo.class) @PrimaryKeyJoinColumn - private JpaTargetInfo targetInfo = null; + private JpaTargetInfo targetInfo; /** * the security token of the target which allows if enabled to authenticate * with this security token. */ @Column(name = "sec_token", insertable = true, updatable = true, nullable = false, length = 128) - private String securityToken = null; + private String securityToken; @CascadeOnDelete @OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE, CascadeType.PERSIST }) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetFilterQuery.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetFilterQuery.java index 1ad1b69b8..55aaec0fe 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetFilterQuery.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetFilterQuery.java @@ -24,7 +24,7 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery; @Table(name = "sp_target_filter_query", indexes = { @Index(name = "sp_idx_target_filter_query_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_tenant_custom_filter_name")) -public class JpaTargetFilterQuery extends JpaTenantAwareBaseEntity implements TargetFilterQuery { +public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity implements TargetFilterQuery { private static final long serialVersionUID = 7493966984413479089L; @Column(name = "name", length = 64) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetInfo.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetInfo.java index 7b7b3e2e4..80e3cd563 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetInfo.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetInfo.java @@ -38,6 +38,7 @@ import javax.persistence.Table; import javax.persistence.Transient; import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.PollStatus; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetInfo; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; @@ -71,7 +72,7 @@ public class JpaTargetInfo implements Persistable, TargetInfo { private Long targetId; @Transient - private boolean entityNew = false; + private boolean entityNew; @CascadeOnDelete @OneToOne(cascade = { CascadeType.MERGE, @@ -81,10 +82,10 @@ public class JpaTargetInfo implements Persistable, TargetInfo { private JpaTarget target; @Column(name = "address", length = 512) - private String address = null; + private String address; @Column(name = "last_target_query") - private Long lastTargetQuery = null; + private Long lastTargetQuery; @Column(name = "install_date") private Long installationDate; @@ -216,6 +217,7 @@ public class JpaTargetInfo implements Persistable, TargetInfo { return controllerAttributes; } + @Override public boolean isRequestControllerAttributes() { return requestControllerAttributes; } @@ -275,63 +277,6 @@ public class JpaTargetInfo implements Persistable, TargetInfo { }); } - /** - * The poll time object which holds all the necessary information around the - * target poll time, e.g. the last poll time, the next poll time and the - * overdue poll time. - * - */ - public static final class PollStatus { - private final LocalDateTime lastPollDate; - private final LocalDateTime nextPollDate; - private final LocalDateTime overdueDate; - private final LocalDateTime currentDate; - - private PollStatus(final LocalDateTime lastPollDate, final LocalDateTime nextPollDate, - final LocalDateTime overdueDate, final LocalDateTime currentDate) { - this.lastPollDate = lastPollDate; - this.nextPollDate = nextPollDate; - this.overdueDate = overdueDate; - this.currentDate = currentDate; - } - - /** - * calculates if the target poll time is overdue and the target has not - * been polled in the configured poll time interval. - * - * @return {@code true} if the current time is after the poll time - * overdue date otherwise {@code false}. - */ - public boolean isOverdue() { - return currentDate.isAfter(overdueDate); - } - - /** - * @return the lastPollDate - */ - public LocalDateTime getLastPollDate() { - return lastPollDate; - } - - public LocalDateTime getNextPollDate() { - return nextPollDate; - } - - public LocalDateTime getOverdueDate() { - return overdueDate; - } - - public LocalDateTime getCurrentDate() { - return currentDate; - } - - @Override - public String toString() { - return "PollTime [lastPollDate=" + lastPollDate + ", nextPollDate=" + nextPollDate + ", overdueDate=" - + overdueDate + ", currentDate=" + currentDate + "]"; - } - } - @Override public int hashCode() { final int prime = 31; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetTag.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetTag.java index 0d8f3a5d1..800fcc15e 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetTag.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetTag.java @@ -29,7 +29,7 @@ import org.eclipse.hawkbit.repository.model.TargetTag; @Table(name = "sp_target_tag", indexes = { @Index(name = "sp_idx_target_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_targ_tag")) -public class JpaTargetTag extends JpaTag implements TargetTag { +public class JpaTargetTag extends AbstractJpaTag implements TargetTag { private static final long serialVersionUID = 1L; @ManyToMany(mappedBy = "tags", targetEntity = JpaTarget.class, fetch = FetchType.LAZY) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantConfiguration.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantConfiguration.java index 2d1342b74..2b28aa55f 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantConfiguration.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantConfiguration.java @@ -23,7 +23,7 @@ import org.eclipse.hawkbit.repository.model.TenantConfiguration; @Entity @Table(name = "sp_tenant_configuration", uniqueConstraints = @UniqueConstraint(columnNames = { "conf_key", "tenant" }, name = "uk_tenant_key")) -public class JpaTenantConfiguration extends JpaTenantAwareBaseEntity implements TenantConfiguration { +public class JpaTenantConfiguration extends AbstractJpaTenantAwareBaseEntity implements TenantConfiguration { private static final long serialVersionUID = 1L; @Column(name = "conf_key", length = 128) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantMetaData.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantMetaData.java index 7cb31b3c4..32b6b1082 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantMetaData.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantMetaData.java @@ -36,7 +36,7 @@ import org.eclipse.hawkbit.repository.model.TenantMetaData; @Index(name = "sp_idx_tenant_prim", columnList = "tenant,id") }, uniqueConstraints = { @UniqueConstraint(columnNames = { "tenant" }, name = "uk_tenantmd_tenant") }) @Entity -public class JpaTenantMetaData extends JpaBaseEntity implements TenantMetaData { +public class JpaTenantMetaData extends AbstractJpaBaseEntity implements TenantMetaData { private static final long serialVersionUID = 1L; @Column(name = "tenant", nullable = false, length = 40) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/RolloutTargetGroupId.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/RolloutTargetGroupId.java index cc1c9cbe7..b4001d9dc 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/RolloutTargetGroupId.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/model/RolloutTargetGroupId.java @@ -50,4 +50,4 @@ public class RolloutTargetGroupId implements Serializable { public Long getTarget() { return target; } -} \ No newline at end of file +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java index 51b57bb17..74f921642 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java @@ -9,13 +9,21 @@ package org.eclipse.hawkbit.repository.model; import java.util.List; +import java.util.concurrent.TimeUnit; +/** + * Operations to be executed by the target. Usually a software update. Other + * supported actions are the cancellation of a running update action or a + * refresh request for target attributes. + * + */ public interface Action extends TenantAwareBaseEntity { /** - * indicating that target action has no force time {@link #hasForcedTime()}. + * indicating that target action has no force time which is only needed in + * case of {@link ActionType#TIMEFORCED}. */ - public static final long NO_FORCE_TIME = 0L; + long NO_FORCE_TIME = 0L; /** * @return the distributionSet @@ -29,74 +37,117 @@ public interface Action extends TenantAwareBaseEntity { void setDistributionSet(DistributionSet distributionSet); /** - * @return true when action is in state {@link Status#CANCELING} or - * {@link Status#CANCELED}, false otherwise + * @return true when action is in state + * {@link Status#CANCELING} or {@link Status#CANCELED}, false + * otherwise */ - boolean isCancelingOrCanceled(); - - void setActive(boolean active); - - Status getStatus(); - - void setStatus(Status status); - - int getDownloadProgressPercent(); - - void setDownloadProgressPercent(int downloadProgressPercent); - - boolean isActive(); - - void setActionType(ActionType actionType); + default boolean isCancelingOrCanceled() { + return Status.CANCELING.equals(getStatus()) || Status.CANCELED.equals(getStatus()); + } /** - * @return the actionType + * @return current {@link Status#DOWNLOAD} progress if known by the update + * server. + */ + int getDownloadProgressPercent(); + + /** + * @return current {@link Status} of the {@link Action}. + */ + Status getStatus(); + + /** + * @param status + * of the {@link Action} + */ + void setStatus(Status status); + + /** + * @return true if {@link Action} is still running. + */ + boolean isActive(); + + /** + * @return the {@link ActionType} */ ActionType getActionType(); + /** + * @return list of {@link ActionStatus} entries. + */ List getActionStatus(); + /** + * @param target + * of this {@link Action} + */ void setTarget(Target target); + /** + * @return {@link Target} of this {@link Action}. + */ Target getTarget(); + /** + * @return time in {@link TimeUnit#MILLISECONDS} after which + * {@link #isForced()} switches to true in case of + * {@link ActionType#TIMEFORCED}. + */ long getForcedTime(); - void setForcedTime(long forcedTime); - + /** + * @return rolloutGroup related to this {@link Action}. + */ RolloutGroup getRolloutGroup(); - void setRolloutGroup(RolloutGroup rolloutGroup); - + /** + * @return rollout related to this {@link Action}. + */ Rollout getRollout(); - void setRollout(Rollout rollout); - /** - * checks if the {@link #forcedTime} is hit by the given + * checks if the {@link #getForcedTime()} is hit by the given * {@code hitTimeMillis}, by means if the given milliseconds are greater * than the forcedTime. * * @param hitTimeMillis * the milliseconds, mostly the * {@link System#currentTimeMillis()} - * @return {@code true} if this {@link #type} is in + * @return {@code true} if this {@link #getActionType()} is in * {@link ActionType#TIMEFORCED} and the given {@code hitTimeMillis} - * is greater than the {@link #forcedTime} otherwise {@code false} + * is greater than the {@link #getForcedTime()} otherwise + * {@code false} */ - boolean isHitAutoForceTime(long hitTimeMillis); + default boolean isHitAutoForceTime(final long hitTimeMillis) { + if (ActionType.TIMEFORCED.equals(getActionType())) { + return hitTimeMillis >= getForcedTime(); + } + return false; + } /** - * @return {@code true} if either the {@link #type} is + * @return {@code true} if either the {@link #getActionType()} is * {@link ActionType#FORCED} or {@link ActionType#TIMEFORCED} but - * then if the {@link #forcedTime} has been exceeded otherwise + * then if the {@link #getForcedTime()} has been exceeded otherwise * always {@code false} */ - boolean isForce(); + default boolean isForce() { + switch (getActionType()) { + case FORCED: + return true; + case TIMEFORCED: + return isHitAutoForceTime(System.currentTimeMillis()); + default: + return false; + } + } /** * @return true when action is forced, false otherwise */ - boolean isForced(); + default boolean isForced() { + return ActionType.FORCED.equals(getActionType()); + } /** * Action status as reported by the controller. @@ -159,7 +210,21 @@ public interface Action extends TenantAwareBaseEntity { * */ public enum ActionType { - FORCED, SOFT, TIMEFORCED; - } + /** + * Forced action execution. Target is advised to executed immediately. + */ + FORCED, -} \ No newline at end of file + /** + * Soft action execution. Target is advised to execute when it fits. + */ + SOFT, + + /** + * {@link #SOFT} action execution until + * {@link Action#isHitAutoForceTime(long)} is reached, {@link #FORCED} + * after that. + */ + TIMEFORCED; + } +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionStatus.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionStatus.java index 05f6966d8..f3ca66887 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionStatus.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionStatus.java @@ -9,13 +9,30 @@ package org.eclipse.hawkbit.repository.model; import java.util.List; +import java.util.concurrent.TimeUnit; import org.eclipse.hawkbit.repository.model.Action.Status; +/** + * Status information of an {@link Action} which can be provided by the + * {@link Target} or is added by the update server itself. This can be the start + * of the {@link Action} life cycle, the end and update notifications in + * between. + * + */ public interface ActionStatus extends TenantAwareBaseEntity { + /** + * @return time in {@link TimeUnit#MILLISECONDS} when the status was + * reported. + */ Long getOccurredAt(); + /** + * @param occurredAt + * time in {@link TimeUnit#MILLISECONDS} when the status was + * reported. + */ void setOccurredAt(Long occurredAt); /** @@ -26,14 +43,36 @@ public interface ActionStatus extends TenantAwareBaseEntity { */ void addMessage(String message); + /** + * @return list of message entries that can be added to the + * {@link ActionStatus}. + */ List getMessages(); + /** + * @return {@link Action} this {@link ActionStatus} belongs to. + */ Action getAction(); + /** + * @param action + * this {@link ActionStatus} belongs to. + */ void setAction(Action action); + /** + * @return the {@link Status} of this {@link ActionStatus}. Caused + * potentially a transition change of the {@link #getAction()} if + * different from the previous {@link ActionStatus#getStatus()}. + */ Status getStatus(); + /** + * @param status + * of this {@link ActionStatus}. May cause a transition change of + * the {@link #getAction()} if different from the previous + * {@link ActionStatus#getStatus()}. + */ void setStatus(Status status); -} \ No newline at end of file +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionWithStatusCount.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionWithStatusCount.java index 4b81320e8..6bc1efa56 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionWithStatusCount.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionWithStatusCount.java @@ -20,8 +20,6 @@ import org.eclipse.hawkbit.repository.model.Action.Status; // TODO: create interface public class ActionWithStatusCount { private final Long actionStatusCount; - private final Long actionId; - private final ActionType actionType; private final boolean actionActive; private final long actionForceTime; private final Status actionStatus; @@ -67,8 +65,6 @@ public class ActionWithStatusCount { final long forcedTime, final Status status, final Long actionCreatedAt, final Long actionLastModifiedAt, final Long dsId, final String dsName, final String dsVersion, final Long actionStatusCount, final String rolloutName) { - this.actionId = actionId; - this.actionType = actionType; actionActive = active; actionForceTime = forcedTime; actionStatus = status; @@ -92,26 +88,6 @@ public class ActionWithStatusCount { return action; } - public Long getActionId() { - return actionId; - } - - public ActionType getActionType() { - return actionType; - } - - public boolean isActionActive() { - return actionActive; - } - - public long getActionForceTime() { - return actionForceTime; - } - - public Status getActionStatus() { - return actionStatus; - } - public Long getActionCreatedAt() { return actionCreatedAt; } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Artifact.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Artifact.java index a4db06d25..95689a9d9 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Artifact.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Artifact.java @@ -8,16 +8,35 @@ */ package org.eclipse.hawkbit.repository.model; +import com.google.common.io.BaseEncoding; + +/** + * Binaries for a {@link SoftwareModule} Note: the decision which artifacts have + * to be downloaded are done on the device side. e.g. Full Package, Signatures, + * binary deltas + * + */ public interface Artifact extends TenantAwareBaseEntity { + /** + * @return {@link SoftwareModule} this {@link Artifact} belongs to. + */ SoftwareModule getSoftwareModule(); - void setSoftwareModule(SoftwareModule softwareModule); - + /** + * @return MD5 hash of the artifact. + */ String getMd5Hash(); + /** + * @return SHA-1 hash of the artifact in {@link BaseEncoding#base16()} + * format. + */ String getSha1Hash(); + /** + * @return size of the artifact in bytes. + */ Long getSize(); } \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/BaseEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/BaseEntity.java index 0b8a8c5ee..f23b226c6 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/BaseEntity.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/BaseEntity.java @@ -9,19 +9,41 @@ package org.eclipse.hawkbit.repository.model; import java.io.Serializable; +import java.util.concurrent.TimeUnit; import org.springframework.hateoas.Identifiable; +/** + * Core information of all entities. + * + */ public interface BaseEntity extends Serializable, Identifiable { + /** + * @return time in {@link TimeUnit#MILLISECONDS} when the {@link BaseEntity} + * was created. + */ Long getCreatedAt(); + /** + * @return user that created the {@link BaseEntity}. + */ String getCreatedBy(); + /** + * @return time in {@link TimeUnit#MILLISECONDS} when the {@link BaseEntity} + * was last time changed. + */ Long getLastModifiedAt(); + /** + * @return user that updated the {@link BaseEntity} last. + */ String getLastModifiedBy(); + /** + * @return version of the {@link BaseEntity}. + */ long getOptLockRevision(); } \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java index 41b1e5f5d..1c23cec27 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java @@ -11,27 +11,63 @@ package org.eclipse.hawkbit.repository.model; import java.util.List; import java.util.Set; +import org.eclipse.hawkbit.repository.DistributionSetManagement; + +/** + * A {@link DistributionSet} defines a meta package that combines a set of + * {@link SoftwareModule}s which have to be or are provisioned to a + * {@link Target}. + * + *

+ * A {@link Target} has exactly one target {@link DistributionSet} assigned. + *

+ * + */ public interface DistributionSet extends NamedVersionedEntity { + /** + * @return {@link Set} of assigned {@link DistributionSetTag}s. + */ Set getTags(); + /** + * @return true if the set is deleted and only kept for history + * purposes. + */ boolean isDeleted(); /** - * @return immutable list of meta data elements. + * @return immutable {@link List} of {@link DistributionSetMetadata} + * elements. See {@link DistributionSetManagement} to alter. */ List getMetadata(); - List getActions(); - + /** + * @return true if {@link DistributionSet} contains a mandatory + * migration step, i.e. unfinished {@link Action}s will kept active + * and not automatically canceled if overridden by a newer update. + */ boolean isRequiredMigrationStep(); + /** + * @param deleted + * to true if {@link DistributionSet} is no longer + * be usage but kept for history purposes. + * @return updated {@link DistributionSet} + */ DistributionSet setDeleted(boolean deleted); + /** + * @param isRequiredMigrationStep + * to true if {@link DistributionSet} contains a + * mandatory migration step, i.e. unfinished {@link Action}s will + * kept active and not automatically canceled if overridden by a + * newer update. + * + * @return updated {@link DistributionSet} + */ DistributionSet setRequiredMigrationStep(boolean isRequiredMigrationStep); - DistributionSet setTags(Set tags); - /** * @return the assignedTargets */ @@ -48,6 +84,9 @@ public interface DistributionSet extends NamedVersionedEntity { */ Set getModules(); + /** + * @return {@link DistributionSetIdName} view. + */ DistributionSetIdName getDistributionSetIdName(); /** @@ -77,10 +116,22 @@ public interface DistributionSet extends NamedVersionedEntity { */ SoftwareModule findFirstModuleByType(SoftwareModuleType type); + /** + * @return type of the {@link DistributionSet}. + */ DistributionSetType getType(); + /** + * @param type + * of the {@link DistributionSet}. + */ void setType(DistributionSetType type); + /** + * @return true if all defined + * {@link DistributionSetType#getMandatoryModuleTypes()} of + * {@link #getType()} are present in this {@link DistributionSet}. + */ boolean isComplete(); } \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetMetadata.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetMetadata.java index 187b04e81..dfa9b9716 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetMetadata.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetMetadata.java @@ -8,10 +8,15 @@ */ package org.eclipse.hawkbit.repository.model; +/** + * {@link MetaData} of a {@link DistributionSet}. + * + */ public interface DistributionSetMetadata extends MetaData { - void setDistributionSet(DistributionSet distributionSet); - + /** + * @return {@link DistributionSet} of this {@link MetaData} entry. + */ DistributionSet getDistributionSet(); } \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTag.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTag.java index cd5ded232..31f909348 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTag.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTag.java @@ -10,8 +10,16 @@ package org.eclipse.hawkbit.repository.model; import java.util.List; +/** + * {@link Tag} of a {@link DistributionSet}. + * + */ public interface DistributionSetTag extends Tag { + /** + * @return {@link List} of {@link DistributionSet}s this {@link Tag} is + * assigned to. + */ List getAssignedToDistributionSet(); } \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java index f540428a9..07c63ee89 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java @@ -12,21 +12,33 @@ import java.util.Set; import org.eclipse.hawkbit.repository.jpa.model.DistributionSetTypeElement; +/** + * A {@link DistributionSetType} is an abstract definition for + * {@link DistributionSet} that defines what {@link SoftwareModule}s can be + * added (optional) to {@link DistributionSet} of that type or have to added + * (mandatory) in order to be considered complete. Only complete DS can be + * assigned to a {@link Target}. + * + */ public interface DistributionSetType extends NamedEntity { /** - * @return the deleted + * @return true if the type is deleted and only kept for + * history purposes. */ boolean isDeleted(); /** - * @param deleted - * the deleted to set + * @return set of {@link SoftwareModuleType}s that need to be in a + * {@link DistributionSet} of this type to be + * {@link DistributionSet#isComplete()}. */ - void setDeleted(boolean deleted); - Set getMandatoryModuleTypes(); + /** + * @return set of optional {@link SoftwareModuleType}s that can be in a + * {@link DistributionSet} of this type. + */ Set getOptionalModuleTypes(); /** @@ -55,7 +67,7 @@ public interface DistributionSetType extends NamedEntity { * {@link DistributionSetType} and defined as * {@link DistributionSetTypeElement#isMandatory()}. * - * @param softwareModuleType + * @param softwareModuleTypeId * search for by {@link SoftwareModuleType#getId()} * @return true if found */ @@ -122,8 +134,15 @@ public interface DistributionSetType extends NamedEntity { */ DistributionSetType removeModuleType(Long smTypeId); + /** + * @return business key of this {@link DistributionSetType}. + */ String getKey(); + /** + * @param key + * of this {@link DistributionSetType}. + */ void setKey(String key); /** @@ -134,8 +153,15 @@ public interface DistributionSetType extends NamedEntity { */ boolean checkComplete(DistributionSet distributionSet); + /** + * @return get color code to by used in management UI views. + */ String getColour(); + /** + * @param colour + * code to by used in management UI views. + */ void setColour(final String colour); } \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifact.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifact.java index daf0d1ae5..4ff3ab5a8 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifact.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifact.java @@ -8,16 +8,30 @@ */ package org.eclipse.hawkbit.repository.model; +import java.net.URL; + +/** + * External artifact representation with all the necessary information to + * generate an artifact {@link URL} at runtime. + * + */ public interface ExternalArtifact extends Artifact { + /** + * @return {@link ExternalArtifactProvider} of this {@link Artifact}. + */ ExternalArtifactProvider getExternalArtifactProvider(); + /** + * @return generated download {@link URL}. + */ String getUrl(); + /** + * @return suffix for {@link URL} generation. + */ String getUrlSuffix(); - void setExternalArtifactProvider(ExternalArtifactProvider externalArtifactProvider); - /** * @param urlSuffix * the urlSuffix to set diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifactProvider.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifactProvider.java index bb9f2fbea..139327096 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifactProvider.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifactProvider.java @@ -8,14 +8,34 @@ */ package org.eclipse.hawkbit.repository.model; +/** + * External repositories for artifact storage. The update server provides URLs + * for the targets to download from these external resources but does not access + * them itself. + * + */ public interface ExternalArtifactProvider extends NamedEntity { + /** + * @return prefix for url generation + */ String getBasePath(); + /** + * @return default for {@link ExternalArtifact#getUrlSuffix()}. + */ String getDefaultSuffix(); + /** + * @param basePath + * prefix for url generation + */ void setBasePath(String basePath); + /** + * @param defaultSuffix + * for {@link ExternalArtifact#getUrlSuffix()}. + */ void setDefaultSuffix(String defaultSuffix); -} \ No newline at end of file +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/LocalArtifact.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/LocalArtifact.java index 0f3a22c41..9aeb791c4 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/LocalArtifact.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/LocalArtifact.java @@ -8,8 +8,21 @@ */ package org.eclipse.hawkbit.repository.model; +import org.eclipse.hawkbit.artifact.repository.ArtifactRepository; + +/** + * Tenant specific locally stored artifact representation that is used by + * {@link SoftwareModule}s . It contains all information that is provided by the + * user while all update server generated information related to the artifact + * (hash, length) is stored directly with the binary itself in the + * {@link ArtifactRepository}. + * + */ public interface LocalArtifact extends Artifact { + /** + * @return the filename that was provided during upload. + */ String getFilename(); -} \ No newline at end of file +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/MetaData.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/MetaData.java index 8d6e6eed6..4f3397b23 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/MetaData.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/MetaData.java @@ -10,14 +10,30 @@ package org.eclipse.hawkbit.repository.model; import java.io.Serializable; +/** + * Meta data for entities, a (key/value) store. + * + */ public interface MetaData extends Serializable { + /** + * @return the key + */ String getKey(); + /** + * @param key + */ void setKey(String key); + /** + * @return the value + */ String getValue(); + /** + * @param value + */ void setValue(String value); } \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedEntity.java index 1cc84bf8f..4d3f3e419 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedEntity.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedEntity.java @@ -8,14 +8,32 @@ */ package org.eclipse.hawkbit.repository.model; +/** + * Entities that have a name and description. + * + */ public interface NamedEntity extends TenantAwareBaseEntity { + /** + * @return the description of the entity. + */ String getDescription(); + /** + * @return the name of the entity. + */ String getName(); + /** + * @param description + * of the entity. + */ void setDescription(String description); + /** + * @param name + * of the entity. + */ void setName(String name); -} \ No newline at end of file +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedVersionedEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedVersionedEntity.java index 710980f13..de6cded12 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedVersionedEntity.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedVersionedEntity.java @@ -8,10 +8,21 @@ */ package org.eclipse.hawkbit.repository.model; +/** + * Entities that have a name and a description. + * + */ public interface NamedVersionedEntity extends NamedEntity { + /** + * @return the version of entity. + */ String getVersion(); + /** + * @param version + * of the entity. + */ void setVersion(String version); } \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java index bf696d2fd..f87b1067f 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java @@ -10,31 +10,53 @@ package org.eclipse.hawkbit.repository.model; import java.util.List; -import org.eclipse.hawkbit.repository.jpa.model.JpaRollout.RolloutStatus; import org.eclipse.hawkbit.repository.model.Action.ActionType; +/** + * Software update operations in large scale IoT scenarios with hundred of + * thousands of devices require special handling. + * + * That includes secure handling of large volumes of devices at rollout creation + * time. Monitoring of the rollout progress. Emergency rollout shutdown in case + * of problems on to many devices and reporting capabilities for a complete + * understanding of the rollout progress at each point in time. + * + */ public interface Rollout extends NamedEntity { + /** + * @return {@link DistributionSet} that is rolled out + */ DistributionSet getDistributionSet(); + /** + * @param distributionSet + * that is rolled out + */ void setDistributionSet(DistributionSet distributionSet); + /** + * @return list of deployment groups of the rollout. + */ List getRolloutGroups(); - void setRolloutGroups(List rolloutGroups); - + /** + * @return rsql query that identifies the targets that are part of this + * rollout. + */ String getTargetFilterQuery(); + /** + * @param targetFilterQuery + * that identifies the targets that are part of this rollout. + */ void setTargetFilterQuery(String targetFilterQuery); + /** + * @return status of the rollout + */ RolloutStatus getStatus(); - void setStatus(RolloutStatus status); - - long getLastCheck(); - - void setLastCheck(long lastCheck); - ActionType getActionType(); void setActionType(ActionType actionType); @@ -45,18 +67,65 @@ public interface Rollout extends NamedEntity { long getTotalTargets(); - void setTotalTargets(long totalTargets); - int getRolloutGroupsTotal(); - void setRolloutGroupsTotal(int rolloutGroupsTotal); - int getRolloutGroupsCreated(); - void setRolloutGroupsCreated(int rolloutGroupsCreated); - TotalTargetCountStatus getTotalTargetCountStatus(); - void setTotalTargetCountStatus(TotalTargetCountStatus totalTargetCountStatus); + /** + * + * State machine for rollout. + * + */ + public enum RolloutStatus { + + /** + * Rollouts is being created. + */ + CREATING, + + /** + * Rollout is ready to start. + */ + READY, + + /** + * Rollout is paused. + */ + PAUSED, + + /** + * Rollout is starting. + */ + STARTING, + + /** + * Rollout is stopped. + */ + STOPPED, + + /** + * Rollout is running. + */ + RUNNING, + + /** + * Rollout is finished. + */ + FINISHED, + + /** + * Rollout could not be created due to errors, might be a database + * problem during asynchronous creating. + */ + ERROR_CREATING, + + /** + * Rollout could not be started due to errors, might be database problem + * during asynchronous starting. + */ + ERROR_STARTING; + } } \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java index 647278b78..cd65c4d2f 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java @@ -8,12 +8,6 @@ */ package org.eclipse.hawkbit.repository.model; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupErrorAction; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupErrorCondition; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupStatus; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupSuccessAction; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupSuccessCondition; - public interface RolloutGroup extends NamedEntity { Rollout getRollout(); @@ -75,4 +69,117 @@ public interface RolloutGroup extends NamedEntity { */ void setTotalTargetCountStatus(TotalTargetCountStatus totalTargetCountStatus); + /** + * Rollout goup state machine. + * + */ + public enum RolloutGroupStatus { + + /** + * Ready to start the group. + */ + READY, + + /** + * Group is scheduled and started sometime, e.g. trigger of group + * before. + */ + SCHEDULED, + + /** + * Group is finished. + */ + FINISHED, + + /** + * Group is finished and has errors. + */ + ERROR, + + /** + * Group is running. + */ + RUNNING; + } + + /** + * The condition to evaluate if an group is success state. + */ + public enum RolloutGroupSuccessCondition { + THRESHOLD("thresholdRolloutGroupSuccessCondition"); + + private final String beanName; + + private RolloutGroupSuccessCondition(final String beanName) { + this.beanName = beanName; + } + + /** + * @return the beanName + */ + public String getBeanName() { + return beanName; + } + } + + /** + * The condition to evaluate if an group is in error state. + */ + public enum RolloutGroupErrorCondition { + THRESHOLD("thresholdRolloutGroupErrorCondition"); + + private final String beanName; + + private RolloutGroupErrorCondition(final String beanName) { + this.beanName = beanName; + } + + /** + * @return the beanName + */ + public String getBeanName() { + return beanName; + } + } + + /** + * The actions executed when the {@link RolloutGroup#errorCondition} is hit. + */ + public enum RolloutGroupErrorAction { + PAUSE("pauseRolloutGroupAction"); + + private final String beanName; + + private RolloutGroupErrorAction(final String beanName) { + this.beanName = beanName; + } + + /** + * @return the beanName + */ + public String getBeanName() { + return beanName; + } + } + + /** + * The actions executed when the {@link RolloutGroup#successCondition} is + * hit. + */ + public enum RolloutGroupSuccessAction { + NEXTGROUP("startNextRolloutGroupAction"); + + private final String beanName; + + private RolloutGroupSuccessAction(final String beanName) { + this.beanName = beanName; + } + + /** + * @return the beanName + */ + public String getBeanName() { + return beanName; + } + } } \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java index 534d45fa3..24417d3f8 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java @@ -12,8 +12,12 @@ public interface SoftwareModuleType extends NamedEntity { String getKey(); + void setKey(String key); + int getMaxAssignments(); + void setMaxAssignments(int maxAssignments); + boolean isDeleted(); void setDeleted(boolean deleted); diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetInfo.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetInfo.java index 657b95c41..e918d7376 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetInfo.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetInfo.java @@ -12,8 +12,6 @@ import java.io.Serializable; import java.net.URI; import java.util.Map; -import org.eclipse.hawkbit.repository.jpa.model.JpaTargetInfo.PollStatus; - public interface TargetInfo extends Serializable { Long getId(); @@ -43,4 +41,6 @@ public interface TargetInfo extends Serializable { */ PollStatus getPollStatus(); + boolean isRequestControllerAttributes(); + } \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/PauseRolloutGroupAction.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/PauseRolloutGroupAction.java index d80fc5a7b..43232ef2d 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/PauseRolloutGroupAction.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/PauseRolloutGroupAction.java @@ -11,9 +11,9 @@ package org.eclipse.hawkbit.rollout.condition; import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.jpa.RolloutGroupRepository; import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupStatus; import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.RolloutGroup; +import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus; import org.eclipse.hawkbit.security.SystemSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/StartNextGroupRolloutGroupSuccessAction.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/StartNextGroupRolloutGroupSuccessAction.java index 223f20125..0f1d1376f 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/StartNextGroupRolloutGroupSuccessAction.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/rollout/condition/StartNextGroupRolloutGroupSuccessAction.java @@ -13,10 +13,10 @@ import java.util.List; import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.jpa.RolloutGroupRepository; import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupStatus; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.RolloutGroup; +import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus; import org.eclipse.hawkbit.security.SystemSecurityContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java index f0e2d382c..5992ed1fc 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java @@ -24,8 +24,8 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.jpa.ActionRepository; +import org.eclipse.hawkbit.repository.jpa.model.AbstractJpaArtifact; import org.eclipse.hawkbit.repository.jpa.model.JpaActionStatus; -import org.eclipse.hawkbit.repository.jpa.model.JpaArtifact; import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet; import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag; import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType; @@ -76,7 +76,7 @@ public class TestDataUtil { // load also lazy stuff set = distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()); - assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(1); + assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true)).hasSize(1); return set; } @@ -232,12 +232,12 @@ public class TestDataUtil { return generateDistributionSet(suffix, "v1.0", softwareManagement, distributionSetManagement, false); } - public static List generateArtifacts(final ArtifactManagement artifactManagement, + public static List generateArtifacts(final ArtifactManagement artifactManagement, final Long moduleId) { - final List artifacts = new ArrayList<>(); + final List artifacts = new ArrayList<>(); for (int i = 0; i < 3; i++) { final InputStream stubInputStream = IOUtils.toInputStream("some test data" + i); - artifacts.add((JpaArtifact) artifactManagement.createLocalArtifact(stubInputStream, moduleId, + artifacts.add((AbstractJpaArtifact) artifactManagement.createLocalArtifact(stubInputStream, moduleId, "filename" + i, false)); } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ActionTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ActionTest.java index 4fbd46a5c..0b8938808 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ActionTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ActionTest.java @@ -11,7 +11,6 @@ package org.eclipse.hawkbit.repository; import static org.fest.assertions.api.Assertions.assertThat; import org.eclipse.hawkbit.repository.jpa.model.JpaAction; -import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.junit.Test; @@ -27,11 +26,11 @@ public class ActionTest { @Description("Ensures that timeforced moded switch from soft to forces after defined timeframe.") public void timeforcedHitNewHasCodeIsGenerated() throws InterruptedException { - final boolean active = true; + final boolean active; // current time + 1 seconds final long sleepTime = 1000; final long timeForceTimeAt = System.currentTimeMillis() + sleepTime; - final Action timeforcedAction = new JpaAction(); + final JpaAction timeforcedAction = new JpaAction(); timeforcedAction.setActionType(ActionType.TIMEFORCED); timeforcedAction.setForcedTime(timeForceTimeAt); assertThat(timeforcedAction.isForce()).isFalse(); diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ControllerManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ControllerManagementTest.java index 76286d217..4b2a92169 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ControllerManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ControllerManagementTest.java @@ -72,7 +72,7 @@ public class ControllerManagementTest extends AbstractIntegrationTest { .isEqualTo(TargetUpdateStatus.IN_SYNC); assertThat(actionStatusRepository.findAll(pageReq).getNumberOfElements()).isEqualTo(3); - assertThat(deploymentManagement.findActionStatusByAction(pageReq, savedAction, false).getNumberOfElements()) + assertThat(deploymentManagement.findActionStatusByAction(pageReq, savedAction).getNumberOfElements()) .isEqualTo(3); } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java index 50b929622..c1b0541f2 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java @@ -511,8 +511,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final List deployedTargetIDs = deploymentResult.getDeployedTargetIDs(); final List undeployedTargetIDs = deploymentResult.getUndeployedTargetIDs(); - final List savedNakedTargets = deploymentResult.getUndeployedTargets(); - final List savedDeployedTargets = deploymentResult.getDeployedTargets(); + final Collection savedNakedTargets = (Collection) deploymentResult.getUndeployedTargets(); + final Collection savedDeployedTargets = (Collection) deploymentResult.getDeployedTargets(); // retrieving all Actions created by the assignDistributionSet call final Page page = actionRepository.findAll(pageReq); @@ -540,11 +540,9 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // test the content of different lists assertThat(allFoundTargets).as("content of founded target is wrong").containsAll(deployedTargetsFromDB) .containsAll(undeployedTargetsFromDB); - assertThat(deployedTargetsFromDB).as("content of deployed target is wrong") - .containsAll((Iterable) savedDeployedTargets) + assertThat(deployedTargetsFromDB).as("content of deployed target is wrong").containsAll(savedDeployedTargets) .doesNotContain(Iterables.toArray(undeployedTargetsFromDB, JpaTarget.class)); - assertThat(undeployedTargetsFromDB).as("content of undeployed target is wrong") - .containsAll((Iterable) savedNakedTargets) + assertThat(undeployedTargetsFromDB).as("content of undeployed target is wrong").containsAll(savedNakedTargets) .doesNotContain(Iterables.toArray(deployedTargetsFromDB, JpaTarget.class)); // For each of the 4 targets 1 distribution sets gets assigned @@ -675,10 +673,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { } // verify that deleted attribute is used correctly - List allFoundDS = distributionSetManagement.findDistributionSetsAll(pageReq, false, true) - .getContent(); + List allFoundDS = distributionSetManagement + .findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true).getContent(); assertThat(allFoundDS.size()).as("no ds should be founded").isEqualTo(0); - allFoundDS = distributionSetManagement.findDistributionSetsAll(pageRequest, true, true).getContent(); + allFoundDS = distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageRequest, true, true) + .getContent(); assertThat(allFoundDS).as("wrong size of founded ds").hasSize(noOfDistributionSets); for (final DistributionSet ds : deploymentResult.getDistributionSets()) { @@ -692,9 +691,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // has been installed // successfully and no activeAction is referring to created distribution // sets - allFoundDS = distributionSetManagement.findDistributionSetsAll(pageRequest, false, true).getContent(); + allFoundDS = distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageRequest, false, true) + .getContent(); assertThat(allFoundDS.size()).as("no ds should be founded").isEqualTo(0); - allFoundDS = distributionSetManagement.findDistributionSetsAll(pageRequest, true, true).getContent(); + allFoundDS = distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageRequest, true, true) + .getContent(); assertThat(allFoundDS).as("size of founded ds is wrong").hasSize(noOfDistributionSets); } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DistributionSetManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DistributionSetManagementTest.java index 3ed4e703e..5a5518cf3 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DistributionSetManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DistributionSetManagementTest.java @@ -404,7 +404,7 @@ public class DistributionSetManagementTest extends AbstractIntegrationTest { // modifying the meta data value dsMetadata.setValue(knownUpdateValue); dsMetadata.setKey(knownKey); - dsMetadata.setDistributionSet(changedLockRevisionDS); + ((JpaDistributionSetMetadata) dsMetadata).setDistributionSet(changedLockRevisionDS); Thread.sleep(100); @@ -728,7 +728,8 @@ public class DistributionSetManagementTest extends AbstractIntegrationTest { public void findDistributionSetsWithoutLazy() { TestDataUtil.generateDistributionSets(20, softwareManagement, distributionSetManagement); - assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(20); + assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true)) + .hasSize(20); } @Test @@ -747,8 +748,9 @@ public class DistributionSetManagementTest extends AbstractIntegrationTest { distributionSetManagement.deleteDistributionSet(ds1.getId()); // not assigned so not marked as deleted but fully deleted assertThat(distributionSetRepository.findAll()).hasSize(1); - assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, Boolean.FALSE, Boolean.TRUE) - .getTotalElements()).isEqualTo(1); + assertThat(distributionSetManagement + .findDistributionSetsByDeletedAndOrCompleted(pageReq, Boolean.FALSE, Boolean.TRUE).getTotalElements()) + .isEqualTo(1); } @Test @@ -816,8 +818,9 @@ public class DistributionSetManagementTest extends AbstractIntegrationTest { // not assigned so not marked as deleted assertThat(distributionSetRepository.findAll()).hasSize(3); - assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, Boolean.FALSE, Boolean.TRUE) - .getTotalElements()).isEqualTo(2); + assertThat(distributionSetManagement + .findDistributionSetsByDeletedAndOrCompleted(pageReq, Boolean.FALSE, Boolean.TRUE).getTotalElements()) + .isEqualTo(2); } private Target sendUpdateActionStatusToTarget(final Status status, final Action updActA, final Target t, diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/RolloutManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/RolloutManagementTest.java index e56ce6cd5..576315b3a 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/RolloutManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/RolloutManagementTest.java @@ -18,23 +18,22 @@ import java.util.concurrent.Callable; import org.eclipse.hawkbit.AbstractIntegrationTest; import org.eclipse.hawkbit.TestDataUtil; -import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.jpa.model.JpaAction; import org.eclipse.hawkbit.repository.jpa.model.JpaActionStatus; import org.eclipse.hawkbit.repository.jpa.model.JpaRollout; -import org.eclipse.hawkbit.repository.jpa.model.JpaRollout.RolloutStatus; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupConditions; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupErrorAction; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupErrorCondition; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupStatus; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupSuccessCondition; import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.Rollout; +import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus; import org.eclipse.hawkbit.repository.model.RolloutGroup; +import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorAction; +import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondition; +import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus; +import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition; +import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder; +import org.eclipse.hawkbit.repository.model.RolloutGroupConditions; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; @@ -876,7 +875,7 @@ public class RolloutManagementTest extends AbstractIntegrationTest { softwareManagement, distributionSetManagement); targetManagement.createTargets( TestDataUtil.buildTargetFixtures(amountTargetsForRollout, targetPrefixName + "-", targetPrefixName)); - final RolloutGroupConditions conditions = new JpaRolloutGroup.RolloutGroupConditionBuilder() + final RolloutGroupConditions conditions = new RolloutGroupConditionBuilder() .successCondition(RolloutGroupSuccessCondition.THRESHOLD, successCondition) .errorCondition(RolloutGroupErrorCondition.THRESHOLD, errorCondition) .errorAction(RolloutGroupErrorAction.PAUSE, null).build(); @@ -963,7 +962,7 @@ public class RolloutManagementTest extends AbstractIntegrationTest { private Rollout createRolloutByVariables(final String rolloutName, final String rolloutDescription, final int groupSize, final String filterQuery, final DistributionSet distributionSet, final String successCondition, final String errorCondition) { - final RolloutGroupConditions conditions = new JpaRolloutGroup.RolloutGroupConditionBuilder() + final RolloutGroupConditions conditions = new RolloutGroupConditionBuilder() .successCondition(RolloutGroupSuccessCondition.THRESHOLD, successCondition) .errorCondition(RolloutGroupErrorCondition.THRESHOLD, errorCondition) .errorAction(RolloutGroupErrorAction.PAUSE, null).build(); diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java index 300fe78dc..befcf5f3d 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java @@ -961,7 +961,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB { .getSoftwareModule(); try { - softwareManagement.findSoftwareModuleMetadata(new SwMetadataCompositeKey(ah, "doesnotexist")); + softwareManagement.findSoftwareModuleMetadata(ah, "doesnotexist"); fail("should not have worked as module metadata with that key does not exist"); } catch (final EntityNotFoundException e) { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLRolloutGroupFields.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLRolloutGroupFields.java index 83c31b31a..32c4d8641 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLRolloutGroupFields.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLRolloutGroupFields.java @@ -14,11 +14,11 @@ import org.eclipse.hawkbit.AbstractIntegrationTest; import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.repository.RolloutGroupFields; import org.eclipse.hawkbit.repository.jpa.model.JpaRollout; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupConditionBuilder; -import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup.RolloutGroupSuccessCondition; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.RolloutGroup; +import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition; +import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder; import org.junit.Before; import org.junit.Test; import org.springframework.data.domain.Page; diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleTypeFieldsTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleTypeFieldsTest.java index 37a501a3f..e4988025e 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleTypeFieldsTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleTypeFieldsTest.java @@ -59,7 +59,7 @@ public class RSQLSoftwareModuleTypeFieldsTest extends AbstractIntegrationTest { } private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) { - final Page find = softwareManagement.findSoftwareModuleTypesByPredicate(rsqlParam, + final Page find = softwareManagement.findSoftwareModuleTypesAll(rsqlParam, new PageRequest(0, 100)); final long countAll = find.getTotalElements(); assertThat(find).isNotNull(); diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java index ca0ef3840..e5cbc18a0 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java @@ -194,7 +194,7 @@ public class MultiTenancyEntityTest extends AbstractIntegrationTest { private Page findDistributionSetForTenant(final String tenant) throws Exception { return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant), - () -> distributionSetManagement.findDistributionSetsAll(pageReq, false, false)); + () -> distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, false)); } } diff --git a/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/JsonBuilder.java b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/JsonBuilder.java index b73320f0e..f67f15815 100644 --- a/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/JsonBuilder.java +++ b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/JsonBuilder.java @@ -16,7 +16,7 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.RandomStringUtils; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetType; -import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupConditions; +import org.eclipse.hawkbit.repository.model.RolloutGroupConditions; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.Target; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactBeanQuery.java index 5e7c0f3c7..b9bceda3a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactBeanQuery.java @@ -12,7 +12,8 @@ import java.util.List; import java.util.Map; import org.eclipse.hawkbit.repository.ArtifactManagement; -import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; +import org.eclipse.hawkbit.repository.jpa.model.JpaLocalArtifact; import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; @@ -72,7 +73,7 @@ public class ArtifactBeanQuery extends AbstractBeanQuery { @Override protected LocalArtifact constructBean() { - return new LocalArtifact(); + return new JpaLocalArtifact(); } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java index ea49d2f1f..29bea30eb 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java @@ -12,8 +12,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.SoftwareManagement; -import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/ProxyBaseSoftwareModuleItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/ProxyBaseSoftwareModuleItem.java index 6e417435c..14568c307 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/ProxyBaseSoftwareModuleItem.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/ProxyBaseSoftwareModuleItem.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.artifacts.smtable; import java.security.SecureRandom; -import org.eclipse.hawkbit.repository.model.SoftwareModule; +import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule; /** * @@ -19,7 +19,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule; * * */ -public class ProxyBaseSoftwareModuleItem extends SoftwareModule { +public class ProxyBaseSoftwareModuleItem extends JpaSoftwareModule { private static final long serialVersionUID = -1555306616599140635L; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java index 1e4029087..d6fbada89 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java @@ -234,7 +234,7 @@ public class SoftwareModuleAddUpdateWindow implements Serializable { mainLayout.addComponent(hLayout); mainLayout.setComponentAlignment(hLayout, Alignment.MIDDLE_LEFT); mainLayout.addComponents(nameTextField, versionTextField, vendorTextField, descTextArea, buttonsLayout); - + /* add main layout to the window */ window = SPUIComponentProvider.getWindow(i18n.get("upload.caption.add.new.swmodule"), null, SPUIDefinitions.CREATE_UPDATE_WINDOW); @@ -277,8 +277,8 @@ public class SoftwareModuleAddUpdateWindow implements Serializable { uiNotifcation.displayValidationError( i18n.get("message.duplicate.softwaremodule", new Object[] { name, version })); } else { - final SoftwareModule newBaseSoftwareModule = HawkbitCommonUtil.addNewBaseSoftware(name, version, vendor, - softwareManagement.findSoftwareModuleTypeByName(type), description); + final SoftwareModule newBaseSoftwareModule = HawkbitCommonUtil.addNewBaseSoftware(softwareManagement, + name, version, vendor, softwareManagement.findSoftwareModuleTypeByName(type), description); if (newBaseSoftwareModule != null) { /* display success message */ uiNotifcation.displaySuccess(i18n.get("message.save.success", new Object[] { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java index f2e43c1fb..c71b06671 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java @@ -625,8 +625,10 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C } if (null != typeNameValue && null != typeKeyValue) { - SoftwareModuleType newSWType = new SoftwareModuleType(typeKeyValue, typeNameValue, typeDescValue, - assignNumber, colorPicked); + SoftwareModuleType newSWType = swTypeManagementService.generateSoftwareModuleType(typeKeyValue, + typeNameValue, typeDescValue, assignNumber); + newSWType.setColour(colorPicked); + if (null != typeDescValue) { newSWType.setDescription(typeDescValue); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/DistributionSetTypeBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/DistributionSetTypeBeanQuery.java index b8f5435dd..04200208b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/DistributionSetTypeBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/DistributionSetTypeBeanQuery.java @@ -13,7 +13,7 @@ import java.util.List; import java.util.Map; import org.eclipse.hawkbit.repository.DistributionSetManagement; -import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SpringContextHelper; @@ -57,8 +57,9 @@ public class DistributionSetTypeBeanQuery extends AbstractBeanQuery itemIds = (List) selectedTable.getItemIds(); if (null != typeNameValue && null != typeKeyValue && null != itemIds && !itemIds.isEmpty()) { - DistributionSetType newDistType = new DistributionSetType(typeKeyValue, typeNameValue, typeDescValue); + DistributionSetType newDistType = distributionSetManagement.generateDistributionSetType(typeKeyValue, + typeNameValue, typeDescValue); for (final Long id : itemIds) { final Item item = selectedTable.getItem(id); final String distTypeName = (String) item.getItemProperty(DIST_TYPE_NAME).getValue(); @@ -704,7 +705,8 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co updateDistSetType.setKey(typeKeyValue); updateDistSetType.setDescription(null != typeDescValue ? typeDescValue : null); - if (distributionSetRepository.countByType(existingType) <= 0 && null != itemIds && !itemIds.isEmpty()) { + if (distributionSetManagement.countDistributionSetsByType(existingType) <= 0 && null != itemIds + && !itemIds.isEmpty()) { for (final Long id : itemIds) { final Item item = selectedTable.getItem(id); final CheckBox mandatoryCheckBox = (CheckBox) item.getItemProperty(DIST_TYPE_MANDATORY).getValue(); @@ -1040,7 +1042,7 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co typeDesc.setValue(selectedTypeTag.getDescription()); typeKey.setValue(selectedTypeTag.getKey()); - if (distributionSetRepository.countByType(selectedTypeTag) <= 0) { + if (distributionSetManagement.countDistributionSetsByType(selectedTypeTag) <= 0) { distTypeSelectLayout.setEnabled(true); selectedTable.setEnabled(true); saveDistSetType.setEnabled(true); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java index 1fd306816..91fd3336c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java @@ -17,7 +17,7 @@ import java.util.Map; import org.eclipse.hawkbit.repository.DistributionSetFilter; import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder; import org.eclipse.hawkbit.repository.DistributionSetManagement; -import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; @@ -96,7 +96,7 @@ public class ManageDistBeanQuery extends AbstractBeanQuery { } else if (Strings.isNullOrEmpty(searchText)) { // if no search filters available distBeans = getDistributionSetManagement() - .findDistributionSetsAll(new OffsetBasedPageRequest(startIndex, count, sort), false, null); + .findDistributionSetsByDeletedAndOrCompleted(new OffsetBasedPageRequest(startIndex, count, sort), false, null); } else { final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false) .setSearchText(searchText).setSelectDSWithNoTag(Boolean.FALSE).setType(distributionSetType).build(); @@ -133,7 +133,7 @@ public class ManageDistBeanQuery extends AbstractBeanQuery { if (Strings.isNullOrEmpty(searchText) && null == distributionSetType) { // if no search filters available firstPageDistributionSets = getDistributionSetManagement() - .findDistributionSetsAll(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, null); + .findDistributionSetsByDeletedAndOrCompleted(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, null); } else { final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false) .setSearchText(searchText).setSelectDSWithNoTag(Boolean.FALSE).setType(distributionSetType).build(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java index eb53cef55..21ce01347 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java @@ -12,8 +12,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.SoftwareManagement; -import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.model.CustomSoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java index 6a671e228..a89e98d56 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java @@ -503,7 +503,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button } private void createTargetFilterQuery() { - final TargetFilterQuery targetFilterQuery = new TargetFilterQuery(); + final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.generateTargetFilterQuery(); targetFilterQuery.setName(nameTextField.getValue()); targetFilterQuery.setQuery(queryTextField.getValue()); targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java index 834566f7e..0288cf9c2 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java @@ -268,29 +268,29 @@ public class ActionHistoryTable extends TreeTable implements Handler { final Action action = actionWithStatusCount.getAction(); - final Item item = hierarchicalContainer.addItem(actionWithStatusCount.getActionId()); + final Item item = hierarchicalContainer.addItem(actionWithStatusCount.getAction().getId()); item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN) - .setValue(actionWithStatusCount.getActionStatus()); + .setValue(actionWithStatusCount.getAction().getStatus()); /* * add action id. */ item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID) - .setValue(actionWithStatusCount.getActionId().toString()); + .setValue(actionWithStatusCount.getAction().getId().toString()); /* * add active/inactive status to the item which will be used in * Column generator to generate respective icon */ item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).setValue( - actionWithStatusCount.isActionActive() ? SPUIDefinitions.ACTIVE : SPUIDefinitions.IN_ACTIVE); + actionWithStatusCount.getAction().isActive() ? SPUIDefinitions.ACTIVE : SPUIDefinitions.IN_ACTIVE); /* * add action Id to the item which will be used for fetching child * items ( previous action status ) during expand */ item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN) - .setValue(actionWithStatusCount.getActionId()); + .setValue(actionWithStatusCount.getAction().getId()); /* * add distribution name to the item which will be displayed in the @@ -301,7 +301,7 @@ public class ActionHistoryTable extends TreeTable implements Handler { item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).setValue(action); /* Default no child */ - ((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), false); + ((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getAction().getId(), false); item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME) .setValue(SPDateTimeUtil.getFormattedDate((actionWithStatusCount.getActionLastModifiedAt() != null) @@ -312,7 +312,7 @@ public class ActionHistoryTable extends TreeTable implements Handler { .setValue(actionWithStatusCount.getRolloutName()); if (actionWithStatusCount.getActionStatusCount() > 0) { - ((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), true); + ((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getAction().getId(), true); } } } @@ -422,8 +422,12 @@ public class ActionHistoryTable extends TreeTable implements Handler { .findActionWithDetails(actionId); final Pageable pageReq = new PageRequest(0, 1000, new Sort(Direction.DESC, ActionStatusFields.ID.getFieldName())); - final Page actionStatusList = deploymentManagement.findActionStatusByAction(pageReq, action, - managementUIState.isActionHistoryMaximized()); + final Page actionStatusList; + if (managementUIState.isActionHistoryMaximized()) { + actionStatusList = deploymentManagement.findActionStatusByActionWithMessages(pageReq, action); + } else { + actionStatusList = deploymentManagement.findActionStatusByAction(pageReq, action); + } final List content = actionStatusList.getContent(); /* * Since the recent action status and messages are already diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java index d13dc94cf..cc52ce795 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java @@ -297,7 +297,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { if (mandatoryCheck(name, version, distSetTypeName) && duplicateCheck(name, version)) { final String desc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue()); final boolean isMigStepReq = reqMigStepCheckbox.getValue(); - DistributionSet newDist = new DistributionSet(); + DistributionSet newDist = distributionSetManagement.generateDistributionSet(); setDistributionValues(newDist, name, version, distSetTypeName, desc, isMigStepReq); newDist = distributionSetManagement.createDistributionSet(newDist); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java index 353ef3e95..5aee6cbe1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java @@ -16,7 +16,7 @@ import java.util.Map; import org.eclipse.hawkbit.repository.DistributionSetFilter; import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder; import org.eclipse.hawkbit.repository.DistributionSetManagement; -import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.ProxyDistribution; @@ -111,7 +111,7 @@ public class DistributionBeanQuery extends AbstractBeanQuery } else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) { // if no search filters available distBeans = getDistributionSetManagement() - .findDistributionSetsAll(new OffsetBasedPageRequest(startIndex, count, sort), false, true); + .findDistributionSetsByDeletedAndOrCompleted(new OffsetBasedPageRequest(startIndex, count, sort), false, true); } else { final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false) .setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked) @@ -153,7 +153,7 @@ public class DistributionBeanQuery extends AbstractBeanQuery } else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) { // if no search filters available firstPageDistributionSets = getDistributionSetManagement() - .findDistributionSetsAll(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, true); + .findDistributionSetsByDeletedAndOrCompleted(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, true); } else { final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false) .setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java index 4d63753fe..e540017c3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java @@ -98,14 +98,13 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo final String tagDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue()); if (null != tagNameValue) { - DistributionSetTag newDistTag = new DistributionSetTag(tagNameValue); - if (null != tagDescValue) { - newDistTag.setDescription(tagDescValue); - } - newDistTag.setColour(new Color(0, 146, 58).getCSS()); + DistributionSetTag newDistTag = tagManagement.generateDistributionSetTag(tagNameValue, tagDescValue, + new Color(0, 146, 58).getCSS()); + if (colorPicked != null) { newDistTag.setColour(colorPicked); } + newDistTag = tagManagement.createDistributionSetTag(newDistTag); uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { newDistTag.getName() })); resetDistTagValues(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java index 9b66f2836..8be9548f7 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java @@ -12,8 +12,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.TagManagement; -import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.ui.management.tag.ProxyTag; import org.eclipse.hawkbit.ui.management.tag.TagIdName; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java index 934d9c4c7..fbf882695 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java @@ -14,6 +14,7 @@ import java.util.Map; import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent; import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent; import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent; +import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtonClickBehaviour; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons; @@ -51,13 +52,16 @@ public class DistributionTagButtons extends AbstractFilterButtons { @Autowired private DistributionTagDropEvent spDistTagDropEvent; + @Autowired + private TagManagement tagManagement; + @Autowired private ManagementUIState managementUIState; @Override public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) { super.init(filterButtonClickBehaviour); - addNewTag(new DistributionSetTag("NO TAG")); + addNewTag(tagManagement.generateDistributionSetTag("NO TAG")); } @EventBusListenerMethod(scope = EventScope.SESSION) @@ -139,7 +143,7 @@ public class DistributionTagButtons extends AbstractFilterButtons { private void refreshTagTable() { ((LazyQueryContainer) getContainerDataSource()).refresh(); removeGeneratedColumn(FILTER_BUTTON_COLUMN); - addNewTag(new DistributionSetTag("NO TAG")); + addNewTag(tagManagement.generateDistributionSetTag("NO TAG")); addColumn(); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java index 2369893c7..9ef0b742c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java @@ -380,7 +380,7 @@ public class BulkUploadHandler extends CustomComponent final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue()); /* create new target entity */ - final Target newTarget = new Target(newControllerId); + final Target newTarget = targetManagement.generateTarget(newControllerId); setTargetValues(newTarget, newName, newDesc); targetManagement.createTarget(newTarget); managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated().add(newControllerId); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java index e54911d86..ddf109773 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java @@ -245,7 +245,7 @@ public class TargetAddUpdateWindowLayout extends CustomComponent { final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue()); /* create new target entity */ - Target newTarget = new Target(newControlllerId); + Target newTarget = targetManagement.generateTarget(newControlllerId); /* set values to the new target entity */ setTargetValues(newTarget, newName, newDesc); /* save new target */ diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java index f3e0078f3..e96a9af8e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java @@ -13,8 +13,8 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.TargetManagement; -import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java index 4ed2580f6..62ad96205 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -21,9 +21,9 @@ import java.util.stream.Collectors; import org.eclipse.hawkbit.eventbus.event.TargetCreatedEvent; import org.eclipse.hawkbit.eventbus.event.TargetDeletedEvent; import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.TargetManagement; -import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayout.java index 79a44c38c..efd4084f5 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayout.java @@ -193,7 +193,7 @@ public class CreateUpdateTargetTagLayout extends CreateUpdateTagLayout { final String tagNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue()); final String tagDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue()); if (null != tagNameValue) { - TargetTag newTargetTag = new TargetTag(tagNameValue); + TargetTag newTargetTag = tagManagement.generateTargetTag(tagNameValue); if (null != tagDescValue) { newTargetTag.setDescription(tagDescValue); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagBeanQuery.java index 066383d8a..5164a409a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagBeanQuery.java @@ -12,8 +12,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.TagManagement; -import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.ui.management.tag.ProxyTag; import org.eclipse.hawkbit.ui.management.tag.TagIdName; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java index 48447f112..58721d77d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java @@ -16,6 +16,7 @@ import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent; import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent; import org.eclipse.hawkbit.eventbus.event.TargetTagUpdateEvent; import org.eclipse.hawkbit.repository.SpPermissionChecker; +import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.repository.model.TargetTag; @@ -75,6 +76,9 @@ public class TargetTagFilterButtons extends AbstractFilterButtons { @Autowired private SpPermissionChecker permChecker; + @Autowired + private TagManagement tagManagement; + @Autowired private transient TargetManagement targetManagement; @@ -90,7 +94,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons { public void init(final TargetTagFilterButtonClick filterButtonClickBehaviour) { this.filterButtonClickBehaviour = filterButtonClickBehaviour; super.init(filterButtonClickBehaviour); - addNewTargetTag(new TargetTag("NO TAG")); + addNewTargetTag(tagManagement.generateTargetTag("NO TAG")); } @EventBusListenerMethod(scope = EventScope.SESSION) @@ -290,7 +294,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons { private void refreshContainer() { removeGeneratedColumn(FILTER_BUTTON_COLUMN); ((LazyQueryContainer) getContainerDataSource()).refresh(); - addNewTargetTag(new TargetTag("NO TAG")); + addNewTargetTag(tagManagement.generateTargetTag("NO TAG")); addColumn(); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java index 7e8d45e1b..c6a2bdc4d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java @@ -21,11 +21,12 @@ import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus; import org.eclipse.hawkbit.repository.model.RolloutGroup; -import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupConditions; import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorAction; import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondition; import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessAction; import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition; +import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder; +import org.eclipse.hawkbit.repository.model.RolloutGroupConditions; import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; @@ -478,12 +479,12 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { } private Rollout saveRollout() { - Rollout rolloutToCreate = new Rollout(); + Rollout rolloutToCreate = rolloutManagement.generateRollout(); final int amountGroup = Integer.parseInt(noOfGroups.getValue()); final String targetFilter = getTargetFilterQuery(); final int errorThresoldPercent = getErrorThresoldPercentage(amountGroup); - final RolloutGroupConditions conditions = new RolloutGroup.RolloutGroupConditionBuilder() + final RolloutGroupConditions conditions = new RolloutGroupConditionBuilder() .successAction(RolloutGroupSuccessAction.NEXTGROUP, null) .successCondition(RolloutGroupSuccessCondition.THRESHOLD, triggerThreshold.getValue()) .errorCondition(RolloutGroupErrorCondition.THRESHOLD, String.valueOf(errorThresoldPercent)) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java index 04c6659a5..4074edb55 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.rollout.rollout; import java.util.Set; -import org.eclipse.hawkbit.repository.model.Rollout; +import org.eclipse.hawkbit.repository.jpa.model.JpaRollout; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData; @@ -20,7 +20,7 @@ import com.vaadin.server.FontAwesome; * Proxy rollout with custom properties. * */ -public class ProxyRollout extends Rollout { +public class ProxyRollout extends JpaRollout { private static final long serialVersionUID = 4539849939617681918L; @@ -59,7 +59,7 @@ public class ProxyRollout extends Rollout { * the isRequiredMigrationStep to set */ - public void setIsRequiredMigrationStep(Boolean isRequiredMigrationStep) { + public void setIsRequiredMigrationStep(final Boolean isRequiredMigrationStep) { this.isRequiredMigrationStep = isRequiredMigrationStep; } @@ -76,7 +76,7 @@ public class ProxyRollout extends Rollout { * the discription to set */ - public void setDiscription(String discription) { + public void setDiscription(final String discription) { this.discription = discription; } @@ -92,7 +92,7 @@ public class ProxyRollout extends Rollout { * the type to set */ - public void setType(String type) { + public void setType(final String type) { this.type = type; } @@ -108,7 +108,7 @@ public class ProxyRollout extends Rollout { * @param swModules * Set to set */ - public void setSwModules(Set swModules) { + public void setSwModules(final Set swModules) { this.swModules = swModules; } @@ -116,7 +116,7 @@ public class ProxyRollout extends Rollout { return rolloutRendererData; } - public void setRolloutRendererData(RolloutRendererData rendererData) { + public void setRolloutRendererData(final RolloutRendererData rendererData) { this.rolloutRendererData = rendererData; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/ProxyRolloutGroup.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/ProxyRolloutGroup.java index 08f2c0a0b..f6653d971 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/ProxyRolloutGroup.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/ProxyRolloutGroup.java @@ -8,212 +8,212 @@ */ package org.eclipse.hawkbit.ui.rollout.rolloutgroup; -import org.eclipse.hawkbit.repository.model.RolloutGroup; +import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup; import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData; /** * Proxy rollout group with renderer properties. * */ -public class ProxyRolloutGroup extends RolloutGroup { +public class ProxyRolloutGroup extends JpaRolloutGroup { - private static final long serialVersionUID = -2745056813306692356L; + private static final long serialVersionUID = -2745056813306692356L; - private String createdDate; + private String createdDate; - private String modifiedDate; + private String modifiedDate; - private String finishedPercentage; + private String finishedPercentage; - private Long runningTargetsCount; + private Long runningTargetsCount; - private Long scheduledTargetsCount; + private Long scheduledTargetsCount; - private Long cancelledTargetsCount; + private Long cancelledTargetsCount; - private Long errorTargetsCount; + private Long errorTargetsCount; - private Long finishedTargetsCount; + private Long finishedTargetsCount; - private Long notStartedTargetsCount; + private Long notStartedTargetsCount; - private Boolean isActionRecieved = Boolean.FALSE; + private Boolean isActionRecieved = Boolean.FALSE; - private String totalTargetsCount; + private String totalTargetsCount; - private RolloutRendererData rolloutRendererData; + private RolloutRendererData rolloutRendererData; - public RolloutRendererData getRolloutRendererData() { - return rolloutRendererData; - } + public RolloutRendererData getRolloutRendererData() { + return rolloutRendererData; + } - public void setRolloutRendererData(RolloutRendererData rendererData) { - this.rolloutRendererData = rendererData; - } + public void setRolloutRendererData(final RolloutRendererData rendererData) { + this.rolloutRendererData = rendererData; + } - /** - * @return the createdDate - */ - public String getCreatedDate() { - return createdDate; - } + /** + * @return the createdDate + */ + public String getCreatedDate() { + return createdDate; + } - /** - * @param createdDate - * the createdDate to set - */ - public void setCreatedDate(final String createdDate) { - this.createdDate = createdDate; - } + /** + * @param createdDate + * the createdDate to set + */ + public void setCreatedDate(final String createdDate) { + this.createdDate = createdDate; + } - /** - * @return the modifiedDate - */ - public String getModifiedDate() { - return modifiedDate; - } + /** + * @return the modifiedDate + */ + public String getModifiedDate() { + return modifiedDate; + } - /** - * @param modifiedDate - * the modifiedDate to set - */ - public void setModifiedDate(final String modifiedDate) { - this.modifiedDate = modifiedDate; - } + /** + * @param modifiedDate + * the modifiedDate to set + */ + public void setModifiedDate(final String modifiedDate) { + this.modifiedDate = modifiedDate; + } - /** - * @return the finishedPercentage - */ - public String getFinishedPercentage() { - return finishedPercentage; - } + /** + * @return the finishedPercentage + */ + public String getFinishedPercentage() { + return finishedPercentage; + } - /** - * @param finishedPercentage - * the finishedPercentage to set - */ - public void setFinishedPercentage(final String finishedPercentage) { - this.finishedPercentage = finishedPercentage; - } + /** + * @param finishedPercentage + * the finishedPercentage to set + */ + public void setFinishedPercentage(final String finishedPercentage) { + this.finishedPercentage = finishedPercentage; + } - /** - * @return the runningTargetsCount - */ - public Long getRunningTargetsCount() { - return runningTargetsCount; - } + /** + * @return the runningTargetsCount + */ + public Long getRunningTargetsCount() { + return runningTargetsCount; + } - /** - * @param runningTargetsCount - * the runningTargetsCount to set - */ - public void setRunningTargetsCount(final Long runningTargetsCount) { - this.runningTargetsCount = runningTargetsCount; - } + /** + * @param runningTargetsCount + * the runningTargetsCount to set + */ + public void setRunningTargetsCount(final Long runningTargetsCount) { + this.runningTargetsCount = runningTargetsCount; + } - /** - * @return the scheduledTargetsCount - */ - public Long getScheduledTargetsCount() { - return scheduledTargetsCount; - } + /** + * @return the scheduledTargetsCount + */ + public Long getScheduledTargetsCount() { + return scheduledTargetsCount; + } - /** - * @param scheduledTargetsCount - * the scheduledTargetsCount to set - */ - public void setScheduledTargetsCount(final Long scheduledTargetsCount) { - this.scheduledTargetsCount = scheduledTargetsCount; - } + /** + * @param scheduledTargetsCount + * the scheduledTargetsCount to set + */ + public void setScheduledTargetsCount(final Long scheduledTargetsCount) { + this.scheduledTargetsCount = scheduledTargetsCount; + } - /** - * @return the cancelledTargetsCount - */ - public Long getCancelledTargetsCount() { - return cancelledTargetsCount; - } + /** + * @return the cancelledTargetsCount + */ + public Long getCancelledTargetsCount() { + return cancelledTargetsCount; + } - /** - * @param cancelledTargetsCount - * the cancelledTargetsCount to set - */ - public void setCancelledTargetsCount(final Long cancelledTargetsCount) { - this.cancelledTargetsCount = cancelledTargetsCount; - } + /** + * @param cancelledTargetsCount + * the cancelledTargetsCount to set + */ + public void setCancelledTargetsCount(final Long cancelledTargetsCount) { + this.cancelledTargetsCount = cancelledTargetsCount; + } - /** - * @return the errorTargetsCount - */ - public Long getErrorTargetsCount() { - return errorTargetsCount; - } + /** + * @return the errorTargetsCount + */ + public Long getErrorTargetsCount() { + return errorTargetsCount; + } - /** - * @param errorTargetsCount - * the errorTargetsCount to set - */ - public void setErrorTargetsCount(final Long errorTargetsCount) { - this.errorTargetsCount = errorTargetsCount; - } + /** + * @param errorTargetsCount + * the errorTargetsCount to set + */ + public void setErrorTargetsCount(final Long errorTargetsCount) { + this.errorTargetsCount = errorTargetsCount; + } - /** - * @return the finishedTargetsCount - */ - public Long getFinishedTargetsCount() { - return finishedTargetsCount; - } + /** + * @return the finishedTargetsCount + */ + public Long getFinishedTargetsCount() { + return finishedTargetsCount; + } - /** - * @param finishedTargetsCount - * the finishedTargetsCount to set - */ - public void setFinishedTargetsCount(final Long finishedTargetsCount) { - this.finishedTargetsCount = finishedTargetsCount; - } + /** + * @param finishedTargetsCount + * the finishedTargetsCount to set + */ + public void setFinishedTargetsCount(final Long finishedTargetsCount) { + this.finishedTargetsCount = finishedTargetsCount; + } - /** - * @return the notStartedTargetsCount - */ - public Long getNotStartedTargetsCount() { - return notStartedTargetsCount; - } + /** + * @return the notStartedTargetsCount + */ + public Long getNotStartedTargetsCount() { + return notStartedTargetsCount; + } - /** - * @param notStartedTargetsCount - * the notStartedTargetsCount to set - */ - public void setNotStartedTargetsCount(final Long notStartedTargetsCount) { - this.notStartedTargetsCount = notStartedTargetsCount; - } + /** + * @param notStartedTargetsCount + * the notStartedTargetsCount to set + */ + public void setNotStartedTargetsCount(final Long notStartedTargetsCount) { + this.notStartedTargetsCount = notStartedTargetsCount; + } - /** - * @return the isActionRecieved - */ - public Boolean getIsActionRecieved() { - return isActionRecieved; - } + /** + * @return the isActionRecieved + */ + public Boolean getIsActionRecieved() { + return isActionRecieved; + } - /** - * @param isActionRecieved - * the isActionRecieved to set - */ - public void setIsActionRecieved(final Boolean isActionRecieved) { - this.isActionRecieved = isActionRecieved; - } + /** + * @param isActionRecieved + * the isActionRecieved to set + */ + public void setIsActionRecieved(final Boolean isActionRecieved) { + this.isActionRecieved = isActionRecieved; + } - /** - * @return the totalTargetsCount - */ - public String getTotalTargetsCount() { - return totalTargetsCount; - } + /** + * @return the totalTargetsCount + */ + public String getTotalTargetsCount() { + return totalTargetsCount; + } - /** - * @param totalTargetsCount - * the totalTargetsCount to set - */ - public void setTotalTargetsCount(final String totalTargetsCount) { - this.totalTargetsCount = totalTargetsCount; - } + /** + * @param totalTargetsCount + * the totalTargetsCount to set + */ + public void setTotalTargetsCount(final String totalTargetsCount) { + this.totalTargetsCount = totalTargetsCount; + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java index 0e71567af..5491acaaf 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java @@ -24,10 +24,10 @@ import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.model.AssignmentResult; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.NamedEntity; +import org.eclipse.hawkbit.repository.model.PollStatus; import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; -import org.eclipse.hawkbit.repository.model.TargetInfo.PollStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status; @@ -781,10 +781,10 @@ public final class HawkbitCommonUtil { * base software module description * @return BaseSoftwareModule new base software module */ - public static SoftwareModule addNewBaseSoftware(final String bsname, final String bsversion, final String bsvendor, - final SoftwareModuleType bstype, final String description) { + public static SoftwareModule addNewBaseSoftware(final SoftwareManagement softwareManagement, final String bsname, + final String bsversion, final String bsvendor, final SoftwareModuleType bstype, final String description) { final SoftwareManagement swMgmtService = SpringContextHelper.getBean(SoftwareManagement.class); - SoftwareModule newSWModule = new SoftwareModule(); + SoftwareModule newSWModule = softwareManagement.generateSoftwareModule(); newSWModule.setType(bstype); newSWModule.setName(bsname); newSWModule.setVersion(bsversion);