This is an automated email from the git hooks/post-receive script. New commit to branch feature/sync in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit 0260856f2f650a1fd0eef4f21ec129e789d69f65 Author: servantie <servantie.c@gmail.com> Date: Wed Jul 6 15:06:20 2016 +0200 corrected a double addition of urls in the synclist, edited some doc --- src/main/java/org/chorem/jtimer/data/TimerDataManager.java | 5 +++++ src/main/java/org/chorem/jtimer/entities/SyncInfo.java | 10 +++++----- src/main/java/org/chorem/jtimer/entities/TimerTask.java | 3 ++- src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java | 7 ++----- .../org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java | 8 +++----- .../java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java | 2 +- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/data/TimerDataManager.java b/src/main/java/org/chorem/jtimer/data/TimerDataManager.java index d51edec..529a349 100644 --- a/src/main/java/org/chorem/jtimer/data/TimerDataManager.java +++ b/src/main/java/org/chorem/jtimer/data/TimerDataManager.java @@ -640,8 +640,11 @@ public class TimerDataManager { /** * Edit Synchronization Information + * @param task : the task to edit + * @param info : the SyncInfo that was added */ public void changeSyncInfo(TimerTask task, SyncInfo info) { + task.addSyncInfo(info); for (DataEventListener dataEventListener : dataEventListeners) { @@ -654,6 +657,8 @@ public class TimerDataManager { /** * When a syncInfo is deleted + * @param task : the task to edit + * @param info : the SyncInfo to remove */ public void deleteSyncInfo(TimerTask task, SyncInfo info) { if (task.getSynchronizingInfoList().contains(info)) { diff --git a/src/main/java/org/chorem/jtimer/entities/SyncInfo.java b/src/main/java/org/chorem/jtimer/entities/SyncInfo.java index 7963eac..a183ea7 100644 --- a/src/main/java/org/chorem/jtimer/entities/SyncInfo.java +++ b/src/main/java/org/chorem/jtimer/entities/SyncInfo.java @@ -11,16 +11,16 @@ import java.time.LocalDateTime; public class SyncInfo { /** the url to synchronize on */ - String syncURL; + protected String syncURL; /** the last time the synchronization happened successfully */ - LocalDateTime lastSync; + protected LocalDateTime lastSync; /** true if the synchronization is active */ - boolean isActiveSync; + protected boolean isActiveSync; /** true if annotations included */ - boolean isWithAnnotations; + protected boolean isWithAnnotations; /** * constructor with all parameters @@ -60,7 +60,7 @@ public class SyncInfo { * Returns a boolean if sync should send to this url * @return aboolean */ - public boolean getActiveSync() { + public boolean getIsActiveSync() { return isActiveSync; } diff --git a/src/main/java/org/chorem/jtimer/entities/TimerTask.java b/src/main/java/org/chorem/jtimer/entities/TimerTask.java index 28980a1..f50d411 100644 --- a/src/main/java/org/chorem/jtimer/entities/TimerTask.java +++ b/src/main/java/org/chorem/jtimer/entities/TimerTask.java @@ -353,7 +353,7 @@ public class TimerTask implements Cloneable, /** * Returns the sync info matching a url - * (if the url is not in the list, returns a new SyncInfo with the url) + * (if the url is not in the list, returns a new SyncInfo with the url and adds it to the list) * @param urlString * @return a SyncInfo matching the url */ @@ -364,6 +364,7 @@ public class TimerTask implements Cloneable, } } SyncInfo newInfo = new SyncInfo(urlString); + synchronisingInfoList.add(newInfo); return newInfo; } diff --git a/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java b/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java index 83900bd..3e1fa4f 100644 --- a/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java +++ b/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java @@ -26,7 +26,6 @@ import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; @@ -62,7 +61,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.jtimer.JTimer; @@ -74,7 +72,6 @@ import org.chorem.jtimer.entities.TimerAlert.Type; import org.chorem.jtimer.entities.TimerProject; import org.chorem.jtimer.entities.TimerTask; import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.Constructor; /** * Charge et sauve les fichiers au format gTimer. @@ -1184,7 +1181,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, for (SyncInfo sync : task.getSynchronizingInfoList()) { Map<String, Object> dataToSave = new HashMap<>(); dataToSave.put("url", sync.getSyncURL()); - dataToSave.put("active", sync.getActiveSync()); + dataToSave.put("active", sync.getIsActiveSync()); dataToSave.put("annotations", sync.getIsWithAnnotations()); if (sync.getLastSync()!= null && sync.getLastSync()!=LocalDateTime.MIN) { dataToSave.put("lastSyncTime", sync.getLastSync()); @@ -1234,7 +1231,7 @@ public class GTimerIncrementalSaver extends AbstractSaver implements Saver, // //write url // out.write(sync.getSyncURL() + " "); // //write isActive -// if (sync.getActiveSync()) { +// if (sync.getIsActiveSync()) { // out.write("true "); // } // else { diff --git a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java index 8378c52..700dee8 100644 --- a/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java +++ b/src/main/java/org/chorem/jtimer/ui/report/TimerTaskSyncInfoEditor.java @@ -22,7 +22,6 @@ */ package org.chorem.jtimer.ui.report; -import com.google.gson.Gson; import com.google.gson.JsonObject; import java.awt.BorderLayout; import java.awt.Dimension; @@ -182,7 +181,7 @@ public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener } lastSyncDateLabel.setVisible(false); } - checkIsActiveSync.setSelected(task.getSynchronizingInfo(selectedInfo.getSyncURL()).getActiveSync()); + checkIsActiveSync.setSelected(task.getSynchronizingInfo(selectedInfo.getSyncURL()).getIsActiveSync()); } } labelBox.add(checkIsActiveSync); @@ -290,9 +289,8 @@ public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener public void itemAdded(String urlToAdd){ if ((urlToAdd != null) && ((!task.getSynchronizingURLList().contains(urlToAdd)))) { SyncInfo infoToAdd = new SyncInfo(urlToAdd); - urlComboBox.addItem(infoToAdd); - task.addSyncInfo(urlToAdd); core.getData().changeSyncInfo(task, infoToAdd); + urlComboBox.addItem(infoToAdd); if (log.isDebugEnabled()) { log.debug("New SyncInfo with URL : " + urlToAdd); } @@ -317,7 +315,7 @@ public class TimerTaskSyncInfoEditor extends FrameView implements ActionListener log.debug("Selected an object : " + urlToDisplay); } if (checkIsActiveSync != null) { - checkIsActiveSync.setSelected(syncInfo.getActiveSync()); + checkIsActiveSync.setSelected(syncInfo.getIsActiveSync()); } if (checkIncludesAnnotations != null) { checkIncludesAnnotations.setSelected(syncInfo.getIsWithAnnotations()); diff --git a/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java b/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java index e8dd169..73a1724 100644 --- a/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java +++ b/src/test/java/org/chorem/jtimer/io/GTimerIncrementalSaverTest.java @@ -435,7 +435,7 @@ public class GTimerIncrementalSaverTest extends AbstractJTimerTest { Assert.assertNotNull(task.getSynchronizingInfoList()); Assert.assertEquals(task.getSynchronizingInfoList().get(0).getSyncURL(), syncInfo.getSyncURL()); - Assert.assertEquals(task.getSynchronizingInfoList().get(0).getActiveSync(), syncInfo.getActiveSync()); + Assert.assertEquals(task.getSynchronizingInfoList().get(0).getIsActiveSync(), syncInfo.getIsActiveSync()); } } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.