builder.equal( busAdmins.get(OrganizationalEntityImpl_.id), userId ), busAdmins.get(OrganizationalEntityImpl_.id).in(groupIds) ) ); predicates.add( builder.or( builder.equal( potOwners.get(OrganizationalEntityImpl_.id), userId ), potOwners.get(OrganizationalEntityImpl_.id).in(groupIds) ) ); predicates.add( builder.or( builder.equal( stakeHols.get(OrganizationalEntityImpl_.id), userId ), stakeHols.get(OrganizationalEntityImpl_.id).in(groupIds) ) );
/** * @param assignedTargetId * the targetID which is assigned to a distribution set to search * for. * @return the specification to search for a distribution set which is * assigned to the given targetId */ public static Specification<JpaDistributionSet> assignedTarget(final String assignedTargetId) { return (dsRoot, query, cb) -> { final ListJoin<JpaDistributionSet, JpaTarget> assignedTargetJoin = dsRoot .join(JpaDistributionSet_.assignedToTargets, JoinType.INNER); return cb.equal(assignedTargetJoin.get(JpaTarget_.controllerId), assignedTargetId); }; }
/** * @param installedTargetId * the targetID which is installed to a distribution set to * search for. * @return the specification to search for a distribution set which is * installed to the given targetId */ public static Specification<JpaDistributionSet> installedTarget(final String installedTargetId) { return (dsRoot, query, cb) -> { final ListJoin<JpaDistributionSet, JpaTarget> installedTargetJoin = dsRoot .join(JpaDistributionSet_.installedAtTargets, JoinType.INNER); return cb.equal(installedTargetJoin.get(JpaTarget_.controllerId), installedTargetId); }; }
/** * @param installedTargetId * the targetID which is installed to a distribution set to * search for. * @return the specification to search for a distribution set which is * installed to the given targetId */ public static Specification<JpaDistributionSet> installedTarget(final String installedTargetId) { return (dsRoot, query, cb) -> { final ListJoin<JpaDistributionSet, JpaTarget> installedTargetJoin = dsRoot .join(JpaDistributionSet_.installedAtTargets, JoinType.INNER); return cb.equal(installedTargetJoin.get(JpaTarget_.controllerId), installedTargetId); }; }
/** * @param assignedTargetId * the targetID which is assigned to a distribution set to search * for. * @return the specification to search for a distribution set which is * assigned to the given targetId */ public static Specification<JpaDistributionSet> assignedTarget(final String assignedTargetId) { return (dsRoot, query, cb) -> { final ListJoin<JpaDistributionSet, JpaTarget> assignedTargetJoin = dsRoot .join(JpaDistributionSet_.assignedToTargets, JoinType.INNER); return cb.equal(assignedTargetJoin.get(JpaTarget_.controllerId), assignedTargetId); }; }
public static Specification<TaskData> hasProperty(TaskProperty taskProperty) { return (root, query, cb) -> { final ListJoin<TaskData, TaskPropertyData> join = root.join(TaskData_.properties); final Path<String> stringPath = root.get(TaskData_.state); return cb.and( cb.equal(join.get(TaskPropertyData_.name), taskProperty.name()), cb.equal(join.get(TaskPropertyData_.value), taskProperty.value()) ); }; }
/** * {@link Specification} for retrieving {@link Target}s that don't have the * given distribution set in their action history * * @param distributionSetId * the ID of the distribution set which must not be assigned * @return the {@link Target} {@link Specification} */ public static Specification<JpaTarget> hasNotDistributionSetInActions(final Long distributionSetId) { return (targetRoot, query, cb) -> { final ListJoin<JpaTarget, JpaAction> actionsJoin = targetRoot.join(JpaTarget_.actions, JoinType.LEFT); actionsJoin.on(cb.equal(actionsJoin.get(JpaAction_.distributionSet).get(JpaDistributionSet_.id), distributionSetId)); return cb.isNull(actionsJoin.get(JpaAction_.id)); }; }
/** * {@link Specification} for retrieving {@link Target}s that don't have the * given distribution set in their action history * * @param distributionSetId * the ID of the distribution set which must not be assigned * @return the {@link Target} {@link Specification} */ public static Specification<JpaTarget> hasNotDistributionSetInActions(final Long distributionSetId) { return (targetRoot, query, cb) -> { final ListJoin<JpaTarget, JpaAction> actionsJoin = targetRoot.join(JpaTarget_.actions, JoinType.LEFT); actionsJoin.on(cb.equal(actionsJoin.get(JpaAction_.distributionSet).get(JpaDistributionSet_.id), distributionSetId)); return cb.isNull(actionsJoin.get(JpaAction_.id)); }; }
/** * {@link Specification} for retrieving {@link Target}s that have no Action * of the {@link RolloutGroup}. * * @param group * the {@link RolloutGroup} * @return the {@link Target} {@link Specification} */ public static Specification<JpaTarget> hasNoActionInRolloutGroup(final Long group) { return (targetRoot, query, cb) -> { final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = targetRoot .join(JpaTarget_.rolloutTargetGroup, JoinType.INNER); rolloutTargetJoin.on( cb.equal(rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup).get(JpaRolloutGroup_.id), group)); final ListJoin<JpaTarget, JpaAction> actionsJoin = targetRoot.join(JpaTarget_.actions, JoinType.LEFT); actionsJoin.on(cb.equal(actionsJoin.get(JpaAction_.rolloutGroup).get(JpaRolloutGroup_.id), group)); return cb.isNull(actionsJoin.get(JpaAction_.id)); }; }
/** * {@link Specification} for retrieving {@link Target}s that have no Action * of the {@link RolloutGroup}. * * @param group * the {@link RolloutGroup} * @return the {@link Target} {@link Specification} */ public static Specification<JpaTarget> hasNoActionInRolloutGroup(final Long group) { return (targetRoot, query, cb) -> { final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = targetRoot .join(JpaTarget_.rolloutTargetGroup, JoinType.INNER); rolloutTargetJoin.on( cb.equal(rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup).get(JpaRolloutGroup_.id), group)); final ListJoin<JpaTarget, JpaAction> actionsJoin = targetRoot.join(JpaTarget_.actions, JoinType.LEFT); actionsJoin.on(cb.equal(actionsJoin.get(JpaAction_.rolloutGroup).get(JpaRolloutGroup_.id), group)); return cb.isNull(actionsJoin.get(JpaAction_.id)); }; }
/** * {@link Specification} for retrieving {@link Target}s that are not in the * given {@link RolloutGroup}s * * @param groups * the {@link RolloutGroup}s * @return the {@link Target} {@link Specification} */ public static Specification<JpaTarget> isNotInRolloutGroups(final Collection<Long> groups) { return (targetRoot, query, cb) -> { final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = targetRoot .join(JpaTarget_.rolloutTargetGroup, JoinType.LEFT); final Predicate inRolloutGroups = rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup) .get(JpaRolloutGroup_.id).in(groups); rolloutTargetJoin.on(inRolloutGroups); return cb.isNull(rolloutTargetJoin.get(RolloutTargetGroup_.target)); }; }
/** * {@link Specification} for retrieving {@link Target}s that are not in the * given {@link RolloutGroup}s * * @param groups * the {@link RolloutGroup}s * @return the {@link Target} {@link Specification} */ public static Specification<JpaTarget> isNotInRolloutGroups(final Collection<Long> groups) { return (targetRoot, query, cb) -> { final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = targetRoot .join(JpaTarget_.rolloutTargetGroup, JoinType.LEFT); final Predicate inRolloutGroups = rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup) .get(JpaRolloutGroup_.id).in(groups); rolloutTargetJoin.on(inRolloutGroups); return cb.isNull(rolloutTargetJoin.get(RolloutTargetGroup_.target)); }; }
/** * Specification which joins all necessary tables to retrieve the dependency * between a target and a local file assignment through the assigned action * of the target. All actions are included, not only active actions. * * @param targetId * the target to verify if the given artifact is currently * assigned or had been assigned * @param sha1Hash * of the local artifact to check wherever the target had ever * been assigned * @return a specification to use with spring JPA */ public static Specification<JpaAction> hasTargetAssignedArtifact(final Long targetId, final String sha1Hash) { return (actionRoot, query, criteriaBuilder) -> { final Join<JpaAction, JpaDistributionSet> dsJoin = actionRoot.join(JpaAction_.distributionSet); final SetJoin<JpaDistributionSet, JpaSoftwareModule> modulesJoin = dsJoin.join(JpaDistributionSet_.modules); final ListJoin<JpaSoftwareModule, JpaArtifact> artifactsJoin = modulesJoin .join(JpaSoftwareModule_.artifacts); return criteriaBuilder.and(criteriaBuilder.equal(artifactsJoin.get(JpaArtifact_.sha1Hash), sha1Hash), criteriaBuilder.equal(actionRoot.get(JpaAction_.target).get(JpaTarget_.id), targetId)); }; } }
/** * Specification which joins all necessary tables to retrieve the dependency * between a target and a local file assignment through the assigned action * of the target. All actions are included, not only active actions. * * @param controllerId * the target to verify if the given artifact is currently * assigned or had been assigned * @param sha1Hash * of the local artifact to check wherever the target had ever * been assigned * @return a specification to use with spring JPA */ public static Specification<JpaAction> hasTargetAssignedArtifact(final String controllerId, final String sha1Hash) { return (actionRoot, query, criteriaBuilder) -> { final Join<JpaAction, JpaDistributionSet> dsJoin = actionRoot.join(JpaAction_.distributionSet); final SetJoin<JpaDistributionSet, JpaSoftwareModule> modulesJoin = dsJoin.join(JpaDistributionSet_.modules); final ListJoin<JpaSoftwareModule, JpaArtifact> artifactsJoin = modulesJoin .join(JpaSoftwareModule_.artifacts); return criteriaBuilder.and(criteriaBuilder.equal(artifactsJoin.get(JpaArtifact_.sha1Hash), sha1Hash), criteriaBuilder.equal(actionRoot.get(JpaAction_.target).get(JpaTarget_.controllerId), controllerId)); }; }
/** * Specification which joins all necessary tables to retrieve the dependency * between a target and a local file assignment through the assigned action * of the target. All actions are included, not only active actions. * * @param controllerId * the target to verify if the given artifact is currently * assigned or had been assigned * @param sha1Hash * of the local artifact to check wherever the target had ever * been assigned * @return a specification to use with spring JPA */ public static Specification<JpaAction> hasTargetAssignedArtifact(final String controllerId, final String sha1Hash) { return (actionRoot, query, criteriaBuilder) -> { final Join<JpaAction, JpaDistributionSet> dsJoin = actionRoot.join(JpaAction_.distributionSet); final SetJoin<JpaDistributionSet, JpaSoftwareModule> modulesJoin = dsJoin.join(JpaDistributionSet_.modules); final ListJoin<JpaSoftwareModule, JpaArtifact> artifactsJoin = modulesJoin .join(JpaSoftwareModule_.artifacts); return criteriaBuilder.and(criteriaBuilder.equal(artifactsJoin.get(JpaArtifact_.sha1Hash), sha1Hash), criteriaBuilder.equal(actionRoot.get(JpaAction_.target).get(JpaTarget_.controllerId), controllerId)); }; }
/** * Specification which joins all necessary tables to retrieve the dependency * between a target and a local file assignment through the assigned action * of the target. All actions are included, not only active actions. * * @param targetId * the target to verify if the given artifact is currently * assigned or had been assigned * @param sha1Hash * of the local artifact to check wherever the target had ever * been assigned * @return a specification to use with spring JPA */ public static Specification<JpaAction> hasTargetAssignedArtifact(final Long targetId, final String sha1Hash) { return (actionRoot, query, criteriaBuilder) -> { final Join<JpaAction, JpaDistributionSet> dsJoin = actionRoot.join(JpaAction_.distributionSet); final SetJoin<JpaDistributionSet, JpaSoftwareModule> modulesJoin = dsJoin.join(JpaDistributionSet_.modules); final ListJoin<JpaSoftwareModule, JpaArtifact> artifactsJoin = modulesJoin .join(JpaSoftwareModule_.artifacts); return criteriaBuilder.and(criteriaBuilder.equal(artifactsJoin.get(JpaArtifact_.sha1Hash), sha1Hash), criteriaBuilder.equal(actionRoot.get(JpaAction_.target).get(JpaTarget_.id), targetId)); }; } }
@Override public Page<Target> findTargetsOfRolloutGroupByRsql(final Pageable pageable, final long rolloutGroupId, final String rsqlParam) { throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId); final Specification<JpaTarget> rsqlSpecification = RSQLUtility.parse(rsqlParam, TargetFields.class, virtualPropertyReplacer, database); return convertTPage(targetRepository.findAll((root, query, criteriaBuilder) -> { final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = root.join(JpaTarget_.rolloutTargetGroup); return criteriaBuilder.and(rsqlSpecification.toPredicate(root, query, criteriaBuilder), criteriaBuilder.equal( rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup).get(JpaRolloutGroup_.id), rolloutGroupId)); }, pageable), pageable); }
@Override public Page<Target> findTargetsOfRolloutGroupByRsql(final Pageable pageable, final long rolloutGroupId, final String rsqlParam) { throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId); final Specification<JpaTarget> rsqlSpecification = RSQLUtility.parse(rsqlParam, TargetFields.class, virtualPropertyReplacer, database); return convertTPage(targetRepository.findAll((root, query, criteriaBuilder) -> { final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = root.join(JpaTarget_.rolloutTargetGroup); return criteriaBuilder.and(rsqlSpecification.toPredicate(root, query, criteriaBuilder), criteriaBuilder.equal( rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup).get(JpaRolloutGroup_.id), rolloutGroupId)); }, pageable), pageable); }
@Override public Specification<MainOrder> specification() { return (root, query, cb) -> { Predicate predicate = cb.equal(unitJoin.type(), HaierOrder.class); if (!StringUtils.isEmpty(mobile)) predicate = cb.and(predicate, cb.like(Customer.getMobile(MainOrder.getCustomer(root)) , "%" + mobile + "%")); if (depotId != null) { predicate = cb.and(predicate, cb.equal(unitJoin.get("origin").get("id"), depotId)); } if (!StringUtils.isEmpty(productCode)) { root.fetch(MainOrder_.amounts); predicate = cb.and(predicate , cb.equal(root.join(MainOrder_.amounts).key().get(MainGood_.product).get(Product_.code) , productCode)); } if (orderDate != null) { predicate = cb.and(predicate, JpaFunctionUtils.dateEqual(cb, root.get("orderTime"), orderDate)); } return predicate; }; } };