Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -89,6 +89,11 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
||||
this.quotaManagement = quotaManagement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<TargetType> getByKey(final String key) {
|
||||
return targetTypeRepository.findOne(TargetTypeSpecification.hasKey(key)).map(TargetType.class::cast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<TargetType> getByName(final String name) {
|
||||
return targetTypeRepository.findOne(TargetTypeSpecification.hasName(name)).map(TargetType.class::cast);
|
||||
|
||||
@@ -50,18 +50,7 @@ public interface TargetTypeRepository
|
||||
* {@link TargetType#getName()}
|
||||
*/
|
||||
default List<JpaTargetType> findByDsType(@Param("id") final Long dsTypeId) {
|
||||
return this.findAll(Specification.where(TargetTypeSpecification.hasDsSetType(dsTypeId)));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* to search for
|
||||
* @return all {@link TargetType}s in the repository with given
|
||||
* {@link TargetType#getName()}
|
||||
*/
|
||||
default Optional<JpaTargetType> findByName(final String name) {
|
||||
return this.findOne(Specification.where(TargetTypeSpecification.hasName(name)));
|
||||
return findAll(Specification.where(TargetTypeSpecification.hasDsSetType(dsTypeId)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -133,6 +133,18 @@ public final class TargetTypeSpecification {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Specification} for retrieving {@link TargetType} with
|
||||
* given {@link TargetType#getKey()} including fetching the
|
||||
* elements list.
|
||||
*
|
||||
* @param key
|
||||
* to search
|
||||
* @return the {@link TargetType} {@link Specification}
|
||||
*/
|
||||
public static Specification<JpaTargetType> hasKey(final String key) {
|
||||
return (targetRoot, query, cb) -> cb.equal(targetRoot.get(JpaTargetType_.key), key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Specification} for retrieving {@link TargetType} with
|
||||
|
||||
Reference in New Issue
Block a user