Feature target with target type in UI (#1178)
* Added the target type combo box to add or update Target in UI Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed NPE for empty target type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target type option to target bulk upload Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added Target type filter Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added Named entity mapper for target type UI Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed review comments Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed sonar issues for serialization Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed Review comments Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed Bulk upload target type combo box Signed-off-by: Anand kumar <anand.kumar@bosch-si.com>
This commit is contained in:
@@ -14,7 +14,6 @@ import org.eclipse.hawkbit.repository.builder.TargetTypeUpdate;
|
||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@@ -84,6 +83,18 @@ public interface TargetTypeManagement {
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetType> findByRsql(@NotNull Pageable pageable, @NotEmpty String rsqlParam);
|
||||
|
||||
/**
|
||||
* Retrieves {@link TargetType}s by filtering on the given parameters.
|
||||
*
|
||||
* @param pageable
|
||||
* page parameter
|
||||
* @param name
|
||||
* has text of filters to be applied.
|
||||
* @return the page of found {@link TargetType}
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetType> findByName(@NotNull Pageable pageable, String name);
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* Target type ID
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.springframework.orm.jpa.vendor.Database;
|
||||
import org.springframework.retry.annotation.Backoff;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
@@ -139,6 +140,11 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
||||
return convertPage(targetTypeRepository.findAll(spec, pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetType> findByName(Pageable pageable, String name) {
|
||||
return convertPage(targetTypeRepository.findAll(TargetTypeSpecification.likeName(name), pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<TargetType> get(final long id) {
|
||||
return targetTypeRepository.findById(id).map(targetType -> targetType);
|
||||
|
||||
@@ -146,4 +146,14 @@ public final class TargetTypeSpecification {
|
||||
return (targetRoot, query, cb) -> cb.equal(targetRoot.get(JpaTargetType_.name), name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Specification} for retrieving {@link TargetType}s by "like name".
|
||||
*
|
||||
* @param name
|
||||
* to be filtered on
|
||||
* @return the {@link TargetType} {@link Specification}
|
||||
*/
|
||||
public static Specification<JpaTargetType> likeName(final String name) {
|
||||
return (targetRoot, query, cb) -> cb.like(cb.lower(targetRoot.get(JpaTargetType_.name)), name.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user