Skip to content
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

Added fields to return to nested querys #466

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public class ViewerConstants {
public static final String SOLR_ROWS_NESTED_ORIGINAL_UUID = "nestedOriginalUUID";
public static final String SOLR_ROWS_NESTED_TABLE_ID = "nestedTableId";
public static final String SOLR_ROWS_NESTED = "nested";

public static final String SOLR_ROWS_NESTED_COL = "nst_";
/*
* DYNAMIC FIELD TYPES (suffixes)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.fusesource.restygwt.client.MethodCallback;
import org.roda.core.data.v2.index.sublist.Sublist;
Expand Down Expand Up @@ -199,7 +200,6 @@ protected void configureDisplay(CellTable<ViewerRow> display) {
}
}
}

Alert alert = new Alert(Alert.MessageAlertType.LIGHT, messages.noItemsToDisplay());
display.setEmptyTableWidget(alert);

Expand Down Expand Up @@ -234,9 +234,14 @@ public SafeHtml getValue(ViewerRow row) {
if (nestedRow != null && nestedRow.getCells() != null && !nestedRow.getCells().isEmpty()
&& nestedRow.getUuid().equals(configColumn.getId())) {
Map<String, ViewerCell> cells = nestedRow.getCells();

// removes the nested prefix of the nested collumn
Map<String, ViewerCell> cells_no_nested_prefix = cells.entrySet().stream().collect(Collectors
.toMap(entry -> entry.getKey().replace(ViewerConstants.SOLR_ROWS_NESTED_COL, ""), Map.Entry::getValue));

String template = configColumn.getSearchStatus().getList().getTemplate().getTemplate();
if (template != null && !template.isEmpty()) {
String json = JSOUtils.cellsToJson(cells, nestedTable);
String json = JSOUtils.cellsToJson(cells_no_nested_prefix, nestedTable);
String s = JavascriptUtils.compileTemplate(template, json);
aggregationList.add(s);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ public static void buildNestedFieldsToReturn(ViewerTable table, CollectionStatus
String key = ViewerConstants.SOLR_ROWS_NESTED + "." + nestedCount;
keys = keys + separator + key;
separator = ",";
addDefaultNestedFieldsToReturn(fieldsToReturn);
fieldsToReturn.add(key + ":[subquery]");
addNestedDefaultFieldList(extraParameters, key);
extraParameters.put(key + ".q", "+nestedUUID:" + nestedTableId + " AND {!terms f=_root_ v=$row.uuid}");
Integer quantity = column.getNestedColumns().getQuantityInList();
if(quantity <= column.getNestedColumns().getMaxQuantityInList()){
Expand All @@ -188,4 +190,16 @@ public static void buildNestedFieldsToReturn(ViewerTable table, CollectionStatus
}
fieldsToReturn.add(ViewerConstants.SOLR_ROWS_NESTED + ":" + "\"" + keys + "\"");
}

public static void addNestedDefaultFieldList(Map<String, String> extraParameters, String key) {
extraParameters.put(key + ".fl", ViewerConstants.SOLR_ROWS_NESTED + "*," + ViewerConstants.INDEX_ID + ","
+ ViewerConstants.SOLR_ROWS_NESTED_COL + "*," + "originalRowUUID_t");
}

public static void addDefaultNestedFieldsToReturn(List<String> fieldsToReturn) {
fieldsToReturn.add(ViewerConstants.SOLR_ROWS_NESTED + "*");
fieldsToReturn.add(ViewerConstants.SOLR_ROWS_NESTED_COL + "*");
fieldsToReturn.add("originalRowUUID_t");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.databasepreservation.common.client.models.JSO.ExtensionFilter;
import com.databasepreservation.common.client.models.JSO.FilterJSO;
import com.databasepreservation.common.client.models.JSO.OpenFileDialogOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
import static com.databasepreservation.common.client.ViewerConstants.SOLR_ROWS_TABLE_ID;
import static com.databasepreservation.common.client.ViewerConstants.SOLR_ROWS_TABLE_UUID;

import com.databasepreservation.common.client.models.structure.ViewerLobStoreType;
import com.databasepreservation.common.client.tools.ViewerCelllUtils;
import java.util.*;

import com.databasepreservation.common.client.models.structure.ViewerMimeType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;

import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrInputDocument;
import org.roda.core.data.exceptions.AuthorizationDeniedException;
Expand All @@ -30,7 +34,10 @@

import com.databasepreservation.common.client.ViewerConstants;
import com.databasepreservation.common.client.models.structure.ViewerCell;
import com.databasepreservation.common.client.models.structure.ViewerLobStoreType;
import com.databasepreservation.common.client.models.structure.ViewerMimeType;
import com.databasepreservation.common.client.models.structure.ViewerRow;
import com.databasepreservation.common.client.tools.ViewerCelllUtils;
import com.databasepreservation.common.exceptions.ViewerException;
import com.databasepreservation.common.server.index.factory.SolrClientFactory;
import com.databasepreservation.common.server.index.schema.AbstractSolrCollection;
Expand Down Expand Up @@ -193,7 +200,8 @@ private ViewerRow populateNestedRow(SolrDocument doc) throws ViewerException {
private Optional<ViewerCell> cellFromEntry(String columnName, Object value, SolrDocument doc) {
Optional<ViewerCell> viewerCell = Optional.empty();

if (columnName.startsWith(ViewerConstants.SOLR_INDEX_ROW_COLUMN_NAME_PREFIX)) {
if (columnName.startsWith(ViewerConstants.SOLR_INDEX_ROW_COLUMN_NAME_PREFIX)
|| columnName.startsWith(ViewerConstants.SOLR_ROWS_NESTED_COL)) {
if (value instanceof Date) {
// DateTime date = new DateTime(value, JodaUtils.DEFAULT_CHRONOLOGY);
final String dateTimeString = ((Date) value).toInstant().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ private void createdNestedDocument(ViewerRow row, String parentUUID, List<SolrIn
ViewerTable viewerTable = database.getMetadata().getTable(relatedTableUUID);
for (ViewerColumn viewerColumn : viewerTable.getColumns()) {
for (Map.Entry<String, ViewerCell> cell : cells.entrySet()) {
String key = cell.getKey();
String key = ViewerConstants.SOLR_ROWS_NESTED_COL + cell.getKey();
String urlPath = null;
if (cell.getKey().equals(viewerColumn.getSolrName())
&& viewerColumn.getType().getTypeName().equals("BINARY LARGE OBJECT")) {
Expand Down
Loading