Package com.trechner.ksync4j.type

Examples of com.trechner.ksync4j.type.Syncable.copy()


    private void syncRefreshFromClient(Map<String, Syncable> database, Map<String, Syncable> clientChanges) throws Exception {
        Map<String, Syncable> resultingClientChanges = new HashMap<String, Syncable>();
        for (Syncable syncable : clientChanges.values()) {
            Syncable copy = syncable.getClass().newInstance();
            copy.copy(syncable);
            copy.setChangeType(ChangeType.NONE);
            resultingClientChanges.put(copy.getGuid(), copy);
        }
        clearDatabase();
        saveSyncablesToDatabase(resultingClientChanges.values());
View Full Code Here


    private void syncRefreshFromServer(Map<String, Syncable> database, Map<String, Syncable> clientChanges) throws Exception {
        Map<String, Syncable> resultingClientChanges = new HashMap<String, Syncable>();
        for (Syncable syncable : database.values()) {
            Syncable copy = syncable.getClass().newInstance();
            copy.copy(syncable);
            copy.setChangeType(ChangeType.ADDED);
            resultingClientChanges.put(copy.getGuid(), copy);
        }
        sendSyncablesToClient(resultingClientChanges.values());
    }
View Full Code Here

    private void resolveConflicts(Map<String, Syncable> database, Map<String, Syncable> clientChanges, Map<String, Syncable> resultingDatabase, Map<String, Syncable> resultingClientChanges, boolean merge) throws Exception {
        // Determine what to write to database.
        for (Syncable syncable : database.values()) {
            Syncable copy = syncable.getClass().newInstance();
            copy.copy(syncable);
            copy.setChangeType(ChangeType.NONE);
            resultingDatabase.put(copy.getGuid(), copy);
        }
        for (String guid : clientChanges.keySet()) {
            Syncable clientSyncable = clientChanges.get(guid);
View Full Code Here

            switch (clientSyncable.getChangeType()) {
                case ChangeType.NONE: {
                    if (merge) {
                        if (databaseSyncable == null) {
                            Syncable copy = clientSyncable.getClass().newInstance();
                            copy.copy(clientSyncable);
                            copy.setChangeType(ChangeType.NONE);
                            resultingDatabase.put(guid, copy);
                        }
                    }
                    break;
View Full Code Here

                    }
                    break;
                }
                case ChangeType.ADDED: {
                    Syncable copy = clientSyncable.getClass().newInstance();
                    copy.copy(clientSyncable);
                    copy.setChangeType(ChangeType.NONE);
                    resultingDatabase.put(guid, copy);
                    break;
                }
                case ChangeType.EDITED: {
View Full Code Here

                    resultingDatabase.put(guid, copy);
                    break;
                }
                case ChangeType.EDITED: {
                    Syncable copy = clientSyncable.getClass().newInstance();
                    copy.copy(clientSyncable);
                    copy.setChangeType(ChangeType.NONE);
                    resultingDatabase.put(guid, copy);
                    break;
                }
                case ChangeType.DELETED: {
View Full Code Here

            switch (databaseSyncable.getChangeType()) {
                case ChangeType.NONE: {
                    if (merge) {
                        if (clientSyncable == null) {
                            Syncable copy = databaseSyncable.getClass().newInstance();
                            copy.copy(databaseSyncable);
                            copy.setChangeType(ChangeType.ADDED);
                            resultingClientChanges.put(guid, copy);
                        }
                    }
                    break;
View Full Code Here

                }
                case ChangeType.ADDED: {
                    // Send editions to client. Conflict. Client and server: NONE/ADDED, DELETED/ADDED (send)
                    if (clientSyncable == null || clientSyncable.getChangeType() == ChangeType.NONE || clientSyncable.getChangeType() == ChangeType.DELETED) {
                        Syncable copy = databaseSyncable.getClass().newInstance();
                        copy.copy(databaseSyncable);
                        resultingClientChanges.put(guid, copy);
                    }
                    break;
                }
                case ChangeType.EDITED: {
View Full Code Here

                }
                case ChangeType.EDITED: {
                    // Send editions to client. Conflict. Client and server: NONE/EDITED, DELETED/EDITED (send)
                    if (clientSyncable == null || clientSyncable.getChangeType() == ChangeType.NONE || clientSyncable.getChangeType() == ChangeType.DELETED) {
                        Syncable copy = databaseSyncable.getClass().newInstance();
                        copy.copy(databaseSyncable);
                        resultingClientChanges.put(guid, copy);
                    }
                    break;
                }
                case ChangeType.DELETED: {
View Full Code Here

                }
                case ChangeType.DELETED: {
                    // Send editions to client. Conflict. Client and server: NONE/DELETED, DELETED/DELETED (send)
                    if (clientSyncable == null || clientSyncable.getChangeType() == ChangeType.NONE || clientSyncable.getChangeType() == ChangeType.DELETED) {
                        Syncable copy = databaseSyncable.getClass().newInstance();
                        copy.copy(databaseSyncable);
                        resultingClientChanges.put(guid, copy);
                        resultingDatabase.remove(guid);
                    }
                    break;
                }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.