Skip to content

Commit

Permalink
Remove hypersistence dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
barreiro authored and stalep committed Apr 2, 2024
1 parent 7dea250 commit 20417bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
5 changes: 0 additions & 5 deletions horreum-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.hypersistence</groupId>
<artifactId>hypersistence-utils-hibernate-62</artifactId>
<version>3.7.3</version>
</dependency>
<dependency>
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.hyperfoil.tools.horreum.svc;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.networknt.schema.AbsoluteIri;
import com.networknt.schema.JsonMetaSchema;
import com.networknt.schema.SchemaLocation;
Expand All @@ -19,6 +20,7 @@
import io.hyperfoil.tools.horreum.entity.data.RunDAO;
import io.hyperfoil.tools.horreum.entity.data.SchemaDAO;
import io.hyperfoil.tools.horreum.entity.data.TransformerDAO;
import io.hyperfoil.tools.horreum.hibernate.JsonBinaryType;
import io.hyperfoil.tools.horreum.mapper.DatasetMapper;
import io.hyperfoil.tools.horreum.mapper.LabelMapper;
import io.hyperfoil.tools.horreum.mapper.SchemaMapper;
Expand All @@ -30,7 +32,6 @@
import io.hyperfoil.tools.horreum.mapper.ValidationErrorMapper;
import io.hyperfoil.tools.horreum.server.WithRoles;
import io.hyperfoil.tools.horreum.server.WithToken;
import io.hypersistence.utils.hibernate.type.json.JsonBinaryType;
import io.quarkus.narayana.jta.runtime.TransactionConfiguration;
import io.quarkus.panache.common.Page;
import io.quarkus.panache.common.Sort;
Expand Down Expand Up @@ -68,9 +69,7 @@
import org.hibernate.Session;
import org.hibernate.query.NativeQuery;
import org.hibernate.query.SelectionQuery;
import org.hibernate.type.CustomType;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.spi.TypeConfiguration;
import org.jboss.logging.Logger;

import com.fasterxml.jackson.databind.JsonNode;
Expand Down Expand Up @@ -101,8 +100,6 @@ SELECT substring(jsonb_path_query(schema, '$.**.\"$ref\" ? (! (@ starts with \"#
""";
//@formatter:on

private final CustomType JSON_STRING_ARRY_TYPE = new CustomType<>(new JsonBinaryType(String[].class), new TypeConfiguration());

private static final JsonSchemaFactory JSON_SCHEMA_FACTORY = new JsonSchemaFactory.Builder()
.defaultMetaSchemaIri(JsonMetaSchema.getV4().getIri())
.addMetaSchema(JsonMetaSchema.getV4())
Expand Down Expand Up @@ -538,17 +535,17 @@ public List<LabelLocation> findUsages(String label) {
.addScalar("testname", StandardBasicTypes.TEXT )
.addScalar("configid", StandardBasicTypes.INTEGER)
.addScalar("title", StandardBasicTypes.TEXT)
.addScalar("filterlabels", JSON_STRING_ARRY_TYPE)
.addScalar("categorylabels", JSON_STRING_ARRY_TYPE)
.addScalar("serieslabels", JSON_STRING_ARRY_TYPE)
.addScalar("scalelabels", JSON_STRING_ARRY_TYPE)
.addScalar("filterlabels", JsonBinaryType.INSTANCE)
.addScalar("categorylabels", JsonBinaryType.INSTANCE)
.addScalar("serieslabels", JsonBinaryType.INSTANCE)
.addScalar("scalelabels", JsonBinaryType.INSTANCE)
.getResultList()) {
Object[] columns = (Object[]) row;
StringBuilder where = new StringBuilder();
if ( columns[4] != null) addPart(where, (String[]) columns[4], label, "filter");
if ( columns[5] != null) addPart(where, (String[]) columns[5], label, "series");
if ( columns[6] != null) addPart(where, (String[]) columns[6], label, "category");
if ( columns[7] != null) addPart(where, (String[]) columns[7], label, "label");
if ( columns[4] != null) addPart(where, (ArrayNode) columns[4], label, "filter");
if ( columns[5] != null) addPart(where, (ArrayNode) columns[5], label, "series");
if ( columns[6] != null) addPart(where, (ArrayNode) columns[6], label, "category");
if ( columns[7] != null) addPart(where, (ArrayNode) columns[7], label, "label");
result.add(new LabelInReport((int) columns[0], (String) columns[1], (int) columns[2], (String) columns[3], where.toString(), null));
}
for (Object row: em.createNativeQuery("SELECT test.id as testid, test.name as testname, trc.id as configid, trc.title, rc.name FROM reportcomponent rc " +
Expand Down Expand Up @@ -902,12 +899,15 @@ public void importSchema(ObjectNode node) {
}
}

private void addPart(StringBuilder where, String[] column, String label, String type) {
if (Arrays.stream(column).anyMatch(col -> col.equals(label))) {
if (where.length() > 0) {
where.append(", ");
private void addPart(StringBuilder where, ArrayNode column, String label, String type) {
for (JsonNode col : column) {
if (label.equals(col.textValue())) {
if (!where.isEmpty()) {
where.append(", ");
}
where.append(type);
return;
}
where.append(type);
}
}

Expand Down

0 comments on commit 20417bf

Please sign in to comment.