update StringUtils.isEmpty -> hasLength

This commit is contained in:
ggmaleva 2021-09-30 16:03:31 +03:00
parent b9a96f2a3f
commit bf2de9f97c
No known key found for this signature in database
GPG Key ID: 0E412B78565B108F
17 changed files with 97 additions and 92 deletions

View File

@ -28,7 +28,7 @@ public class CommandToAuditLogConverter implements Converter<Command, CommandAud
model.setCommandType(CommandType.valueOf(command.getCommandType().name()));
model.setObjectType(TBaseUtil.unionFieldToEnum(command.getCommandBody(), ObjectType.class));
model.setObject(command.getCommandBody().getFieldValue().toString());
model.setInitiator(command.getUserInfo() != null && !StringUtils.isEmpty(command.getUserInfo().getUserId())
model.setInitiator(command.getUserInfo() != null && StringUtils.hasLength(command.getUserInfo().getUserId())
? command.getUserInfo().getUserId()
: UNKNOWN);
return model;

View File

@ -23,7 +23,7 @@ public class EventToAuditLogConverter implements Converter<Event, CommandAudit>
model.setCommandType(parseEventType(event));
model.setObjectType(ObjectType.valueOf(event.getRow().getListType().name()));
model.setObject(event.getRow().toString());
model.setInitiator(event.getUserInfo() != null && !StringUtils.isEmpty(event.getUserInfo().getUserId())
model.setInitiator(event.getUserInfo() != null && StringUtils.hasLength(event.getUserInfo().getUserId())
? event.getUserInfo().getUserId()
: UNKNOWN);
return model;

View File

@ -43,14 +43,14 @@ public class CommandAuditDaoImpl extends AbstractDao implements CommandAuditDao
.selectFrom(COMMAND_AUDIT);
Condition condition =
COMMAND_AUDIT.COMMAND_TYPE.in(commandTypes).and(COMMAND_AUDIT.OBJECT_TYPE.in(objectTypes));
SelectConditionStep<CommandAuditRecord> where = StringUtils.isEmpty(filterRequest.getSearchValue())
? select.where(condition.and(COMMAND_AUDIT.INSERT_TIME.between(from, to)))
: select.where(condition.and(
SelectConditionStep<CommandAuditRecord> where = StringUtils.hasLength(filterRequest.getSearchValue())
? select.where(condition.and(
COMMAND_AUDIT.INITIATOR.like(filterRequest.getSearchValue()))
.and(COMMAND_AUDIT.INSERT_TIME.between(from, to)));
Field field = StringUtils.isEmpty(filterRequest.getSortBy())
? COMMAND_AUDIT.INSERT_TIME
: COMMAND_AUDIT.field(filterRequest.getSortBy());
.and(COMMAND_AUDIT.INSERT_TIME.between(from, to)))
: select.where(condition.and(COMMAND_AUDIT.INSERT_TIME.between(from, to)));
Field field = StringUtils.hasLength(filterRequest.getSortBy())
? COMMAND_AUDIT.field(filterRequest.getSortBy())
: COMMAND_AUDIT.INSERT_TIME;
SelectSeekStep2<CommandAuditRecord, Object, String> auditRecords = addSortCondition(COMMAND_AUDIT.ID,
field, filterRequest.getSortOrder(), where);
return fetch(
@ -74,10 +74,10 @@ public class CommandAuditDaoImpl extends AbstractDao implements CommandAuditDao
SelectConditionStep<Record1<Integer>> where = getDslContext()
.selectCount()
.from(COMMAND_AUDIT)
.where(StringUtils.isEmpty(filterRequest.getSearchValue())
? condition.and(COMMAND_AUDIT.INSERT_TIME.between(from, to))
: condition.and(COMMAND_AUDIT.INITIATOR.like(filterRequest.getSearchValue()))
.and(COMMAND_AUDIT.INSERT_TIME.between(from, to)));
.where(StringUtils.hasLength(filterRequest.getSearchValue())
? condition.and(COMMAND_AUDIT.INITIATOR.like(filterRequest.getSearchValue()))
.and(COMMAND_AUDIT.INSERT_TIME.between(from, to))
: condition.and(COMMAND_AUDIT.INSERT_TIME.between(from, to)));
return fetchOne(where, Integer.class);
}

View File

@ -61,13 +61,13 @@ public class DefaultP2pReferenceDaoImpl extends AbstractDao implements DefaultRe
public List<DefaultP2pReferenceModel> filterReferences(FilterRequest filterRequest) {
SelectWhereStep<P2pFDefaultRefRecord> from = getDslContext()
.selectFrom(P2P_F_DEFAULT_REF);
Field<String> field = StringUtils.isEmpty(filterRequest.getSortBy())
? P2P_F_DEFAULT_REF.TEMPLATE_ID
: P2P_F_DEFAULT_REF.field(filterRequest.getSortBy(), String.class);
SelectConditionStep<P2pFDefaultRefRecord> whereQuery = StringUtils.isEmpty(filterRequest.getSearchValue())
? from.where(DSL.trueCondition())
: from.where(P2P_F_DEFAULT_REF.TEMPLATE_ID.like(filterRequest.getSearchValue())
.or(P2P_F_DEFAULT_REF.IDENTITY_ID.like(filterRequest.getSearchValue())));
Field<String> field = StringUtils.hasLength(filterRequest.getSortBy())
? P2P_F_DEFAULT_REF.field(filterRequest.getSortBy(), String.class)
: P2P_F_DEFAULT_REF.TEMPLATE_ID;
SelectConditionStep<P2pFDefaultRefRecord> whereQuery = StringUtils.hasLength(filterRequest.getSearchValue())
? from.where(P2P_F_DEFAULT_REF.TEMPLATE_ID.like(filterRequest.getSearchValue())
.or(P2P_F_DEFAULT_REF.IDENTITY_ID.like(filterRequest.getSearchValue())))
: from.where(DSL.trueCondition());
SelectSeekStep2<P2pFDefaultRefRecord, String, String> filterReferenceRecords = addSortCondition(
P2P_F_DEFAULT_REF.ID, field, filterRequest.getSortOrder(), whereQuery);
return fetch(addSeekIfNeed(
@ -83,7 +83,7 @@ public class DefaultP2pReferenceDaoImpl extends AbstractDao implements DefaultRe
SelectConditionStep<Record1<Integer>> where = getDslContext()
.selectCount()
.from(P2P_F_DEFAULT_REF)
.where(!StringUtils.isEmpty(filterValue)
.where(StringUtils.hasLength(filterValue)
? P2P_F_DEFAULT_REF.TEMPLATE_ID.like(filterValue)
.or(P2P_F_DEFAULT_REF.IDENTITY_ID.like(filterValue))
: DSL.noCondition());

View File

@ -99,7 +99,7 @@ public class P2PGroupDao extends AbstractDao implements GroupDao {
P2P_F_GROUP.MODIFIED_BY_USER)
.from(P2P_F_GROUP);
SelectConditionStep<Record1<String>> selectGroupsId = null;
if (!StringUtils.isEmpty(filterValue)) {
if (StringUtils.hasLength(filterValue)) {
selectGroupsId = getDslContext()
.selectDistinct(P2P_F_GROUP.GROUP_ID)
.from(P2P_F_GROUP)

View File

@ -73,13 +73,13 @@ public class P2pGroupReferenceDaoImpl extends AbstractDao implements P2pGroupRef
@Override
public List<P2pGroupReferenceModel> filterReference(FilterRequest filterRequest) {
SelectWhereStep<P2pFGroupReferenceRecord> from = getDslContext().selectFrom(P2P_F_GROUP_REFERENCE);
Field<String> field = StringUtils.isEmpty(filterRequest.getSortBy())
? P2P_F_GROUP_REFERENCE.GROUP_ID
: P2P_F_GROUP_REFERENCE.field(filterRequest.getSortBy(), String.class);
SelectConditionStep<P2pFGroupReferenceRecord> whereQuery = StringUtils.isEmpty(filterRequest.getSearchValue())
? from.where(DSL.trueCondition())
: from.where(P2P_F_GROUP_REFERENCE.GROUP_ID.like(filterRequest.getSearchValue())
.or(P2P_F_GROUP_REFERENCE.IDENTITY_ID.like(filterRequest.getSearchValue())));
Field<String> field = StringUtils.hasLength(filterRequest.getSortBy())
? P2P_F_GROUP_REFERENCE.field(filterRequest.getSortBy(), String.class)
: P2P_F_GROUP_REFERENCE.GROUP_ID;
SelectConditionStep<P2pFGroupReferenceRecord> whereQuery = StringUtils.hasLength(filterRequest.getSearchValue())
? from.where(P2P_F_GROUP_REFERENCE.GROUP_ID.like(filterRequest.getSearchValue())
.or(P2P_F_GROUP_REFERENCE.IDENTITY_ID.like(filterRequest.getSearchValue())))
: from.where(DSL.trueCondition());
SelectSeekStep2<P2pFGroupReferenceRecord, String, Long> filterGroupReferenceRecords =
addSortCondition(P2P_F_GROUP_REFERENCE.ID,
field, filterRequest.getSortOrder(), whereQuery);
@ -102,7 +102,7 @@ public class P2pGroupReferenceDaoImpl extends AbstractDao implements P2pGroupRef
SelectConditionStep<Record1<Integer>> where = getDslContext()
.selectCount()
.from(P2P_F_GROUP_REFERENCE)
.where(!StringUtils.isEmpty(filterValue)
.where(StringUtils.hasLength(filterValue)
? P2P_F_GROUP_REFERENCE.GROUP_ID.like(filterValue)
.or(P2P_F_GROUP_REFERENCE.IDENTITY_ID.like(filterValue))
: DSL.noCondition());

View File

@ -94,13 +94,13 @@ public class P2pReferenceDaoImpl extends AbstractDao implements P2pReferenceDao
public List<P2pReferenceModel> filterReferences(FilterRequest filterRequest, boolean isGlobal) {
SelectWhereStep<P2pFReferenceRecord> from = getDslContext()
.selectFrom(P2P_F_REFERENCE);
Field<String> field = StringUtils.isEmpty(filterRequest.getSortBy())
? P2P_F_REFERENCE.TEMPLATE_ID
: P2P_F_REFERENCE.field(filterRequest.getSortBy(), String.class);
SelectConditionStep<P2pFReferenceRecord> whereQuery = StringUtils.isEmpty(filterRequest.getSearchValue())
? from.where(DSL.trueCondition())
: from.where(P2P_F_REFERENCE.TEMPLATE_ID.like(filterRequest.getSearchValue())
.or(P2P_F_REFERENCE.IDENTITY_ID.like(filterRequest.getSearchValue())));
Field<String> field = StringUtils.hasLength(filterRequest.getSortBy())
? P2P_F_REFERENCE.field(filterRequest.getSortBy(), String.class)
: P2P_F_REFERENCE.TEMPLATE_ID;
SelectConditionStep<P2pFReferenceRecord> whereQuery = StringUtils.hasLength(filterRequest.getSearchValue())
? from.where(P2P_F_REFERENCE.TEMPLATE_ID.like(filterRequest.getSearchValue())
.or(P2P_F_REFERENCE.IDENTITY_ID.like(filterRequest.getSearchValue())))
: from.where(DSL.trueCondition());
SelectSeekStep2<P2pFReferenceRecord, String, String> filterReferenceRecords = addSortCondition(
P2P_F_REFERENCE.ID, field, filterRequest.getSortOrder(), whereQuery);
return fetch(
@ -118,7 +118,8 @@ public class P2pReferenceDaoImpl extends AbstractDao implements P2pReferenceDao
}
private Condition referenceFullFieldSearchCondition(String searchValue, Boolean isGlobal) {
return appendConditions(StringUtils.isEmpty(searchValue) ? DSL.trueCondition() : DSL.falseCondition(),
return appendConditions(StringUtils.hasLength(searchValue)
? DSL.falseCondition() : DSL.trueCondition(),
Operator.OR,
new ConditionParameterSource()
.addValue(P2P_F_REFERENCE.ID, searchValue, LIKE)

View File

@ -71,7 +71,7 @@ public class P2pTemplateDao extends AbstractDao implements TemplateDao {
p2pFTemplateRecord.setId(filterRequest.getLastId());
SelectConditionStep<P2pFTemplateRecord> where = getDslContext()
.selectFrom(P2P_F_TEMPLATE)
.where(!StringUtils.isEmpty(filterRequest.getSearchValue())
.where(StringUtils.hasLength(filterRequest.getSearchValue())
? P2P_F_TEMPLATE.ID.like(filterRequest.getSearchValue())
: DSL.noCondition());
SelectSeekStep1<P2pFTemplateRecord, String> selectSeekStep =
@ -95,7 +95,7 @@ public class P2pTemplateDao extends AbstractDao implements TemplateDao {
SelectConditionStep<Record1<Integer>> where = getDslContext()
.selectCount()
.from(P2P_F_TEMPLATE)
.where(!StringUtils.isEmpty(id) ? P2P_F_TEMPLATE.ID.like(id) : DSL.noCondition());
.where(StringUtils.hasLength(id) ? P2P_F_TEMPLATE.ID.like(id) : DSL.noCondition());
return fetchOne(where, Integer.class);
}

View File

@ -110,14 +110,14 @@ public class P2PWbListDaoImpl extends AbstractDao implements P2PWbListDao {
.selectFrom(P2P_WB_LIST_RECORDS);
Condition condition =
P2P_WB_LIST_RECORDS.LIST_NAME.in(listNames).and(P2P_WB_LIST_RECORDS.LIST_TYPE.eq(listType));
SelectConditionStep<P2pWbListRecordsRecord> whereQuery = StringUtils.isEmpty(filterRequest.getSearchValue())
? from.where(condition)
: from.where(condition.and(
SelectConditionStep<P2pWbListRecordsRecord> whereQuery = StringUtils.hasLength(filterRequest.getSearchValue())
? from.where(condition.and(
P2P_WB_LIST_RECORDS.VALUE.like(filterRequest.getSearchValue())
.or(P2P_WB_LIST_RECORDS.IDENTITY_ID.like(filterRequest.getSearchValue()))));
Field field = StringUtils.isEmpty(filterRequest.getSortBy())
? P2P_WB_LIST_RECORDS.INSERT_TIME
: P2P_WB_LIST_RECORDS.field(filterRequest.getSortBy());
.or(P2P_WB_LIST_RECORDS.IDENTITY_ID.like(filterRequest.getSearchValue()))))
: from.where(condition);
Field field = StringUtils.hasLength(filterRequest.getSortBy())
? P2P_WB_LIST_RECORDS.field(filterRequest.getSortBy())
: P2P_WB_LIST_RECORDS.INSERT_TIME;
SelectSeekStep2<P2pWbListRecordsRecord, Object, String> wbListRecordsRecords =
addSortCondition(P2P_WB_LIST_RECORDS.ID,
field, filterRequest.getSortOrder(), whereQuery);
@ -139,11 +139,11 @@ public class P2PWbListDaoImpl extends AbstractDao implements P2PWbListDao {
.from(P2P_WB_LIST_RECORDS);
Condition condition =
P2P_WB_LIST_RECORDS.LIST_NAME.in(listNames).and(P2P_WB_LIST_RECORDS.LIST_TYPE.eq(listType));
SelectConditionStep<Record1<Integer>> where = StringUtils.isEmpty(filterValue)
? from.where(condition)
: from.where(condition.and(
SelectConditionStep<Record1<Integer>> where = StringUtils.hasLength(filterValue)
? from.where(condition.and(
P2P_WB_LIST_RECORDS.VALUE.like(filterValue)
.or(P2P_WB_LIST_RECORDS.IDENTITY_ID.like(filterValue))));
.or(P2P_WB_LIST_RECORDS.IDENTITY_ID.like(filterValue))))
: from.where(condition);
return fetchOne(where, Integer.class);
}

View File

@ -61,14 +61,14 @@ public class DefaultPaymentReferenceDaoImpl extends AbstractDao
public List<DefaultPaymentReferenceModel> filterReferences(FilterRequest filterRequest) {
SelectWhereStep<FDefaultRefRecord> from = getDslContext()
.selectFrom(F_DEFAULT_REF);
Field<String> field = StringUtils.isEmpty(filterRequest.getSortBy())
? F_DEFAULT_REF.TEMPLATE_ID
: F_DEFAULT_REF.field(filterRequest.getSortBy(), String.class);
SelectConditionStep<FDefaultRefRecord> whereQuery = StringUtils.isEmpty(filterRequest.getSearchValue())
? from.where(DSL.trueCondition())
: from.where(F_DEFAULT_REF.TEMPLATE_ID.like(filterRequest.getSearchValue())
Field<String> field = StringUtils.hasLength(filterRequest.getSortBy())
? F_DEFAULT_REF.field(filterRequest.getSortBy(), String.class)
: F_DEFAULT_REF.TEMPLATE_ID;
SelectConditionStep<FDefaultRefRecord> whereQuery = StringUtils.hasLength(filterRequest.getSearchValue())
? from.where(F_DEFAULT_REF.TEMPLATE_ID.like(filterRequest.getSearchValue())
.or(F_DEFAULT_REF.PARTY_ID.like(filterRequest.getSearchValue()))
.or(F_DEFAULT_REF.SHOP_ID.like(filterRequest.getSearchValue())));
.or(F_DEFAULT_REF.SHOP_ID.like(filterRequest.getSearchValue())))
: from.where(DSL.trueCondition());
SelectSeekStep2<FDefaultRefRecord, String, String> filterReferenceRecords = addSortCondition(
F_DEFAULT_REF.ID, field, filterRequest.getSortOrder(), whereQuery);
return fetch(
@ -87,7 +87,7 @@ public class DefaultPaymentReferenceDaoImpl extends AbstractDao
SelectConditionStep<Record1<Integer>> where = getDslContext()
.selectCount()
.from(F_DEFAULT_REF)
.where(!StringUtils.isEmpty(filterValue)
.where(StringUtils.hasLength(filterValue)
? F_DEFAULT_REF.TEMPLATE_ID.like(filterValue)
.or(F_DEFAULT_REF.PARTY_ID.like(filterValue)
.or(F_DEFAULT_REF.SHOP_ID.like(filterValue)))

View File

@ -70,14 +70,14 @@ public class GroupReferenceDaoImpl extends AbstractDao implements PaymentGroupRe
public List<PaymentGroupReferenceModel> filterReference(FilterRequest filterRequest) {
SelectWhereStep<FGroupReferenceRecord> from = getDslContext()
.selectFrom(F_GROUP_REFERENCE);
Field<String> field = StringUtils.isEmpty(filterRequest.getSortBy())
? F_GROUP_REFERENCE.GROUP_ID
: F_GROUP_REFERENCE.field(filterRequest.getSortBy(), String.class);
SelectConditionStep<FGroupReferenceRecord> whereQuery = StringUtils.isEmpty(filterRequest.getSearchValue())
? from.where(DSL.trueCondition())
: from.where(F_GROUP_REFERENCE.GROUP_ID.like(filterRequest.getSearchValue())
Field<String> field = StringUtils.hasLength(filterRequest.getSortBy())
? F_GROUP_REFERENCE.field(filterRequest.getSortBy(), String.class)
: F_GROUP_REFERENCE.GROUP_ID;
SelectConditionStep<FGroupReferenceRecord> whereQuery = StringUtils.hasLength(filterRequest.getSearchValue())
? from.where(F_GROUP_REFERENCE.GROUP_ID.like(filterRequest.getSearchValue())
.or(F_GROUP_REFERENCE.PARTY_ID.like(filterRequest.getSearchValue())
.or(F_GROUP_REFERENCE.SHOP_ID.like(filterRequest.getSearchValue()))));
.or(F_GROUP_REFERENCE.SHOP_ID.like(filterRequest.getSearchValue()))))
: from.where(DSL.trueCondition());
SelectSeekStep2<FGroupReferenceRecord, String, Long> filterGroupReferenceRecords = addSortCondition(
F_GROUP_REFERENCE.ID, field, filterRequest.getSortOrder(), whereQuery);
return fetch(
@ -94,7 +94,7 @@ public class GroupReferenceDaoImpl extends AbstractDao implements PaymentGroupRe
SelectConditionStep<Record1<Integer>> where = getDslContext()
.selectCount()
.from(F_GROUP_REFERENCE)
.where(!StringUtils.isEmpty(filterValue)
.where(StringUtils.hasLength(filterValue)
? F_GROUP_REFERENCE.GROUP_ID.like(filterValue)
.or(F_GROUP_REFERENCE.PARTY_ID.like(filterValue)
.or(F_GROUP_REFERENCE.SHOP_ID.like(filterValue)))

View File

@ -100,7 +100,7 @@ public class PaymentGroupDao extends AbstractDao implements GroupDao {
.select(F_GROUP.GROUP_ID, F_GROUP.TEMPLATE_ID, F_GROUP.PRIORITY, F_GROUP.LAST_UPDATE_DATE)
.from(F_GROUP);
SelectConditionStep<Record1<String>> selectGroupsId = null;
if (!StringUtils.isEmpty(filterValue)) {
if (StringUtils.hasLength(filterValue)) {
selectGroupsId = getDslContext()
.selectDistinct(F_GROUP.GROUP_ID)
.from(F_GROUP)
@ -108,7 +108,9 @@ public class PaymentGroupDao extends AbstractDao implements GroupDao {
.or(F_GROUP.TEMPLATE_ID.like(filterValue)));
}
List<GroupPriorityRow> list =
fetch(StringUtils.isEmpty(filterValue) ? from : from.where(F_GROUP.GROUP_ID.in(selectGroupsId)),
fetch(StringUtils.hasLength(filterValue)
? from.where(F_GROUP.GROUP_ID.in(selectGroupsId))
: from,
(rs, rowNum) -> createGroupPriorityRow(rs)
);
return groupRowToModelMapper.groupByGroupId(list);

View File

@ -112,13 +112,14 @@ public class PaymentReferenceDaoImpl extends AbstractDao implements PaymentRefer
public List<PaymentReferenceModel> filterReferences(FilterRequest filterRequest) {
SelectWhereStep<FReferenceRecord> from = getDslContext()
.selectFrom(F_REFERENCE);
Field<String> field = StringUtils.isEmpty(filterRequest.getSortBy()) ? F_REFERENCE.TEMPLATE_ID :
F_REFERENCE.field(filterRequest.getSortBy(), String.class);
SelectConditionStep<FReferenceRecord> whereQuery = StringUtils.isEmpty(filterRequest.getSearchValue())
? from.where(DSL.trueCondition())
: from.where(F_REFERENCE.TEMPLATE_ID.like(filterRequest.getSearchValue())
Field<String> field = StringUtils.hasLength(filterRequest.getSortBy())
? F_REFERENCE.field(filterRequest.getSortBy(), String.class)
: F_REFERENCE.TEMPLATE_ID;
SelectConditionStep<FReferenceRecord> whereQuery = StringUtils.hasLength(filterRequest.getSearchValue())
? from.where(F_REFERENCE.TEMPLATE_ID.like(filterRequest.getSearchValue())
.or(F_REFERENCE.PARTY_ID.like(filterRequest.getSearchValue()))
.or(F_REFERENCE.SHOP_ID.like(filterRequest.getSearchValue())));
.or(F_REFERENCE.SHOP_ID.like(filterRequest.getSearchValue())))
: from.where(DSL.trueCondition());
SelectSeekStep2<FReferenceRecord, String, String> filterReferenceRecords = addSortCondition(
F_REFERENCE.ID, field, filterRequest.getSortOrder(), whereQuery);
return fetch(
@ -137,7 +138,7 @@ public class PaymentReferenceDaoImpl extends AbstractDao implements PaymentRefer
SelectConditionStep<Record1<Integer>> where = getDslContext()
.selectCount()
.from(F_REFERENCE)
.where(!StringUtils.isEmpty(filterValue)
.where(StringUtils.hasLength(filterValue)
? F_REFERENCE.TEMPLATE_ID.like(filterValue)
.or(F_REFERENCE.PARTY_ID.like(filterValue)
.or(F_REFERENCE.SHOP_ID.like(filterValue)))

View File

@ -81,7 +81,7 @@ public class PaymentTemplateDao extends AbstractDao implements TemplateDao {
filterTemplateRecord.setId(filterRequest.getLastId());
SelectConditionStep<FTemplateRecord> where = getDslContext()
.selectFrom(F_TEMPLATE)
.where(!StringUtils.isEmpty(filterRequest.getSearchValue())
.where(StringUtils.hasLength(filterRequest.getSearchValue())
? F_TEMPLATE.ID.like(filterRequest.getSearchValue())
: DSL.noCondition());
SelectSeekStep1<FTemplateRecord, String> selectSeekStep =
@ -95,7 +95,7 @@ public class PaymentTemplateDao extends AbstractDao implements TemplateDao {
SelectConditionStep<Record1<Integer>> where = getDslContext()
.selectCount()
.from(F_TEMPLATE)
.where(!StringUtils.isEmpty(id) ? F_TEMPLATE.ID.like(id) : DSL.noCondition());
.where(StringUtils.hasLength(id) ? F_TEMPLATE.ID.like(id) : DSL.noCondition());
return fetchOne(where, Integer.class);
}

View File

@ -120,14 +120,15 @@ public class WbListDaoImpl extends AbstractDao implements WbListDao {
SelectWhereStep<WbListRecordsRecord> from = getDslContext()
.selectFrom(WB_LIST_RECORDS);
Condition condition = WB_LIST_RECORDS.LIST_NAME.in(listNames).and(WB_LIST_RECORDS.LIST_TYPE.eq(listType));
SelectConditionStep<WbListRecordsRecord> whereQuery = StringUtils.isEmpty(filterRequest.getSearchValue())
? from.where(condition)
: from.where(condition.and(
SelectConditionStep<WbListRecordsRecord> whereQuery = StringUtils.hasLength(filterRequest.getSearchValue())
? from.where(condition.and(
WB_LIST_RECORDS.VALUE.like(filterRequest.getSearchValue())
.or(WB_LIST_RECORDS.PARTY_ID.like(filterRequest.getSearchValue())
.or(WB_LIST_RECORDS.SHOP_ID.like(filterRequest.getSearchValue())))));
Field field = StringUtils.isEmpty(filterRequest.getSortBy()) ? WB_LIST_RECORDS.INSERT_TIME :
WB_LIST_RECORDS.field(filterRequest.getSortBy());
.or(WB_LIST_RECORDS.SHOP_ID.like(filterRequest.getSearchValue())))))
: from.where(condition);
Field field = StringUtils.hasLength(filterRequest.getSortBy())
? WB_LIST_RECORDS.field(filterRequest.getSortBy())
: WB_LIST_RECORDS.INSERT_TIME;
SelectSeekStep2<WbListRecordsRecord, Object, String> wbListRecordsRecords = addSortCondition(WB_LIST_RECORDS.ID,
field, filterRequest.getSortOrder(), whereQuery);
return fetch(
@ -146,12 +147,12 @@ public class WbListDaoImpl extends AbstractDao implements WbListDao {
.selectCount()
.from(WB_LIST_RECORDS);
Condition condition = WB_LIST_RECORDS.LIST_NAME.in(listNames).and(WB_LIST_RECORDS.LIST_TYPE.eq(listType));
SelectConditionStep<Record1<Integer>> where = StringUtils.isEmpty(filterValue)
? from.where(condition)
: from.where(condition.and(
SelectConditionStep<Record1<Integer>> where = StringUtils.hasLength(filterValue)
? from.where(condition.and(
WB_LIST_RECORDS.VALUE.like(filterValue)
.or(WB_LIST_RECORDS.PARTY_ID.like(filterValue)
.or(WB_LIST_RECORDS.SHOP_ID.like(filterValue)))));
.or(WB_LIST_RECORDS.SHOP_ID.like(filterValue)))))
: from.where(condition);
return fetchOne(where, Integer.class);
}

View File

@ -29,7 +29,7 @@ public class CsvFraudPaymentParser implements CsvParser<FraudPayment> {
@Override
public FraudPayment mapFraudPayment(CSVRecord csvRecord) {
String eventTime = Instant.now().toString();
if (!StringUtils.isEmpty(csvRecord.get(CsvFraudPaymentFields.EVENT_TIME))) {
if (StringUtils.hasLength(csvRecord.get(CsvFraudPaymentFields.EVENT_TIME))) {
isValidFormat(csvRecord.get(CsvFraudPaymentFields.EVENT_TIME));
eventTime = csvRecord.get(CsvFraudPaymentFields.EVENT_TIME);
}

View File

@ -5,7 +5,7 @@ import com.rbkmoney.fraudbusters.management.domain.tables.pojos.CommandAudit;
import org.junit.jupiter.api.Test;
import org.springframework.util.StringUtils;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
class EventToAuditLogConverterTest {
@ -22,7 +22,7 @@ class EventToAuditLogConverterTest {
.setUserInfo(new UserInfo())
.setCommandTime(""));
assertFalse(StringUtils.isEmpty(audit.getObject()));
assertTrue(StringUtils.hasLength(audit.getObject()));
audit = eventToAuditLogConverter.convert(new Event().setEventType(EventType.CREATED)
.setRow(new Row()
@ -33,6 +33,6 @@ class EventToAuditLogConverterTest {
.setUserInfo(new UserInfo())
.setCommandTime(""));
assertFalse(StringUtils.isEmpty(audit.getObject()));
assertTrue(StringUtils.hasLength(audit.getObject()));
}
}