Skip to content

Commit

Permalink
LPS-129972 Update usages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Preston-Crary committed Apr 1, 2021
1 parent 6313756 commit 5c43361
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 81 deletions.
Expand Up @@ -27,6 +27,7 @@
import com.liferay.account.service.base.AccountEntryLocalServiceBaseImpl;
import com.liferay.petra.sql.dsl.DSLFunctionFactoryUtil;
import com.liferay.petra.sql.dsl.DSLQueryFactoryUtil;
import com.liferay.petra.sql.dsl.expression.Expression;
import com.liferay.petra.sql.dsl.expression.Predicate;
import com.liferay.petra.sql.dsl.query.DSLQuery;
import com.liferay.petra.sql.dsl.query.FromStep;
Expand Down Expand Up @@ -723,30 +724,13 @@ private GroupByStep _getGroupByStep(
}

if (Validator.isNotNull(keywords)) {
String[] terms = _customSQL.keywords(keywords, true);

Predicate keywordsPredicate = null;

for (String term : terms) {
Predicate termPredicate = DSLFunctionFactoryUtil.lower(
AccountEntryTable.INSTANCE.name
).like(
term
);

if (keywordsPredicate == null) {
keywordsPredicate = termPredicate;
}
else {
keywordsPredicate = keywordsPredicate.or(
termPredicate);
}
}

if (keywordsPredicate != null) {
predicate = predicate.and(
keywordsPredicate.withParentheses());
}
predicate = predicate.and(
Predicate.withParentheses(
_customSQL.getKeywordsPredicate(
DSLFunctionFactoryUtil.lower(
AccountEntryTable.INSTANCE.name),
Expression::like,
_customSQL.keywords(keywords, true))));
}

if (types != null) {
Expand Down
Expand Up @@ -30,6 +30,7 @@
import com.liferay.change.tracking.service.persistence.CTAutoResolutionInfoPersistence;
import com.liferay.petra.sql.dsl.DSLFunctionFactoryUtil;
import com.liferay.petra.sql.dsl.DSLQueryFactoryUtil;
import com.liferay.petra.sql.dsl.expression.Expression;
import com.liferay.petra.sql.dsl.expression.Predicate;
import com.liferay.petra.sql.dsl.query.DSLQuery;
import com.liferay.petra.string.StringBundler;
Expand Down Expand Up @@ -442,42 +443,24 @@ private Predicate _getPredicate(
ArrayUtil.toArray(statuses)));
}

Predicate keywordsPredicate = null;

for (String keyword :
_customSQL.keywords(keywords, true, WildcardMode.SURROUND)) {

if (keyword == null) {
continue;
}

Predicate keywordPredicate = DSLFunctionFactoryUtil.lower(
CTCollectionTable.INSTANCE.name
).like(
keyword
).or(
DSLFunctionFactoryUtil.lower(
CTCollectionTable.INSTANCE.description
).like(
keyword
)
);

if (keywordsPredicate == null) {
keywordsPredicate = keywordPredicate;
}
else {
keywordsPredicate = keywordsPredicate.or(keywordPredicate);
}
}

if (keywordsPredicate != null) {
predicate = predicate.and(keywordsPredicate.withParentheses());
}
String[] keywordsArray = _customSQL.keywords(
keywords, true, WildcardMode.SURROUND);

return predicate.and(
Predicate.withParentheses(
Predicate.or(
_customSQL.getKeywordsPredicate(
DSLFunctionFactoryUtil.lower(
CTCollectionTable.INSTANCE.name),
Expression::like, keywordsArray),
_customSQL.getKeywordsPredicate(
DSLFunctionFactoryUtil.lower(
CTCollectionTable.INSTANCE.description),
Expression::like, keywordsArray)))
).and(
_inlineSQLHelper.getPermissionWherePredicate(
CTCollection.class, CTCollectionTable.INSTANCE.ctCollectionId));
CTCollection.class, CTCollectionTable.INSTANCE.ctCollectionId)
);
}

@Reference
Expand Down
Expand Up @@ -29,6 +29,7 @@
import com.liferay.commerce.account.util.CommerceAccountRoleHelper;
import com.liferay.petra.sql.dsl.DSLFunctionFactoryUtil;
import com.liferay.petra.sql.dsl.DSLQueryFactoryUtil;
import com.liferay.petra.sql.dsl.expression.Expression;
import com.liferay.petra.sql.dsl.expression.Predicate;
import com.liferay.petra.sql.dsl.query.DSLQuery;
import com.liferay.petra.sql.dsl.query.FromStep;
Expand Down Expand Up @@ -859,30 +860,13 @@ private GroupByStep _getGroupByStep(
}

if (Validator.isNotNull(keywords)) {
String[] terms = _customSQL.keywords(keywords, true);

Predicate keywordsPredicate = null;

for (String term : terms) {
Predicate termPredicate = DSLFunctionFactoryUtil.lower(
AccountEntryTable.INSTANCE.name
).like(
term
);

if (keywordsPredicate == null) {
keywordsPredicate = termPredicate;
}
else {
keywordsPredicate = keywordsPredicate.or(
termPredicate);
}
}

if (keywordsPredicate != null) {
predicate = predicate.and(
keywordsPredicate.withParentheses());
}
predicate = predicate.and(
Predicate.withParentheses(
_customSQL.getKeywordsPredicate(
DSLFunctionFactoryUtil.lower(
AccountEntryTable.INSTANCE.name),
Expression::like,
_customSQL.keywords(keywords, true))));
}

if (types != null) {
Expand Down

0 comments on commit 5c43361

Please sign in to comment.