diff --git a/src/main/java/com/databasepreservation/common/client/ViewerConstants.java b/src/main/java/com/databasepreservation/common/client/ViewerConstants.java index 2d6117bc..1a46fd25 100644 --- a/src/main/java/com/databasepreservation/common/client/ViewerConstants.java +++ b/src/main/java/com/databasepreservation/common/client/ViewerConstants.java @@ -245,6 +245,7 @@ public class ViewerConstants { public static final String SOLR_DYN_LOCATION_RPT = "_srpt"; public static final String SOLR_DYN_LONG = "_l"; public static final String SOLR_DYN_STRING = "_s"; + public static final String SOLR_DYN_STRING_MULTI = "_ss"; public static final String SOLR_DYN_TEXT_GENERAL = "_t"; public static final String SOLR_DYN_TEXT_MULTI = "_txt"; public static final String SOLR_DYN_NEST_MULTI = "_nst"; diff --git a/src/main/java/com/databasepreservation/common/client/models/structure/ViewerCell.java b/src/main/java/com/databasepreservation/common/client/models/structure/ViewerCell.java index 161b2937..e939c484 100644 --- a/src/main/java/com/databasepreservation/common/client/models/structure/ViewerCell.java +++ b/src/main/java/com/databasepreservation/common/client/models/structure/ViewerCell.java @@ -9,6 +9,7 @@ import java.io.Serial; import java.io.Serializable; +import java.util.List; /** * @author Bruno Ferreira @@ -17,6 +18,7 @@ public class ViewerCell implements Serializable { @Serial private static final long serialVersionUID = -5345114836590659380L; private String value; + private List listValue; private String mimeType; private String fileExtension; private ViewerLobStoreType storeType; @@ -53,6 +55,19 @@ public void setValue(String value) { this.value = value; } + /** + * Gets the value of this cell as list of strings + * + * @return the value or null if the database cell value was NULL + */ + public List getListValue() { + return listValue; + } + + public void setListValue(List listValue) { + this.listValue = listValue; + } + public String getMimeType() { return mimeType; } diff --git a/src/main/java/com/databasepreservation/common/server/index/schema/collections/RowsCollection.java b/src/main/java/com/databasepreservation/common/server/index/schema/collections/RowsCollection.java index 1f296318..31becb1d 100644 --- a/src/main/java/com/databasepreservation/common/server/index/schema/collections/RowsCollection.java +++ b/src/main/java/com/databasepreservation/common/server/index/schema/collections/RowsCollection.java @@ -95,8 +95,12 @@ public SolrInputDocument toSolrDocument(ViewerRow row) throws ViewerException, R doc.setField(SOLR_ROWS_TABLE_UUID, row.getTableUUID()); for (Map.Entry cellEntry : row.getCells().entrySet()) { String solrColumnName = cellEntry.getKey(); - String cellValue = cellEntry.getValue().getValue(); - doc.addField(solrColumnName, cellValue); + if (solrColumnName.endsWith(ViewerConstants.SOLR_DYN_STRING_MULTI)) { + doc.addField(solrColumnName, cellEntry.getValue().getListValue()); + } else { + String cellValue = cellEntry.getValue().getValue(); + doc.addField(solrColumnName, cellValue); + } } for (Map.Entry cellEntry : row.getColsMimeTypeList().entrySet()) { diff --git a/src/main/java/com/databasepreservation/common/transformers/ToolkitStructure2ViewerStructure.java b/src/main/java/com/databasepreservation/common/transformers/ToolkitStructure2ViewerStructure.java index 68d7e4ee..ae0b684b 100644 --- a/src/main/java/com/databasepreservation/common/transformers/ToolkitStructure2ViewerStructure.java +++ b/src/main/java/com/databasepreservation/common/transformers/ToolkitStructure2ViewerStructure.java @@ -24,6 +24,7 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import com.databasepreservation.model.data.ArrayCell; import org.apache.commons.codec.binary.Base64; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -67,7 +68,6 @@ import com.databasepreservation.common.client.models.structure.ViewerTable; import com.databasepreservation.common.client.models.structure.ViewerTrigger; import com.databasepreservation.common.client.models.structure.ViewerType; -import com.databasepreservation.common.client.models.structure.ViewerTypeArray; import com.databasepreservation.common.client.models.structure.ViewerTypeStructure; import com.databasepreservation.common.client.models.structure.ViewerUserStructure; import com.databasepreservation.common.client.models.structure.ViewerView; @@ -687,7 +687,7 @@ private static String getColumnSolrName(int index, Type type, ViewerType viewerT } else if (type instanceof SimpleTypeString) { suffix = ViewerConstants.SOLR_DYN_TEXT_GENERAL; } else if (type instanceof ComposedTypeArray) { - throw new ViewerException("Arrays are not yet supported."); + suffix = ViewerConstants.SOLR_DYN_STRING_MULTI; } else if (type instanceof ComposedTypeStructure) { throw new ViewerException("Composed types are not yet supported."); } else { @@ -735,10 +735,11 @@ private static ViewerType getType(Type type) throws ViewerException { result.setDbType(ViewerType.dbTypes.STRING); } } else if (type instanceof ComposedTypeArray) { - result = new ViewerTypeArray(); + // result = new ViewerTypeArray(); result.setDbType(ViewerType.dbTypes.COMPOSED_ARRAY); // set type of elements in the array - ((ViewerTypeArray) result).setElementType(getType(((ComposedTypeArray) type).getElementType())); + // ((ViewerTypeArray) result).setElementType(getType(((ComposedTypeArray) + // type).getElementType())); } else if (type instanceof ComposedTypeStructure) { result = new ViewerTypeStructure(); result.setDbType(ViewerType.dbTypes.COMPOSED_STRUCTURE); @@ -897,6 +898,13 @@ private static ViewerCell getCell(CollectionStatus collectionConfiguration, View default: result.setValue(removeUnicode(simpleCell.getSimpleData())); } + } else if (cell instanceof ArrayCell) { + ArrayCell arrayCell = (ArrayCell) cell; + List valuesList = new ArrayList<>(); + arrayCell.forEach(arrayElement -> { + valuesList.add(((SimpleCell) arrayElement.getValue()).getSimpleData()); + }); + result.setListValue(valuesList); } else if (!(cell instanceof NullCell)) { // nothing to do for null cells throw new ViewerException("Unexpected cell type");