-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RETIRED: Hibernate Migration (replaced by 543) #532
Changes from all commits
7cc1781
3075465
edce067
48ab3e2
330e213
756df3b
096f86e
78d72ce
cacc35d
900748e
7c9d8c9
955f76c
59309d3
bd55a86
92d7146
82534aa
2936fbc
f1bdf82
81b5dcb
bf9c8c5
6f9e870
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,8 +84,32 @@ | |
<groupId>org.apache.opennlp</groupId> | ||
<artifactId>opennlp-tools</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-hibernate-orm</artifactId> | ||
<version>3.2.11.Final</version> | ||
</dependency> | ||
Comment on lines
+87
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would try to keep |
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<!-- The entity classes need to be indexed --> | ||
<plugin> | ||
<groupId>org.jboss.jandex</groupId> | ||
<artifactId>jandex-maven-plugin</artifactId> | ||
<version>1.1.0</version> | ||
<executions> | ||
<execution> | ||
<id>make-index</id> | ||
<goals> | ||
<goal>jandex</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>default</id> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.kie.trustyai.explainability.model; | ||
|
||
import java.io.Serializable; | ||
import java.util.Objects; | ||
|
||
public class UnderlyingObject implements Serializable { | ||
private Object object; | ||
|
||
public UnderlyingObject() { | ||
|
||
} | ||
|
||
public UnderlyingObject(Object o) { | ||
object = o; | ||
} | ||
|
||
public Object getObject() { | ||
return this.object; | ||
} | ||
|
||
public void setObject(Object o) { | ||
this.object = o; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
UnderlyingObject that = (UnderlyingObject) o; | ||
return Objects.equals(object, that.object); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(object); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,44 +28,54 @@ | |
import com.fasterxml.jackson.databind.MappingIterator; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import jakarta.persistence.Access; | ||
import jakarta.persistence.AccessType; | ||
import jakarta.persistence.Embeddable; | ||
import jakarta.persistence.Transient; | ||
|
||
/** | ||
* Wrapper class for any kind of value part of a prediction input or output. | ||
* | ||
*/ | ||
@Embeddable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you only need similar annotation in core you can add jakarta-persistance-api dependency |
||
public class Value { | ||
|
||
private final Object underlyingObject; | ||
private final UnderlyingObject wrappedUnderlyingObject; | ||
|
||
public Value(Object underlyingObject) { | ||
this.underlyingObject = underlyingObject; | ||
this.wrappedUnderlyingObject = new UnderlyingObject(underlyingObject); | ||
} | ||
|
||
public Value() { | ||
this.wrappedUnderlyingObject = new UnderlyingObject(null); | ||
} | ||
|
||
public String asString() { | ||
if (underlyingObject instanceof List) { | ||
if (getUnderlyingObject() instanceof List) { | ||
try { | ||
@SuppressWarnings("unchecked") | ||
List<Feature> composite = (List<Feature>) underlyingObject; | ||
List<Feature> composite = (List<Feature>) getUnderlyingObject(); | ||
return composite.stream().map(f -> f.getValue().asString()).collect(Collectors.joining(" ")); | ||
} catch (ClassCastException ignored) { | ||
// ignored | ||
} | ||
} | ||
if (underlyingObject instanceof ByteBuffer) { | ||
ByteBuffer byteBuffer = (ByteBuffer) this.underlyingObject; | ||
if (getUnderlyingObject() instanceof ByteBuffer) { | ||
ByteBuffer byteBuffer = (ByteBuffer) getUnderlyingObject(); | ||
return new String(byteBuffer.array()); | ||
} | ||
return ArrayUtils.toString(underlyingObject); | ||
return ArrayUtils.toString(getUnderlyingObject()); | ||
} | ||
|
||
public double asNumber() { | ||
if (underlyingObject != null) { | ||
if (getUnderlyingObject() != null) { | ||
try { | ||
if (underlyingObject instanceof Double) { | ||
return (double) underlyingObject; | ||
} else if (underlyingObject instanceof Number) { | ||
return ((Number) underlyingObject).doubleValue(); | ||
} else if (underlyingObject instanceof Boolean) { | ||
return (boolean) underlyingObject ? 1d : 0d; | ||
if (getUnderlyingObject() instanceof Double) { | ||
return (double) getUnderlyingObject(); | ||
} else if (getUnderlyingObject() instanceof Number) { | ||
return ((Number) getUnderlyingObject()).doubleValue(); | ||
} else if (getUnderlyingObject() instanceof Boolean) { | ||
return (boolean) getUnderlyingObject() ? 1d : 0d; | ||
} else { | ||
return Double.parseDouble(asString()); | ||
} | ||
|
@@ -77,25 +87,31 @@ public double asNumber() { | |
} | ||
} | ||
|
||
@Transient | ||
public Object getUnderlyingObject() { | ||
return underlyingObject; | ||
return wrappedUnderlyingObject.getObject(); | ||
} | ||
|
||
@Access(AccessType.FIELD) | ||
public UnderlyingObject getUnderlyingObjectContainer() { | ||
return wrappedUnderlyingObject; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return Objects.toString(underlyingObject); | ||
return Objects.toString(getUnderlyingObject()); | ||
} | ||
|
||
public double[] asVector() { | ||
double[] doubles; | ||
if (underlyingObject instanceof double[]) { | ||
doubles = (double[]) underlyingObject; | ||
if (getUnderlyingObject() instanceof double[]) { | ||
doubles = (double[]) getUnderlyingObject(); | ||
} else { | ||
if (underlyingObject instanceof String) { | ||
String string = (String) this.underlyingObject; | ||
if (getUnderlyingObject() instanceof String) { | ||
String string = (String) getUnderlyingObject(); | ||
doubles = parseVectorString(string); | ||
} else if (underlyingObject instanceof ByteBuffer) { | ||
ByteBuffer byteBuffer = (ByteBuffer) underlyingObject; | ||
} else if (getUnderlyingObject() instanceof ByteBuffer) { | ||
ByteBuffer byteBuffer = (ByteBuffer) getUnderlyingObject(); | ||
String string = StandardCharsets.UTF_8.decode(byteBuffer).toString(); | ||
doubles = parseVectorString(string); | ||
} else { | ||
|
@@ -138,11 +154,11 @@ public boolean equals(Object o) { | |
return false; | ||
} | ||
Value value = (Value) o; | ||
return Objects.equals(underlyingObject, value.underlyingObject); | ||
return Objects.equals(getUnderlyingObject(), value.getUnderlyingObject()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(underlyingObject); | ||
return Objects.hash(getUnderlyingObject()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be managed via the import of quarkus bom instead of explicit version (this version is tied to quarkus version)