From 7dec1afdb4d44f9d5c660729145eceb104e5ec92 Mon Sep 17 00:00:00 2001 From: Christopher Schnick Date: Wed, 13 Apr 2022 20:35:16 +0200 Subject: [PATCH] Add textual flag to value node, prepare for text data sources, and various other small fixes --- .../java/io/xpipe/api/impl/DataTableImpl.java | 4 +- .../java/io/xpipe/beacon/BeaconClient.java | 5 ++ .../exchange/ReadPreparationExchange.java | 3 +- .../exchange/api/QueryTableDataExchange.java | 4 +- .../exchange/api/QueryTextDataExchange.java | 44 ++++++++++++++++ .../io/xpipe/core/config/ConfigOption.java | 14 +++++ .../io/xpipe/core/config/ConfigOptionSet.java | 23 ++++++++ .../core/config/ConfigOptionSetInstance.java | 26 ++++++++++ .../core/data/generic/GenericArrayReader.java | 6 +-- .../generic/GenericDataStreamCallback.java | 2 +- .../data/generic/GenericDataStreamParser.java | 3 +- .../data/generic/GenericDataStreamWriter.java | 1 + .../GenericDataStructureNodeReader.java | 6 +-- .../core/data/generic/GenericTupleReader.java | 6 +-- .../core/data/node/DataStructureNode.java | 14 +++-- .../core/data/node/ImmutableValueNode.java | 25 +++++++-- .../core/data/node/MutableValueNode.java | 52 ++++++++++++++++--- .../io/xpipe/core/data/node/ValueNode.java | 51 +++++++++++------- .../data/typed/TypedDataStreamCallback.java | 2 +- .../data/typed/TypedDataStreamParser.java | 3 +- .../data/typed/TypedDataStreamWriter.java | 1 + .../typed/TypedDataStructureNodeReader.java | 4 +- .../TypedReusableDataStructureNodeReader.java | 8 +-- .../core/source/DataSourceConfigInstance.java | 19 ++++--- .../core/source/DataSourceConfigOptions.java | 32 ------------ .../core/source/DataSourceDescriptor.java | 4 ++ .../io/xpipe/core/source/DataSourceInfo.java | 9 ++-- .../core/source/DataSourceReadConnection.java | 6 +++ .../core/source/StructureReadConnection.java | 9 +++- .../core/source/TableReadConnection.java | 13 ++++- .../core/source/TextDataSourceDescriptor.java | 25 ++++++--- .../xpipe/core/source/TextReadConnection.java | 27 ++++++++-- .../core/source/TextWriteConnection.java | 4 +- .../io/xpipe/core/store/FileDataStore.java | 6 +++ .../xpipe/core/store/LocalFileDataStore.java | 7 ++- .../io/xpipe/core/util/CoreJacksonModule.java | 5 +- core/src/main/java/module-info.java | 2 + .../io/xpipe/core/test/DataStructureTest.java | 2 +- .../xpipe/core/test/DataStructureTests.java | 12 ++--- deps | 2 +- .../xpipe/extension/DataSourceProvider.java | 27 +++++++--- .../xpipe/extension/DataSourceProviders.java | 20 +++++++ .../xpipe/extension/comp/CharChoiceComp.java | 4 +- 43 files changed, 414 insertions(+), 128 deletions(-) create mode 100644 beacon/src/main/java/io/xpipe/beacon/exchange/api/QueryTextDataExchange.java create mode 100644 core/src/main/java/io/xpipe/core/config/ConfigOption.java create mode 100644 core/src/main/java/io/xpipe/core/config/ConfigOptionSet.java create mode 100644 core/src/main/java/io/xpipe/core/config/ConfigOptionSetInstance.java delete mode 100644 core/src/main/java/io/xpipe/core/source/DataSourceConfigOptions.java create mode 100644 core/src/main/java/io/xpipe/core/source/DataSourceReadConnection.java create mode 100644 core/src/main/java/io/xpipe/core/store/FileDataStore.java diff --git a/api/src/main/java/io/xpipe/api/impl/DataTableImpl.java b/api/src/main/java/io/xpipe/api/impl/DataTableImpl.java index 4837c9112..307bdc462 100644 --- a/api/src/main/java/io/xpipe/api/impl/DataTableImpl.java +++ b/api/src/main/java/io/xpipe/api/impl/DataTableImpl.java @@ -59,7 +59,7 @@ public class DataTableImpl extends DataSourceImpl implements DataTable { List nodes = new ArrayList<>(); XPipeConnection.execute(con -> { var req = QueryTableDataExchange.Request.builder() - .id(getId()).maxRows(maxRows).build(); + .ref(DataSourceReference.id(getId())).maxRows(maxRows).build(); con.performInputExchange(req, (QueryTableDataExchange.Response res, InputStream in) -> { var r = new TypedDataStreamParser(info.getDataType()); r.parseStructures(in, TypedDataStructureNodeReader.immutable(info.getDataType()), nodes::add); @@ -82,7 +82,7 @@ public class DataTableImpl extends DataSourceImpl implements DataTable { connection = XPipeConnection.open(); var req = QueryTableDataExchange.Request.builder() - .id(getId()).build(); + .ref(DataSourceReference.id(getId())).build(); connection.sendRequest(req); connection.receiveResponse(); connection.receiveBody(); diff --git a/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java b/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java index 93e514504..d1f1f0dc7 100644 --- a/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java +++ b/beacon/src/main/java/io/xpipe/beacon/BeaconClient.java @@ -138,6 +138,11 @@ public class BeaconClient implements AutoCloseable { System.out.println("Sending request to server of type " + req.getClass().getName()); } + if (BeaconConfig.debugEnabled()) { + System.out.println("Sending raw request:"); + System.out.println(msg.toPrettyString()); + } + try { var mapper = JacksonHelper.newMapper().disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET); var gen = mapper.createGenerator(socket.getOutputStream()); diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/ReadPreparationExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/ReadPreparationExchange.java index 778c4c648..d749620a0 100644 --- a/beacon/src/main/java/io/xpipe/beacon/exchange/ReadPreparationExchange.java +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/ReadPreparationExchange.java @@ -43,7 +43,8 @@ public class ReadPreparationExchange implements MessageExchange { + + @Override + public String getId() { + return "queryTextData"; + } + + @Override + public Class getRequestClass() { + return QueryTextDataExchange.Request.class; + } + + @Override + public Class getResponseClass() { + return QueryTextDataExchange.Response.class; + } + + @Jacksonized + @Builder + @Value + public static class Request implements RequestMessage { + @NonNull + DataSourceReference ref; + + int maxLines; + } + + @Jacksonized + @Builder + @Value + public static class Response implements ResponseMessage { + } +} diff --git a/core/src/main/java/io/xpipe/core/config/ConfigOption.java b/core/src/main/java/io/xpipe/core/config/ConfigOption.java new file mode 100644 index 000000000..69e8d7c22 --- /dev/null +++ b/core/src/main/java/io/xpipe/core/config/ConfigOption.java @@ -0,0 +1,14 @@ +package io.xpipe.core.config; + +import com.fasterxml.jackson.annotation.JsonCreator; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Value; + +@Value +@Builder +@AllArgsConstructor(onConstructor_={@JsonCreator}) +public class ConfigOption { + String name; + String key; +} diff --git a/core/src/main/java/io/xpipe/core/config/ConfigOptionSet.java b/core/src/main/java/io/xpipe/core/config/ConfigOptionSet.java new file mode 100644 index 000000000..522c2005b --- /dev/null +++ b/core/src/main/java/io/xpipe/core/config/ConfigOptionSet.java @@ -0,0 +1,23 @@ +package io.xpipe.core.config; + + +import com.fasterxml.jackson.annotation.JsonCreator; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Singular; +import lombok.Value; + +import java.util.List; + +@Value +@Builder +@AllArgsConstructor(onConstructor_={@JsonCreator}) +public class ConfigOptionSet { + + public static ConfigOptionSet empty() { + return new ConfigOptionSet(List.of()); + } + + @Singular + List options; +} diff --git a/core/src/main/java/io/xpipe/core/config/ConfigOptionSetInstance.java b/core/src/main/java/io/xpipe/core/config/ConfigOptionSetInstance.java new file mode 100644 index 000000000..f49d51502 --- /dev/null +++ b/core/src/main/java/io/xpipe/core/config/ConfigOptionSetInstance.java @@ -0,0 +1,26 @@ +package io.xpipe.core.config; + +import com.fasterxml.jackson.annotation.JsonCreator; +import lombok.AllArgsConstructor; +import lombok.Value; + +import java.util.Map; + +@Value +@AllArgsConstructor(onConstructor_={@JsonCreator}) +public class ConfigOptionSetInstance { + + /** + * The available configuration options. + */ + ConfigOptionSet configOptions; + + /** + * The current configuration options that are set. + */ + Map currentValues; + + public boolean isComplete() { + return currentValues.size() == configOptions.getOptions().size(); + } +} diff --git a/core/src/main/java/io/xpipe/core/data/generic/GenericArrayReader.java b/core/src/main/java/io/xpipe/core/data/generic/GenericArrayReader.java index 9230fda23..fbb832833 100644 --- a/core/src/main/java/io/xpipe/core/data/generic/GenericArrayReader.java +++ b/core/src/main/java/io/xpipe/core/data/generic/GenericArrayReader.java @@ -127,9 +127,9 @@ public class GenericArrayReader implements GenericAbstractReader { } @Override - public void onValue(byte[] value) { + public void onValue(byte[] value, boolean textual) { if (currentReader != null) { - currentReader.onValue(value); + currentReader.onValue(value, textual); return; } @@ -141,7 +141,7 @@ public class GenericArrayReader implements GenericAbstractReader { throw new IllegalStateException("Array is full but got another value"); } - put(ValueNode.mutable(value)); + put(ValueNode.mutable(value, textual)); } @Override diff --git a/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamCallback.java b/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamCallback.java index 14ddfbe6b..8d9f8a1a1 100644 --- a/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamCallback.java +++ b/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamCallback.java @@ -17,6 +17,6 @@ public interface GenericDataStreamCallback { default void onTupleEnd() { } - default void onValue(byte[] value) { + default void onValue(byte[] value, boolean textual) { } } diff --git a/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamParser.java b/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamParser.java index dcef86073..ce442bc9f 100644 --- a/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamParser.java +++ b/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamParser.java @@ -79,8 +79,9 @@ public class GenericDataStreamParser { } private static void parseValue(InputStream in, GenericDataStreamCallback cb) throws IOException { + var textual = in.read() != 0; var size = in.read(); var data = in.readNBytes(size); - cb.onValue(data); + cb.onValue(data, textual); } } diff --git a/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamWriter.java b/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamWriter.java index 134497997..b05f45306 100644 --- a/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamWriter.java +++ b/core/src/main/java/io/xpipe/core/data/generic/GenericDataStreamWriter.java @@ -53,6 +53,7 @@ public class GenericDataStreamWriter { private static void writeValue(OutputStream out, ValueNode value) throws IOException { out.write(DataStructureNodeIO.GENERIC_VALUE_ID); + out.write(value.isTextual() ? 1 : 0); out.write(value.getRawData().length); out.write(value.getRawData()); } diff --git a/core/src/main/java/io/xpipe/core/data/generic/GenericDataStructureNodeReader.java b/core/src/main/java/io/xpipe/core/data/generic/GenericDataStructureNodeReader.java index 9d4fad9aa..4d3a0b295 100644 --- a/core/src/main/java/io/xpipe/core/data/generic/GenericDataStructureNodeReader.java +++ b/core/src/main/java/io/xpipe/core/data/generic/GenericDataStructureNodeReader.java @@ -78,12 +78,12 @@ public class GenericDataStructureNodeReader implements GenericDataStreamCallback } @Override - public void onValue(byte[] value) { + public void onValue(byte[] value, boolean textual) { if (hasReader()) { - reader.onValue(value); + reader.onValue(value, textual); return; } - node = ValueNode.mutable(value); + node = ValueNode.mutable(value, textual); } } diff --git a/core/src/main/java/io/xpipe/core/data/generic/GenericTupleReader.java b/core/src/main/java/io/xpipe/core/data/generic/GenericTupleReader.java index 1ce0df6e7..31101fd49 100644 --- a/core/src/main/java/io/xpipe/core/data/generic/GenericTupleReader.java +++ b/core/src/main/java/io/xpipe/core/data/generic/GenericTupleReader.java @@ -139,9 +139,9 @@ public class GenericTupleReader implements GenericAbstractReader { } @Override - public void onValue(byte[] value) { + public void onValue(byte[] value, boolean textual) { if (currentReader != null) { - currentReader.onValue(value); + currentReader.onValue(value, textual); return; } @@ -153,7 +153,7 @@ public class GenericTupleReader implements GenericAbstractReader { throw new IllegalStateException("Tuple is full but got another value"); } - putNode(ValueNode.mutable(value)); + putNode(ValueNode.mutable(value, textual)); } @Override diff --git a/core/src/main/java/io/xpipe/core/data/node/DataStructureNode.java b/core/src/main/java/io/xpipe/core/data/node/DataStructureNode.java index 7a1ab59e3..e668ec3c7 100644 --- a/core/src/main/java/io/xpipe/core/data/node/DataStructureNode.java +++ b/core/src/main/java/io/xpipe/core/data/node/DataStructureNode.java @@ -51,12 +51,20 @@ public abstract class DataStructureNode implements Iterable { throw unsupported("clear"); } - public DataStructureNode setRawData(byte[] data) { + public boolean isTextual() { + throw unsupported("textual check"); + } + + public DataStructureNode setRaw(byte[] data) { throw unsupported("set raw data"); } - public DataStructureNode setNull() { - throw unsupported("set null"); + public DataStructureNode set(Object newValue) { + throw unsupported("set"); + } + + public DataStructureNode set(Object newValue, boolean textual) { + throw unsupported("set"); } public DataStructureNode set(int index, DataStructureNode node) { diff --git a/core/src/main/java/io/xpipe/core/data/node/ImmutableValueNode.java b/core/src/main/java/io/xpipe/core/data/node/ImmutableValueNode.java index cca60e36a..577915fa1 100644 --- a/core/src/main/java/io/xpipe/core/data/node/ImmutableValueNode.java +++ b/core/src/main/java/io/xpipe/core/data/node/ImmutableValueNode.java @@ -3,14 +3,16 @@ package io.xpipe.core.data.node; public class ImmutableValueNode extends ValueNode { private final byte[] data; + private final boolean textual; - ImmutableValueNode(byte[] data) { + ImmutableValueNode(byte[] data, boolean textual) { this.data = data; + this.textual = textual; } @Override public String toString(int indent) { - return new String(data) + "(I)"; + return (textual ? "\"" : "") + new String(data) + (textual ? "\"" : "") + " (I)"; } @Override @@ -25,11 +27,26 @@ public class ImmutableValueNode extends ValueNode { @Override public ValueNode mutableCopy() { - return ValueNode.mutable(data); + return ValueNode.mutable(data, textual); } @Override - public DataStructureNode setRawData(byte[] data) { + public boolean isTextual() { + return textual; + } + + @Override + public DataStructureNode setRaw(byte[] data) { + throw new UnsupportedOperationException("Value node is immutable"); + } + + @Override + public DataStructureNode set(Object newValue) { + throw new UnsupportedOperationException("Value node is immutable"); + } + + @Override + public DataStructureNode set(Object newValue, boolean textual) { throw new UnsupportedOperationException("Value node is immutable"); } diff --git a/core/src/main/java/io/xpipe/core/data/node/MutableValueNode.java b/core/src/main/java/io/xpipe/core/data/node/MutableValueNode.java index a100359f1..ef5a39dd2 100644 --- a/core/src/main/java/io/xpipe/core/data/node/MutableValueNode.java +++ b/core/src/main/java/io/xpipe/core/data/node/MutableValueNode.java @@ -1,16 +1,27 @@ package io.xpipe.core.data.node; +import java.nio.charset.StandardCharsets; + public class MutableValueNode extends ValueNode { - private byte[] data; + static final MutableValueNode NULL = new MutableValueNode(null, false); - MutableValueNode(byte[] data) { + private byte[] data; + private boolean textual; + + MutableValueNode(byte[] data, boolean textual) { this.data = data; + this.textual = textual; } @Override public String toString(int indent) { - return new String(data) + "(M)"; + return (textual ? "\"" : "") + new String(data) + (textual ? "\"" : "") + " (M)"; + } + + @Override + public boolean isTextual() { + return textual; } @Override @@ -20,20 +31,49 @@ public class MutableValueNode extends ValueNode { @Override public ValueNode immutableView() { - return new ImmutableValueNode(data); + return new ImmutableValueNode(data, textual); } @Override public ValueNode mutableCopy() { - return new MutableValueNode(data); + return new MutableValueNode(data, textual); } @Override - public DataStructureNode setRawData(byte[] data) { + public DataStructureNode setRaw(byte[] data) { this.data = data; return this; } + @Override + public DataStructureNode set(Object newValue) { + if (newValue == null) { + this.data = null; + this.textual = false; + } else { + setRaw(newValue.toString().getBytes(StandardCharsets.UTF_8)); + } + + return this; + } + + @Override + public DataStructureNode set(Object newValue, boolean textual) { + if (newValue == null && textual) { + throw new IllegalArgumentException("Can't set a textual null"); + } + + if (newValue == null) { + this.data = null; + this.textual = false; + } else { + setRaw(newValue.toString().getBytes(StandardCharsets.UTF_8)); + this.textual = textual; + } + + return this; + } + public byte[] getRawData() { return data; } diff --git a/core/src/main/java/io/xpipe/core/data/node/ValueNode.java b/core/src/main/java/io/xpipe/core/data/node/ValueNode.java index ae3cdc67d..5ceb1b39a 100644 --- a/core/src/main/java/io/xpipe/core/data/node/ValueNode.java +++ b/core/src/main/java/io/xpipe/core/data/node/ValueNode.java @@ -8,8 +8,6 @@ import java.util.Arrays; public abstract class ValueNode extends DataStructureNode { - private static final byte[] NULL = new byte[]{0}; - protected ValueNode() { } @@ -31,40 +29,57 @@ public abstract class ValueNode extends DataStructureNode { @Override public abstract ValueNode mutableCopy(); - public static ValueNode immutable(byte[] data) { - return new ImmutableValueNode(data); + public static ValueNode immutable(byte[] data, boolean textual) { + return new ImmutableValueNode(data, textual); } - public static ValueNode immutable(Object o) { - return immutable(o.toString().getBytes(StandardCharsets.UTF_8)); + public static ValueNode immutable(Object o, boolean textual) { + return immutable(o.toString().getBytes(StandardCharsets.UTF_8), textual); + } + + public static ValueNode immutableNull() { + return MutableValueNode.NULL.immutableView(); } public static ValueNode mutableNull() { - return mutable(NULL); + return MutableValueNode.NULL.mutableCopy(); } - public static ValueNode nullValue() { - return mutable(NULL); + public static ValueNode mutable(byte[] data, boolean textual) { + return new MutableValueNode(data, textual); } - public static ValueNode mutable(byte[] data) { - return new MutableValueNode(data); - } - - public static ValueNode mutable(Object o) { - return mutable(o.toString().getBytes(StandardCharsets.UTF_8)); + public static ValueNode mutable(Object o, boolean textual) { + return mutable(o.toString().getBytes(StandardCharsets.UTF_8), textual); } public static ValueNode of(byte[] data) { - return mutable(data); + return mutable(data, false); } public static ValueNode of(Object o) { - return mutable(o); + return mutable(o, false); + } + + public static ValueNode ofText(byte[] data) { + return mutable(data, true); + } + + public static ValueNode ofText(Object o) { + return mutable(o, true); } @Override - public abstract DataStructureNode setRawData(byte[] data); + public abstract boolean isTextual(); + + @Override + public abstract DataStructureNode setRaw(byte[] data); + + @Override + public abstract DataStructureNode set(Object newValue); + + @Override + public abstract DataStructureNode set(Object newValue, boolean textual); @Override public final int asInt() { diff --git a/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamCallback.java b/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamCallback.java index f1e9b68db..26dbc7481 100644 --- a/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamCallback.java +++ b/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamCallback.java @@ -5,7 +5,7 @@ import io.xpipe.core.data.type.TupleType; public interface TypedDataStreamCallback { - default void onValue(byte[] data) { + default void onValue(byte[] data, boolean textual) { } default void onGenericNode(DataStructureNode node) { diff --git a/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamParser.java b/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamParser.java index 54c07b636..eb06e68ad 100644 --- a/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamParser.java +++ b/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamParser.java @@ -129,8 +129,9 @@ public class TypedDataStreamParser { } private void parseValue(InputStream in, TypedDataStreamCallback cb) throws IOException { + var textual = in.read() != 0; var size = in.read(); var data = in.readNBytes(size); - cb.onValue(data); + cb.onValue(data, textual); } } diff --git a/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamWriter.java b/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamWriter.java index c749e6242..c6cd19f28 100644 --- a/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamWriter.java +++ b/core/src/main/java/io/xpipe/core/data/typed/TypedDataStreamWriter.java @@ -32,6 +32,7 @@ public class TypedDataStreamWriter { private static void writeValue(OutputStream out, ValueNode n) throws IOException { out.write(DataStructureNodeIO.TYPED_VALUE_ID); + out.write(n.isTextual() ? 1 : 0); out.write(n.getRawData().length); out.write(n.getRawData()); } diff --git a/core/src/main/java/io/xpipe/core/data/typed/TypedDataStructureNodeReader.java b/core/src/main/java/io/xpipe/core/data/typed/TypedDataStructureNodeReader.java index 0df133ce1..3f747a703 100644 --- a/core/src/main/java/io/xpipe/core/data/typed/TypedDataStructureNodeReader.java +++ b/core/src/main/java/io/xpipe/core/data/typed/TypedDataStructureNodeReader.java @@ -81,12 +81,12 @@ public class TypedDataStructureNodeReader implements TypedAbstractReader { } @Override - public void onValue(byte[] data) { + public void onValue(byte[] data, boolean textual) { if (!expectedType.isValue()) { throw new IllegalStateException("Expected " + expectedType.getName() + " but got value"); } - var val = makeImmutable ? ValueNode.immutable(data) : ValueNode.mutable(data); + var val = makeImmutable ? ValueNode.immutable(data, textual) : ValueNode.mutable(data, textual); finishNode(val); moveExpectedType(false); } diff --git a/core/src/main/java/io/xpipe/core/data/typed/TypedReusableDataStructureNodeReader.java b/core/src/main/java/io/xpipe/core/data/typed/TypedReusableDataStructureNodeReader.java index 065cdad7b..edb22499e 100644 --- a/core/src/main/java/io/xpipe/core/data/typed/TypedReusableDataStructureNodeReader.java +++ b/core/src/main/java/io/xpipe/core/data/typed/TypedReusableDataStructureNodeReader.java @@ -47,16 +47,16 @@ public class TypedReusableDataStructureNodeReader implements TypedAbstractReader } @Override - public void onValue(byte[] data) { + public void onValue(byte[] data, boolean textual) { if (!initialized()) { - initialReader.onValue(data); + initialReader.onValue(data, textual); return; } if (isInArray()) { - getCurrentParent().set(indices.peek(), ValueNode.mutable(data)); + getCurrentParent().set(indices.peek(), ValueNode.mutable(data, textual)); } else { - getCurrent().setRawData(data); + getCurrent().setRaw(data); } if (!indices.isEmpty()) { diff --git a/core/src/main/java/io/xpipe/core/source/DataSourceConfigInstance.java b/core/src/main/java/io/xpipe/core/source/DataSourceConfigInstance.java index aad847996..dbb86ee28 100644 --- a/core/src/main/java/io/xpipe/core/source/DataSourceConfigInstance.java +++ b/core/src/main/java/io/xpipe/core/source/DataSourceConfigInstance.java @@ -1,9 +1,10 @@ package io.xpipe.core.source; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.xpipe.core.config.ConfigOptionSet; +import io.xpipe.core.config.ConfigOptionSetInstance; import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Value; -import lombok.extern.jackson.Jacksonized; import java.util.Map; @@ -12,13 +13,11 @@ import java.util.Map; * This configuration can either be in progress or complete. */ @Value -@Builder -@Jacksonized -@AllArgsConstructor +@AllArgsConstructor(onConstructor_={@JsonCreator}) public class DataSourceConfigInstance { public static DataSourceConfigInstance xpbt() { - return new DataSourceConfigInstance("xpbt", DataSourceConfigOptions.empty(), Map.of()); + return new DataSourceConfigInstance("xpbt", ConfigOptionSet.empty(), Map.of()); } /** @@ -29,7 +28,7 @@ public class DataSourceConfigInstance { /** * The available configuration options. */ - DataSourceConfigOptions configOptions; + ConfigOptionSet configOptions; /** * The current configuration options that are set. @@ -39,4 +38,10 @@ public class DataSourceConfigInstance { public boolean isComplete() { return currentValues.size() == configOptions.getOptions().size(); } + + public DataSourceConfigInstance(String provider, ConfigOptionSetInstance cInstance) { + this.provider = provider; + this.configOptions = cInstance.getConfigOptions(); + this.currentValues = cInstance.getCurrentValues(); + } } diff --git a/core/src/main/java/io/xpipe/core/source/DataSourceConfigOptions.java b/core/src/main/java/io/xpipe/core/source/DataSourceConfigOptions.java deleted file mode 100644 index 495165d89..000000000 --- a/core/src/main/java/io/xpipe/core/source/DataSourceConfigOptions.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.xpipe.core.source; - - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Singular; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -import java.util.List; - -@Value -@Builder -@Jacksonized -public class DataSourceConfigOptions { - - public static DataSourceConfigOptions empty() { - return new DataSourceConfigOptions(List.of()); - } - - @Singular - List