diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c58ec7a82..ca38149fe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,9 +12,9 @@ on: env: GH_USER_NAME: github.actor SCRIPTS_VERSION: 5.12.0 - BOM_VERSION: 5.12.1 - MIGRATIONS_VERSION: 5.12.0 - RELEASE_VERSION: 5.12.1 + BOM_VERSION: 5.13.0 + MIGRATIONS_VERSION: 5.13.0 + RELEASE_VERSION: 5.13.0 jobs: release: diff --git a/build.gradle b/build.gradle index 800aedb37..bd5b32258 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,7 @@ ext['spring-boot.version'] = '2.5.15' dependencyManagement { imports { - mavenBom(releaseMode ? 'com.epam.reportportal:commons-bom:5.12.1' : 'com.epam.reportportal:commons-bom:5.12.1') + mavenBom(releaseMode ? 'com.epam.reportportal:commons-bom:5.13.0' : 'com.epam.reportportal:commons-bom:5.13.0') mavenBom('io.zonky.test.postgres:embedded-postgres-binaries-bom:16.2.0') } } @@ -122,3 +122,7 @@ tasks.withType(JavaCompile) { checkCommitNeeded.dependsOn removeScripts test.dependsOn copyTestDatabaseScripts //build.dependsOn jacocoTestReport + +tasks.preTagCommit.enabled = false +tasks.updateVersion.enabled = false +tasks.commitNewVersion.enabled = false diff --git a/gradle.properties b/gradle.properties index 6a568fd60..0a85bbffb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ -version=5.12.2 +version=5.13.0 lombokVersion=1.18.30 jooqVersion=3.19.13 \ No newline at end of file diff --git a/src/main/java/com/epam/ta/reportportal/commons/querygen/FilterTarget.java b/src/main/java/com/epam/ta/reportportal/commons/querygen/FilterTarget.java index cb73123f6..ec658b9f4 100644 --- a/src/main/java/com/epam/ta/reportportal/commons/querygen/FilterTarget.java +++ b/src/main/java/com/epam/ta/reportportal/commons/querygen/FilterTarget.java @@ -159,6 +159,7 @@ import static com.epam.ta.reportportal.jooq.Tables.WIDGET; import static com.epam.ta.reportportal.jooq.tables.JOwnedEntity.OWNED_ENTITY; import static org.jooq.impl.DSL.choose; +import static org.jooq.impl.DSL.coalesce; import static org.jooq.impl.DSL.field; import com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant; @@ -603,15 +604,13 @@ private List> getSelectSimpleFields() { } private List> getSelectAggregatedFields() { - return Lists.newArrayList(DSL.arrayAgg( - DSL.field("concat({0}, {1}, {2}, {3}, {4})", - ITEM_ATTRIBUTE.KEY, - KEY_VALUE_SEPARATOR, - ITEM_ATTRIBUTE.VALUE, - KEY_VALUE_SEPARATOR, - ITEM_ATTRIBUTE.SYSTEM - )).as(ATTRIBUTE_ALIAS) - ); + return Lists.newArrayList( + DSL.arrayAgg(DSL.jsonArray( + coalesce(ITEM_ATTRIBUTE.KEY, ""), + coalesce(ITEM_ATTRIBUTE.VALUE, ""), + ITEM_ATTRIBUTE.SYSTEM + )) + .as(ATTRIBUTE_ALIAS)); } }, @@ -1042,15 +1041,13 @@ private List> getSelectSimpleFields() { } private List> getSelectAggregatedFields() { - return Lists.newArrayList(DSL.arrayAgg( - DSL.field("concat({0}, {1}, {2}, {3}, {4})", - ITEM_ATTRIBUTE.KEY, - KEY_VALUE_SEPARATOR, - ITEM_ATTRIBUTE.VALUE, - KEY_VALUE_SEPARATOR, - ITEM_ATTRIBUTE.SYSTEM - )).as(ATTRIBUTE_ALIAS) - ); + return Lists.newArrayList( + DSL.arrayAgg(DSL.jsonArray( + coalesce(ITEM_ATTRIBUTE.KEY, ""), + coalesce(ITEM_ATTRIBUTE.VALUE, ""), + ITEM_ATTRIBUTE.SYSTEM + )) + .as(ATTRIBUTE_ALIAS)); } }, diff --git a/src/main/java/com/epam/ta/reportportal/dao/LaunchRepositoryCustomImpl.java b/src/main/java/com/epam/ta/reportportal/dao/LaunchRepositoryCustomImpl.java index 7bd1be7c6..9a2e1dd4f 100644 --- a/src/main/java/com/epam/ta/reportportal/dao/LaunchRepositoryCustomImpl.java +++ b/src/main/java/com/epam/ta/reportportal/dao/LaunchRepositoryCustomImpl.java @@ -67,6 +67,7 @@ import java.util.stream.Collectors; import org.jooq.DSLContext; import org.jooq.Field; +import org.jooq.JSON; import org.jooq.SortField; import org.jooq.impl.DSL; import org.springframework.beans.factory.annotation.Autowired; @@ -186,7 +187,7 @@ public Page findAllLatestByFilter(Queryable filter, Pageable pageable) { List> simpleSelectedFields = getLaunchSimpleSelectedFields(); List> selectFields = new ArrayList<>(simpleSelectedFields); - selectFields.add(getAttributeConcatedFields()); + selectFields.addAll(getAttributeConcatenatedFields()); List> groupFields = new ArrayList<>(simpleSelectedFields); for (SortField sortField : sortFieldList) { @@ -223,11 +224,14 @@ public Page findAllLatestByFilter(Queryable filter, Pageable pageable) { ); } - private Field getAttributeConcatedFields() { - return DSL.arrayAgg(DSL.concat( - ITEM_ATTRIBUTE.KEY, DSL.val(":"), - ITEM_ATTRIBUTE.VALUE, DSL.val(":"), - ITEM_ATTRIBUTE.SYSTEM)).as(ATTRIBUTE_ALIAS); + private ArrayList> getAttributeConcatenatedFields() { + return Lists.newArrayList( + DSL.arrayAgg(DSL.jsonArray( + coalesce(ITEM_ATTRIBUTE.KEY, ""), + coalesce(ITEM_ATTRIBUTE.VALUE, ""), + ITEM_ATTRIBUTE.SYSTEM + )) + .as(ATTRIBUTE_ALIAS)); } private ArrayList> getLaunchSimpleSelectedFields() { @@ -263,7 +267,7 @@ public Optional findLastRun(Long projectId, String mode) { List> simpleSelectedFields = getLaunchSimpleSelectedFields(); List> selectFields = new ArrayList<>(simpleSelectedFields); - selectFields.add(getAttributeConcatedFields()); + selectFields.addAll(getAttributeConcatenatedFields()); return LAUNCH_FETCHER.apply(dsl.fetch(dsl.with(FILTERED_QUERY) .as(dsl.select(LAUNCH.ID) diff --git a/src/main/java/com/epam/ta/reportportal/dao/util/RecordMappers.java b/src/main/java/com/epam/ta/reportportal/dao/util/RecordMappers.java index 6bc60fd39..28ad72b6c 100644 --- a/src/main/java/com/epam/ta/reportportal/dao/util/RecordMappers.java +++ b/src/main/java/com/epam/ta/reportportal/dao/util/RecordMappers.java @@ -110,7 +110,10 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import java.io.IOException; +import java.lang.reflect.Type; import java.time.Instant; import java.time.LocalDateTime; import java.util.ArrayList; @@ -126,6 +129,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.logging.log4j.util.Strings; import org.jooq.Field; +import org.jooq.JSON; import org.jooq.Record; import org.jooq.RecordMapper; import org.jooq.Result; @@ -554,17 +558,19 @@ public class RecordMappers { List attributeList = new ArrayList<>(); if (r.get(ATTRIBUTE_ALIAS) != null) { - String[] attributesArray = r.get(ATTRIBUTE_ALIAS, String[].class); + List attributesArray = r.get(ATTRIBUTE_ALIAS, List.class); + Gson gson = new Gson(); + Type listType = new TypeToken>() {}.getType(); - for (String attributeString : attributesArray) { - if (Strings.isEmpty(attributeString)) { + for (JSON attributeEntry : attributesArray) { + if (attributeEntry == null) { continue; } + String[] attributes = gson.>fromJson(attributeEntry.data(), listType) + .toArray(new String[0]); - // explode attributes from string "key:value:system" - String[] attributes = attributeString.split(":", -1); - if (attributes.length > 1 && (Strings.isNotEmpty(attributes[0]) || Strings.isNotEmpty( - attributes[1]))) { + if (attributes.length > 1 && (Strings.isNotEmpty(attributes[0]) + || Strings.isNotEmpty(attributes[1]))) { Boolean systemAttribute; //Case when system attribute is retrieved as 't' or 'f' if ("t".equals(attributes[2]) || "f".equals(attributes[2])) { diff --git a/src/test/java/com/epam/ta/reportportal/dao/LaunchCompositeAttributeFilteringTest.java b/src/test/java/com/epam/ta/reportportal/dao/LaunchCompositeAttributeFilteringTest.java index 883488e99..42fa8405d 100644 --- a/src/test/java/com/epam/ta/reportportal/dao/LaunchCompositeAttributeFilteringTest.java +++ b/src/test/java/com/epam/ta/reportportal/dao/LaunchCompositeAttributeFilteringTest.java @@ -41,6 +41,24 @@ void compositeAttributeHas() { assertEquals(1, launches.size()); assertEquals(1L, launches.get(0).getId()); + + launches = launchRepository.findByFilter( + buildFilterWithConditions(buildCompositeAttributeCondition(Condition.HAS, + "key:semi:value:colon", + false + ))); + + assertEquals(1, launches.size()); + assertEquals(1L, launches.get(0).getId()); + + launches = launchRepository.findByFilter( + buildFilterWithConditions(buildCompositeAttributeCondition(Condition.HAS, + "key:semi:value:colon,key1:value1,key2:value2,key3:value3", + false + ))); + + assertEquals(1, launches.size()); + assertEquals(1L, launches.get(0).getId()); } @Test diff --git a/src/test/resources/db/fill/launch/launch-filtering-data.sql b/src/test/resources/db/fill/launch/launch-filtering-data.sql index 14acbff58..75ea03015 100644 --- a/src/test/resources/db/fill/launch/launch-filtering-data.sql +++ b/src/test/resources/db/fill/launch/launch-filtering-data.sql @@ -10,6 +10,8 @@ INSERT INTO item_attribute(key, value, launch_id) VALUES ('key2', 'value2', 1); INSERT INTO item_attribute(key, value, launch_id) VALUES ('key3', 'value3', 1); +INSERT INTO item_attribute(key, value, launch_id) +VALUES ('key:semi', 'value:colon', 1); INSERT INTO launch(id, uuid, project_id, user_id, name, start_time, end_time, last_modified, mode, status)