Skip to content

Commit

Permalink
Eliminating empty deltas in preview changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Apr 1, 2016
1 parent abbf04f commit 7386497
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
Expand Up @@ -97,9 +97,9 @@ public PagePreviewChanges(ModelContext<? extends ObjectType> modelContext, Model
LOGGER.info("Creating context DTO for secondary deltas:\n{}", DebugUtil.debugDump(secondaryScenes));

final WrapperScene primaryScene = new WrapperScene(primaryScenes,
primaryDeltas.size() != 1 ? "PagePreviewChanges.primaryChangesMore" : "PagePreviewChanges.primaryChangesOne", primaryDeltas.size());
primaryScenes.size() != 1 ? "PagePreviewChanges.primaryChangesMore" : "PagePreviewChanges.primaryChangesOne", primaryScenes.size());
final WrapperScene secondaryScene = new WrapperScene(secondaryScenes,
secondaryDeltas.size() != 1 ? "PagePreviewChanges.secondaryChangesMore" : "PagePreviewChanges.secondaryChangesOne", secondaryDeltas.size());
secondaryScenes.size() != 1 ? "PagePreviewChanges.secondaryChangesMore" : "PagePreviewChanges.secondaryChangesOne", secondaryScenes.size());
final SceneDto primarySceneDto = new SceneDto(primaryScene);
final SceneDto secondarySceneDto = new SceneDto(secondaryScene);
primaryDeltasModel = new AbstractReadOnlyModel<SceneDto>() {
Expand Down
Expand Up @@ -146,7 +146,12 @@ private List<? extends SceneImpl> visualizeDeltas(List<ObjectDelta<? extends Obj
throws SchemaException {
List<SceneImpl> rv = new ArrayList<>(deltas.size());
for (ObjectDelta<? extends ObjectType> delta : deltas) {
rv.add(visualizeDelta(delta, null, context, task, result));
if (!delta.isEmpty()) {
final SceneImpl scene = visualizeDelta(delta, null, context, task, result);
if (!scene.isEmpty()) {
rv.add(scene);
}
}
}
return rv;
}
Expand Down
Expand Up @@ -218,4 +218,22 @@ public Long getSourceContainerValueId() {
public boolean isFocusObject() {
return sourceDefinition != null && sourceDefinition.getCompileTimeClass() != null && FocusType.class.isAssignableFrom(sourceDefinition.getCompileTimeClass());
}

public boolean isEmpty() {
if (changeType != ChangeType.MODIFY) {
return false; // ADD or DELETE are never 'empty'
}
for (SceneItemImpl item : getItems()) {
if (item.isDescriptive()) {
continue;
}
return false;
}
for (SceneImpl partialScene : getPartialScenes()) {
if (!partialScene.isEmpty()) {
return false;
}
}
return true;
}
}

0 comments on commit 7386497

Please sign in to comment.