Implement TargetFilterQueryManagement with AbstractJpaRepositoryManagement (#2587)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-08-05 09:53:24 +03:00
committed by GitHub
parent 1824839a6f
commit 7b24981a1d
36 changed files with 736 additions and 1482 deletions

View File

@@ -1,129 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.hawkbit.repository.builder;
import java.util.Optional;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import org.eclipse.hawkbit.repository.ValidString;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
/**
* Create and update builder DTO.
*
* @param <T> update or create builder interface
*/
public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractBaseEntityBuilder {
@ValidString
protected String name;
@ValidString
protected String query;
protected Long distributionSetId;
protected ActionType actionType;
@Min(Action.WEIGHT_MIN)
@Max(Action.WEIGHT_MAX)
protected Integer weight;
protected Boolean confirmationRequired;
/**
* Set DS ID of the {@link Action} created during auto assignment
*
* @param distributionSetId of the {@link TargetFilterQuery}
* @return this builder
*/
public T autoAssignDistributionSet(final Long distributionSetId) {
this.distributionSetId = distributionSetId;
return (T) this;
}
public Optional<Long> getAutoAssignDistributionSetId() {
return Optional.ofNullable(distributionSetId);
}
/**
* Set {@link ActionType} of the {@link Action} created during auto
* assignment
*
* @param actionType of the {@link TargetFilterQuery}
* @return this builder
*/
public T autoAssignActionType(final ActionType actionType) {
this.actionType = actionType;
return (T) this;
}
/**
* Set weight of the {@link Action} created during auto assignment
*
* @param weight of the {@link TargetFilterQuery}
* @return this builder
*/
public T autoAssignWeight(final Integer weight) {
this.weight = weight;
return (T) this;
}
public Optional<Integer> getAutoAssignWeight() {
return Optional.ofNullable(weight);
}
public Optional<ActionType> getAutoAssignActionType() {
return Optional.ofNullable(actionType);
}
/**
* Set name of the filter
*
* @param name of the {@link TargetFilterQuery}
* @return this builder
*/
public T name(final String name) {
this.name = AbstractBaseEntityBuilder.strip(name);
return (T) this;
}
public Optional<String> getName() {
return Optional.ofNullable(name);
}
/**
* Set query used by the filter
*
* @param query of the {@link TargetFilterQuery}
* @return this builder
*/
public T query(final String query) {
this.query = AbstractBaseEntityBuilder.strip(query);
return (T) this;
}
public Optional<String> getQuery() {
return Optional.ofNullable(query);
}
/**
* @param confirmationRequired if confirmation is required for configured auto assignment
* (considered with confirmation flow active)
* @return updated builder instance
*/
public T confirmationRequired(final boolean confirmationRequired) {
this.confirmationRequired = confirmationRequired;
return (T) this;
}
public Optional<Boolean> getConfirmationRequired() {
return Optional.ofNullable(confirmationRequired);
}
}

View File

@@ -1,21 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.hawkbit.repository.builder;
/**
* Update implementation.
*/
public class GenericTargetFilterQueryUpdate extends AbstractTargetFilterQueryUpdateCreate<TargetFilterQueryUpdate>
implements TargetFilterQueryUpdate {
public GenericTargetFilterQueryUpdate(final Long id) {
super.id = id;
}
}