Skip to content

Commit

Permalink
fixes for #59 #58
Browse files Browse the repository at this point in the history
  • Loading branch information
hangal committed Apr 18, 2019
1 parent 2478feb commit df3e61c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion WebContent/filter-controls.jspf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if (Util.nullOrEmpty(filterSpec)) { placeholder = "No filter is set. All rows ma
<label for="groupViewControlSpec">Clusters to show:</label>
<select class="form-control selectpicker" id="groupViewControlSpec" name="groupViewControlSpec">
<option <%=MergeManager.GroupViewControl.GROUPS_WITH_ONE_OR_MORE_ROWS.name().equals (gvc.name()) ? "selected":""%> value="<%=MergeManager.GroupViewControl.GROUPS_WITH_ONE_OR_MORE_ROWS%>">Clusters with one or more rows matching filter</option>
<option <%=MergeManager.GroupViewControl.GROUPS_WITH_ONE_OR_MORE_ROWS_AND_TWO_OR_MORE_IDS.name().equals (gvc.name()) ? "selected":""%> value="<%=MergeManager.GroupViewControl.GROUPS_WITH_ONE_OR_MORE_ROWS_AND_TWO_OR_MORE_IDS%>">Clusters with one or more rows and two or more IDs matching filter</option>
<option <%=MergeManager.GroupViewControl.GROUPS_WITH_ONE_OR_MORE_ROWS_AND_TWO_OR_MORE_IDS.name().equals (gvc.name()) ? "selected":""%> value="<%=MergeManager.GroupViewControl.GROUPS_WITH_ONE_OR_MORE_ROWS_AND_TWO_OR_MORE_IDS%>">Clusters with two or more IDs and at least one row matching filter</option>
<option <%=MergeManager.GroupViewControl.GROUPS_WITH_TWO_OR_MORE_ROWS.name().equals (gvc.name()) ? "selected":""%> value="<%=MergeManager.GroupViewControl.GROUPS_WITH_TWO_OR_MORE_ROWS%>">Clusters with two or more rows matching filter</option>
<option <%=MergeManager.GroupViewControl.GROUPS_WITH_TWO_OR_MORE_IDS.name().equals (gvc.name()) ? "selected":""%> value="<%=MergeManager.GroupViewControl.GROUPS_WITH_TWO_OR_MORE_IDS%>">Clusters with two or more IDs matching filter</option>
<option <%=MergeManager.GroupViewControl.GROUPS_WITH_MULTIPLE_VALUES_IN_SECONDARY_FIELD.name().equals (gvc.name()) ? "selected":""%> value="<%=MergeManager.GroupViewControl.GROUPS_WITH_MULTIPLE_VALUES_IN_SECONDARY_FIELD%>">Clusters with more than 1 value in secondary column</option>
Expand Down
3 changes: 2 additions & 1 deletion WebContent/table.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ pageEncoding="UTF-8"

<td class="cell-table table-cell-merge"><%=mergeCheckboxHTML%></td>

<td style="min-width:300px" class="cell-table table-cell-name"><a href="<%=href%>" title="<%=hoverText%>" target="_blank"><%=Util.escapeHTML(row.get(Config.MERGE_FIELD).toUpperCase())%></a></td>
<!-- need word-wrap: break-all to break very long names -->
<td style="min-width:300px;word-wrap:break-all" class="cell-table table-cell-name"><a href="<%=href%>" title="<%=hoverText%>" target="_blank"><%=Util.escapeHTML(row.get(Config.MERGE_FIELD).toUpperCase())%></a></td>
<%-- <td class="cell-table table-cell-constituency"><a href="<%=pc_href%>" title="<%=pcInfo%>" target="_blank"><%=Util.escapeHTML(row.get("Constituency_Name").toUpperCase())%></a></td> --%>

<%
Expand Down
11 changes: 7 additions & 4 deletions src/in/edu/ashoka/surf/MergeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ public void applyUpdatesAndSave(Command[] commands) throws IOException {
datasetNeedsToBeSaved = true;
} else if ("unmerge".equalsIgnoreCase(command.op)) {
// create unique id's for all rows

for (String id : command.ids) {
log.info("Unmerging id " + id);
Collection<Row> rowsForThisId = idToRows.get(id);
for (Row row : rowsForThisId) {
row.set(Config.ID_FIELD, Integer.toString(nextAvailableId));
Expand Down Expand Up @@ -466,14 +468,15 @@ private List<List<List<Row>>> applyFilter (Filter filter, GroupViewControl gvc,
break;
case ALL_GROUPS:
break;
case GROUPS_WITH_TWO_OR_MORE_IDS:
case GROUPS_WITH_TWO_OR_MORE_IDS: {
Set<String> idsInGroup = group.stream().filter(filter::passes).map(r -> r.get(Config.ID_FIELD)).collect(Collectors.toSet()); // limit(2) to ensure early out at finding the first row passing the filter
groupWillBeShown = (idsInGroup.size() >= 2);
break;
}
case GROUPS_WITH_ONE_OR_MORE_ROWS_AND_TWO_OR_MORE_IDS: {
Collection<Row> tempGroup = group.stream().filter(filter::passes).collect(Collectors.toList());
Set<String> idsInGroupWithOneOrMoreRows = tempGroup.stream().filter(filter::passes).map(r -> r.get(Config.ID_FIELD)).collect(Collectors.toSet()); // limit(2) to ensure early out at finding the first row passing the filter
groupWillBeShown = (idsInGroupWithOneOrMoreRows.size() >= 2);
Collection<Row> rowsMatchingFilter = group.stream().filter(filter::passes).collect(Collectors.toList());
Set<String> idsInGroup = group.stream().filter(filter::passes).map(r -> r.get(Config.ID_FIELD)).collect(Collectors.toSet());
groupWillBeShown = (rowsMatchingFilter.size() > 0 && idsInGroup.size() >= 2);
break;
}
case GROUPS_WITH_MULTIPLE_VALUES_IN_SECONDARY_FIELD: {
Expand Down

0 comments on commit df3e61c

Please sign in to comment.