From 766ed0651de813e48c3bc09ad40135d0f17088bb Mon Sep 17 00:00:00 2001 From: David Randolph Phillips Date: Wed, 4 Sep 2024 16:09:26 -0400 Subject: [PATCH] [BI-2267] Addressed bug that occures when a trailing blank is in Breeding Method Name --- .../daos/impl/BreedingMethodDAOImpl.java | 9 +++++---- ...29.0__remove_blank_from_breeding_method.sql | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/db/migration/V1.29.0__remove_blank_from_breeding_method.sql diff --git a/src/main/java/org/breedinginsight/daos/impl/BreedingMethodDAOImpl.java b/src/main/java/org/breedinginsight/daos/impl/BreedingMethodDAOImpl.java index 6e0f7e71e..aed68e119 100644 --- a/src/main/java/org/breedinginsight/daos/impl/BreedingMethodDAOImpl.java +++ b/src/main/java/org/breedinginsight/daos/impl/BreedingMethodDAOImpl.java @@ -4,6 +4,7 @@ import org.breedinginsight.dao.db.tables.pojos.ProgramBreedingMethodEntity; import org.breedinginsight.daos.BreedingMethodDAO; import org.jooq.*; +import org.jooq.impl.DSL; import javax.inject.Inject; import javax.inject.Singleton; @@ -54,13 +55,13 @@ public List getSystemBreedingMethods() { public List findByNameOrAbbreviation(String nameOrAbbrev, UUID programId) { List breedingMethodEntities = systemMethodBase(programId) - .and(BREEDING_METHOD.ABBREVIATION.equalIgnoreCase(nameOrAbbrev) - .or(BREEDING_METHOD.NAME.equalIgnoreCase(nameOrAbbrev))) + .and(DSL.trim(BREEDING_METHOD.ABBREVIATION).equalIgnoreCase(nameOrAbbrev) + .or(DSL.trim(BREEDING_METHOD.NAME).equalIgnoreCase(nameOrAbbrev))) .fetchInto(ProgramBreedingMethodEntity.class); List programBreedingMethodEntities = programMethodBase(programId) - .and(PROGRAM_BREEDING_METHOD.ABBREVIATION.equalIgnoreCase(nameOrAbbrev) - .or(PROGRAM_BREEDING_METHOD.NAME.equalIgnoreCase(nameOrAbbrev))) + .and(DSL.trim(PROGRAM_BREEDING_METHOD.ABBREVIATION).equalIgnoreCase(nameOrAbbrev) + .or(DSL.trim(PROGRAM_BREEDING_METHOD.NAME).equalIgnoreCase(nameOrAbbrev))) .fetchInto(ProgramBreedingMethodEntity.class); List ret = new ArrayList<>(); diff --git a/src/main/resources/db/migration/V1.29.0__remove_blank_from_breeding_method.sql b/src/main/resources/db/migration/V1.29.0__remove_blank_from_breeding_method.sql new file mode 100644 index 000000000..b0b873cd3 --- /dev/null +++ b/src/main/resources/db/migration/V1.29.0__remove_blank_from_breeding_method.sql @@ -0,0 +1,18 @@ +/* + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +update breeding_method set name = 'Bulk or population' where name = 'Bulk or population ';