private boolean moreRows(HollowDiffViewRow parent, int childIdx, boolean from) { for(int i=childIdx+1;i<parent.getChildren().size();i++) { EffigyFieldPair fieldPair = parent.getChildren().get(i).getFieldPair(); if((from && fieldPair.getFrom() != null) || (!from && fieldPair.getTo() != null)) return true; } return false; }
List<HollowDiffViewRow> traverseEffigyToCreateViewRows(HollowDiffViewRow parent) { if(parent.getFieldPair().isLeafNode()) return Collections.emptyList(); Field fromField = parent.getFieldPair().getFrom(); Field toField = parent.getFieldPair().getTo(); HollowEffigy from = fromField == null ? null : (HollowEffigy) fromField.getValue(); HollowEffigy to = toField == null ? null : (HollowEffigy) toField.getValue(); List<EffigyFieldPair> pairs = HollowEffigyFieldPairer.pair(from, to, diffUI.getMatchHints()); List<HollowDiffViewRow> childRows = new ArrayList<HollowDiffViewRow>(); for(int i=0;i<pairs.size();i++) { EffigyFieldPair pair = pairs.get(i); int indentation = parent.getRowPath().length + 1; int rowPath[] = Arrays.copyOf(parent.getRowPath(), indentation); rowPath[rowPath.length - 1] = i; childRows.add(new HollowDiffViewRow(pair, rowPath, parent, this)); } return childRows; }
/** * Returns a String representation of the provided row's field value. If `useFrom` is * true, this will use the `from` value from the pair, otherwise this will use the * `to` value. */ private static String getFieldValue(HollowDiffViewRow row, boolean useFrom) { Field field = useFrom ? row.getFieldPair().getFrom() : row.getFieldPair().getTo(); if (row.getFieldPair().isLeafNode()) { return field.getValue() == null ? "null" : field.getValue().toString().replace("|", "│"); } else { String suffix = field.getValue() == null ? " [null]" : ""; return "(" + field.getTypeName() + ")" + suffix; } }
private static String fromCellClassname(HollowDiffViewRow currentRow) { if(currentRow.getFieldPair().getTo() == null) return "delete"; else if(currentRow.getFieldPair().getFrom() == null) return "empty"; if(currentRow.getFieldPair().getFrom().getValue() == null && currentRow.getFieldPair().getTo().getValue() != null) return "replace"; if(currentRow.getFieldPair().getFrom().getValue() != null && currentRow.getFieldPair().getTo().getValue() == null) return "replace"; if(currentRow.getFieldPair().getFrom().getValue() == null && currentRow.getFieldPair().getTo().getValue() == null) return "equal"; if(currentRow.getFieldPair().isLeafNode() && !currentRow.getFieldPair().getFrom().getValue().equals(currentRow.getFieldPair().getTo().getValue())) return "replace"; return "equal"; }
private static String toCellClassname(HollowDiffViewRow currentRow) { if(currentRow.getFieldPair().getFrom() == null) return "insert"; else if(currentRow.getFieldPair().getTo() == null) return "empty"; if(currentRow.getFieldPair().getFrom().getValue() == null && currentRow.getFieldPair().getTo().getValue() != null) return "replace"; if(currentRow.getFieldPair().getFrom().getValue() != null && currentRow.getFieldPair().getTo().getValue() == null) return "replace"; if(currentRow.getFieldPair().getFrom().getValue() == null && currentRow.getFieldPair().getTo().getValue() == null) return "equal"; if(currentRow.getFieldPair().isLeafNode() && !currentRow.getFieldPair().getFrom().getValue().equals(currentRow.getFieldPair().getTo().getValue())) return "replace"; return "equal"; }
private void assertPair(EffigyFieldPair pair, String expectedFromField1, String expectedToField1) { if(expectedFromField1 != null) { HollowEffigy element = (HollowEffigy) pair.getFrom().getValue(); Assert.assertEquals(expectedFromField1, element.getFields().get(0).getValue()); } else { Assert.assertNull(pair.getFrom()); } if(expectedToField1 != null) { HollowEffigy element = (HollowEffigy) pair.getTo().getValue(); Assert.assertEquals(expectedToField1, element.getFields().get(0).getValue()); } else { Assert.assertNull(pair.getTo()); } }
private static String fromContent(HollowDiffViewRow row) { boolean moreRows[] = new boolean[row.getIndentation() + 1]; for(int i=0;i<=row.getIndentation();i++) moreRows[i] = row.hasMoreFromRows(i); if(row.getFieldPair().getFrom() == null) return unpopulatedContent(moreRows); String fieldName = row.getFieldPair().getFrom().getFieldName(); return populatedContent(moreRows, row.getIndentation(), row.getFieldPair().isLeafNode(), fieldName, getFieldValue(row, true)); }
private boolean rowIsExactMatch(HollowDiffViewRow row) { EffigyFieldPair fieldPair = row.getFieldPair(); if(fieldPair.getFrom() == null || fieldPair.getTo() == null || fieldPair.isLeafNode()) return false; HollowEffigy fromEffigy = (HollowEffigy)fieldPair.getFrom().getValue(); HollowEffigy toEffigy = (HollowEffigy)fieldPair.getTo().getValue(); if(fromEffigy == null || toEffigy == null) return false; return exactRecordMatcher.isExactMatch(fromEffigy.getDataAccess(), fromEffigy.getOrdinal(), toEffigy.getDataAccess(), toEffigy.getOrdinal()); }