Commit fb97d49b authored by Vitaliy Vashchenko's avatar Vitaliy Vashchenko

#843 turned off overwriting of difficulty choice settings for background sync task.

parent fa049bba
......@@ -48,7 +48,6 @@ import cz.nic.tablexia.bus.ApplicationBus.ApplicationEvent;
import cz.nic.tablexia.bus.event.DeleteUserSynchronizationEvent;
import cz.nic.tablexia.bus.event.DimmerControlEvent;
import cz.nic.tablexia.bus.event.DownloadUserSynchronizationEvent;
import cz.nic.tablexia.bus.event.MenuControlEvent;
import cz.nic.tablexia.bus.event.StartFullSynchronizationEvent;
import cz.nic.tablexia.bus.event.StartIncrementalSynchronizationEvent;
import cz.nic.tablexia.debug.DebugInfo;
......@@ -57,17 +56,15 @@ import cz.nic.tablexia.loader.TablexiaAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.menu.AbstractMenu;
import cz.nic.tablexia.menu.MenuController;
import cz.nic.tablexia.menu.main.MainMenu;
import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.screen.AbstractTablexiaScreen.ScreenLoadingListener;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.sync.RestSynchronizationService;
import cz.nic.tablexia.sync.work.DeleteUser;
import cz.nic.tablexia.sync.work.DownloadUser;
import cz.nic.tablexia.sync.work.PushDataToServer;
import cz.nic.tablexia.sync.work.SyncUser;
import cz.nic.tablexia.sync.work.UpdateAvatar;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.ui.AnimatedImage;
......@@ -949,7 +946,7 @@ public abstract class TablexiaApplication implements ApplicationListener {
return;
}
Log.debug(this.getClass(), "Download user request for uuid: " + syncEvent.getUser().getUuid());
RestSynchronizationService.doSyncWork(new DownloadUser(syncEvent.getUser().getUuid()));
RestSynchronizationService.doSyncWork(new SyncUser(syncEvent.getUser().getUuid()));
}
@Handler
......
......@@ -18,7 +18,6 @@
package cz.nic.tablexia.menu.user;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
......
......@@ -262,6 +262,10 @@ public class UserDAO {
}
public static Long importUser(User user) {
return importUser(user, true);
}
public static Long importUser(User user, boolean overwriteLocalDifficultySettings) {
try {
TablexiaStorage.getInstance().setAutoCommit(false);
......@@ -313,7 +317,7 @@ public class UserDAO {
}
}
if (user.getDifficultySettings() != null) {
if (user.getDifficultySettings() != null && overwriteLocalDifficultySettings) {
for (UserDifficultySettings setting : user.getDifficultySettings()) {
UserDifficultySettingsDAO.saveSettingsForUser(dbUser.getId(), setting.getGameNumber(), setting.getGameDifficulty());
}
......
......@@ -65,7 +65,7 @@ public class DownloadUser extends SyncWork {
}
long start = System.currentTimeMillis();
user.setId(UserDAO.importUser(user));
user.setId(importUser(user));
long finish = System.currentTimeMillis();
setUser(user);
......@@ -80,6 +80,10 @@ public class DownloadUser extends SyncWork {
Log.debug(this.getClass(), "Duration: " + getTime(start, finish));
}
protected Long importUser(User user){
return UserDAO.importUser(user);
}
@Override
protected int getExpectedSuccessResponseCode() {
return HttpStatus.SC_OK;
......
/*
*
* * Copyright (C) 2016 CZ.NIC, z.s.p.o. (http://www.nic.cz/)
* *
* * This program is free software: you can redistribute it and/or modify
* * it under the terms of the GNU General Public License as published by
* * the Free Software Foundation, either version 3 of the License, or
* * (at your option) any later version.
* *
* * This program is distributed in the hope that it will be useful,
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU General Public License for more details.
* *
* * You should have received a copy of the GNU General Public License
* * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package cz.nic.tablexia.sync.work;
import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.shared.model.User;
public class SyncUser extends DownloadUser {
public SyncUser(String uuid) {
super(uuid);
}
@Override
protected Long importUser(User user) {
return UserDAO.importUser(user, false);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment