001/*
002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     ataillefer
018 */
019package org.nuxeo.ecm.diff.model.impl;
020
021import java.util.Map;
022
023import org.apache.commons.collections.MapUtils;
024import org.nuxeo.ecm.diff.model.DiffDisplayBlock;
025import org.nuxeo.ecm.diff.model.PropertyDiffDisplay;
026import org.nuxeo.ecm.platform.forms.layout.api.LayoutDefinition;
027
028/**
029 * Handles...
030 *
031 * @author <a href="mailto:ataillefer@nuxeo.com">Antoine Taillefer</a>
032 */
033public class DiffDisplayBlockImpl implements DiffDisplayBlock {
034
035    private static final long serialVersionUID = 5777784629522360126L;
036
037    protected String label;
038
039    protected Map<String, Map<String, PropertyDiffDisplay>> leftValue;
040
041    protected Map<String, Map<String, PropertyDiffDisplay>> rightValue;
042
043    protected Map<String, Map<String, PropertyDiffDisplay>> contentDiffValue;
044
045    protected LayoutDefinition layoutDefinition;
046
047    public DiffDisplayBlockImpl(String label, Map<String, Map<String, PropertyDiffDisplay>> leftValue,
048            Map<String, Map<String, PropertyDiffDisplay>> rightValue,
049            Map<String, Map<String, PropertyDiffDisplay>> contentDiffValue, LayoutDefinition layoutDefinition) {
050        this.label = label;
051        this.leftValue = leftValue;
052        this.rightValue = rightValue;
053        this.contentDiffValue = contentDiffValue;
054        this.layoutDefinition = layoutDefinition;
055    }
056
057    public String getLabel() {
058        return label;
059    }
060
061    public void setLabel(String label) {
062        this.label = label;
063    }
064
065    public Map<String, Map<String, PropertyDiffDisplay>> getLeftValue() {
066        return leftValue;
067    }
068
069    public void setLeftValue(Map<String, Map<String, PropertyDiffDisplay>> leftValue) {
070        this.leftValue = leftValue;
071    }
072
073    public Map<String, Map<String, PropertyDiffDisplay>> getRightValue() {
074        return rightValue;
075    }
076
077    public void setRightValue(Map<String, Map<String, PropertyDiffDisplay>> rightValue) {
078        this.rightValue = rightValue;
079    }
080
081    public Map<String, Map<String, PropertyDiffDisplay>> getContentDiffValue() {
082        return contentDiffValue;
083    }
084
085    public void setContentDiffValue(Map<String, Map<String, PropertyDiffDisplay>> contentDiffValue) {
086        this.contentDiffValue = contentDiffValue;
087    }
088
089    public LayoutDefinition getLayoutDefinition() {
090        return layoutDefinition;
091    }
092
093    public void setLayoutDefinition(LayoutDefinition layoutDefinition) {
094        this.layoutDefinition = layoutDefinition;
095    }
096
097    public boolean isEmpty() {
098        return MapUtils.isEmpty(this.contentDiffValue)
099                && (MapUtils.isEmpty(this.leftValue) || MapUtils.isEmpty(this.rightValue));
100    }
101}