Skip to content

Commit

Permalink
Merge branch 'develop' into feature/orgs
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/com/epam/ta/reportportal/dao/util/RecordMappers.java
  • Loading branch information
grabsefx committed Dec 18, 2024
2 parents 239b084 + 8dcc514 commit 4337d0b
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 37 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=5.12.2
version=5.13.0
lombokVersion=1.18.30
jooqVersion=3.19.13
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -603,15 +604,13 @@ private List<Field<?>> getSelectSimpleFields() {
}

private List<Field<?>> 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));
}
},

Expand Down Expand Up @@ -1042,15 +1041,13 @@ private List<Field<?>> getSelectSimpleFields() {
}

private List<Field<?>> 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));
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -186,7 +187,7 @@ public Page<Launch> findAllLatestByFilter(Queryable filter, Pageable pageable) {
List<Field<?>> simpleSelectedFields = getLaunchSimpleSelectedFields();

List<Field<?>> selectFields = new ArrayList<>(simpleSelectedFields);
selectFields.add(getAttributeConcatedFields());
selectFields.addAll(getAttributeConcatenatedFields());

List<Field<?>> groupFields = new ArrayList<>(simpleSelectedFields);
for (SortField<?> sortField : sortFieldList) {
Expand Down Expand Up @@ -223,11 +224,14 @@ public Page<Launch> findAllLatestByFilter(Queryable filter, Pageable pageable) {
);
}

private Field<String[]> getAttributeConcatedFields() {
return DSL.arrayAgg(DSL.concat(
ITEM_ATTRIBUTE.KEY, DSL.val(":"),
ITEM_ATTRIBUTE.VALUE, DSL.val(":"),
ITEM_ATTRIBUTE.SYSTEM)).as(ATTRIBUTE_ALIAS);
private ArrayList<Field<JSON[]>> getAttributeConcatenatedFields() {
return Lists.newArrayList(
DSL.arrayAgg(DSL.jsonArray(
coalesce(ITEM_ATTRIBUTE.KEY, ""),
coalesce(ITEM_ATTRIBUTE.VALUE, ""),
ITEM_ATTRIBUTE.SYSTEM
))
.as(ATTRIBUTE_ALIAS));
}

private ArrayList<Field<?>> getLaunchSimpleSelectedFields() {
Expand Down Expand Up @@ -263,7 +267,7 @@ public Optional<Launch> findLastRun(Long projectId, String mode) {
List<Field<?>> simpleSelectedFields = getLaunchSimpleSelectedFields();

List<Field<?>> 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)
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/com/epam/ta/reportportal/dao/util/RecordMappers.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -554,17 +558,19 @@ public class RecordMappers {
List<ItemAttribute> attributeList = new ArrayList<>();

if (r.get(ATTRIBUTE_ALIAS) != null) {
String[] attributesArray = r.get(ATTRIBUTE_ALIAS, String[].class);
List<JSON> attributesArray = r.get(ATTRIBUTE_ALIAS, List.class);
Gson gson = new Gson();
Type listType = new TypeToken<List<String>>() {}.getType();

for (String attributeString : attributesArray) {
if (Strings.isEmpty(attributeString)) {
for (JSON attributeEntry : attributesArray) {
if (attributeEntry == null) {
continue;
}
String[] attributes = gson.<List<String>>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])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/db/fill/launch/launch-filtering-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4337d0b

Please sign in to comment.