/** * @return The entity this {@link Diff} represents in the newer Atlas. null if this Diff is of * type "REMOVED" */ public AtlasEntity getAfterEntity() { return this.itemType.entityForIdentifier(this.after, this.identifier); }
/** * @return The entity this {@link Diff} represents in the older Atlas. null if this Diff is of * type "ADDED" */ public AtlasEntity getBeforeEntity() { return this.itemType.entityForIdentifier(this.before, this.identifier); }
/** * Check if a given entity is missing from a given atlas. Optionally, we can match using the * underlying geometry if the itemType/identifier check fails. * * @param entity * the entity to check for * @param atlasToCheck * the atlas to check * @param useGeometryMatching * use geometry matching * @return if the entity was missing from the atlas */ private boolean isEntityMissingFromGivenAtlas(final AtlasEntity entity, final Atlas atlasToCheck) { /* * Look up the given entity's ID in the atlasToCheck. If the returned entity is null, we * know it was NOT PRESENT in the atlasToCheck. */ return entity.getType().entityForIdentifier(atlasToCheck, entity.getIdentifier()) == null; } }
@Test public void testEntityForIdentifier() { final Atlas atlas = this.rule.getAtlas(); Assert.assertEquals(atlas.node(1), ItemType.NODE.entityForIdentifier(atlas, 1)); Assert.assertEquals(atlas.edge(1), ItemType.EDGE.entityForIdentifier(atlas, 1)); Assert.assertEquals(atlas.area(1), ItemType.AREA.entityForIdentifier(atlas, 1)); Assert.assertEquals(atlas.line(1), ItemType.LINE.entityForIdentifier(atlas, 1)); Assert.assertEquals(atlas.point(1), ItemType.POINT.entityForIdentifier(atlas, 1)); Assert.assertEquals(atlas.relation(1), ItemType.RELATION.entityForIdentifier(atlas, 1)); }
final AtlasEntity beforeEntity = entity.getType().entityForIdentifier(this.before, entity.getIdentifier()); final AtlasEntity afterEntity = entity.getType().entityForIdentifier(this.after, entity.getIdentifier());
if (entity.getType().entityForIdentifier(this.after, entity.getIdentifier()) == null && (!(entity instanceof Edge) || !hasGoodMatch((Edge) entity, this.after))) if (entity.getType().entityForIdentifier(this.before, entity.getIdentifier()) == null && (!(entity instanceof Edge) || !hasGoodMatch((Edge) entity, this.before))) final AtlasEntity alterEntity = baseEntity.getType().entityForIdentifier(this.after, baseEntity.getIdentifier());