Move Query Language (RSQL) in separate package and add Entity Matcher (#2531)
* Move Query Language (RSQL) in separate package - hawkbit-repository-ql * Add Entity Matcher which match an entity object agains filter * Spec to string utils now in runtime (as a library) - could be used in tests or to dump something in runtimes * Move eclipselink/hibernate profiles in new QL module, this way provided / set to hawkbit-repository-jpa * Remove unused javax.el imports
This commit is contained in:
@@ -70,11 +70,6 @@
|
|||||||
<classifier>tests</classifier>
|
<classifier>tests</classifier>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>javax.el</groupId>
|
|
||||||
<artifactId>javax.el-api</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.security</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<artifactId>spring-security-config</artifactId>
|
<artifactId>spring-security-config</artifactId>
|
||||||
|
|||||||
@@ -78,11 +78,6 @@
|
|||||||
<classifier>tests</classifier>
|
<classifier>tests</classifier>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>javax.el</groupId>
|
|
||||||
<artifactId>javax.el-api</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-json</artifactId>
|
<artifactId>spring-boot-starter-json</artifactId>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
<artifactId>hawkbit-repository-api</artifactId>
|
<artifactId>hawkbit-repository-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-text</artifactId>
|
<artifactId>commons-text</artifactId>
|
||||||
|
|||||||
@@ -26,78 +26,10 @@
|
|||||||
<jpa.vendor>eclipselink</jpa.vendor>
|
<jpa.vendor>eclipselink</jpa.vendor>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>eclipselink</id>
|
|
||||||
<activation>
|
|
||||||
<property>
|
|
||||||
<!-- default, if not set (or not hibernate) - eclipse link -->
|
|
||||||
<name>jpa.vendor</name>
|
|
||||||
<value>!hibernate</value>
|
|
||||||
</property>
|
|
||||||
</activation>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
|
||||||
<artifactId>hawkbit-repository-jpa-eclipselink</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<!-- Static weaver for EclipseLink -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>com.ethlo.persistence.tools</groupId>
|
|
||||||
<artifactId>eclipselink-maven-plugin</artifactId>
|
|
||||||
<version>${eclipselink.maven.plugin.version}</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>process-classes</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>weave</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<basePackage>org.eclipse.hawkbit.repository.jpa.model</basePackage>
|
|
||||||
</configuration>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.persistence</groupId>
|
|
||||||
<artifactId>org.eclipse.persistence.jpa</artifactId>
|
|
||||||
<version>${eclipselink.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
|
||||||
<id>hibernate</id>
|
|
||||||
<activation>
|
|
||||||
<property>
|
|
||||||
<name>jpa.vendor</name>
|
|
||||||
<value>hibernate</value>
|
|
||||||
</property>
|
|
||||||
</activation>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
|
||||||
<artifactId>hawkbit-repository-jpa-hibernate</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Hawkbit -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-repository-jpa-api</artifactId>
|
<artifactId>hawkbit-repository-ql</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -126,10 +58,6 @@
|
|||||||
<groupId>org.springframework.integration</groupId>
|
<groupId>org.springframework.integration</groupId>
|
||||||
<artifactId>spring-integration-jdbc</artifactId>
|
<artifactId>spring-integration-jdbc</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>cz.jirutka.rsql</groupId>
|
|
||||||
<artifactId>rsql-parser</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jsoup</groupId>
|
<groupId>org.jsoup</groupId>
|
||||||
<artifactId>jsoup</artifactId>
|
<artifactId>jsoup</artifactId>
|
||||||
@@ -150,11 +78,6 @@
|
|||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>javax.el</groupId>
|
|
||||||
<artifactId>javax.el-api</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Enable metrics -->
|
<!-- Enable metrics -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
|||||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.SystemSecurityContextHolder;
|
import org.eclipse.hawkbit.repository.model.helper.SystemSecurityContextHolder;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.TenantConfigurationManagementHolder;
|
import org.eclipse.hawkbit.repository.model.helper.TenantConfigurationManagementHolder;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder;
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||||
import org.eclipse.hawkbit.security.HawkbitSecurityProperties;
|
import org.eclipse.hawkbit.security.HawkbitSecurityProperties;
|
||||||
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaTarget_;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.repository.ActionRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.ActionRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.ActionStatusRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.ActionStatusRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlUtility;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.ActionSpecifications;
|
import org.eclipse.hawkbit.repository.jpa.specifications.ActionSpecifications;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.TargetSpecifications;
|
import org.eclipse.hawkbit.repository.jpa.specifications.TargetSpecifications;
|
||||||
import org.eclipse.hawkbit.repository.jpa.utils.DeploymentHelper;
|
import org.eclipse.hawkbit.repository.jpa.utils.DeploymentHelper;
|
||||||
@@ -274,7 +274,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
assertTargetReadAllowed(controllerId);
|
assertTargetReadAllowed(controllerId);
|
||||||
|
|
||||||
final List<Specification<JpaAction>> specList = Arrays.asList(
|
final List<Specification<JpaAction>> specList = Arrays.asList(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database),
|
||||||
ActionSpecifications.byTargetControllerId(controllerId));
|
ActionSpecifications.byTargetControllerId(controllerId));
|
||||||
|
|
||||||
return JpaManagementHelper.countBySpec(actionRepository, specList);
|
return JpaManagementHelper.countBySpec(actionRepository, specList);
|
||||||
@@ -288,7 +288,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
@Override
|
@Override
|
||||||
public long countActions(final String rsql) {
|
public long countActions(final String rsql) {
|
||||||
final List<Specification<JpaAction>> specList = List.of(
|
final List<Specification<JpaAction>> specList = List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database));
|
RsqlUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database));
|
||||||
return JpaManagementHelper.countBySpec(actionRepository, specList);
|
return JpaManagementHelper.countBySpec(actionRepository, specList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +313,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
@Override
|
@Override
|
||||||
public Slice<Action> findActions(final String rsql, final Pageable pageable) {
|
public Slice<Action> findActions(final String rsql, final Pageable pageable) {
|
||||||
final List<Specification<JpaAction>> specList = List.of(
|
final List<Specification<JpaAction>> specList = List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database));
|
RsqlUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database));
|
||||||
return JpaManagementHelper.findAllWithoutCountBySpec(actionRepository, specList, pageable);
|
return JpaManagementHelper.findAllWithoutCountBySpec(actionRepository, specList, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +322,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
assertTargetReadAllowed(controllerId);
|
assertTargetReadAllowed(controllerId);
|
||||||
|
|
||||||
final List<Specification<JpaAction>> specList = Arrays.asList(
|
final List<Specification<JpaAction>> specList = Arrays.asList(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database),
|
||||||
ActionSpecifications.byTargetControllerId(controllerId));
|
ActionSpecifications.byTargetControllerId(controllerId));
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(actionRepository, specList, pageable);
|
return JpaManagementHelper.findAllWithCountBySpec(actionRepository, specList, pageable);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTagRepositor
|
|||||||
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetFilterQueryRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.TargetFilterQueryRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlUtility;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetSpecification;
|
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetSpecification;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.TargetSpecifications;
|
import org.eclipse.hawkbit.repository.jpa.specifications.TargetSpecifications;
|
||||||
import org.eclipse.hawkbit.repository.jpa.utils.QuotaHelper;
|
import org.eclipse.hawkbit.repository.jpa.utils.QuotaHelper;
|
||||||
@@ -282,7 +282,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Override
|
@Override
|
||||||
public Page<DistributionSet> findByRsql(final String rsql, final Pageable pageable) {
|
public Page<DistributionSet> findByRsql(final String rsql, final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, List.of(
|
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, DistributionSetFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, DistributionSetFields.class, virtualPropertyReplacer, database),
|
||||||
DistributionSetSpecification.isNotDeleted()), pageable);
|
DistributionSetSpecification.isNotDeleted()), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,7 +551,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
assertDsTagExists(tagId);
|
assertDsTagExists(tagId);
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, List.of(
|
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, DistributionSetFields.class, virtualPropertyReplacer,
|
RsqlUtility.buildRsqlSpecification(rsql, DistributionSetFields.class, virtualPropertyReplacer,
|
||||||
database),
|
database),
|
||||||
DistributionSetSpecification.hasTag(tagId), DistributionSetSpecification.isNotDeleted()), pageable);
|
DistributionSetSpecification.hasTag(tagId), DistributionSetSpecification.isNotDeleted()), pageable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTagRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTagRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlUtility;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetTagSpecifications;
|
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetTagSpecifications;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.TagSpecification;
|
import org.eclipse.hawkbit.repository.jpa.specifications.TagSpecification;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
@@ -155,7 +155,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSetTag> findByRsql(final String rsql, final Pageable pageable) {
|
public Page<DistributionSetTag> findByRsql(final String rsql, final Pageable pageable) {
|
||||||
final Specification<JpaDistributionSetTag> spec = RSQLUtility.buildRsqlSpecification(
|
final Specification<JpaDistributionSetTag> spec = RsqlUtility.buildRsqlSpecification(
|
||||||
rsql, DistributionSetTagFields.class, virtualPropertyReplacer, database);
|
rsql, DistributionSetTagFields.class, virtualPropertyReplacer, database);
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTagRepository, Collections.singletonList(spec), pageable);
|
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTagRepository, Collections.singletonList(spec), pageable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetRepository;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTypeRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTypeRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleTypeRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleTypeRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetTypeRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.TargetTypeRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlUtility;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetTypeSpecification;
|
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetTypeSpecification;
|
||||||
import org.eclipse.hawkbit.repository.jpa.utils.QuotaHelper;
|
import org.eclipse.hawkbit.repository.jpa.utils.QuotaHelper;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||||
@@ -198,7 +198,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
@Override
|
@Override
|
||||||
public Page<DistributionSetType> findByRsql(final String rsql, final Pageable pageable) {
|
public Page<DistributionSetType> findByRsql(final String rsql, final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTypeRepository, List.of(
|
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTypeRepository, List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, DistributionSetTypeFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, DistributionSetTypeFields.class, virtualPropertyReplacer, database),
|
||||||
DistributionSetTypeSpecification.isNotDeleted()), pageable);
|
DistributionSetTypeSpecification.isNotDeleted()), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import org.eclipse.hawkbit.repository.jpa.repository.ActionRepository;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.repository.RolloutGroupRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.RolloutGroupRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.RolloutRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.RolloutRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlUtility;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.TargetSpecifications;
|
import org.eclipse.hawkbit.repository.jpa.specifications.TargetSpecifications;
|
||||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||||
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
|
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
|
||||||
@@ -122,7 +122,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
|||||||
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
||||||
|
|
||||||
final List<Specification<JpaRolloutGroup>> specList = Arrays.asList(
|
final List<Specification<JpaRolloutGroup>> specList = Arrays.asList(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, RolloutGroupFields.class, virtualPropertyReplacer,
|
RsqlUtility.buildRsqlSpecification(rsql, RolloutGroupFields.class, virtualPropertyReplacer,
|
||||||
database),
|
database),
|
||||||
(root, query, cb) -> cb.equal(root.get(JpaRolloutGroup_.rollout).get(AbstractJpaBaseEntity_.id), rolloutId));
|
(root, query, cb) -> cb.equal(root.get(JpaRolloutGroup_.rollout).get(AbstractJpaBaseEntity_.id), rolloutId));
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
|||||||
throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId);
|
throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId);
|
||||||
|
|
||||||
final List<Specification<JpaTarget>> specList = Arrays.asList(
|
final List<Specification<JpaTarget>> specList = Arrays.asList(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||||
(root, query, cb) -> {
|
(root, query, cb) -> {
|
||||||
final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = root.join(JpaTarget_.rolloutTargetGroup);
|
final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = root.join(JpaTarget_.rolloutTargetGroup);
|
||||||
return cb.equal(rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup).get(AbstractJpaBaseEntity_.id), rolloutGroupId);
|
return cb.equal(rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup).get(AbstractJpaBaseEntity_.id), rolloutGroupId);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ import org.eclipse.hawkbit.repository.jpa.repository.ActionRepository;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.repository.RolloutGroupRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.RolloutGroupRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.RolloutRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.RolloutRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rollout.condition.StartNextGroupRolloutGroupSuccessAction;
|
import org.eclipse.hawkbit.repository.jpa.rollout.condition.StartNextGroupRolloutGroupSuccessAction;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlUtility;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.RolloutSpecification;
|
import org.eclipse.hawkbit.repository.jpa.specifications.RolloutSpecification;
|
||||||
import org.eclipse.hawkbit.repository.jpa.utils.QuotaHelper;
|
import org.eclipse.hawkbit.repository.jpa.utils.QuotaHelper;
|
||||||
import org.eclipse.hawkbit.repository.jpa.utils.WeightValidationHelper;
|
import org.eclipse.hawkbit.repository.jpa.utils.WeightValidationHelper;
|
||||||
@@ -273,7 +273,7 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
@Override
|
@Override
|
||||||
public Page<Rollout> findByRsql(final String rsql, final boolean deleted, final Pageable pageable) {
|
public Page<Rollout> findByRsql(final String rsql, final boolean deleted, final Pageable pageable) {
|
||||||
final List<Specification<JpaRollout>> specList = List.of(
|
final List<Specification<JpaRollout>> specList = List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, RolloutFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, RolloutFields.class, virtualPropertyReplacer, database),
|
||||||
RolloutSpecification.isDeleted(deleted, pageable.getSort()));
|
RolloutSpecification.isDeleted(deleted, pageable.getSort()));
|
||||||
return JpaManagementHelper.convertPage(rolloutRepository.findAll(JpaManagementHelper.combineWithAnd(specList), pageable), pageable);
|
return JpaManagementHelper.convertPage(rolloutRepository.findAll(JpaManagementHelper.combineWithAnd(specList), pageable), pageable);
|
||||||
}
|
}
|
||||||
@@ -281,7 +281,7 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
@Override
|
@Override
|
||||||
public Page<Rollout> findByRsqlWithDetailedStatus(final String rsql, final boolean deleted, final Pageable pageable) {
|
public Page<Rollout> findByRsqlWithDetailedStatus(final String rsql, final boolean deleted, final Pageable pageable) {
|
||||||
final List<Specification<JpaRollout>> specList = List.of(
|
final List<Specification<JpaRollout>> specList = List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, RolloutFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, RolloutFields.class, virtualPropertyReplacer, database),
|
||||||
RolloutSpecification.isDeleted(deleted, pageable.getSort()));
|
RolloutSpecification.isDeleted(deleted, pageable.getSort()));
|
||||||
return appendStatusDetails(JpaManagementHelper.convertPage(
|
return appendStatusDetails(JpaManagementHelper.convertPage(
|
||||||
rolloutRepository.findAll(JpaManagementHelper.combineWithAnd(specList), JpaRollout_.GRAPH_ROLLOUT_DS, pageable), pageable));
|
rolloutRepository.findAll(JpaManagementHelper.combineWithAnd(specList), JpaRollout_.GRAPH_ROLLOUT_DS, pageable), pageable));
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetRepository;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleMetadataRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleMetadataRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleTypeRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleTypeRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlUtility;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.SoftwareModuleSpecification;
|
import org.eclipse.hawkbit.repository.jpa.specifications.SoftwareModuleSpecification;
|
||||||
import org.eclipse.hawkbit.repository.jpa.utils.QuotaHelper;
|
import org.eclipse.hawkbit.repository.jpa.utils.QuotaHelper;
|
||||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||||
@@ -261,7 +261,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
@Override
|
@Override
|
||||||
public Page<SoftwareModule> findByRsql(final String rsql, final Pageable pageable) {
|
public Page<SoftwareModule> findByRsql(final String rsql, final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleRepository, List.of(
|
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleRepository, List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, SoftwareModuleFields.class, virtualPropertyReplacer,
|
RsqlUtility.buildRsqlSpecification(rsql, SoftwareModuleFields.class, virtualPropertyReplacer,
|
||||||
database),
|
database),
|
||||||
SoftwareModuleSpecification.isNotDeleted()), pageable);
|
SoftwareModuleSpecification.isNotDeleted()), pageable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTypeRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTypeRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleTypeRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleTypeRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlUtility;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.SoftwareModuleTypeSpecification;
|
import org.eclipse.hawkbit.repository.jpa.specifications.SoftwareModuleTypeSpecification;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||||
@@ -144,7 +144,7 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
@Override
|
@Override
|
||||||
public Page<SoftwareModuleType> findByRsql(final String rsql, final Pageable pageable) {
|
public Page<SoftwareModuleType> findByRsql(final String rsql, final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleTypeRepository, List.of(
|
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleTypeRepository, List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, SoftwareModuleTypeFields.class,
|
RsqlUtility.buildRsqlSpecification(rsql, SoftwareModuleTypeFields.class,
|
||||||
virtualPropertyReplacer, database),
|
virtualPropertyReplacer, database),
|
||||||
SoftwareModuleTypeSpecification.isNotDeleted()), pageable
|
SoftwareModuleTypeSpecification.isNotDeleted()), pageable
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetFilterQuery;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetFilterQuery;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetFilterQueryRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.TargetFilterQueryRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlUtility;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.TargetFilterQuerySpecification;
|
import org.eclipse.hawkbit.repository.jpa.specifications.TargetFilterQuerySpecification;
|
||||||
import org.eclipse.hawkbit.repository.jpa.utils.QuotaHelper;
|
import org.eclipse.hawkbit.repository.jpa.utils.QuotaHelper;
|
||||||
import org.eclipse.hawkbit.repository.jpa.utils.WeightValidationHelper;
|
import org.eclipse.hawkbit.repository.jpa.utils.WeightValidationHelper;
|
||||||
@@ -119,7 +119,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
|
|
||||||
create.getQuery().ifPresent(query -> {
|
create.getQuery().ifPresent(query -> {
|
||||||
// validate the RSQL query syntax
|
// validate the RSQL query syntax
|
||||||
RSQLUtility.validateRsqlFor(query, TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
RsqlUtility.validateRsqlFor(query, TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
||||||
|
|
||||||
// enforce the 'max targets per auto assign' quota right here even
|
// enforce the 'max targets per auto assign' quota right here even
|
||||||
// if the result of the filter query can vary over time
|
// if the result of the filter query can vary over time
|
||||||
@@ -148,7 +148,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
@Override
|
@Override
|
||||||
public boolean verifyTargetFilterQuerySyntax(final String query) {
|
public boolean verifyTargetFilterQuerySyntax(final String query) {
|
||||||
try {
|
try {
|
||||||
RSQLUtility.validateRsqlFor(query, TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
RsqlUtility.validateRsqlFor(query, TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
||||||
return true;
|
return true;
|
||||||
} catch (final RSQLParserException | RSQLParameterUnsupportedFieldException e) {
|
} catch (final RSQLParserException | RSQLParameterUnsupportedFieldException e) {
|
||||||
log.debug("The RSQL query '{}}' is invalid.", query, e);
|
log.debug("The RSQL query '{}}' is invalid.", query, e);
|
||||||
@@ -195,7 +195,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
@Override
|
@Override
|
||||||
public Page<TargetFilterQuery> findByRsql(final String rsqlFilter, final Pageable pageable) {
|
public Page<TargetFilterQuery> findByRsql(final String rsqlFilter, final Pageable pageable) {
|
||||||
final List<Specification<JpaTargetFilterQuery>> specList = !ObjectUtils.isEmpty(rsqlFilter)
|
final List<Specification<JpaTargetFilterQuery>> specList = !ObjectUtils.isEmpty(rsqlFilter)
|
||||||
? Collections.singletonList(RSQLUtility.buildRsqlSpecification(rsqlFilter,
|
? Collections.singletonList(RsqlUtility.buildRsqlSpecification(rsqlFilter,
|
||||||
TargetFilterQueryFields.class, virtualPropertyReplacer, database))
|
TargetFilterQueryFields.class, virtualPropertyReplacer, database))
|
||||||
: Collections.emptyList();
|
: Collections.emptyList();
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
final List<Specification<JpaTargetFilterQuery>> specList = new ArrayList<>(2);
|
final List<Specification<JpaTargetFilterQuery>> specList = new ArrayList<>(2);
|
||||||
specList.add(TargetFilterQuerySpecification.byAutoAssignDS(distributionSet));
|
specList.add(TargetFilterQuerySpecification.byAutoAssignDS(distributionSet));
|
||||||
if (!ObjectUtils.isEmpty(rsql)) {
|
if (!ObjectUtils.isEmpty(rsql)) {
|
||||||
specList.add(RSQLUtility.buildRsqlSpecification(rsql, TargetFilterQueryFields.class,
|
specList.add(RsqlUtility.buildRsqlSpecification(rsql, TargetFilterQueryFields.class,
|
||||||
virtualPropertyReplacer, database));
|
virtualPropertyReplacer, database));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ import org.eclipse.hawkbit.repository.jpa.repository.TargetFilterQueryRepository
|
|||||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetTagRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.TargetTagRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetTypeRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.TargetTypeRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlUtility;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.SpecificationsBuilder;
|
import org.eclipse.hawkbit.repository.jpa.specifications.SpecificationsBuilder;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.TargetSpecifications;
|
import org.eclipse.hawkbit.repository.jpa.specifications.TargetSpecifications;
|
||||||
import org.eclipse.hawkbit.repository.jpa.utils.QuotaHelper;
|
import org.eclipse.hawkbit.repository.jpa.utils.QuotaHelper;
|
||||||
@@ -157,13 +157,13 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
public long countByRsql(final String rsql) {
|
public long countByRsql(final String rsql) {
|
||||||
return JpaManagementHelper.countBySpec(
|
return JpaManagementHelper.countBySpec(
|
||||||
targetRepository,
|
targetRepository,
|
||||||
List.of(RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database)));
|
List.of(RsqlUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long countByRsqlAndUpdatable(String rsql) {
|
public long countByRsqlAndUpdatable(String rsql) {
|
||||||
final List<Specification<JpaTarget>> specList = List.of(
|
final List<Specification<JpaTarget>> specList = List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database));
|
RsqlUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database));
|
||||||
return targetRepository.count(
|
return targetRepository.count(
|
||||||
AccessController.Operation.UPDATE,
|
AccessController.Operation.UPDATE,
|
||||||
combineWithAnd(specList));
|
combineWithAnd(specList));
|
||||||
@@ -172,7 +172,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
@Override
|
@Override
|
||||||
public long countByRsqlAndCompatible(final String rsql, final Long distributionSetIdTypeId) {
|
public long countByRsqlAndCompatible(final String rsql, final Long distributionSetIdTypeId) {
|
||||||
final List<Specification<JpaTarget>> specList = List.of(
|
final List<Specification<JpaTarget>> specList = List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||||
TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetIdTypeId));
|
TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetIdTypeId));
|
||||||
return JpaManagementHelper.countBySpec(targetRepository, specList);
|
return JpaManagementHelper.countBySpec(targetRepository, specList);
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
@Override
|
@Override
|
||||||
public long countByRsqlAndCompatibleAndUpdatable(String rsql, Long distributionSetIdTypeId) {
|
public long countByRsqlAndCompatibleAndUpdatable(String rsql, Long distributionSetIdTypeId) {
|
||||||
final List<Specification<JpaTarget>> specList = List.of(
|
final List<Specification<JpaTarget>> specList = List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||||
TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetIdTypeId));
|
TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetIdTypeId));
|
||||||
return targetRepository.count(AccessController.Operation.UPDATE, combineWithAnd(specList));
|
return targetRepository.count(AccessController.Operation.UPDATE, combineWithAnd(specList));
|
||||||
}
|
}
|
||||||
@@ -253,7 +253,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
.findAllWithoutCount(
|
.findAllWithoutCount(
|
||||||
AccessController.Operation.UPDATE,
|
AccessController.Operation.UPDATE,
|
||||||
combineWithAnd(List.of(
|
combineWithAnd(List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||||
TargetSpecifications.hasNotDistributionSetInActions(distributionSetId),
|
TargetSpecifications.hasNotDistributionSetInActions(distributionSetId),
|
||||||
TargetSpecifications.isCompatibleWithDistributionSetType(distSetTypeId))),
|
TargetSpecifications.isCompatibleWithDistributionSetType(distSetTypeId))),
|
||||||
pageable)
|
pageable)
|
||||||
@@ -268,7 +268,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
return targetRepository.count(
|
return targetRepository.count(
|
||||||
AccessController.Operation.UPDATE,
|
AccessController.Operation.UPDATE,
|
||||||
combineWithAnd(List.of(
|
combineWithAnd(List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(
|
RsqlUtility.buildRsqlSpecification(
|
||||||
rsql, TargetFields.class, virtualPropertyReplacer, database),
|
rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||||
TargetSpecifications.hasNotDistributionSetInActions(distributionSetId),
|
TargetSpecifications.hasNotDistributionSetInActions(distributionSetId),
|
||||||
TargetSpecifications.isCompatibleWithDistributionSetType(distSetTypeId))));
|
TargetSpecifications.isCompatibleWithDistributionSetType(distSetTypeId))));
|
||||||
@@ -280,7 +280,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
return targetRepository
|
return targetRepository
|
||||||
.findAllWithoutCount(AccessController.Operation.UPDATE,
|
.findAllWithoutCount(AccessController.Operation.UPDATE,
|
||||||
combineWithAnd(List.of(
|
combineWithAnd(List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||||
TargetSpecifications.isNotInRolloutGroups(groups),
|
TargetSpecifications.isNotInRolloutGroups(groups),
|
||||||
TargetSpecifications.isCompatibleWithDistributionSetType(dsType.getId()))),
|
TargetSpecifications.isCompatibleWithDistributionSetType(dsType.getId()))),
|
||||||
pageable)
|
pageable)
|
||||||
@@ -292,7 +292,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
final String rsql, final Collection<Long> groups, final DistributionSetType dsType) {
|
final String rsql, final Collection<Long> groups, final DistributionSetType dsType) {
|
||||||
return targetRepository.count(AccessController.Operation.UPDATE,
|
return targetRepository.count(AccessController.Operation.UPDATE,
|
||||||
combineWithAnd(List.of(
|
combineWithAnd(List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||||
TargetSpecifications.isNotInRolloutGroups(groups),
|
TargetSpecifications.isNotInRolloutGroups(groups),
|
||||||
TargetSpecifications.isCompatibleWithDistributionSetType(dsType.getId()))));
|
TargetSpecifications.isCompatibleWithDistributionSetType(dsType.getId()))));
|
||||||
}
|
}
|
||||||
@@ -319,7 +319,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
return targetRepository
|
return targetRepository
|
||||||
.findAllWithoutCount(AccessController.Operation.UPDATE,
|
.findAllWithoutCount(AccessController.Operation.UPDATE,
|
||||||
combineWithAnd(List.of(
|
combineWithAnd(List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||||
TargetSpecifications.hasNoOverridingActionsAndNotInRollout(rolloutId),
|
TargetSpecifications.hasNoOverridingActionsAndNotInRollout(rolloutId),
|
||||||
TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetType.getId()))),
|
TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetType.getId()))),
|
||||||
pageable)
|
pageable)
|
||||||
@@ -355,7 +355,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
|
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
|
||||||
|
|
||||||
final List<Specification<JpaTarget>> specList = List.of(
|
final List<Specification<JpaTarget>> specList = List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||||
TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId()));
|
TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId()));
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
|
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
|
||||||
@@ -395,7 +395,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
|
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
|
||||||
|
|
||||||
final List<Specification<JpaTarget>> specList = List.of(
|
final List<Specification<JpaTarget>> specList = List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||||
TargetSpecifications.hasInstalledDistributionSet(validDistSet.getId()));
|
TargetSpecifications.hasInstalledDistributionSet(validDistSet.getId()));
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
|
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
|
||||||
@@ -416,7 +416,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
public Slice<Target> findByRsql(final String rsql, final Pageable pageable) {
|
public Slice<Target> findByRsql(final String rsql, final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithoutCountBySpec(
|
return JpaManagementHelper.findAllWithoutCountBySpec(
|
||||||
targetRepository,
|
targetRepository,
|
||||||
List.of(RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database)), pageable
|
List.of(RsqlUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database)), pageable
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,7 +426,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId));
|
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId));
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithoutCountBySpec(
|
return JpaManagementHelper.findAllWithoutCountBySpec(
|
||||||
targetRepository, List.of(RSQLUtility.buildRsqlSpecification(
|
targetRepository, List.of(RsqlUtility.buildRsqlSpecification(
|
||||||
targetFilterQuery.getQuery(), TargetFields.class, virtualPropertyReplacer, database)), pageable
|
targetFilterQuery.getQuery(), TargetFields.class, virtualPropertyReplacer, database)), pageable
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -442,7 +442,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
throwEntityNotFoundExceptionIfTagDoesNotExist(tagId);
|
throwEntityNotFoundExceptionIfTagDoesNotExist(tagId);
|
||||||
|
|
||||||
final List<Specification<JpaTarget>> specList = List.of(
|
final List<Specification<JpaTarget>> specList = List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||||
TargetSpecifications.hasTag(tagId));
|
TargetSpecifications.hasTag(tagId));
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
|
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
|
||||||
@@ -611,12 +611,12 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isTargetMatchingQueryAndDSNotAssignedAndCompatibleAndUpdatable(
|
public boolean isTargetMatchingQueryAndDSNotAssignedAndCompatibleAndUpdatable(
|
||||||
final String controllerId, final long distributionSetId, final String targetFilterQuery) {
|
final String controllerId, final long distributionSetId, final String targetFilterQuery) {
|
||||||
RSQLUtility.validateRsqlFor(targetFilterQuery, TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
RsqlUtility.validateRsqlFor(targetFilterQuery, TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
||||||
final DistributionSet ds = distributionSetManagement.get(distributionSetId)
|
final DistributionSet ds = distributionSetManagement.get(distributionSetId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, distributionSetId));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, distributionSetId));
|
||||||
final Long distSetTypeId = ds.getType().getId();
|
final Long distSetTypeId = ds.getType().getId();
|
||||||
final List<Specification<JpaTarget>> specList = List.of(
|
final List<Specification<JpaTarget>> specList = List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database),
|
RsqlUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database),
|
||||||
TargetSpecifications.hasNotDistributionSetInActions(distributionSetId),
|
TargetSpecifications.hasNotDistributionSetInActions(distributionSetId),
|
||||||
TargetSpecifications.isCompatibleWithDistributionSetType(distSetTypeId),
|
TargetSpecifications.isCompatibleWithDistributionSetType(distSetTypeId),
|
||||||
TargetSpecifications.hasControllerId(controllerId));
|
TargetSpecifications.hasControllerId(controllerId));
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.model.AbstractJpaNamedEntity_;
|
import org.eclipse.hawkbit.repository.jpa.model.AbstractJpaNamedEntity_;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetTagRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.TargetTagRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlUtility;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||||
import org.springframework.dao.ConcurrencyFailureException;
|
import org.springframework.dao.ConcurrencyFailureException;
|
||||||
@@ -105,7 +105,7 @@ public class JpaTargetTagManagement implements TargetTagManagement {
|
|||||||
@Override
|
@Override
|
||||||
public Page<TargetTag> findByRsql(final String rsql, final Pageable pageable) {
|
public Page<TargetTag> findByRsql(final String rsql, final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetTagRepository, Collections.singletonList(
|
return JpaManagementHelper.findAllWithCountBySpec(targetTagRepository, Collections.singletonList(
|
||||||
RSQLUtility.buildRsqlSpecification(rsql, TargetTagFields.class, virtualPropertyReplacer, database)), pageable);
|
RsqlUtility.buildRsqlSpecification(rsql, TargetTagFields.class, virtualPropertyReplacer, database)), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaTargetType;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTypeRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTypeRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetTypeRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.TargetTypeRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlUtility;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.TargetTypeSpecification;
|
import org.eclipse.hawkbit.repository.jpa.specifications.TargetTypeSpecification;
|
||||||
import org.eclipse.hawkbit.repository.jpa.utils.QuotaHelper;
|
import org.eclipse.hawkbit.repository.jpa.utils.QuotaHelper;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||||
@@ -146,7 +146,7 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
|||||||
@Override
|
@Override
|
||||||
public Page<TargetType> findByRsql(final String rsql, final Pageable pageable) {
|
public Page<TargetType> findByRsql(final String rsql, final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetTypeRepository, List.of(
|
return JpaManagementHelper.findAllWithCountBySpec(targetTypeRepository, List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(
|
RsqlUtility.buildRsqlSpecification(
|
||||||
rsql, TargetTypeFields.class, virtualPropertyReplacer, database)), pageable
|
rsql, TargetTypeFields.class, virtualPropertyReplacer, database)), pageable
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ package org.eclipse.hawkbit.repository.jpa.management;
|
|||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
import static org.assertj.core.api.Assertions.fail;
|
import static org.assertj.core.api.Assertions.fail;
|
||||||
import static org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G1;
|
import static org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G1;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -69,7 +69,7 @@ import org.eclipse.hawkbit.repository.model.TargetTag;
|
|||||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTypeAssignmentResult;
|
import org.eclipse.hawkbit.repository.model.TargetTypeAssignmentResult;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder;
|
||||||
import org.eclipse.hawkbit.repository.test.matcher.Expect;
|
import org.eclipse.hawkbit.repository.test.matcher.Expect;
|
||||||
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
|
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
|
||||||
import org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch;
|
import org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository.jpa.rsql;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.ql.Node;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class NodeTest {
|
class NodeTest {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import org.springframework.orm.jpa.vendor.Database;
|
|||||||
* Feature: Component Tests - Repository<br/>
|
* Feature: Component Tests - Repository<br/>
|
||||||
* Story: RSQL filter actions
|
* Story: RSQL filter actions
|
||||||
*/
|
*/
|
||||||
class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
|
class RsqlActionFieldsTest extends AbstractJpaIntegrationTest {
|
||||||
|
|
||||||
private JpaTarget target;
|
private JpaTarget target;
|
||||||
private JpaAction action;
|
private JpaAction action;
|
||||||
@@ -26,7 +26,7 @@ import org.springframework.data.domain.PageRequest;
|
|||||||
* Feature: Component Tests - Repository<br/>
|
* Feature: Component Tests - Repository<br/>
|
||||||
* Story: RSQL filter rollout group
|
* Story: RSQL filter rollout group
|
||||||
*/
|
*/
|
||||||
class RSQLRolloutFieldTest extends AbstractJpaIntegrationTest {
|
class RsqlRolloutFieldTest extends AbstractJpaIntegrationTest {
|
||||||
|
|
||||||
private Rollout rollout;
|
private Rollout rollout;
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ import org.springframework.orm.jpa.vendor.Database;
|
|||||||
* Feature: Component Tests - Repository<br/>
|
* Feature: Component Tests - Repository<br/>
|
||||||
* Story: RSQL filter rollout group
|
* Story: RSQL filter rollout group
|
||||||
*/
|
*/
|
||||||
class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest {
|
class RsqlRolloutGroupFieldTest extends AbstractJpaIntegrationTest {
|
||||||
|
|
||||||
private Long rolloutGroupId;
|
private Long rolloutGroupId;
|
||||||
private Rollout rollout;
|
private Rollout rollout;
|
||||||
@@ -27,7 +27,7 @@ import org.springframework.orm.jpa.vendor.Database;
|
|||||||
* Feature: Component Tests - Repository<br/>
|
* Feature: Component Tests - Repository<br/>
|
||||||
* Story: RSQL filter software module
|
* Story: RSQL filter software module
|
||||||
*/
|
*/
|
||||||
class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
class RsqlSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||||
|
|
||||||
private SoftwareModule ah;
|
private SoftwareModule ah;
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ import org.springframework.orm.jpa.vendor.Database;
|
|||||||
* Feature: Component Tests - Repository<br/>
|
* Feature: Component Tests - Repository<br/>
|
||||||
* Story: RSQL filter software module test type
|
* Story: RSQL filter software module test type
|
||||||
*/
|
*/
|
||||||
class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest {
|
class RsqlSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test filter software module test type by id
|
* Test filter software module test type by id
|
||||||
@@ -25,7 +25,7 @@ import org.springframework.data.domain.PageRequest;
|
|||||||
* Feature: Component Tests - Repository<br/>
|
* Feature: Component Tests - Repository<br/>
|
||||||
* Story: RSQL filter target and distribution set tags
|
* Story: RSQL filter target and distribution set tags
|
||||||
*/
|
*/
|
||||||
class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
class RsqlTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void seuptBeforeTest() {
|
void seuptBeforeTest() {
|
||||||
@@ -11,8 +11,8 @@ package org.eclipse.hawkbit.repository.jpa.rsql;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
import static org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G2;
|
import static org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G2;
|
||||||
import static org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G1;
|
import static org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G1;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -28,7 +28,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
|||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder;
|
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||||
import org.eclipse.hawkbit.repository.test.util.TestdataFactory;
|
import org.eclipse.hawkbit.repository.test.util.TestdataFactory;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
@@ -41,7 +40,7 @@ import org.springframework.data.domain.Slice;
|
|||||||
* Story: RSQL filter target
|
* Story: RSQL filter target
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("java:S6813") // constructor injects are not possible for test classes
|
@SuppressWarnings("java:S6813") // constructor injects are not possible for test classes
|
||||||
class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
class RsqlTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||||
|
|
||||||
private static final String OR = ",";
|
private static final String OR = ",";
|
||||||
private static final String AND = ";";
|
private static final String AND = ";";
|
||||||
@@ -387,26 +386,26 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void rsqlValidTargetFields() {
|
void rsqlValidTargetFields() {
|
||||||
RSQLUtility.validateRsqlFor(
|
RsqlUtility.validateRsqlFor(
|
||||||
"ID == '0123' and NAME == abcd and DESCRIPTION == absd and CREATEDAT =lt= 0123 and LASTMODIFIEDAT =gt= 0123" +
|
"ID == '0123' and NAME == abcd and DESCRIPTION == absd and CREATEDAT =lt= 0123 and LASTMODIFIEDAT =gt= 0123" +
|
||||||
" and CONTROLLERID == 0123 and UPDATESTATUS == PENDING and IPADDRESS == 0123 and LASTCONTROLLERREQUESTAT == 0123" +
|
" and CONTROLLERID == 0123 and UPDATESTATUS == PENDING and IPADDRESS == 0123 and LASTCONTROLLERREQUESTAT == 0123" +
|
||||||
" and tag == beta",
|
" and tag == beta",
|
||||||
TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
||||||
RSQLUtility.validateRsqlFor(
|
RsqlUtility.validateRsqlFor(
|
||||||
"ASSIGNEDDS.name == abcd and ASSIGNEDDS.version == 0123 and INSTALLEDDS.name == abcd and INSTALLEDDS.version == 0123",
|
"ASSIGNEDDS.name == abcd and ASSIGNEDDS.version == 0123 and INSTALLEDDS.name == abcd and INSTALLEDDS.version == 0123",
|
||||||
TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
||||||
RSQLUtility.validateRsqlFor(
|
RsqlUtility.validateRsqlFor(
|
||||||
"ATTRIBUTE.subkey1 == test and ATTRIBUTE.subkey2 == test and METADATA.metakey1 == abcd and METADATA.metavalue2 == asdfg",
|
"ATTRIBUTE.subkey1 == test and ATTRIBUTE.subkey2 == test and METADATA.metakey1 == abcd and METADATA.metavalue2 == asdfg",
|
||||||
TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
||||||
RSQLUtility.validateRsqlFor(
|
RsqlUtility.validateRsqlFor(
|
||||||
"CREATEDAT =lt= ${NOW_TS} and LASTMODIFIEDAT =ge= ${OVERDUE_TS}",
|
"CREATEDAT =lt= ${NOW_TS} and LASTMODIFIEDAT =ge= ${OVERDUE_TS}",
|
||||||
TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
||||||
RSQLUtility.validateRsqlFor(
|
RsqlUtility.validateRsqlFor(
|
||||||
"ATTRIBUTE.test.dot == test and ATTRIBUTE.subkey2 == test and METADATA.test.dot == abcd and METADATA.metavalue2 == asdfg",
|
"ATTRIBUTE.test.dot == test and ATTRIBUTE.subkey2 == test and METADATA.test.dot == abcd and METADATA.metavalue2 == asdfg",
|
||||||
TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager);
|
||||||
|
|
||||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||||
.isThrownBy(() -> RSQLUtility.validateRsqlFor(
|
.isThrownBy(() -> RsqlUtility.validateRsqlFor(
|
||||||
"wrongfield == abcd",
|
"wrongfield == abcd",
|
||||||
TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager));
|
TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager));
|
||||||
}
|
}
|
||||||
@@ -453,7 +452,7 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
private void assertRSQLQueryThrowsException(final String rsql) {
|
private void assertRSQLQueryThrowsException(final String rsql) {
|
||||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||||
.isThrownBy(() -> RSQLUtility.validateRsqlFor(
|
.isThrownBy(() -> RsqlUtility.validateRsqlFor(
|
||||||
rsql, TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager));
|
rsql, TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ import org.springframework.orm.jpa.vendor.Database;
|
|||||||
* Feature: Component Tests - Repository<br/>
|
* Feature: Component Tests - Repository<br/>
|
||||||
* Story: RSQL filter target filter query
|
* Story: RSQL filter target filter query
|
||||||
*/
|
*/
|
||||||
class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest {
|
class RsqlTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest {
|
||||||
|
|
||||||
private TargetFilterQuery filter1;
|
private TargetFilterQuery filter1;
|
||||||
private TargetFilterQuery filter2;
|
private TargetFilterQuery filter2;
|
||||||
@@ -9,9 +9,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||||
|
|
||||||
import static org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G2;
|
import static org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G2;
|
||||||
import static org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder.RsqlToSpecBuilder.G3;
|
import static org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder.RsqlToSpecBuilder.G3;
|
||||||
import static org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G1;
|
import static org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G1;
|
||||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
|
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
|
||||||
|
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
@@ -21,6 +21,7 @@ import org.eclipse.hawkbit.repository.RsqlQueryField;
|
|||||||
import org.eclipse.hawkbit.repository.TargetFields;
|
import org.eclipse.hawkbit.repository.TargetFields;
|
||||||
import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
|
import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.ql.utils.HawkbitQlToSql;
|
||||||
import org.eclipse.hawkbit.repository.test.TestConfiguration;
|
import org.eclipse.hawkbit.repository.test.TestConfiguration;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -37,10 +38,10 @@ import org.springframework.test.context.ContextConfiguration;
|
|||||||
@ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, TestConfiguration.class })
|
@ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, TestConfiguration.class })
|
||||||
@Disabled("For manual run only, while playing around with RSQL to SQL")
|
@Disabled("For manual run only, while playing around with RSQL to SQL")
|
||||||
@SuppressWarnings("java:S2699") // java:S2699 - manual test, don't actually does assertions
|
@SuppressWarnings("java:S2699") // java:S2699 - manual test, don't actually does assertions
|
||||||
class RSQLToSQLTest {
|
class RsqlToSqlTest {
|
||||||
|
|
||||||
private static final boolean FULL = Boolean.getBoolean("full");
|
private static final boolean FULL = Boolean.getBoolean("full");
|
||||||
private RSQLToSQL rsqlToSQL;
|
private HawkbitQlToSql rsqlToSQL;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void printPG() {
|
void printPG() {
|
||||||
@@ -107,7 +108,7 @@ class RSQLToSQLTest {
|
|||||||
|
|
||||||
@PersistenceContext
|
@PersistenceContext
|
||||||
private void setEntityManager(final EntityManager entityManager) {
|
private void setEntityManager(final EntityManager entityManager) {
|
||||||
rsqlToSQL = new RSQLToSQL(entityManager);
|
rsqlToSQL = new HawkbitQlToSql(entityManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T, A extends Enum<A> & RsqlQueryField> void print(final Class<T> domainClass, final Class<A> fieldsClass, final String rsql) {
|
private <T, A extends Enum<A> & RsqlQueryField> void print(final Class<T> domainClass, final Class<A> fieldsClass, final String rsql) {
|
||||||
@@ -46,7 +46,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
|||||||
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
|
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.SystemSecurityContextHolder;
|
import org.eclipse.hawkbit.repository.model.helper.SystemSecurityContextHolder;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.TenantConfigurationManagementHolder;
|
import org.eclipse.hawkbit.repository.model.helper.TenantConfigurationManagementHolder;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder;
|
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyResolver;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyResolver;
|
||||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||||
@@ -73,7 +72,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|||||||
@Disabled
|
@Disabled
|
||||||
// TODO: fully document tests -> description for long text and reasonable
|
// TODO: fully document tests -> description for long text and reasonable
|
||||||
// method name as short text
|
// method name as short text
|
||||||
class RSQLUtilityTest {
|
class RsqlUtilityTest {
|
||||||
|
|
||||||
private static final TenantConfigurationValue<String> TEST_POLLING_TIME_INTERVAL =
|
private static final TenantConfigurationValue<String> TEST_POLLING_TIME_INTERVAL =
|
||||||
TenantConfigurationValue.<String> builder().value("00:05:00").build();
|
TenantConfigurationValue.<String> builder().value("00:05:00").build();
|
||||||
@@ -109,7 +108,7 @@ class RSQLUtilityTest {
|
|||||||
@Test
|
@Test
|
||||||
void wrongFieldThrowUnsupportedFieldException() {
|
void wrongFieldThrowUnsupportedFieldException() {
|
||||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
||||||
final Specification<Object> rsqlSpecification = RSQLUtility.buildRsqlSpecification("unknownField==abc", SoftwareModuleFields.class, null, testDb);
|
final Specification<Object> rsqlSpecification = RsqlUtility.buildRsqlSpecification("unknownField==abc", SoftwareModuleFields.class, null, testDb);
|
||||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||||
.as("RSQLParameterUnsupportedFieldException because of unknown RSQL field")
|
.as("RSQLParameterUnsupportedFieldException because of unknown RSQL field")
|
||||||
.isThrownBy(() -> rsqlSpecification.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
.isThrownBy(() -> rsqlSpecification.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
||||||
@@ -118,25 +117,25 @@ class RSQLUtilityTest {
|
|||||||
@Test
|
@Test
|
||||||
void wrongRsqlMapSyntaxThrowSyntaxException() {
|
void wrongRsqlMapSyntaxThrowSyntaxException() {
|
||||||
final Specification<Object> rsqlSpecification =
|
final Specification<Object> rsqlSpecification =
|
||||||
RSQLUtility.buildRsqlSpecification(TargetFields.ATTRIBUTE + "==abc", TargetFields.class, null, testDb);
|
RsqlUtility.buildRsqlSpecification(TargetFields.ATTRIBUTE + "==abc", TargetFields.class, null, testDb);
|
||||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||||
.as("RSQLParameterSyntaxException for target attributes map, caused by wrong RSQL syntax (key was not present)")
|
.as("RSQLParameterSyntaxException for target attributes map, caused by wrong RSQL syntax (key was not present)")
|
||||||
.isThrownBy(() -> rsqlSpecification.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
.isThrownBy(() -> rsqlSpecification.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
||||||
|
|
||||||
final Specification<Object> rsqlSpecification2 =
|
final Specification<Object> rsqlSpecification2 =
|
||||||
RSQLUtility.buildRsqlSpecification(TargetFields.ATTRIBUTE + ".unknown.wrong==abc", TargetFields.class, null, testDb);
|
RsqlUtility.buildRsqlSpecification(TargetFields.ATTRIBUTE + ".unknown.wrong==abc", TargetFields.class, null, testDb);
|
||||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||||
.as("RSQLParameterSyntaxException for target attributes map, caused by wrong RSQL syntax (key includes dots)")
|
.as("RSQLParameterSyntaxException for target attributes map, caused by wrong RSQL syntax (key includes dots)")
|
||||||
.isThrownBy(() -> rsqlSpecification2.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
.isThrownBy(() -> rsqlSpecification2.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
||||||
|
|
||||||
final Specification<Object> rsqlSpecification3 =
|
final Specification<Object> rsqlSpecification3 =
|
||||||
RSQLUtility.buildRsqlSpecification(TargetFields.METADATA + ".unknown.wrong==abc", TargetFields.class, null, testDb);
|
RsqlUtility.buildRsqlSpecification(TargetFields.METADATA + ".unknown.wrong==abc", TargetFields.class, null, testDb);
|
||||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||||
.as("RSQLParameterSyntaxException for target metadata map, caused by wrong RSQL syntax (key includes dots)")
|
.as("RSQLParameterSyntaxException for target metadata map, caused by wrong RSQL syntax (key includes dots)")
|
||||||
.isThrownBy(() -> rsqlSpecification3.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
.isThrownBy(() -> rsqlSpecification3.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
||||||
|
|
||||||
final Specification<Object> rsqlSpecification4 =
|
final Specification<Object> rsqlSpecification4 =
|
||||||
RSQLUtility.buildRsqlSpecification(DistributionSetFields.METADATA + "==abc", TargetFields.class, null, testDb);
|
RsqlUtility.buildRsqlSpecification(DistributionSetFields.METADATA + "==abc", TargetFields.class, null, testDb);
|
||||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||||
.as("RSQLParameterSyntaxException for distribution set metadata map, caused by wrong RSQL syntax (key was not present)\"")
|
.as("RSQLParameterSyntaxException for distribution set metadata map, caused by wrong RSQL syntax (key was not present)\"")
|
||||||
.isThrownBy(() -> rsqlSpecification4.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
.isThrownBy(() -> rsqlSpecification4.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
||||||
@@ -145,19 +144,19 @@ class RSQLUtilityTest {
|
|||||||
@Test
|
@Test
|
||||||
void wrongRsqlSubEntitySyntaxThrowSyntaxException() {
|
void wrongRsqlSubEntitySyntaxThrowSyntaxException() {
|
||||||
final Specification<Object> rsqlSpecification =
|
final Specification<Object> rsqlSpecification =
|
||||||
RSQLUtility.buildRsqlSpecification(TargetFields.ASSIGNEDDS + "==abc", TargetFields.class, null, testDb);
|
RsqlUtility.buildRsqlSpecification(TargetFields.ASSIGNEDDS + "==abc", TargetFields.class, null, testDb);
|
||||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||||
.as("RSQLParameterSyntaxException because of wrong RSQL syntax")
|
.as("RSQLParameterSyntaxException because of wrong RSQL syntax")
|
||||||
.isThrownBy(() -> rsqlSpecification.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
.isThrownBy(() -> rsqlSpecification.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
||||||
|
|
||||||
final Specification<Object> rsqlSpecification2 =
|
final Specification<Object> rsqlSpecification2 =
|
||||||
RSQLUtility.buildRsqlSpecification(TargetFields.ASSIGNEDDS + ".unknownField==abc", TargetFields.class, null, testDb);
|
RsqlUtility.buildRsqlSpecification(TargetFields.ASSIGNEDDS + ".unknownField==abc", TargetFields.class, null, testDb);
|
||||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||||
.as("RSQLParameterSyntaxException because of wrong RSQL syntax")
|
.as("RSQLParameterSyntaxException because of wrong RSQL syntax")
|
||||||
.isThrownBy(() -> rsqlSpecification2.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
.isThrownBy(() -> rsqlSpecification2.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
||||||
|
|
||||||
final Specification<Object> rsqlSpecification3 =
|
final Specification<Object> rsqlSpecification3 =
|
||||||
RSQLUtility.buildRsqlSpecification(TargetFields.ASSIGNEDDS + ".unknownField.ToMuch==abc", TargetFields.class, null, testDb);
|
RsqlUtility.buildRsqlSpecification(TargetFields.ASSIGNEDDS + ".unknownField.ToMuch==abc", TargetFields.class, null, testDb);
|
||||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||||
.as("RSQLParameterSyntaxException because of wrong RSQL syntax")
|
.as("RSQLParameterSyntaxException because of wrong RSQL syntax")
|
||||||
.isThrownBy(() -> rsqlSpecification3.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
.isThrownBy(() -> rsqlSpecification3.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
||||||
@@ -176,7 +175,7 @@ class RSQLUtilityTest {
|
|||||||
when(criteriaBuilderMock.and(any(Predicate[].class))).thenReturn(mock(Predicate.class));
|
when(criteriaBuilderMock.and(any(Predicate[].class))).thenReturn(mock(Predicate.class));
|
||||||
|
|
||||||
// test
|
// test
|
||||||
RSQLUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, testDb)
|
RsqlUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, testDb)
|
||||||
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
|
||||||
// verification
|
// verification
|
||||||
@@ -195,7 +194,7 @@ class RSQLUtilityTest {
|
|||||||
when(criteriaBuilderMock.upper(pathOfString(baseSoftwareModuleRootMock))).thenReturn(pathOfString(baseSoftwareModuleRootMock));
|
when(criteriaBuilderMock.upper(pathOfString(baseSoftwareModuleRootMock))).thenReturn(pathOfString(baseSoftwareModuleRootMock));
|
||||||
|
|
||||||
// test
|
// test
|
||||||
RSQLUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, testDb)
|
RsqlUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, testDb)
|
||||||
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
|
||||||
// verification
|
// verification
|
||||||
@@ -217,7 +216,7 @@ class RSQLUtilityTest {
|
|||||||
when(criteriaBuilderMock.upper(pathOfString(baseSoftwareModuleRootMock))).thenReturn(pathOfString(baseSoftwareModuleRootMock));
|
when(criteriaBuilderMock.upper(pathOfString(baseSoftwareModuleRootMock))).thenReturn(pathOfString(baseSoftwareModuleRootMock));
|
||||||
|
|
||||||
// test
|
// test
|
||||||
RSQLUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, testDb)
|
RsqlUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, testDb)
|
||||||
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
|
||||||
// verification
|
// verification
|
||||||
@@ -247,7 +246,7 @@ class RSQLUtilityTest {
|
|||||||
when(subqueryMock.where(any(Expression.class))).thenReturn(subqueryMock);
|
when(subqueryMock.where(any(Expression.class))).thenReturn(subqueryMock);
|
||||||
|
|
||||||
// test
|
// test
|
||||||
RSQLUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, testDb)
|
RsqlUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, testDb)
|
||||||
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
|
||||||
// verification
|
// verification
|
||||||
@@ -264,7 +263,7 @@ class RSQLUtilityTest {
|
|||||||
when(criteriaBuilderMock.greaterThanOrEqualTo(any(Expression.class), any(String.class))).thenReturn(mock(Predicate.class));
|
when(criteriaBuilderMock.greaterThanOrEqualTo(any(Expression.class), any(String.class))).thenReturn(mock(Predicate.class));
|
||||||
when(criteriaBuilderMock.upper(pathOfString(baseSoftwareModuleRootMock))).thenReturn(pathOfString(baseSoftwareModuleRootMock));
|
when(criteriaBuilderMock.upper(pathOfString(baseSoftwareModuleRootMock))).thenReturn(pathOfString(baseSoftwareModuleRootMock));
|
||||||
// test
|
// test
|
||||||
RSQLUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, Database.H2)
|
RsqlUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, Database.H2)
|
||||||
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
|
||||||
// verification
|
// verification
|
||||||
@@ -282,7 +281,7 @@ class RSQLUtilityTest {
|
|||||||
when(criteriaBuilderMock.greaterThanOrEqualTo(any(Expression.class), any(String.class))).thenReturn(mock(Predicate.class));
|
when(criteriaBuilderMock.greaterThanOrEqualTo(any(Expression.class), any(String.class))).thenReturn(mock(Predicate.class));
|
||||||
when(criteriaBuilderMock.upper(pathOfString(baseSoftwareModuleRootMock))).thenReturn(pathOfString(baseSoftwareModuleRootMock));
|
when(criteriaBuilderMock.upper(pathOfString(baseSoftwareModuleRootMock))).thenReturn(pathOfString(baseSoftwareModuleRootMock));
|
||||||
// test
|
// test
|
||||||
RSQLUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, Database.H2)
|
RsqlUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, Database.H2)
|
||||||
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
|
||||||
// verification
|
// verification
|
||||||
@@ -304,7 +303,7 @@ class RSQLUtilityTest {
|
|||||||
when(criteriaBuilderMock.<String> greaterThanOrEqualTo(any(Expression.class), any(String.class))).thenReturn(mock(Predicate.class));
|
when(criteriaBuilderMock.<String> greaterThanOrEqualTo(any(Expression.class), any(String.class))).thenReturn(mock(Predicate.class));
|
||||||
|
|
||||||
// test
|
// test
|
||||||
RSQLUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, Database.SQL_SERVER)
|
RsqlUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, Database.SQL_SERVER)
|
||||||
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
|
||||||
// verification
|
// verification
|
||||||
@@ -322,7 +321,7 @@ class RSQLUtilityTest {
|
|||||||
when(criteriaBuilderMock.<String> greaterThanOrEqualTo(any(Expression.class), any(String.class)))
|
when(criteriaBuilderMock.<String> greaterThanOrEqualTo(any(Expression.class), any(String.class)))
|
||||||
.thenReturn(mock(Predicate.class));
|
.thenReturn(mock(Predicate.class));
|
||||||
// test
|
// test
|
||||||
RSQLUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, testDb)
|
RsqlUtility.buildRsqlSpecification(correctRsql, SoftwareModuleFields.class, null, testDb)
|
||||||
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
|
||||||
// verification
|
// verification
|
||||||
@@ -339,7 +338,7 @@ class RSQLUtilityTest {
|
|||||||
when(criteriaBuilderMock.equal(any(Root.class), any(TestValueEnum.class))).thenReturn(mock(Predicate.class));
|
when(criteriaBuilderMock.equal(any(Root.class), any(TestValueEnum.class))).thenReturn(mock(Predicate.class));
|
||||||
|
|
||||||
// test
|
// test
|
||||||
RSQLUtility.buildRsqlSpecification(correctRsql, TestFieldEnum.class, null, testDb)
|
RsqlUtility.buildRsqlSpecification(correctRsql, TestFieldEnum.class, null, testDb)
|
||||||
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
|
||||||
// verification
|
// verification
|
||||||
@@ -355,7 +354,7 @@ class RSQLUtilityTest {
|
|||||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) TestValueEnum.class);
|
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) TestValueEnum.class);
|
||||||
when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class));
|
when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class));
|
||||||
|
|
||||||
final Specification<Object> rsqlSpecification = RSQLUtility.buildRsqlSpecification(correctRsql, TestFieldEnum.class, null, testDb);
|
final Specification<Object> rsqlSpecification = RsqlUtility.buildRsqlSpecification(correctRsql, TestFieldEnum.class, null, testDb);
|
||||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||||
.as("RSQLParameterUnsupportedFieldException for wrong enum value")
|
.as("RSQLParameterUnsupportedFieldException for wrong enum value")
|
||||||
.isThrownBy(() -> rsqlSpecification.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
.isThrownBy(() -> rsqlSpecification.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock));
|
||||||
@@ -377,7 +376,7 @@ class RSQLUtilityTest {
|
|||||||
when(criteriaBuilderMock.lessThanOrEqualTo(any(Expression.class), eq(overduePropPlaceholder))).thenReturn(mock(Predicate.class));
|
when(criteriaBuilderMock.lessThanOrEqualTo(any(Expression.class), eq(overduePropPlaceholder))).thenReturn(mock(Predicate.class));
|
||||||
|
|
||||||
// test
|
// test
|
||||||
RSQLUtility.buildRsqlSpecification(correctRsql, TestFieldEnum.class, setupMacroLookup(), testDb)
|
RsqlUtility.buildRsqlSpecification(correctRsql, TestFieldEnum.class, setupMacroLookup(), testDb)
|
||||||
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
|
||||||
// verification
|
// verification
|
||||||
@@ -401,7 +400,7 @@ class RSQLUtilityTest {
|
|||||||
.thenReturn(mock(Predicate.class));
|
.thenReturn(mock(Predicate.class));
|
||||||
|
|
||||||
// test
|
// test
|
||||||
RSQLUtility.buildRsqlSpecification(correctRsql, TestFieldEnum.class, setupMacroLookup(), testDb)
|
RsqlUtility.buildRsqlSpecification(correctRsql, TestFieldEnum.class, setupMacroLookup(), testDb)
|
||||||
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
|
||||||
// verification
|
// verification
|
||||||
3
hawkbit-repository/hawkbit-repository-ql/README.md
Normal file
3
hawkbit-repository/hawkbit-repository-ql/README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# hawkBit QL
|
||||||
|
|
||||||
|
hawkBit Query Language Support (based on RSQL)
|
||||||
127
hawkbit-repository/hawkbit-repository-ql/pom.xml
Normal file
127
hawkbit-repository/hawkbit-repository-ql/pom.xml
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
<!--
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
-->
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
|
<artifactId>hawkbit-repository</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>hawkbit-repository-ql</artifactId>
|
||||||
|
<name>hawkBit :: Query Language</name>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>eclipselink</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<!-- default, if not set (or not hibernate) - eclipse link -->
|
||||||
|
<name>jpa.vendor</name>
|
||||||
|
<value>!hibernate</value>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
|
<artifactId>hawkbit-repository-jpa-eclipselink</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<!-- Static weaver for EclipseLink -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.ethlo.persistence.tools</groupId>
|
||||||
|
<artifactId>eclipselink-maven-plugin</artifactId>
|
||||||
|
<version>${eclipselink.maven.plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>process-classes</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>weave</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<basePackage>org.eclipse.hawkbit.repository.jpa.model</basePackage>
|
||||||
|
</configuration>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.persistence</groupId>
|
||||||
|
<artifactId>org.eclipse.persistence.jpa</artifactId>
|
||||||
|
<version>${eclipselink.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>hibernate</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>jpa.vendor</name>
|
||||||
|
<value>hibernate</value>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
|
<artifactId>hawkbit-repository-jpa-hibernate</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate.orm</groupId>
|
||||||
|
<artifactId>hibernate-core</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.persistence</groupId>
|
||||||
|
<artifactId>jakarta.persistence-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.hibernate.orm</groupId>
|
||||||
|
<artifactId>hibernate-core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cz.jirutka.rsql</groupId>
|
||||||
|
<artifactId>rsql-parser</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Test -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
|
<artifactId>hawkbit-repository-test</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@@ -7,18 +7,18 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: EPL-2.0
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.rsql.sa;
|
package org.eclipse.hawkbit.repository.jpa.ql;
|
||||||
|
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.EQ;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.EQ;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.GT;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.GT;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.GTE;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.GTE;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.IN;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.IN;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.LIKE;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.LIKE;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.LT;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.LT;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.LTE;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.LTE;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.NE;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.NE;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.NOT_IN;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.NOT_IN;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.NOT_LIKE;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.NOT_LIKE;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@@ -29,30 +29,29 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.Node;
|
import org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator;
|
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlParser;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides matching reference for if an object matches a {@link Node}.
|
* Provides entity matcher that matches an entity object against a filter (a {@link Node} or an RSQL string).
|
||||||
*/
|
*/
|
||||||
class ReferenceMatcher {
|
public class EntityMatcher {
|
||||||
|
|
||||||
private final Node root;
|
private final Node root;
|
||||||
|
|
||||||
private ReferenceMatcher(final Node root) {
|
private EntityMatcher(final Node root) {
|
||||||
this.root = root;
|
this.root = root;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ReferenceMatcher of(final Node root) {
|
public static EntityMatcher forNode(final Node root) {
|
||||||
return new ReferenceMatcher(root);
|
return new EntityMatcher(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ReferenceMatcher ofRsql(final String rsql) {
|
public static EntityMatcher forRsql(final String rsql) {
|
||||||
return of(RsqlParser.parse(rsql));
|
return forNode(RsqlParser.parse(rsql));
|
||||||
}
|
}
|
||||||
|
|
||||||
<T> boolean match(final T t) {
|
public <T> boolean match(final T t) {
|
||||||
return match(t, root);
|
return match(t, root);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: EPL-2.0
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
package org.eclipse.hawkbit.repository.jpa.ql;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -7,17 +7,17 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: EPL-2.0
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
package org.eclipse.hawkbit.repository.jpa.ql;
|
||||||
|
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.GT;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.GT;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.GTE;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.GTE;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.IN;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.IN;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.LIKE;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.LIKE;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.LT;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.LT;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.LTE;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.LTE;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.NE;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.NE;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.NOT_IN;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.NOT_IN;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.NOT_LIKE;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.NOT_LIKE;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -47,9 +47,9 @@ import jakarta.persistence.metamodel.SetAttribute;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison;
|
import org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator;
|
import org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.Node.Logical;
|
import org.eclipse.hawkbit.repository.jpa.ql.Node.Logical;
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.orm.jpa.vendor.Database;
|
import org.springframework.orm.jpa.vendor.Database;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2024 Contributors to the Eclipse Foundation
|
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||||
*
|
*
|
||||||
* This program and the accompanying materials are made
|
* This program and the accompanying materials are made
|
||||||
* available under the terms of the Eclipse Public License 2.0
|
* available under the terms of the Eclipse Public License 2.0
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: EPL-2.0
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
package org.eclipse.hawkbit.repository.jpa.ql.utils;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
@@ -18,17 +18,18 @@ import jakarta.persistence.criteria.CriteriaBuilder;
|
|||||||
import jakarta.persistence.criteria.CriteriaQuery;
|
import jakarta.persistence.criteria.CriteriaQuery;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.RsqlQueryField;
|
import org.eclipse.hawkbit.repository.RsqlQueryField;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlUtility;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder.RsqlToSpecBuilder;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder.RsqlToSpecBuilder;
|
||||||
import org.springframework.orm.jpa.vendor.Database;
|
import org.springframework.orm.jpa.vendor.Database;
|
||||||
|
|
||||||
public class RSQLToSQL {
|
public class HawkbitQlToSql {
|
||||||
|
|
||||||
private static final Database DATABASE = Database.H2;
|
private static final Database DATABASE = Database.H2;
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
private final boolean isEclipselink;
|
private final boolean isEclipselink;
|
||||||
|
|
||||||
public RSQLToSQL(final EntityManager entityManager) {
|
public HawkbitQlToSql(final EntityManager entityManager) {
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
isEclipselink = entityManager.getProperties().keySet().stream().anyMatch(key -> key.startsWith("eclipselink."));
|
isEclipselink = entityManager.getProperties().keySet().stream().anyMatch(key -> key.startsWith("eclipselink."));
|
||||||
}
|
}
|
||||||
@@ -65,7 +66,7 @@ public class RSQLToSQL {
|
|||||||
RsqlConfigHolder.getInstance().setRsqlToSpecBuilder(rsqlToSpecBuilder);
|
RsqlConfigHolder.getInstance().setRsqlToSpecBuilder(rsqlToSpecBuilder);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return query.where(RSQLUtility.<A, T> buildRsqlSpecification(rsql, fieldsClass, null, DATABASE)
|
return query.where(RsqlUtility.<A, T> buildRsqlSpecification(rsql, fieldsClass, null, DATABASE)
|
||||||
.toPredicate(query.from(domainClass), cb.createQuery(domainClass), cb));
|
.toPredicate(query.from(domainClass), cb.createQuery(domainClass), cb));
|
||||||
} finally {
|
} finally {
|
||||||
if (defaultRsqlToSpecBuilder != rsqlToSpecBuilder) {
|
if (defaultRsqlToSpecBuilder != rsqlToSpecBuilder) {
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: EPL-2.0
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
package org.eclipse.hawkbit.repository.jpa.ql.utils;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2021 Bosch.IO GmbH and others
|
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||||
*
|
*
|
||||||
* This program and the accompanying materials are made
|
* This program and the accompanying materials are made
|
||||||
* available under the terms of the Eclipse Public License 2.0
|
* available under the terms of the Eclipse Public License 2.0
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: EPL-2.0
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.rsql;
|
package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@@ -11,16 +11,16 @@ package org.eclipse.hawkbit.repository.jpa.rsql;
|
|||||||
|
|
||||||
import static org.eclipse.hawkbit.repository.RsqlQueryField.SUB_ATTRIBUTE_SEPARATOR;
|
import static org.eclipse.hawkbit.repository.RsqlQueryField.SUB_ATTRIBUTE_SEPARATOR;
|
||||||
import static org.eclipse.hawkbit.repository.RsqlQueryField.SUB_ATTRIBUTE_SPLIT_REGEX;
|
import static org.eclipse.hawkbit.repository.RsqlQueryField.SUB_ATTRIBUTE_SPLIT_REGEX;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.EQ;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.EQ;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.GT;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.GT;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.GTE;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.GTE;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.IN;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.IN;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.LIKE;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.LIKE;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.LT;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.LT;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.LTE;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.LTE;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.NE;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.NE;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.NOT_IN;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.NOT_IN;
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison.Operator.NOT_LIKE;
|
import static org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison.Operator.NOT_LIKE;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -45,7 +45,8 @@ import org.eclipse.hawkbit.repository.FieldValueConverter;
|
|||||||
import org.eclipse.hawkbit.repository.RsqlQueryField;
|
import org.eclipse.hawkbit.repository.RsqlQueryField;
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.Node.Comparison;
|
import org.eclipse.hawkbit.repository.jpa.ql.Node;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link RsqlParser} parses RSQL query stings to {@link Node} objects. Doing that it does the following:
|
* {@link RsqlParser} parses RSQL query stings to {@link Node} objects. Doing that it does the following:
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||||
*
|
*
|
||||||
* This program and the accompanying materials are made
|
* This program and the accompanying materials are made
|
||||||
* available under the terms of the Eclipse Public License 2.0
|
* available under the terms of the Eclipse Public License 2.0
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||||
|
|
||||||
import static org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder.RsqlToSpecBuilder.G3;
|
import static org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder.RsqlToSpecBuilder.G3;
|
||||||
|
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||||
@@ -23,8 +23,8 @@ import org.apache.commons.lang3.text.StrLookup;
|
|||||||
import org.eclipse.hawkbit.repository.RsqlQueryField;
|
import org.eclipse.hawkbit.repository.RsqlQueryField;
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsqllegacy.SpecificationBuilderLegacy;
|
import org.eclipse.hawkbit.repository.jpa.ql.SpecificationBuilder;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder;
|
import org.eclipse.hawkbit.repository.jpa.rsql.legacy.SpecificationBuilderLegacy;
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyResolver;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyResolver;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
@@ -65,7 +65,7 @@ import org.springframework.orm.jpa.vendor.Database;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public final class RSQLUtility {
|
public final class RsqlUtility {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a JPA {@link Specification} which corresponds with the given RSQL query. The specification can be used to filter for JPA entities
|
* Builds a JPA {@link Specification} which corresponds with the given RSQL query. The specification can be used to filter for JPA entities
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: EPL-2.0
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.rsqllegacy;
|
package org.eclipse.hawkbit.repository.jpa.rsql.legacy;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -25,8 +25,13 @@ import lombok.Value;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.hawkbit.repository.RsqlQueryField;
|
import org.eclipse.hawkbit.repository.RsqlQueryField;
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.ql.SpecificationBuilder;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Old implementation of RSQL Visitor (G2). Deprecated in favour of next gen implementation - {@link SpecificationBuilder}.
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "0.9.0")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class AbstractRSQLVisitor<A extends Enum<A> & RsqlQueryField> {
|
public abstract class AbstractRSQLVisitor<A extends Enum<A> & RsqlQueryField> {
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: EPL-2.0
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.rsqllegacy;
|
package org.eclipse.hawkbit.repository.jpa.rsql.legacy;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: EPL-2.0
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.rsqllegacy;
|
package org.eclipse.hawkbit.repository.jpa.rsql.legacy;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -44,6 +44,7 @@ import org.eclipse.hawkbit.repository.FieldValueConverter;
|
|||||||
import org.eclipse.hawkbit.repository.RsqlQueryField;
|
import org.eclipse.hawkbit.repository.RsqlQueryField;
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.ql.SpecificationBuilder;
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||||
import org.springframework.orm.jpa.vendor.Database;
|
import org.springframework.orm.jpa.vendor.Database;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
@@ -55,7 +56,7 @@ import org.springframework.util.ObjectUtils;
|
|||||||
* @param <A> the enum for providing the field name of the entity field to filter on.
|
* @param <A> the enum for providing the field name of the entity field to filter on.
|
||||||
* @param <T> the entity type referenced by the root
|
* @param <T> the entity type referenced by the root
|
||||||
* @deprecated Old implementation of RSQL Visitor (G2). Deprecated in favour of next gen implementation -
|
* @deprecated Old implementation of RSQL Visitor (G2). Deprecated in favour of next gen implementation -
|
||||||
* {@link org.eclipse.hawkbit.repository.jpa.rsql.SpecificationBuilder}.
|
* {@link SpecificationBuilder}.
|
||||||
* It will be kept for some time in order to keep backward compatibility and to allow for a smooth transition. Also, in case of
|
* It will be kept for some time in order to keep backward compatibility and to allow for a smooth transition. Also, in case of
|
||||||
* problems with the new implementation, this one can be used as a fallback.
|
* problems with the new implementation, this one can be used as a fallback.
|
||||||
*/
|
*/
|
||||||
@@ -7,10 +7,10 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: EPL-2.0
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.rsqllegacy;
|
package org.eclipse.hawkbit.repository.jpa.rsql.legacy;
|
||||||
|
|
||||||
import static org.eclipse.hawkbit.repository.jpa.rsqllegacy.AbstractRSQLVisitor.OPERATORS;
|
import static org.eclipse.hawkbit.repository.jpa.rsql.legacy.AbstractRSQLVisitor.OPERATORS;
|
||||||
import static org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G1;
|
import static org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G1;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -23,12 +23,17 @@ import cz.jirutka.rsql.parser.ast.RSQLVisitor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.hawkbit.repository.RsqlQueryField;
|
import org.eclipse.hawkbit.repository.RsqlQueryField;
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder;
|
import org.eclipse.hawkbit.repository.jpa.ql.SpecificationBuilder;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder;
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.orm.jpa.vendor.Database;
|
import org.springframework.orm.jpa.vendor.Database;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Old implementation of RSQL Visitor (G2). Deprecated in favour of next gen implementation - {@link SpecificationBuilder}.
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "0.9.0")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SpecificationBuilderLegacy<A extends Enum<A> & RsqlQueryField, T> {
|
public class SpecificationBuilderLegacy<A extends Enum<A> & RsqlQueryField, T> {
|
||||||
|
|
||||||
@@ -9,8 +9,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.rsql.sa;
|
package org.eclipse.hawkbit.repository.jpa.rsql.sa;
|
||||||
|
|
||||||
import static org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G1;
|
import static org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G1;
|
||||||
import static org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G2;
|
import static org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G2;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -18,9 +18,9 @@ import java.util.List;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.hawkbit.repository.RsqlQueryField;
|
import org.eclipse.hawkbit.repository.RsqlQueryField;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsqllegacy.SpecificationBuilderLegacy;
|
import org.eclipse.hawkbit.repository.jpa.rsql.legacy.SpecificationBuilderLegacy;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder.RsqlToSpecBuilder;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder.RsqlToSpecBuilder;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.orm.jpa.vendor.Database;
|
import org.springframework.orm.jpa.vendor.Database;
|
||||||
@@ -10,9 +10,9 @@
|
|||||||
package org.eclipse.hawkbit.repository.jpa.rsql.sa;
|
package org.eclipse.hawkbit.repository.jpa.rsql.sa;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder.RsqlToSpecBuilder.G3;
|
import static org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder.RsqlToSpecBuilder.G3;
|
||||||
import static org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G1;
|
import static org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G1;
|
||||||
import static org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G2;
|
import static org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder.RsqlToSpecBuilder.LEGACY_G2;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -22,10 +22,11 @@ import java.util.stream.StreamSupport;
|
|||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLToSQL;
|
import org.eclipse.hawkbit.repository.jpa.ql.EntityMatcher;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.ql.utils.HawkbitQlToSql;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlParser;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlParser;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.SpecificationBuilder;
|
import org.eclipse.hawkbit.repository.jpa.ql.SpecificationBuilder;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlConfigHolder;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.SpringBootConfiguration;
|
import org.springframework.boot.SpringBootConfiguration;
|
||||||
@@ -37,8 +38,7 @@ import org.springframework.orm.jpa.vendor.Database;
|
|||||||
|
|
||||||
@SuppressWarnings("java:S5961") // complex check because the matter is very complex
|
@SuppressWarnings("java:S5961") // complex check because the matter is very complex
|
||||||
@DataJpaTest(properties = {
|
@DataJpaTest(properties = {
|
||||||
"spring.jpa.database=H2",
|
"spring.jpa.database=H2"
|
||||||
"logging.level.org.eclipse.hawkbit.repository.jpa.rsql=DEBUG"
|
|
||||||
}, excludeAutoConfiguration = { FlywayAutoConfiguration.class })
|
}, excludeAutoConfiguration = { FlywayAutoConfiguration.class })
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -471,7 +471,7 @@ class SpecificationBuilderTest {
|
|||||||
|
|
||||||
private List<Root> filter(final String rsql) {
|
private List<Root> filter(final String rsql) {
|
||||||
// reference / auto filter (using elements and reflection)
|
// reference / auto filter (using elements and reflection)
|
||||||
final ReferenceMatcher matcher = ReferenceMatcher.ofRsql(rsql);
|
final EntityMatcher matcher = EntityMatcher.forRsql(rsql);
|
||||||
final List<Root> refResult = StreamSupport.stream(rootRepository.findAll().spliterator(), false).filter(matcher::match).toList();
|
final List<Root> refResult = StreamSupport.stream(rootRepository.findAll().spliterator(), false).filter(matcher::match).toList();
|
||||||
final List<Root> result = rootRepository.findAll(getSpecification(rsql));
|
final List<Root> result = rootRepository.findAll(getSpecification(rsql));
|
||||||
// auto check with reference result
|
// auto check with reference result
|
||||||
@@ -480,7 +480,7 @@ class SpecificationBuilderTest {
|
|||||||
} catch (final AssertionError e) {
|
} catch (final AssertionError e) {
|
||||||
log.error(
|
log.error(
|
||||||
"Fail to get expected result for RSQL: {} with SQL query: {}",
|
"Fail to get expected result for RSQL: {} with SQL query: {}",
|
||||||
rsql, new RSQLToSQL(entityManager).toSQL(Root.class, null, rsql, G3),
|
rsql, new HawkbitQlToSql(entityManager).toSQL(Root.class, null, rsql, G3),
|
||||||
e);
|
e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>hawkbit-repository-api</module>
|
<module>hawkbit-repository-api</module>
|
||||||
<module>hawkbit-repository-core</module>
|
<module>hawkbit-repository-core</module>
|
||||||
|
<module>hawkbit-repository-ql</module>
|
||||||
<module>hawkbit-repository-jpa-api</module>
|
<module>hawkbit-repository-jpa-api</module>
|
||||||
<module>hawkbit-repository-jpa-eclipselink</module>
|
<module>hawkbit-repository-jpa-eclipselink</module>
|
||||||
<module>hawkbit-repository-jpa-hibernate</module>
|
<module>hawkbit-repository-jpa-hibernate</module>
|
||||||
|
|||||||
6
pom.xml
6
pom.xml
@@ -67,7 +67,6 @@
|
|||||||
<!-- Misc libraries versions - START -->
|
<!-- Misc libraries versions - START -->
|
||||||
<cron-utils.version>9.2.1</cron-utils.version>
|
<cron-utils.version>9.2.1</cron-utils.version>
|
||||||
<jsoup.version>1.21.1</jsoup.version>
|
<jsoup.version>1.21.1</jsoup.version>
|
||||||
<javax.el-api.version>3.0.0</javax.el-api.version>
|
|
||||||
<rsql-parser.version>2.1.0</rsql-parser.version>
|
<rsql-parser.version>2.1.0</rsql-parser.version>
|
||||||
<commons-io.version>2.19.0</commons-io.version>
|
<commons-io.version>2.19.0</commons-io.version>
|
||||||
<commons-collections4.version>4.5.0</commons-collections4.version>
|
<commons-collections4.version>4.5.0</commons-collections4.version>
|
||||||
@@ -233,11 +232,6 @@
|
|||||||
<artifactId>jsoup</artifactId>
|
<artifactId>jsoup</artifactId>
|
||||||
<version>${jsoup.version}</version>
|
<version>${jsoup.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>javax.el</groupId>
|
|
||||||
<artifactId>javax.el-api</artifactId>
|
|
||||||
<version>${javax.el-api.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
Reference in New Issue
Block a user