From 011d91445eb511b11ad57a34cdc04424f579a404 Mon Sep 17 00:00:00 2001 From: delchev Date: Sun, 2 Feb 2025 16:04:10 +0200 Subject: [PATCH] Fixed: #4608 - CLOB Support in EDM Editor --- .../format/ResultSetJsonWriter.java | 21 +++++++++++++++++++ .../dirigible/ide-entity/js/details.js | 1 + .../editor-entity/dialogs/js/details.js | 1 + 3 files changed, 23 insertions(+) diff --git a/components/data/data-management/src/main/java/org/eclipse/dirigible/components/data/management/format/ResultSetJsonWriter.java b/components/data/data-management/src/main/java/org/eclipse/dirigible/components/data/management/format/ResultSetJsonWriter.java index 880dd89ec3..f8743e128f 100644 --- a/components/data/data-management/src/main/java/org/eclipse/dirigible/components/data/management/format/ResultSetJsonWriter.java +++ b/components/data/data-management/src/main/java/org/eclipse/dirigible/components/data/management/format/ResultSetJsonWriter.java @@ -13,6 +13,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.sql.Blob; +import java.sql.Clob; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; @@ -152,6 +153,10 @@ public void write(ResultSet resultSet, OutputStream output) throws Exception { Blob blob = (Blob) value; int[] intArray = readBlob(blob); jsonGenerator.writeArray(intArray, 0, intArray.length - 1); + } else if (value instanceof Clob) { + Clob clob = (Clob) value; + String clobValue = readClob(clob); + jsonGenerator.writeString(clobValue); } else { jsonGenerator.writeString(value == null ? null : value.toString()); } @@ -184,4 +189,20 @@ private int[] readBlob(Blob blob) throws SQLException { return intArray; } + /** + * Read clob. + * + * @param clob the clob + * @return the string + * @throws SQLException the SQL exception + */ + private String readClob(Clob clob) throws SQLException { + long clobLength = clob.length(); + if (clobLength <= Integer.MAX_VALUE) { + String clobAsString = clob.getSubString(1, (int) clobLength); + return clobAsString; + } + return "The size of the CLOB is too big"; + } + } diff --git a/components/ide/ide-ui-entity/src/main/resources/META-INF/dirigible/ide-entity/js/details.js b/components/ide/ide-ui-entity/src/main/resources/META-INF/dirigible/ide-entity/js/details.js index 23b6de4311..3b0d0ab8a7 100644 --- a/components/ide/ide-ui-entity/src/main/resources/META-INF/dirigible/ide-entity/js/details.js +++ b/components/ide/ide-ui-entity/src/main/resources/META-INF/dirigible/ide-entity/js/details.js @@ -70,6 +70,7 @@ angular.module('edmDetails', ['ideUI', 'ideView']) { value: "DOUBLE", label: "DOUBLE" }, { value: "BOOLEAN", label: "BOOLEAN" }, { value: "BLOB", label: "BLOB" }, + { value: 'CLOB', label: 'CLOB' }, { value: "DECIMAL", label: "DECIMAL" }, { value: "BIT", label: "BIT" } ]; diff --git a/components/ui/editor-entity/src/main/resources/META-INF/dirigible/editor-entity/dialogs/js/details.js b/components/ui/editor-entity/src/main/resources/META-INF/dirigible/editor-entity/dialogs/js/details.js index 028ed47838..382aa12b7c 100644 --- a/components/ui/editor-entity/src/main/resources/META-INF/dirigible/editor-entity/dialogs/js/details.js +++ b/components/ui/editor-entity/src/main/resources/META-INF/dirigible/editor-entity/dialogs/js/details.js @@ -75,6 +75,7 @@ angular.module('edmDetails', ['blimpKit', 'platformView']) { value: 'DOUBLE', label: 'DOUBLE' }, { value: 'BOOLEAN', label: 'BOOLEAN' }, { value: 'BLOB', label: 'BLOB' }, + { value: 'CLOB', label: 'CLOB' }, { value: 'DECIMAL', label: 'DECIMAL' }, { value: 'BIT', label: 'BIT' } ];