Added auto assign distribution set to target filter query feature
Signed-off-by: Dominik Herbst <dominik.herbst@bosch-si.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Rollout Management properties.
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties("hawkbit.autoassign")
|
||||
public class AutoAssignProperties {
|
||||
/**
|
||||
* Autoassign scheduler configuration.
|
||||
*/
|
||||
public static class Scheduler {
|
||||
// used by @Scheduled annotation which needs constant
|
||||
public static final String PROP_SCHEDULER_DELAY_PLACEHOLDER = "${hawkbit.autoassign.scheduler.fixedDelay:60000}";
|
||||
|
||||
/**
|
||||
* Schedule where the autoassign scheduler looks necessary state changes in
|
||||
* milliseconds.
|
||||
*/
|
||||
private long fixedDelay = 60000L;
|
||||
|
||||
public long getFixedDelay() {
|
||||
return fixedDelay;
|
||||
}
|
||||
|
||||
public void setFixedDelay(final long fixedDelay) {
|
||||
this.fixedDelay = fixedDelay;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final Scheduler scheduler = new Scheduler();
|
||||
|
||||
public Scheduler getScheduler() {
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -104,6 +104,27 @@ public interface DeploymentManagement {
|
||||
DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID,
|
||||
@NotEmpty Collection<TargetWithActionType> targets);
|
||||
|
||||
/**
|
||||
* method assigns the {@link DistributionSet} to all {@link Target}s by
|
||||
* their IDs with a specific {@link ActionType} and an action message.
|
||||
*
|
||||
* @param dsID
|
||||
* the ID of the distribution set to assign
|
||||
* @param targets
|
||||
* a list of all targets and their action type
|
||||
* @param actionMessage
|
||||
* an optional message for the action status
|
||||
* @return the assignment result
|
||||
*
|
||||
* @throw IncompleteDistributionSetException if mandatory
|
||||
* {@link SoftwareModuleType} are not assigned as define by the
|
||||
* {@link DistributionSetType}.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
|
||||
DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID,
|
||||
@NotEmpty Collection<TargetWithActionType> targets,
|
||||
String actionMessage);
|
||||
|
||||
/**
|
||||
* method assigns the {@link DistributionSet} to all {@link Target}s by
|
||||
* their IDs with a specific {@link ActionType} and {@code forcetime}.
|
||||
@@ -364,9 +385,6 @@ public interface DeploymentManagement {
|
||||
* pagination parameter
|
||||
* @param action
|
||||
* to be filtered on
|
||||
* @param withMessages
|
||||
* to <code>true</code> if {@link ActionStatus#getMessages()}
|
||||
* need to be fetched.
|
||||
* @return the corresponding {@link Page} of {@link ActionStatus}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
@@ -463,8 +481,6 @@ public interface DeploymentManagement {
|
||||
*
|
||||
* @param action
|
||||
* to be canceled
|
||||
* @param target
|
||||
* for which the action needs cancellation
|
||||
*
|
||||
* @return generated {@link Action} or <code>null</code> if not active on
|
||||
* {@link Target}.
|
||||
@@ -478,8 +494,6 @@ public interface DeploymentManagement {
|
||||
* Updates a {@link Action} and forces the {@link Action} if it's not
|
||||
* already forced.
|
||||
*
|
||||
* @param targetId
|
||||
* the ID of the target
|
||||
* @param actionId
|
||||
* the ID of the action
|
||||
* @return the updated or the found {@link Action}
|
||||
|
||||
@@ -316,6 +316,30 @@ public interface EntityFactory {
|
||||
*/
|
||||
TargetFilterQuery generateTargetFilterQuery();
|
||||
|
||||
/**
|
||||
* Generates an {@link TargetFilterQuery} without persisting it.
|
||||
*
|
||||
* @param name
|
||||
* name for the filter
|
||||
* @param query
|
||||
* query of the filter
|
||||
* @return {@link TargetFilterQuery} object
|
||||
*/
|
||||
TargetFilterQuery generateTargetFilterQuery(String name, String query);
|
||||
|
||||
/**
|
||||
* Generates an {@link TargetFilterQuery} without persisting it.
|
||||
*
|
||||
* @param name
|
||||
* name for the filter
|
||||
* @param query
|
||||
* query of the filter
|
||||
* @param autoAssignDS
|
||||
* auto assign distribution set
|
||||
* @return {@link TargetFilterQuery} object
|
||||
*/
|
||||
TargetFilterQuery generateTargetFilterQuery(String name, String query, DistributionSet autoAssignDS);
|
||||
|
||||
/**
|
||||
* Generates an empty {@link TargetTag} without persisting it.
|
||||
*
|
||||
|
||||
@@ -13,6 +13,7 @@ import javax.validation.constraints.NotNull;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -70,6 +71,13 @@ public interface TargetFilterQueryManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findAllTargetFilterQuery(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Counts all target filter queries
|
||||
* @return the number of all target filter queries
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countAllTargetFilterQuery();
|
||||
|
||||
/**
|
||||
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
||||
*
|
||||
@@ -77,11 +85,64 @@ public interface TargetFilterQueryManagement {
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @param name
|
||||
* target filter query name
|
||||
* name filter
|
||||
* @return the page with the found {@link TargetFilterQuery}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByFilters(@NotNull Pageable pageable, String name);
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByName(@NotNull Pageable pageable, String name);
|
||||
|
||||
/**
|
||||
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
||||
*
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @param rsqlFilter
|
||||
* RSQL filter string
|
||||
* @return the page with the found {@link TargetFilterQuery}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByFilter(@NotNull Pageable pageable, String rsqlFilter);
|
||||
|
||||
/**
|
||||
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
||||
*
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @param distributionSet
|
||||
* the auto assign distribution set
|
||||
* @return the page with the found {@link TargetFilterQuery}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByAutoAssignDS(@NotNull Pageable pageable,
|
||||
DistributionSet distributionSet);
|
||||
|
||||
/**
|
||||
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
||||
*
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @param distributionSet
|
||||
* the auto assign distribution set
|
||||
* @param rsqlParam
|
||||
* RSQL filter
|
||||
* @return the page with the found {@link TargetFilterQuery}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByAutoAssignDS(@NotNull Pageable pageable,
|
||||
DistributionSet distributionSet, String rsqlParam);
|
||||
|
||||
/**
|
||||
* Retrieves all target filter query with auto assign DS which {@link TargetFilterQuery}.
|
||||
*
|
||||
*
|
||||
* @return the page with the found {@link TargetFilterQuery}
|
||||
* @param pageable
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findTargetFilterQueryWithAutoAssignDS(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Find target filter query by id.
|
||||
|
||||
@@ -242,6 +242,35 @@ public interface TargetManagement {
|
||||
List<TargetIdName> findAllTargetIdsByTargetFilterQuery(@NotNull Pageable pageRequest,
|
||||
@NotNull TargetFilterQuery targetFilterQuery);
|
||||
|
||||
/**
|
||||
* Finds all targets for all the given parameter {@link TargetFilterQuery}
|
||||
* and that don't have the specified assigned distribution set.
|
||||
* and returns not the full target but {@link TargetIdName}.
|
||||
*
|
||||
* @param pageRequest
|
||||
* the pageRequest to enhance the query for paging and sorting
|
||||
* @param targetFilterQuery
|
||||
* {@link TargetFilterQuery}
|
||||
* @return the found {@link TargetIdName}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Target> findAllTargetIdsByTargetFilterQueryAndNonDS(@NotNull Pageable pageRequest,
|
||||
Long distributionSetId,
|
||||
@NotNull TargetFilterQuery targetFilterQuery);
|
||||
|
||||
/**
|
||||
* Counts all targets for all the given parameter {@link TargetFilterQuery}
|
||||
* and that don't have the specified assigned distribution set. and returns
|
||||
* not the full target but {@link TargetIdName}.
|
||||
*
|
||||
* @param targetFilterQuery
|
||||
* {@link TargetFilterQuery}
|
||||
* @return the found {@link TargetIdName}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countTargetByTargetFilterQueryAndNonDS(Long distributionSetId,
|
||||
@NotNull TargetFilterQuery targetFilterQuery);
|
||||
|
||||
/**
|
||||
* retrieves {@link Target}s by the assigned {@link DistributionSet} without
|
||||
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
|
||||
|
||||
@@ -73,6 +73,11 @@ public interface DistributionSet extends NamedVersionedEntity {
|
||||
*/
|
||||
List<Target> getAssignedTargets();
|
||||
|
||||
/**
|
||||
* @return the auto assign target filters
|
||||
*/
|
||||
List<TargetFilterQuery> getAutoAssignFilters();
|
||||
|
||||
/**
|
||||
* @return the installedTargets
|
||||
*/
|
||||
|
||||
@@ -56,4 +56,16 @@ public interface TargetFilterQuery extends TenantAwareBaseEntity {
|
||||
*/
|
||||
void setQuery(String query);
|
||||
|
||||
/**
|
||||
* @return the auto assign {@link DistributionSet} if given.
|
||||
*/
|
||||
DistributionSet getAutoAssignDistributionSet();
|
||||
|
||||
/**
|
||||
* @param distributionSet
|
||||
* the {@link DistributionSet} that should be assigned to a
|
||||
* target when this filter matches.
|
||||
*/
|
||||
void setAutoAssignDistributionSet(DistributionSet distributionSet);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user