Continued on the model API extraction. Merged rest api split branch.
Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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<String> messages);
|
||||
|
||||
ActionStatus generateActionStatus(Action action, Status status, Long occurredAt);
|
||||
|
||||
}
|
||||
|
||||
@@ -322,8 +322,10 @@ public interface DeploymentManagement {
|
||||
* @return the corresponding {@link Page} of {@link ActionStatus}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<ActionStatus> findActionStatusByAction(@NotNull Pageable pageReq, @NotNull Action action,
|
||||
boolean withMessages);
|
||||
Page<ActionStatus> findActionStatusByAction(@NotNull Pageable pageReq, @NotNull Action action);
|
||||
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<ActionStatus> 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<ActionStatus> findActionStatusAll(@NotNull Pageable pageable);
|
||||
}
|
||||
|
||||
@@ -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<DistributionSet> findDistributionSetsAll(Collection<Long> dist);
|
||||
|
||||
/**
|
||||
* finds all meta data by the given distribution set id.
|
||||
*
|
||||
@@ -305,6 +300,20 @@ public interface DistributionSetManagement {
|
||||
Page<DistributionSetMetadata> 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<DistributionSet> findDistributionSetsAll(Collection<Long> 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<DistributionSet> findDistributionSetsAll(@NotNull Pageable pageReq, Boolean deleted, Boolean complete);
|
||||
Page<DistributionSet> 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<SoftwareModule> moduleList);
|
||||
|
||||
/**
|
||||
* Generates an empty {@link DistributionSet} without persisting it.
|
||||
*
|
||||
* @return {@link DistributionSet} object
|
||||
*/
|
||||
DistributionSet generateDistributionSet();
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<RolloutGroup> findAllRolloutGroupsWithDetailedStatus(@NotNull Long rolloutId, @NotNull Pageable page);
|
||||
Page<RolloutGroup> 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<RolloutGroup> 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<RolloutGroup> findRolloutGroupsByRolloutId(@NotNull Long rolloutId, @NotNull Pageable page);
|
||||
Page<RolloutGroup> 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<Target> list of targets of a rollout group
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<Target> findRolloutGroupTargets(@NotNull RolloutGroup rolloutGroup, @NotNull String rsqlParam,
|
||||
@NotNull Pageable page);
|
||||
@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Get count of targets in different status in rollout group.
|
||||
|
||||
@@ -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<Rollout> findAll(@NotNull Pageable page);
|
||||
Page<Rollout> 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<Rollout> findAllRolloutsWithDetailedStatus(@NotNull Pageable page);
|
||||
Page<Rollout> 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<Rollout> findAllWithDetailedStatusByPredicate(@NotNull String rsqlParam, @NotNull Pageable page);
|
||||
Page<Rollout> findAllWithDetailedStatusByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Finds rollouts by given text in name or description.
|
||||
|
||||
@@ -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<SoftwareModuleType> findSoftwareModuleTypesByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
Page<SoftwareModuleType> 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);
|
||||
|
||||
}
|
||||
|
||||
@@ -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<TargetTag> findAllTargetTags(@NotNull Pageable pageReq);
|
||||
Page<TargetTag> 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);
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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<T extends JpaTenantAwareBaseEntity, I extends Serializable>
|
||||
public interface BaseEntityRepository<T extends AbstractJpaTenantAwareBaseEntity, I extends Serializable>
|
||||
extends PagingAndSortingRepository<T, I> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<String> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -598,11 +598,11 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
|
||||
return convertAcPage(actionRepository.findAll((Specification<JpaAction>) (root, query, cb) -> cb
|
||||
.and(specification.toPredicate(root, query, cb), cb.equal(root.get(JpaAction_.target), target)),
|
||||
pageable));
|
||||
pageable), pageable);
|
||||
}
|
||||
|
||||
private static Page<Action> convertAcPage(final Page<JpaAction> findAll) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()));
|
||||
private static Page<Action> convertAcPage(final Page<JpaAction> 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<ActionStatus> 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<ActionStatus> findActionStatusByAction(final Pageable pageReq, final Action action) {
|
||||
return actionStatusRepository.findByAction(pageReq, (JpaAction) action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ActionStatus> 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<ActionStatus> findActionStatusAll(final Pageable pageable) {
|
||||
return convertAcSPage(actionStatusRepository.findAll(pageable), pageable);
|
||||
}
|
||||
|
||||
private static Page<ActionStatus> convertAcSPage(final Page<JpaActionStatus> findAll, final Pageable pageable) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,11 +298,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
final DistributionSetFilter distributionSetFilter) {
|
||||
final List<Specification<JpaDistributionSet>> specList = buildDistributionSetSpecifications(
|
||||
distributionSetFilter);
|
||||
return convertDsPage(findByCriteriaAPI(pageable, specList));
|
||||
return convertDsPage(findByCriteriaAPI(pageable, specList), pageable);
|
||||
}
|
||||
|
||||
private static Page<DistributionSet> convertDsPage(final Page<JpaDistributionSet> findAll) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()));
|
||||
private static Page<DistributionSet> convertDsPage(final Page<JpaDistributionSet> 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<DistributionSet> findDistributionSetsAll(final Pageable pageReq, final Boolean deleted,
|
||||
final Boolean complete) {
|
||||
public Page<DistributionSet> findDistributionSetsByDeletedAndOrCompleted(final Pageable pageReq,
|
||||
final Boolean deleted, final Boolean complete) {
|
||||
final List<Specification<JpaDistributionSet>> 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<JpaDistributionSetMetadata>) (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<JpaDistributionSetMetadata>) (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<DistributionSetMetadata> convertMdPage(final Page<JpaDistributionSetMetadata> findAll) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()));
|
||||
private static Page<DistributionSetMetadata> convertMdPage(final Page<JpaDistributionSetMetadata> 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<SoftwareModule> moduleList) {
|
||||
return new JpaDistributionSet(name, version, description, type, moduleList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countDistributionSetsByType(final DistributionSetType type) {
|
||||
return distributionSetRepository.countByType((JpaDistributionSetType) type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<RolloutGroup> findRolloutGroupsByRolloutId(final Long rolloutId, final Pageable page) {
|
||||
return convertPage(rolloutGroupRepository.findByRolloutId(rolloutId, page));
|
||||
public Page<RolloutGroup> findRolloutGroupsByRolloutId(final Long rolloutId, final Pageable pageable) {
|
||||
return convertPage(rolloutGroupRepository.findByRolloutId(rolloutId, pageable), pageable);
|
||||
}
|
||||
|
||||
private static Page<RolloutGroup> convertPage(final Slice<JpaRolloutGroup> findAll) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()));
|
||||
private static Page<RolloutGroup> convertPage(final Page<JpaRolloutGroup> findAll, final Pageable pageable) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
|
||||
private static Page<Target> convertTPage(final Page<JpaTarget> findAll) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()));
|
||||
private static Page<Target> convertTPage(final Page<JpaTarget> findAll, final Pageable pageable) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<RolloutGroup> findRolloutGroupsAll(final Rollout rollout, final String rsqlParam, final Pageable page) {
|
||||
public Page<RolloutGroup> findRolloutGroupsAll(final Rollout rollout, final String rsqlParam,
|
||||
final Pageable pageable) {
|
||||
|
||||
final Specification<JpaRolloutGroup> 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<RolloutGroup> findAllRolloutGroupsWithDetailedStatus(final Long rolloutId, final Pageable page) {
|
||||
final Page<JpaRolloutGroup> rolloutGroups = rolloutGroupRepository.findByRolloutId(rolloutId, page);
|
||||
public Page<RolloutGroup> findAllRolloutGroupsWithDetailedStatus(final Long rolloutId, final Pageable pageable) {
|
||||
final Page<JpaRolloutGroup> rolloutGroups = rolloutGroupRepository.findByRolloutId(rolloutId, pageable);
|
||||
final List<Long> rolloutGroupIds = rolloutGroups.getContent().stream().map(rollout -> rollout.getId())
|
||||
.collect(Collectors.toList());
|
||||
final Map<Long, List<TotalTargetCountActionStatus>> 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<Target> findRolloutGroupTargets(final RolloutGroup rolloutGroup, final String rsqlParam,
|
||||
final Pageable page) {
|
||||
final Pageable pageable) {
|
||||
|
||||
final Specification<JpaTarget> rsqlSpecification = RSQLUtility.parse(rsqlParam, TargetFields.class);
|
||||
|
||||
@@ -153,7 +154,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = root.join(JpaTarget_.rolloutTargetGroup);
|
||||
return criteriaBuilder.and(rsqlSpecification.toPredicate(root, query, criteriaBuilder),
|
||||
criteriaBuilder.equal(rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup), rolloutGroup));
|
||||
}, page));
|
||||
}, pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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<String> startingRollouts = ConcurrentHashMap.newKeySet();
|
||||
|
||||
@Override
|
||||
public Page<Rollout> findAll(final Pageable page) {
|
||||
return convertPage(rolloutRepository.findAll(page));
|
||||
public Page<Rollout> findAll(final Pageable pageable) {
|
||||
return convertPage(rolloutRepository.findAll(pageable), pageable);
|
||||
}
|
||||
|
||||
private static Page<Rollout> convertPage(final Slice<JpaRollout> findAll) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()));
|
||||
private static Page<Rollout> convertPage(final Page<JpaRollout> findAll, final Pageable pageable) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
|
||||
private static Slice<Rollout> convertPage(final Slice<JpaRollout> findAll, final Pageable pageable) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Rollout> findAllWithDetailedStatusByPredicate(final String rsqlParam, final Pageable page) {
|
||||
public Page<Rollout> findAllWithDetailedStatusByPredicate(final String rsqlParam, final Pageable pageable) {
|
||||
|
||||
final Specification<JpaRollout> specification = RSQLUtility.parse(rsqlParam, RolloutFields.class);
|
||||
|
||||
final Page<JpaRollout> findAll = rolloutRepository.findAll(specification, page);
|
||||
final Page<JpaRollout> 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<JpaRollout> specs = likeNameOrDescription(searchText);
|
||||
final Slice<JpaRollout> 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<Rollout> findAllRolloutsWithDetailedStatus(final Pageable page) {
|
||||
final Page<JpaRollout> rollouts = rolloutRepository.findAll(page);
|
||||
public Page<Rollout> findAllRolloutsWithDetailedStatus(final Pageable pageable) {
|
||||
final Page<JpaRollout> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<SoftwareModule> convertSmPage(final Slice<JpaSoftwareModule> findAll) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()));
|
||||
private static Slice<SoftwareModule> convertSmPage(final Slice<JpaSoftwareModule> findAll,
|
||||
final Pageable pageable) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, 0);
|
||||
}
|
||||
|
||||
private static Page<SoftwareModuleMetadata> convertSmMdPage(final Slice<JpaSoftwareModuleMetadata> findAll) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()));
|
||||
private static Page<SoftwareModule> convertSmPage(final Page<JpaSoftwareModule> findAll, final Pageable pageable) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
|
||||
private static Page<SoftwareModuleMetadata> convertSmMdPage(final Page<JpaSoftwareModuleMetadata> 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<SoftwareModule> findSoftwareModulesByPredicate(final String rsqlParam, final Pageable pageable) {
|
||||
final Specification<JpaSoftwareModule> spec = RSQLUtility.parse(rsqlParam, SoftwareModuleFields.class);
|
||||
|
||||
return convertSmPage(softwareModuleRepository.findAll(spec, pageable));
|
||||
return convertSmPage(softwareModuleRepository.findAll(spec, pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SoftwareModuleType> findSoftwareModuleTypesByPredicate(final String rsqlParam,
|
||||
final Pageable pageable) {
|
||||
public Page<SoftwareModuleType> findSoftwareModuleTypesAll(final String rsqlParam, final Pageable pageable) {
|
||||
|
||||
final Specification<JpaSoftwareModuleType> spec = RSQLUtility.parse(rsqlParam, SoftwareModuleTypeFields.class);
|
||||
|
||||
return convertSmTPage(softwareModuleTypeRepository.findAll(spec, pageable));
|
||||
return convertSmTPage(softwareModuleTypeRepository.findAll(spec, pageable), pageable);
|
||||
}
|
||||
|
||||
private static Page<SoftwareModuleType> convertSmTPage(final Slice<JpaSoftwareModuleType> findAll) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()));
|
||||
private static Page<SoftwareModuleType> convertSmTPage(final Page<JpaSoftwareModuleType> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -151,15 +151,16 @@ public class JpaTagManagement implements TagManagement {
|
||||
public Page<TargetTag> findAllTargetTags(final String rsqlParam, final Pageable pageable) {
|
||||
|
||||
final Specification<JpaTargetTag> spec = RSQLUtility.parse(rsqlParam, TagFields.class);
|
||||
return convertTPage(targetTagRepository.findAll(spec, pageable));
|
||||
return convertTPage(targetTagRepository.findAll(spec, pageable), pageable);
|
||||
}
|
||||
|
||||
private static Page<TargetTag> convertTPage(final Page<JpaTargetTag> findAll) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()));
|
||||
private static Page<TargetTag> convertTPage(final Page<JpaTargetTag> findAll, final Pageable pageable) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
|
||||
private static Page<DistributionSetTag> convertDsPage(final Page<JpaDistributionSetTag> findAll) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()));
|
||||
private static Page<DistributionSetTag> convertDsPage(final Page<JpaDistributionSetTag> 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<TargetTag> findAllTargetTags(final Pageable pageReq) {
|
||||
return convertTPage(targetTagRepository.findAll(pageReq));
|
||||
public Page<TargetTag> findAllTargetTags(final Pageable pageable) {
|
||||
return convertTPage(targetTagRepository.findAll(pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSetTag> findAllDistributionSetTags(final Pageable pageReq) {
|
||||
return convertDsPage(distributionSetTagRepository.findAll(pageReq));
|
||||
public Page<DistributionSetTag> findAllDistributionSetTags(final Pageable pageable) {
|
||||
return convertDsPage(distributionSetTagRepository.findAll(pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSetTag> findAllDistributionSetTags(final String rsqlParam, final Pageable pageable) {
|
||||
final Specification<JpaDistributionSetTag> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,11 +64,12 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
|
||||
@Override
|
||||
public Page<TargetFilterQuery> findAllTargetFilterQuery(final Pageable pageable) {
|
||||
return convertPage(targetFilterQueryRepository.findAll(pageable));
|
||||
return convertPage(targetFilterQueryRepository.findAll(pageable), pageable);
|
||||
}
|
||||
|
||||
private static Page<TargetFilterQuery> convertPage(final Page<JpaTargetFilterQuery> findAll) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()));
|
||||
private static Page<TargetFilterQuery> convertPage(final Page<JpaTargetFilterQuery> 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<JpaTargetFilterQuery> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<Target> findTargetsBySpec(final Specification<JpaTarget> 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<JpaTarget> spec = RSQLUtility.parse(rsqlParam, TargetFields.class);
|
||||
|
||||
return convertPage(targetRepository.findAll((Specification<JpaTarget>) (root, query, cb) -> cb.and(
|
||||
TargetSpecifications.hasAssignedDistributionSet(distributionSetID).toPredicate(root, query, cb),
|
||||
spec.toPredicate(root, query, cb)), pageReq));
|
||||
return convertPage(
|
||||
targetRepository
|
||||
.findAll((Specification<JpaTarget>) (root, query,
|
||||
cb) -> cb.and(TargetSpecifications.hasAssignedDistributionSet(distributionSetID)
|
||||
.toPredicate(root, query, cb), spec.toPredicate(root, query, cb)),
|
||||
pageReq),
|
||||
pageReq);
|
||||
}
|
||||
|
||||
private static Page<Target> convertPage(final Page<JpaTarget> findAll) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()));
|
||||
private static Page<Target> convertPage(final Page<JpaTarget> findAll, final Pageable pageable) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
|
||||
private static Slice<Target> convertPage(final Slice<JpaTarget> findAll) {
|
||||
return new PageImpl<>(new ArrayList<>(findAll.getContent()));
|
||||
private static Slice<Target> convertPage(final Slice<JpaTarget> 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<JpaTarget> spec = RSQLUtility.parse(rsqlParam, TargetFields.class);
|
||||
|
||||
return convertPage(targetRepository.findAll((Specification<JpaTarget>) (root, query, cb) -> cb.and(
|
||||
TargetSpecifications.hasInstalledDistributionSet(distributionSetId).toPredicate(root, query, cb),
|
||||
spec.toPredicate(root, query, cb)), pageable));
|
||||
return convertPage(
|
||||
targetRepository
|
||||
.findAll((Specification<JpaTarget>) (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<Target> findByCriteriaAPI(final Pageable pageable, final List<Specification<JpaTarget>> 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<Specification<JpaTarget>> specList) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Actions are managed by the SP server and applied to the targets by the
|
||||
* client.
|
||||
* <p>
|
||||
* 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() + "]";
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The {@link DistributionSet} is defined in the SP repository and contains at
|
||||
* least an OS and an Agent Hub.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* A {@link Target} has exactly one target {@link DistributionSet} assigned.
|
||||
* </p>
|
||||
* 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<DistributionSetTag> tags = new HashSet<>();
|
||||
|
||||
@Column(name = "deleted")
|
||||
private boolean deleted = false;
|
||||
private boolean deleted;
|
||||
|
||||
@OneToMany(mappedBy = "assignedDistributionSet", targetEntity = JpaTarget.class, fetch = FetchType.LAZY)
|
||||
private List<Target> 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<SoftwareModule> moduleList) {
|
||||
final DistributionSetType type, final Collection<SoftwareModule> 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<DistributionSetMetadata> getMetadata() {
|
||||
return Collections.unmodifiableList(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Action> getActions() {
|
||||
return actions;
|
||||
}
|
||||
@@ -182,23 +172,16 @@ public class JpaDistributionSet extends JpaNamedVersionedEntity implements Distr
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributionSet setTags(final Set<DistributionSetTag> tags) {
|
||||
this.tags = tags;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the assignedTargets
|
||||
*/
|
||||
@Override
|
||||
public List<Target> getAssignedTargets() {
|
||||
return assignedToTargets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the installedTargets
|
||||
*/
|
||||
@Override
|
||||
public List<TargetInfo> getInstalledTargets() {
|
||||
return installedAtTargets;
|
||||
@@ -210,10 +193,6 @@ public class JpaDistributionSet extends JpaNamedVersionedEntity implements Distr
|
||||
+ ", getId()=" + getId() + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return unmodifiableSet of {@link SoftwareModule}.
|
||||
*/
|
||||
@Override
|
||||
public Set<SoftwareModule> 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 <code>true</code> if the module was added and <code>false</code>
|
||||
* 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 <code>true</code> if element was found and removed
|
||||
*/
|
||||
@Override
|
||||
public boolean removeModule(final SoftwareModule softwareModule) {
|
||||
final Optional<SoftwareModule> 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 <code>null</code> if not in the
|
||||
* list.
|
||||
*/
|
||||
@Override
|
||||
public SoftwareModule findFirstModuleByType(final SoftwareModuleType type) {
|
||||
final Optional<SoftwareModule> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 <code>true</code> 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 <code>true</code> 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 <code>true</code> 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 <code>true</code> 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 <code>true</code> 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 <code>true</code> if the lists are identical.
|
||||
*/
|
||||
@Override
|
||||
public boolean areModuleEntriesIdentical(final DistributionSetType dsType) {
|
||||
return new HashSet<DistributionSetTypeElement>(((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 <code>true</code> 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())
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<RolloutGroup> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<DistributionSet> assignedTo = new ArrayList<>();
|
||||
|
||||
@Column(name = "deleted")
|
||||
private boolean deleted = false;
|
||||
private boolean deleted;
|
||||
|
||||
@Column(name = "vendor", nullable = true, length = 256)
|
||||
private String vendor;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Long>, Target {
|
||||
public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Long>, Target {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "controller_id", length = 64)
|
||||
@@ -82,7 +82,7 @@ public class JpaTarget extends JpaNamedEntity implements Persistable<Long>, 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<Long>, 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 })
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<Long>, 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<Long>, 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<Long>, TargetInfo {
|
||||
return controllerAttributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequestControllerAttributes() {
|
||||
return requestControllerAttributes;
|
||||
}
|
||||
@@ -275,63 +277,6 @@ public class JpaTargetInfo implements Persistable<Long>, 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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -50,4 +50,4 @@ public class RolloutTargetGroupId implements Serializable {
|
||||
public Long getTarget() {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <code>true</code> 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 <code>true</code> if {@link Action} is still running.
|
||||
*/
|
||||
boolean isActive();
|
||||
|
||||
/**
|
||||
* @return the {@link ActionType}
|
||||
*/
|
||||
ActionType getActionType();
|
||||
|
||||
/**
|
||||
* @return list of {@link ActionStatus} entries.
|
||||
*/
|
||||
List<ActionStatus> 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 <code>true</code> 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,
|
||||
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String> 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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
@@ -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<Long> {
|
||||
|
||||
/**
|
||||
* @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();
|
||||
|
||||
}
|
||||
@@ -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}.
|
||||
*
|
||||
* <p>
|
||||
* A {@link Target} has exactly one target {@link DistributionSet} assigned.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public interface DistributionSet extends NamedVersionedEntity {
|
||||
|
||||
/**
|
||||
* @return {@link Set} of assigned {@link DistributionSetTag}s.
|
||||
*/
|
||||
Set<DistributionSetTag> getTags();
|
||||
|
||||
/**
|
||||
* @return <code>true</code> 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<DistributionSetMetadata> getMetadata();
|
||||
|
||||
List<Action> getActions();
|
||||
|
||||
/**
|
||||
* @return <code>true</code> 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 <code>true</code> if {@link DistributionSet} is no longer
|
||||
* be usage but kept for history purposes.
|
||||
* @return updated {@link DistributionSet}
|
||||
*/
|
||||
DistributionSet setDeleted(boolean deleted);
|
||||
|
||||
/**
|
||||
* @param isRequiredMigrationStep
|
||||
* to <code>true</code> 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<DistributionSetTag> tags);
|
||||
|
||||
/**
|
||||
* @return the assignedTargets
|
||||
*/
|
||||
@@ -48,6 +84,9 @@ public interface DistributionSet extends NamedVersionedEntity {
|
||||
*/
|
||||
Set<SoftwareModule> 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 <code>true</code> if all defined
|
||||
* {@link DistributionSetType#getMandatoryModuleTypes()} of
|
||||
* {@link #getType()} are present in this {@link DistributionSet}.
|
||||
*/
|
||||
boolean isComplete();
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
@@ -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<DistributionSet> getAssignedToDistributionSet();
|
||||
|
||||
}
|
||||
@@ -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 <code>true</code> 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<SoftwareModuleType> getMandatoryModuleTypes();
|
||||
|
||||
/**
|
||||
* @return set of optional {@link SoftwareModuleType}s that can be in a
|
||||
* {@link DistributionSet} of this type.
|
||||
*/
|
||||
Set<SoftwareModuleType> 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 <code>true</code> 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);
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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<RolloutGroup> getRolloutGroups();
|
||||
|
||||
void setRolloutGroups(List<RolloutGroup> 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<JpaArtifact> generateArtifacts(final ArtifactManagement artifactManagement,
|
||||
public static List<AbstractJpaArtifact> generateArtifacts(final ArtifactManagement artifactManagement,
|
||||
final Long moduleId) {
|
||||
final List<JpaArtifact> artifacts = new ArrayList<>();
|
||||
final List<AbstractJpaArtifact> 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));
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -511,8 +511,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
final List<Long> deployedTargetIDs = deploymentResult.getDeployedTargetIDs();
|
||||
final List<Long> undeployedTargetIDs = deploymentResult.getUndeployedTargetIDs();
|
||||
final List<Target> savedNakedTargets = deploymentResult.getUndeployedTargets();
|
||||
final List<Target> savedDeployedTargets = deploymentResult.getDeployedTargets();
|
||||
final Collection<JpaTarget> savedNakedTargets = (Collection) deploymentResult.getUndeployedTargets();
|
||||
final Collection<JpaTarget> savedDeployedTargets = (Collection) deploymentResult.getDeployedTargets();
|
||||
|
||||
// retrieving all Actions created by the assignDistributionSet call
|
||||
final Page<JpaAction> 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<? extends JpaTarget>) 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<? extends JpaTarget>) 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<DistributionSet> allFoundDS = distributionSetManagement.findDistributionSetsAll(pageReq, false, true)
|
||||
.getContent();
|
||||
List<DistributionSet> 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);
|
||||
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class RSQLSoftwareModuleTypeFieldsTest extends AbstractIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {
|
||||
final Page<SoftwareModuleType> find = softwareManagement.findSoftwareModuleTypesByPredicate(rsqlParam,
|
||||
final Page<SoftwareModuleType> find = softwareManagement.findSoftwareModuleTypesAll(rsqlParam,
|
||||
new PageRequest(0, 100));
|
||||
final long countAll = find.getTotalElements();
|
||||
assertThat(find).isNotNull();
|
||||
|
||||
@@ -194,7 +194,7 @@ public class MultiTenancyEntityTest extends AbstractIntegrationTest {
|
||||
|
||||
private Page<DistributionSet> findDistributionSetForTenant(final String tenant) throws Exception {
|
||||
return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant),
|
||||
() -> distributionSetManagement.findDistributionSetsAll(pageReq, false, false));
|
||||
() -> distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, false));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user