001/**
002 *   GRANITE DATA SERVICES
003 *   Copyright (C) 2006-2013 GRANITE DATA SERVICES S.A.S.
004 *
005 *   This file is part of the Granite Data Services Platform.
006 *
007 *                               ***
008 *
009 *   Community License: GPL 3.0
010 *
011 *   This file is free software: you can redistribute it and/or modify
012 *   it under the terms of the GNU General Public License as published
013 *   by the Free Software Foundation, either version 3 of the License,
014 *   or (at your option) any later version.
015 *
016 *   This file is distributed in the hope that it will be useful, but
017 *   WITHOUT ANY WARRANTY; without even the implied warranty of
018 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
019 *   GNU General Public License for more details.
020 *
021 *   You should have received a copy of the GNU General Public License
022 *   along with this program. If not, see <http://www.gnu.org/licenses/>.
023 *
024 *                               ***
025 *
026 *   Available Commercial License: GraniteDS SLA 1.0
027 *
028 *   This is the appropriate option if you are creating proprietary
029 *   applications and you are not prepared to distribute and share the
030 *   source code of your application under the GPL v3 license.
031 *
032 *   Please visit http://www.granitedataservices.com/license for more
033 *   details.
034 */
035package org.granite.client.tide.data;
036
037import java.util.List;
038
039import org.granite.logging.Logger;
040
041/**
042 *  Holds conflict data when locally changed data is in conflict with data coming from the server
043 * 
044 *  @author William DRAI
045 */
046public class Conflict {
047    
048    @SuppressWarnings("unused")
049    private static Logger log = Logger.getLogger(Conflict.class);
050
051    private Conflicts conflicts;
052    
053    private Object localEntity;
054    private Object receivedEntity;
055    private List<String> properties;
056    private boolean resolved = false;
057    
058
059
060    public Conflict(Conflicts conflicts, Object localEntity, Object receivedEntity, List<String> properties) {
061        this.conflicts = conflicts;
062        this.localEntity = localEntity;
063        this.receivedEntity = receivedEntity;
064        this.properties = properties;
065    }
066    
067    public Object getLocalEntity() {
068        return localEntity;
069    }        
070    
071    public Object getReceivedEntity() {
072        return receivedEntity;
073    }
074    
075    public List<String> getProperties() {
076        return properties;
077    }
078    
079    public boolean isRemoval() {
080        return receivedEntity == null;
081    }
082    
083    public boolean isResolved() {
084        return resolved;
085    }
086    
087    public void acceptClient() {
088        conflicts.acceptClient(this);
089        resolved = true;
090    }
091    
092    public void acceptServer() {
093        conflicts.acceptServer(this);
094        resolved = true;
095    }
096}