writeElement("changetype", entry.getValue().getType().toString()); if (entry.getValue().getOldValue() != null) { writeElement("oldvalue", entry.getValue().getOldValue().toString()); if (entry.getValue().getNewValue() != null && !entry.getValue().getType().equals(TYPE.NO_CHANGE)) { writeElement("newvalue", entry.getValue().getNewValue().toString());
/** * Returns a serialized text version of this object * * @return */ public String asText() { StringBuilder sb = new StringBuilder(); Set<Entry<PropertyDescriptor, AttributeDiff>> entries = diffs.entrySet(); Iterator<Entry<PropertyDescriptor, AttributeDiff>> iter = entries.iterator(); while (iter.hasNext()) { Entry<PropertyDescriptor, AttributeDiff> entry = iter.next(); PropertyDescriptor pd = entry.getKey(); AttributeDiff ad = entry.getValue(); sb.append(pd.getName().toString() + "\t" + ad.asText() + "\n"); } return sb.toString(); }
.iterator(); iterator.hasNext();) { Entry<PropertyDescriptor, AttributeDiff> entry = iterator.next(); if (entry.getValue().getType() == TYPE.REMOVED) { removed.add(entry.getKey().getName().getLocalPart()); } else if (entry.getValue().getType() == TYPE.ADDED) { PropertyDescriptor pd = entry.getKey(); added.add((AttributeDescriptor) pd);
AttributeDiff attrDiff = entry.getValue(); PropertyDescriptor descriptor = entry.getKey(); switch (attrDiff.getType()) { case ADDED: if (descriptors.contains(descriptor)) { if (descriptors.get(i).equals(descriptor)) { Optional<Object> value = feature.get(i); if (!attrDiff.canBeAppliedOn(value.orNull())) { ok = false;
AttributeDiff rightAttDiff = rightDiffs.get(descriptor); Object valueA = leftAttDiff == null ? null : leftAttDiff.getNewValue(); Object valueB = rightAttDiff == null ? null : rightAttDiff.getNewValue();
@Override public boolean conflicts(AttributeDiff ad) { if (!(ad instanceof GeometryAttributeDiff)) { return true; } final GeometryAttributeDiff gad = (GeometryAttributeDiff) ad; final TYPE myType = getType(); final TYPE otherType = ad.getType(); // if either side of the diff is a no change, then there's no conflict, regardless of the // type of the other side if (NO_CHANGE == myType || NO_CHANGE == otherType) { return false; } if (REMOVED == myType && REMOVED == otherType) { return false; } if (MODIFIED == myType && MODIFIED == otherType) { if (gad.diff.equals(diff)) { return false; } else { return true; } } if (ADDED == myType && ADDED == otherType) { return !gad.newGeometry.equalsExact(newGeometry); } return true; }
AttributeDiff attrDiff = entry.getValue(); PropertyDescriptor descriptor = entry.getKey(); switch (attrDiff.getType()) { case ADDED: if (descriptors.contains(descriptor)) { if (descriptors.get(i).equals(descriptor)) { Optional<Object> value = feature.get(i); if (!attrDiff.canBeAppliedOn(value.orNull())) { ok = false;
AttributeDiff rightAttDiff = rightDiffs.get(descriptor); Object valueA = leftAttDiff == null ? null : leftAttDiff.getNewValue(); Object valueB = rightAttDiff == null ? null : rightAttDiff.getNewValue();
@Test public void testAttributeDiffRemoved() { Integer oldValue = 1; Integer newValue = null; AttributeDiff diff = new GenericAttributeDiffImpl(oldValue, newValue); assertEquals(AttributeDiff.TYPE.REMOVED, diff.getType()); assertEquals(oldValue, diff.getOldValue()); assertNull(diff.getNewValue()); }
@Override public boolean conflicts(AttributeDiff ad) { if (!(ad instanceof GeometryAttributeDiff)) { return true; } final GeometryAttributeDiff gad = (GeometryAttributeDiff) ad; final TYPE myType = getType(); final TYPE otherType = ad.getType(); // if either side of the diff is a no change, then there's no conflict, regardless of the // type of the other side if (NO_CHANGE == myType || NO_CHANGE == otherType) { return false; } if (REMOVED == myType && REMOVED == otherType) { return false; } if (MODIFIED == myType && MODIFIED == otherType) { if (gad.diff.equals(diff)) { return false; } else { return true; } } if (ADDED == myType && ADDED == otherType) { return !gad.newGeometry.equalsExact(newGeometry); } return true; }
AttributeDiff attrDiff = entry.getValue(); PropertyDescriptor descriptor = entry.getKey(); switch (attrDiff.getType()) { case ADDED: if (descriptors.contains(descriptor)) { ok = attrDiff.canBeAppliedOn(value.orNull()); break;
PropertyDescriptor key = iter.next(); Optional<?> value = Optional .fromNullable(attribDiffs.get(key).getNewValue()); String attribute = key.getName().toString(); report.addDiff(attribute, value, commit);
/** * Returns a serialized text version of this object * * @return */ public String asText() { StringBuilder sb = new StringBuilder(); Set<Entry<PropertyDescriptor, AttributeDiff>> entries = diffs.entrySet(); Iterator<Entry<PropertyDescriptor, AttributeDiff>> iter = entries.iterator(); while (iter.hasNext()) { Entry<PropertyDescriptor, AttributeDiff> entry = iter.next(); PropertyDescriptor pd = entry.getKey(); AttributeDiff ad = entry.getValue(); sb.append(pd.getName().toString() + "\t" + ad.asText() + "\n"); } return sb.toString(); }
@Test public void testAttributeDiffRemoved() { Integer oldValue = 1; Integer newValue = null; AttributeDiff diff = new GenericAttributeDiffImpl(oldValue, newValue); assertEquals(AttributeDiff.TYPE.REMOVED, diff.getType()); assertEquals(oldValue, diff.getOldValue()); assertNull(diff.getNewValue()); }
.iterator(); iterator.hasNext();) { Entry<PropertyDescriptor, AttributeDiff> entry = iterator.next(); if (entry.getValue().getType() == TYPE.REMOVED) { removed.add(entry.getKey().getName().getLocalPart()); } else if (entry.getValue().getType() == TYPE.ADDED) { PropertyDescriptor pd = entry.getKey(); added.add((AttributeDescriptor) pd);
AttributeDiff attrDiff = entry.getValue(); PropertyDescriptor descriptor = entry.getKey(); switch (attrDiff.getType()) { case ADDED: if (descriptors.contains(descriptor)) { if (!attrDiff.canBeAppliedOn(value.orNull())) { ok = false;
PropertyDescriptor key = iter.next(); Optional<?> value = Optional .fromNullable(attribDiffs.get(key).getNewValue()); String attribute = key.getName().toString(); report.addDiff(attribute, value, commit);
@Test public void testAttributeDiffModified() { Integer oldValue = 1; Integer newValue = 2; AttributeDiff diff = new GenericAttributeDiffImpl(oldValue, newValue); assertEquals(AttributeDiff.TYPE.MODIFIED, diff.getType()); assertEquals(oldValue, diff.getOldValue()); assertEquals(newValue, diff.getNewValue()); }