Jtimer-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
August 2014
- 2 participants
- 10 discussions
r3032 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/entities java/org/chorem/jtimer/storage resources webapp/js webapp/partials
by obruce@users.chorem.org 22 Aug '14
by obruce@users.chorem.org 22 Aug '14
22 Aug '14
Author: obruce
Date: 2014-08-22 16:54:01 +0200 (Fri, 22 Aug 2014)
New Revision: 3032
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3032
Log:
fix hidden task behaviour dans le rapport
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/resources/jtimer-default.properties
branches/ng-jtimer/src/main/webapp/js/controllers.js
branches/ng-jtimer/src/main/webapp/js/entities.js
branches/ng-jtimer/src/main/webapp/partials/reportModal.html
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2014-08-22 14:50:11 UTC (rev 3031)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2014-08-22 14:54:01 UTC (rev 3032)
@@ -81,6 +81,9 @@
/** Array of ordered tags */
protected String[] tags;
+ /** boolean if hidden */
+ protected Boolean hidden;
+
/**
* Constructor.
*/
@@ -105,6 +108,7 @@
this.removed = 0;
this.path = null;
this.tags = null;
+ this.hidden = false;
}
/**
@@ -123,6 +127,7 @@
this.removed = 0;
this.path = null;
this.tags = null;
+ this.hidden = false;
}
/**
@@ -141,6 +146,7 @@
this.removed = other.isClosed()? 1 : 0 ;
this.path = null;
this.tags = null;
+ this.hidden = false;
}
@@ -280,6 +286,15 @@
return this.tags;
}
+
+ public Boolean getHidden() {
+ return hidden;
+ }
+
+ public void setHidden(Boolean hidden) {
+ this.hidden = hidden;
+ }
+
@Override
public String toString() {
String res ="TimerTask {" +
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-08-22 14:50:11 UTC (rev 3031)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-08-22 14:54:01 UTC (rev 3032)
@@ -391,6 +391,7 @@
task.setCreationDate(new java.util.Date((rs.getTimestamp("creationDate").getTime())));
task.setModificationDate(new java.util.Date(rs.getTimestamp("modificationDate").getTime()));
task.setTotalTime(rs.getLong("totalduration"));
+
tasks.add(task);
}
Modified: branches/ng-jtimer/src/main/resources/jtimer-default.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-08-22 14:50:11 UTC (rev 3031)
+++ branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-08-22 14:54:01 UTC (rev 3032)
@@ -2,7 +2,7 @@
# jTimer default properties
###
# jTimer storage path
-jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/BDDtag3
+jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/BDDplop
###
# SQL properties
###
@@ -92,19 +92,6 @@
WHERE TA.taskId = TI.taskid \
AND TA.removed > 0 \
GROUP BY TA.taskId
-jtimer.storage.select.report.timedtasks=SELECT TA.* , sum(TI.duration) AS totalduration \
- FROM task TA, tasktime TI \
- WHERE TA.taskId = TI.taskid \
- AND TI.creationDate BETWEEN ? AND ? \
- AND TA.removed = 0 \
- GROUP BY TA.taskId
-jtimer.storage.select.report.rootTask=SELECT TA.* AS totalduration \
- FROM task TA \
- WHERE TA.taskId = TI.taskid \
- AND TI.creationDate BETWEEN ? AND ? \
- AND ARRAY_LENGTH(TA.path) = 1 \
- AND TA.removed = 0 \
- GROUP BY TA.taskId
jtimer.storage.select.report.byProject=SELECT TA.*, sum(TI.duration) AS totalduration \
FROM task TA, tasktime TI \
WHERE TA.taskId = TI.taskid \
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-22 14:50:11 UTC (rev 3031)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-22 14:54:01 UTC (rev 3032)
@@ -690,7 +690,7 @@
});
var children = $scope.getChildren(task);
- $scope.hideTaskRecurse(children);
+ $scope.hideTaskRecurse(children, bool);
save();
});
};
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-08-22 14:50:11 UTC (rev 3031)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-08-22 14:54:01 UTC (rev 3032)
@@ -417,7 +417,7 @@
* @param {type} parentTaskId l'identifiant de la tache parente
* @returns {Task}
*/
-var Task = function (name,taskId, parentTaskId, parentTags,description) {
+var Task = function (name,taskId, parentTaskId, parentTags,description,hidden) {
if(taskId == undefined){
this.taskId =generateUUID();
@@ -437,7 +437,12 @@
this.name = name;
this.description = description;
this.isReported = true;
- this.hidden = false;
+ if(hidden){
+ this.hidden = hidden;
+ }else{
+ this.hidden = false;
+ }
+
this.alarms=[];
if(parentTags){
this.tags = parentTags;
Modified: branches/ng-jtimer/src/main/webapp/partials/reportModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-08-22 14:50:11 UTC (rev 3031)
+++ branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-08-22 14:54:01 UTC (rev 3032)
@@ -145,23 +145,36 @@
<br/>
</div>
- <div class="tr" ng-show="taskData[$node.task.taskId].selftime
+ <div class="tr" ng-if="taskData[$node.task.taskId].selftime
|| hasSelfOrChildTime(taskData,$node,false)
- || ($node.task.isRoot() && getTotalProjectTime($node,0) != 0 )">
+ || ($node.task.isRoot() && getTotalProjectTime($node,0) != 0 )
+ ">
<div class="td" >
<span class="spacer level{{$level}}"></span>
- <b ng-if="$node.task.isRoot()">Projet : {{$node.task.name}}</b>
+ <b ng-if="$node.task.isRoot() && !$node.task.hidden">Projet : {{$node.task.name}}</b>
+ <b ng-if="$node.task.isRoot() && $node.task.hidden">**Projet : {{$node.task.name}}**</b>
<span ng-if="!$node.task.isRoot() && !$node.task.hidden">{{$node.task.name}} </span>
<span ng-if="!$node.task.isRoot() && ($node.task.hidden && modal.showHidden)">**{{$node.task.name}}** </span>
</div >
- <div class="td" ng-show="!$node.task.isRoot() && taskData[$node.task.taskId].selftime && modal.showTime && ($node.task.hidden && modal.showHidden)" >
+ <div class="td" ng-show="!$node.task.isRoot() && taskData[$node.task.taskId].selftime
+ && modal.showTime && !$node.task.hidden" >
<span class="spacer level{{$level}}"></span>
<span>{{taskData[$node.task.taskId].selftime |time }} </span>
</div>
+
+ <div class="td" ng-show="!$node.task.isRoot() && taskData[$node.task.taskId].selftime
+ && modal.showTime && ($node.task.hidden && modal.showHidden)" >
+ <span class="spacer level{{$level}}"></span>
+ <span>{{taskData[$node.task.taskId].selftime |time }} </span>
+
+ </div>
+
+
+ <!--Total pour les taches root -->
<div class="td" ng-show="$node.task.isRoot() && modal.showTime" >
<span class="spacer level{{$level}}"></span>
<b> Total : {{getTotalProjectTime($node,0) |time }} </b>
@@ -190,23 +203,30 @@
<!-- If root task -->
<div class="td paded-top" ng-if="$node.task.isRoot()" >
<span class="spacer level{{$level}}"></span>
- <b>Projet : {{$node.task.name}}</b>
+ <b ng-if="!$node.task.hidden">Projet : {{$node.task.name}}</b>
+ <b ng-if="$node.task.hidden && modal.showHidden">**Projet : {{$node.task.name}}**</b>
</div >
<div class="td paded-top" ng-show="$node.task.isRoot() && modal.showTime" >
<span class="spacer level{{$level}}"></span>
- <b>Total : {{getTotalPeriodTime($node,0,period) |time }} </b>
+ <b ng-if="!$node.task.hidden">Total : {{getTotalPeriodTime($node,0,period) |time }} </b>
+ <b ng-if="$node.task.hidden && modal.showHidden">
+ Total : {{getTotalPeriodTime($node,0,period) |time }} </b>
</div>
+
+
<!-- not root task -->
<div class="td" ng-if="!$node.task.isRoot()" >
<span class="spacer level{{$level}}"></span>
- <span>{{$node.task.name}} </span>
+ <span ng-if="!$node.task.hidden">{{$node.task.name}} </span>
+ <span ng-if="$node.task.hidden && modal.showHidden">**{{$node.task.name}}** </span>
</div >
<div class="td" ng-show="!$node.task.isRoot() && periodTaskData[period][$node.task.taskId] && modal.showTime" >
<span class="spacer level{{$level}}"></span>
- <span>{{tasks[$node.task.taskId] |time }} </span>
+ <span ng-if="!$node.task.hidden">{{tasks[$node.task.taskId] |time }} </span>
+ <span ng-if="$node.task.hidden && modal.showHidden">{{tasks[$node.task.taskId] |time }} </span>
</div>
</div>
1
0
Author: obruce
Date: 2014-08-22 16:50:11 +0200 (Fri, 22 Aug 2014)
New Revision: 3031
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3031
Log:
ajout du readme
Modified:
branches/ng-jtimer/README.txt
Modified: branches/ng-jtimer/README.txt
===================================================================
--- branches/ng-jtimer/README.txt 2014-08-21 15:57:32 UTC (rev 3030)
+++ branches/ng-jtimer/README.txt 2014-08-22 14:50:11 UTC (rev 3031)
@@ -0,0 +1,118 @@
+Ce qui a été fait:
+------------------
+
+Fonctionnalité
+-Création/ Modification/ Suppression de tâche/ soustâche.
+ Création avec persistance automatique
+ Modification avec persistance automatique
+ Suppression avec modification de l'attribut removed des task en base
+ Suppression soit de la tache et des soit repport des temps vers le parent.
+
+-Minuter la tâche.
+ A l'activation création d'une période puis ajout de seconde.
+ Puis chaque seconde verification du jour (si nouveau jour nouvelle période).
+
+-Augmenter/Diminuer le temps passé sur une tâche avec des raccourcis ou par l'interface.
+
+-Faire apparaître/ Masquer des tâches.
+ Masquage reccursif. Possibilité de voir les taches masquées en configurant.
+
+-Commenter une tâche.
+ Ajout de description.
+
+-Poser/ Enlever des alertes sur une tâche du type :
+ temps total à ne pas dépasser par tâche.
+ temps total à ne pas dépasser par jour sur une tâche.
+ Si parent a une alarme et enfant minute l'alarme sera declenchée
+-Masquer/Démasquer les tâches.
+ Masque la tache et ses sous taches.
+
+-Architecture rest avec restlet.
+les chemins
+ /rest/tasks/task //toutes les taches parampossible: deb et fin de periode voulu
+ /rest/tasks/task/{taskId} //une tache avec id
+ /rest/tasks/time/{taskId} //un time avec son id
+ /rest/tasks/time //tous les temps
+ /rest/report //le rapport param possible: type,deb,fin de periode voulu
+ /rest/tasks/alarm //les alarmes
+ /rest/tasks/alarm/{taskId} // une alarme par id
+ /rest/import // pour importer les taches param: le chemin
+
+
+
+
+Ce qui reste à faire :
+----------------------
+
+Task:
+----
+-Ajouter boolean hidden.
+
+Alarme :
+-------
+-Avoir des alarmes par fréquence
+ autres que jour et total (mois, annees). *
+
+Périodes:
+---------
+-Ajouter une vérification pour les chevauchementsdes périodes. *
+-Revoir l'interface de modification de période qui est très moche **
+
+Settings:
+---------
+-Ajouter un mode de suppression (toujours) direct -
+
+Ecran principal :
+-----------------
+-Changer l'iconed'arbre vide *
+-Voir sur quelle tache il y a des alarmes. *
+ Avoir une colonne alarme?
+-Cacher les secondes? configurable? -
+-Afficher le total pour le jour et le total total avec un petit graph. **
+
+Raccourcis:
+-----------
+Ajouter une limite de temps à ajouter.
+
+Rapport :
+---------
+-Eviter les effets de bord sur l'écran principal de l'ouverture de l'arbre. *
+-Changer la portée des boutons previous/curent/next week pour faire en sorte,
+ qu'il change en mois/année/semaine selon le choix de filtre. *
+-Générer le rapport dans une autre fenêtre. *
+-Ajouter une liste des tags existant avec drag and drop *
+-Avoir un petit message quand raport vide *
+
+Recherche:
+----------
+-Corriger bug. ***
+
+Detection de l'inactivite :
+---------------------------
+- Ajouter le retrait du temps ou continuité quand inactif ***
+
+Controller:
+----------
+-Enlever le save
+
+Import: ***
+-------
+-Voir ce qui prend du temps dans les algo, cause des lags:
+ ->creation des taches -
+ ->requetes persistances -
+ -> get de l'interface -
+ ->requetes base -
+ ->envoie -
+ ->construction de l'arbre (à mon avis c'est ça ou le poid des données)
+
+
+//le chemin que moi j'utilise
+/home/olivia/.gtimer/backups/backup-20140814140938.zip
+
+Importance:
+peu
+-
+*
+**
+***
+beaucoup
\ No newline at end of file
1
0
r3030 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/io java/org/chorem/jtimer/storage java/org/chorem/jtimer/web resources webapp/css webapp/js webapp/partials
by obruce@users.chorem.org 21 Aug '14
by obruce@users.chorem.org 21 Aug '14
21 Aug '14
Author: obruce
Date: 2014-08-21 17:57:32 +0200 (Thu, 21 Aug 2014)
New Revision: 3030
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3030
Log:
changement au niveau des taches cachees et de l'import
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ImportResource.java
branches/ng-jtimer/src/main/resources/jtimer-default.properties
branches/ng-jtimer/src/main/webapp/css/app.css
branches/ng-jtimer/src/main/webapp/js/app.js
branches/ng-jtimer/src/main/webapp/js/controllers.js
branches/ng-jtimer/src/main/webapp/js/entities.js
branches/ng-jtimer/src/main/webapp/partials/reportModal.html
branches/ng-jtimer/src/main/webapp/partials/settings.html
branches/ng-jtimer/src/main/webapp/partials/tasks.html
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java 2014-08-20 08:19:42 UTC (rev 3029)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java 2014-08-21 15:57:32 UTC (rev 3030)
@@ -583,6 +583,8 @@
folder.mkdir();
}
+ log.warn("le fichier" + zipFile);
+
// We get zip's content
ZipInputStream zip = new ZipInputStream(new FileInputStream(zipFile));
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-08-20 08:19:42 UTC (rev 3029)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-08-21 15:57:32 UTC (rev 3030)
@@ -218,7 +218,7 @@
statement.executeUpdate();
- String[] path;
+ String[] path= new String[]{task.getTaskId()};;
//On recupere le path du parent
if(!task.getParent().equals("")) {
@@ -232,22 +232,23 @@
try {
rs.first();
Object[] parentArray = (Object[]) rs.getObject("path");
- path = new String[parentArray.length + 1];
- int cpt = 0;
- for(Object s : parentArray){
- parentArray[cpt] = s;
- cpt++;
+ if(parentArray != null) {
+ path = new String[parentArray.length + 1];
+
+ int cpt = 0;
+ for (Object s : parentArray) {
+ parentArray[cpt] = s;
+ cpt++;
+ }
+
+ path[parentArray.length] = task.getTaskId();
}
- path[parentArray.length] = task.getTaskId();
-
}catch(JdbcSQLException eee){
log.error(eee);
path = new String[]{task.getTaskId()};
}
- } else {
- path = new String[]{task.getTaskId()};
}
updateTaskPath(task.getTaskId(), path);
@@ -373,18 +374,19 @@
task.setDescription(rs.getString("description"));
Object[] obj = (Object[]) rs.getObject("tags");
- String[] tag = new String[obj.length];
- log.warn(ArrayUtils.toString(obj));
- int cpt = 0;
+ if(obj != null) {
+ String[] tag = new String[obj.length];
- for(Object s :obj){
- tag[cpt] = (String)s;
- cpt++;
+ int cpt = 0;
+ for (Object s : obj) {
+ tag[cpt] = (String) s;
+ cpt++;
+ }
+
+ task.setTags(tag);
}
- task.setTags(tag);
-
task.setTodayTime(0);
task.setCreationDate(new java.util.Date((rs.getTimestamp("creationDate").getTime())));
task.setModificationDate(new java.util.Date(rs.getTimestamp("modificationDate").getTime()));
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ImportResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ImportResource.java 2014-08-20 08:19:42 UTC (rev 3029)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ImportResource.java 2014-08-21 15:57:32 UTC (rev 3030)
@@ -1,11 +1,15 @@
package org.chorem.jtimer.web;
+import com.google.gson.Gson;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.io.DataHandler;
+import org.restlet.data.MediaType;
import org.restlet.representation.Representation;
+import org.restlet.representation.StringRepresentation;
import org.restlet.resource.Post;
+import java.io.File;
import java.io.IOException;
/**
@@ -24,13 +28,32 @@
* suite d'une requête de type POST
*/
@Post("json")
- public void importTasks(Representation representation) throws IOException {
+ public Representation importTasks(Representation representation) throws IOException {
+ //Le message a retourner
+ String json = "No available path.";
+
if(representation.isAvailable()) {
- DataHandler g = new DataHandler(storage);
- g.migrateData();
- //g.migrateData(representation.getText());
+
+ //Le path du fichier
+ Gson gson = new Gson();
+ String path = gson.fromJson(representation.getText(), String.class);
+
+ File file = new File(path);
+
+ if(file.exists()){
+ DataHandler g = new DataHandler(storage);
+
+ g.migrateData(path);
+
+ json = "{\"message\" : \"Ok\"}";
+
+ }else{
+ json = "{\"message\" : \"The file doesn't exist\"}";
+ }
}
+
+ return new StringRepresentation(json, MediaType.APPLICATION_JSON);
}
}
Modified: branches/ng-jtimer/src/main/resources/jtimer-default.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-08-20 08:19:42 UTC (rev 3029)
+++ branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-08-21 15:57:32 UTC (rev 3030)
@@ -2,7 +2,7 @@
# jTimer default properties
###
# jTimer storage path
-jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/BDDtag
+jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/BDDtag3
###
# SQL properties
###
Modified: branches/ng-jtimer/src/main/webapp/css/app.css
===================================================================
--- branches/ng-jtimer/src/main/webapp/css/app.css 2014-08-20 08:19:42 UTC (rev 3029)
+++ branches/ng-jtimer/src/main/webapp/css/app.css 2014-08-21 15:57:32 UTC (rev 3030)
@@ -417,4 +417,8 @@
.borderedbottom{
border-bottom : 1px solid #E8E8E8;
+}
+
+.glyphSizeSmall{
+ font-size:10px;
}
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/webapp/js/app.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/app.js 2014-08-20 08:19:42 UTC (rev 3029)
+++ branches/ng-jtimer/src/main/webapp/js/app.js 2014-08-21 15:57:32 UTC (rev 3030)
@@ -22,7 +22,7 @@
* @param {ngFilter} $filter permet de filtrer les elements de l'arbre a afficher (filtre, tri, ...)
* @param {ngParse} $parse permet de parser des expressions qui doivent etre evaluer regulierement sur une scope
*/
-var wtTreeRepeatDirective = ['$animate', '$filter', '$parse', function($animate, $filter, $parse) {
+var wtTreeRepeatDirective = ['$animate', '$filter', '$parse','settings', function($animate, $filter, $parse, settings) {
return {
transclude: 'element',
priority: 1000,
@@ -108,8 +108,8 @@
// new item which we don't know about
var childScope = cacheEntry.scope;
-
- if (node.children.length === 0) {
+
+ if (node.children.length === 0 || (node.hasAllChildHidden(true) && !settings.showHidden)) {
state = 'empty';
} else {
if (node.$$open || forceOpen($scope)) {
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-20 08:19:42 UTC (rev 3029)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-21 15:57:32 UTC (rev 3030)
@@ -12,9 +12,9 @@
$scope.taskAccess = $scope.todo.lastTaskAccess;
$scope.timeAccess = $scope.todo.lastTimeAccess;
- //interval de conec
- var interval = 60000; //TODO: obruce 05-05-14 decider d'un intervalle interessant
- // periode de delais = 3 periode +1msec
+ //{int} interval de conec
+ var interval = 5 * 60000;
+ // {int} delais pour avoir acces au modifications sur plusieurs inter
var delayAccess = interval + 1;
@@ -28,6 +28,7 @@
$scope.selectedTask = null;
// {Task} la tache en cours de timing
$scope.currentTask = null;
+ $scope.currentTime = null;
// {Date in millis} le temps pour la tache en cours de timing
$scope.currentTaskDate = null;
@@ -126,16 +127,30 @@
} else if (e.keyCode === 73 && e.ctrlKey && e.shiftKey) {
// increment by 30min
taskTime.addTime(30*60*1000);
+ update();
} else if (e.keyCode === 68 && e.ctrlKey && e.shiftKey) {
// decrement by 30min
taskTime.addTime(-30*60*1000);
+ update();
} else if (e.keyCode === 73 && e.ctrlKey) {
// increment by 5min
taskTime.addTime(5*60*1000);
+ update();
} else if (e.keyCode === 68 && e.ctrlKey) {
// decrement by 5min
taskTime.addTime(-5*60*1000);
+ update();
}
+ var update = function(){
+ serverTimeAccess.update({taskId: $scope.selectedTask.taskId,dispatch:true}, angular.toJson(taskTime),
+ function(){
+ console.log("update time success" );
+ },
+ function(){
+ console.log("fail");
+ $scope.todo.stockedEditedTimes[$scope.selectedTask.taskId].push(taskTime);
+ });
+ };
}
};
@@ -182,6 +197,22 @@
var now = Date.now();
var taskTime = $scope.getRecentTaskTime($scope.currentTask);
taskTime.addTime(now - $scope.currentTaskDate);
+
+ // toutes les 5 minutes on update la periode en cours
+ if((parseInt(taskTime.time/ 1000) % (5 *60)) == 0){
+
+ var prom = serverTimeAccess.update({taskId: taskTime.taskId,dispatch:true}, angular.toJson(taskTime)).$promise;
+
+ prom.then(function(){
+ console.log("update time success" +$scope.currentTask.name);
+ },
+ function(){
+ console.log("fail");
+ $scope.todo.stockedEditedTimes[$scope.currentTask.taskId].push(taskTime);
+ }
+ );
+ }
+
$scope.currentTaskDate = now;
save();
}
@@ -359,22 +390,28 @@
var editedTime = getTimeInArrayWithId($scope.data.times[item.taskId],item.timeId);
+ //Si la periode existe
if(editedTime){
- if(item.removed == 0){
- console.log("Temps existe donc remplacé");
- //Le temps existe
- editedTime.time = item.time;
- editedTime.creationDate = item.creationDate;
- //TODO obruce 2/6/14 verfication chevauchement temps
+ if(!($scope.currentTime && item.timeId == $scope.currentTime.timeId)){
- save();
- }else{
- //TODO supprimer si existant mais removed
- suppressObjectInArrayWithId($scope.data.times[item.taskId],item.timeId);
+ //si la tache n'a pas ete supprime
+ if(item.removed == 0){
+ console.log("Temps existe donc remplacé");
+ //Le temps existe
+ editedTime.time = item.time;
+ editedTime.creationDate = item.creationDate;
+
+ //TODO obruce 2/6/14 verfication chevauchement temps
+
+ save();
+ }else{
+ suppressObjectInArrayWithId($scope.data.times[item.taskId],item.timeId);
+ }
}
- }else if(item.removed == 0){
+ //Elle n'existe pas et n'est pas supprimee
+ }else if(item.removed == 0 ){
console.log("le temps n'existe pas");
//init de l'array des temps de la tache
if(!$scope.data.times[item.taskId]){$scope.data.times[item.taskId] = []}
@@ -396,33 +433,7 @@
}
- /**
- * Methode qui recupere les temps pour une tache
- */
- var getTimesFromServerWithTask = function(task){
- serverTimeAccess.query({taskId : task.taskId, date : $scope.timeAccess}, function (response) {
-
- angular.forEach(response, function (item) {
-
- if(!$scope.data.times[task.taskId]){$scope.data.times[task.taskId] = []}
-
- if(!(existInObject($scope.data.times,item.timeId,task.taskId)) && !(existInObject($scope.todo.stockedDeletedTimes, item.timeId, task.taskId)) && !item.isremoved){
- //On cree le tasktime
- taskTime = new TaskTime(task, item.timeId, item.creationDate, item.time);
- $scope.data.times[task.taskId].push(taskTime);
- save();
- //TODO obruce 2/6/14 verfication chevauchement temps
- }
- });
- //On change la date de dernier acces
- $scope.timeAccess = new Date().getTime();
- $scope.todo.lastTimeAccess= $scope.timeAccess;
- save();
- });
- }
-
-
//Recuperer un element dans un array avec son id
var getTimeInArrayWithId= function(array, id){
var res;
@@ -492,7 +503,7 @@
if(getAlarmInArrayWithId(task.alarms, item.alarmId) == undefined && !item.removed){
//On cree le taskalarm
- taskAlarm = new TaskAlarm(task, item.alarmId, item.name, item.type, item.modificationDate); //TODO
+ taskAlarm = new TaskAlarm(task, item.alarmId, item.name, item.type, item.modificationDate);
task.alarms.push(taskAlarm);
save();
}
@@ -637,7 +648,7 @@
*/
$scope.addSubTask = function(node) {
var task = node.task;
- var newTask = new Task("New task", undefined,task.taskId, task.tags);
+ var newTask = new Task("New task", undefined,task.taskId);
$scope.data.tasks[newTask.taskId] = newTask;
//On synchronise la tache creer
@@ -861,6 +872,7 @@
* @returns {nodes}
*/
$scope.getRecentTaskTime = function(task) {
+ //On recupere les temps
var times = $scope.data.times[task.taskId];
if (!times) {
@@ -868,9 +880,11 @@
$scope.data.times[task.taskId]= times;
}
+ // Le temps max pour la journee
var maxDate = new Date(0,0,0,0,0).getTime();
var result;
+ //Pour chaque on recupere celui qui a la date la plus haute pour la journee
angular.forEach(times, function (t) {
if (t.isToday() ) {
if(maxDate < t.creationDate){
@@ -885,6 +899,7 @@
times.push(result);
}
+
return result;
};
@@ -930,19 +945,18 @@
var taskTime = $scope.getRecentTaskTime($scope.currentTask);
taskTime.addTime(now - $scope.currentTaskDate);
- //On pousse la tache
- serverTimeAccess.create({taskId: task.taskId,dispatch:true} , angular.toJson(taskTime),
+ serverTimeAccess.update({taskId: task.taskId,dispatch:true}, angular.toJson(taskTime),
function(){
- console.log("persist time success" + task);
+ console.log("update time success" );
},
function(){
console.log("fail");
- if(!$scope.todo.stockedNewTimes[task.taskId]){$scope.todo.stockedNewTimes[task.taskId]=[];}
- $scope.todo.stockedNewTimes[task.taskId].push(taskTime);
+ $scope.todo.stockedEditedTimes[task.taskId].push(taskTime);
}
);
}
- //si ce n'est la la tache courante actuel
+
+ //si ce n'est pas la la tache courante actuel
if ($scope.currentTask !== task) {
//On ajoute un nouveau timeTask dans la liste des times
@@ -953,8 +967,21 @@
//On change la task courante
$scope.currentTask = task;
+ $scope.currentTime = temp;
$scope.currentTaskDate = now;
+
+ serverTimeAccess.create({taskId: task.taskId,dispatch:true} , angular.toJson(temp),
+ function(){
+ console.log("persist time success" + task);
+ },
+ function(){
+ console.log("fail");
+ if(!$scope.todo.stockedNewTimes[task.taskId]){$scope.todo.stockedNewTimes[task.taskId]=[];}
+ $scope.todo.stockedNewTimes[task.taskId].push(temp);
+ }
+ );
+
//A voir pour mettre enlever quelques secondes en trop
checkAlarms(0);
@@ -976,6 +1003,7 @@
$scope.currentTask = null;
+ $scope.currentTime = null;
$scope.currentTaskDate = null;
}
@@ -1598,7 +1626,7 @@
// On parcours les data pour maj
angular.forEach(child.children, function(childnode){recurseGenerateChildReport(childnode, parentHasTag)});
- if( parentHasTag && child.task.isReported){
+ if( parentHasTag && child.task.isReported ){
toReportTask.push(child.task.taskId);
}
}
@@ -1932,13 +1960,12 @@
serverTimeAccess.update({taskId: task.taskId,dispatch:true} , angular.toJson($scope.selectedItem),
function(){
- console.log("update time success" + task);
-
+ console.log("update time success" + task.taskId);
},
function(){
console.log("fail");
+ $scope.todo.stockedEditedTimes[$scope.selectedTask.taskId].push(taskTime);
});
-
}
/**
@@ -2041,9 +2068,13 @@
$scope.import = function(path){
if(path){
- importService.import({}, angular.toJson($scope.path));
+ var prom = importService.import({}, angular.toJson($scope.path)).$promise;
- $scope.done = true;
+ prom.then(function(data){
+ $scope.response = data;
+ });
+
+ // $scope.done = true;
}
};
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-08-20 08:19:42 UTC (rev 3029)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-08-21 15:57:32 UTC (rev 3030)
@@ -258,6 +258,20 @@
this.children = children || [];
};
+TreeNode.prototype.hasAllChildHidden = function(f){
+ var bool = true;
+
+ if(!f){
+ bool = this.task.hidden;
+ };
+
+ angular.forEach(this.children , function(child){
+ bool = bool && child.hasAllChildHidden(false);
+ });
+
+ return bool;
+};
+
/**
* Methode qui fait un parcours reccursif de l'arbre et recupere l'element voulu
*/
Modified: branches/ng-jtimer/src/main/webapp/partials/reportModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-08-20 08:19:42 UTC (rev 3029)
+++ branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-08-21 15:57:32 UTC (rev 3030)
@@ -101,9 +101,9 @@
<span class="spacer level{{$level}}"></span>
<!--Task state icon-->
- <i class="glyphicon glyphicon-ban-circle" ng-show="$state=='empty'"></i>
- <i class="glyphicon glyphicon-plus-sign" ng-click="$toggleState()" ng-show="$state=='close'"></i>
- <i class="glyphicon glyphicon-minus-sign" ng-click="$toggleState()" ng-show="$state=='open'"></i>
+ <i style="font-size:10px" class="glyphicon glyphicon-ban-circle glyphSizeSmall" ng-show="$state=='empty'"></i>
+ <i style="font-size:10px" class="glyphicon glyphicon-chevron-right glyphSizeSmall" ng-click="$toggleState()" ng-show="$state=='close'"></i>
+ <i style="font-size:10px" class="glyphicon glyphicon-chevron-down glyphSizeSmall" ng-click="$toggleState()" ng-show="$state=='open'"></i>
<!--Project name-->
<input type="checkbox" ng-model="$node.task.isReported" ng-change="setChildrenCheckbox($node)">
@@ -123,6 +123,8 @@
</div>
+ <!-- Affichage du résultat -->
+
<div style="display : inline-block; vertical-align: top; width : 350px">
<alert type="info" >
@@ -143,15 +145,18 @@
<br/>
</div>
- <div class="tr" ng-show="taskData[$node.task.taskId].selftime || hasSelfOrChildTime(taskData,$node,false) || ($node.task.isRoot() && getTotalProjectTime($node,0) != 0 )">
+ <div class="tr" ng-show="taskData[$node.task.taskId].selftime
+ || hasSelfOrChildTime(taskData,$node,false)
+ || ($node.task.isRoot() && getTotalProjectTime($node,0) != 0 )">
<div class="td" >
<span class="spacer level{{$level}}"></span>
<b ng-if="$node.task.isRoot()">Projet : {{$node.task.name}}</b>
- <span ng-if="!$node.task.isRoot()">{{$node.task.name}} </span>
+ <span ng-if="!$node.task.isRoot() && !$node.task.hidden">{{$node.task.name}} </span>
+ <span ng-if="!$node.task.isRoot() && ($node.task.hidden && modal.showHidden)">**{{$node.task.name}}** </span>
</div >
- <div class="td" ng-show="!$node.task.isRoot() && taskData[$node.task.taskId].selftime && modal.showTime" >
+ <div class="td" ng-show="!$node.task.isRoot() && taskData[$node.task.taskId].selftime && modal.showTime && ($node.task.hidden && modal.showHidden)" >
<span class="spacer level{{$level}}"></span>
<span>{{taskData[$node.task.taskId].selftime |time }} </span>
@@ -193,6 +198,7 @@
<b>Total : {{getTotalPeriodTime($node,0,period) |time }} </b>
</div>
+ <!-- not root task -->
<div class="td" ng-if="!$node.task.isRoot()" >
<span class="spacer level{{$level}}"></span>
<span>{{$node.task.name}} </span>
Modified: branches/ng-jtimer/src/main/webapp/partials/settings.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/settings.html 2014-08-20 08:19:42 UTC (rev 3029)
+++ branches/ng-jtimer/src/main/webapp/partials/settings.html 2014-08-21 15:57:32 UTC (rev 3030)
@@ -28,8 +28,8 @@
<input ng-if="path" type="submit" id="submit" value="Submit" />
</p>
</form>
-<div ng-click="edit()" ng-show="done">
- {{path}}
+<div ng-click="edit()" ng-show="!done">
+ {{path}} - {{response.message}}
</div>
<!-- Footer -->
Modified: branches/ng-jtimer/src/main/webapp/partials/tasks.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-08-20 08:19:42 UTC (rev 3029)
+++ branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-08-21 15:57:32 UTC (rev 3030)
@@ -12,9 +12,9 @@
<span class="right">
<i class="glyphicon glyphicon-stop color_red" ng-show="currentTask" ng-click="timeTask(currentTask)">Stop </i>
<i popover-placement="left" popover="Report " popover-trigger="mouseenter"
- class="glyphicon glyphicon-cog" ng-click="reportPopup()"></i>
+ class="glyphicon glyphicon-list-alt" ng-click="reportPopup()"></i>
<a popover-placement="left" popover="Settings" popover-trigger="mouseenter" href="#/settings"
- class="glyphicon glyphicon-list-alt" ></a>
+ class="glyphicon glyphicon-cog" ></a>
<i class="glyphicon glyphicon-cloud" ng-class="{online: online, offline: !online}"></i>
</span>
</div>
@@ -66,9 +66,9 @@
<!--Task state icon-->
<span >
- <i style="font-size:10px" class="glyphicon glyphicon-ban-circle" ng-show="$state=='empty'"></i>
- <i style="font-size:10px" class="glyphicon glyphicon-chevron-right" ng-click="$toggleState()" ng-show="$state=='close'"></i>
- <i style="font-size:10px" class="glyphicon glyphicon-chevron-down" ng-click="$toggleState()" ng-show="$state=='open'"></i>
+ <i class="glyphicon glyphicon-ban-circle glyphSizeSmall" ng-show="$state=='empty'"></i>
+ <i class="glyphicon glyphicon-chevron-right glyphSizeSmall" ng-click="$toggleState()" ng-show="$state=='close'"></i>
+ <i class="glyphicon glyphicon-chevron-down glyphSizeSmall" ng-click="$toggleState()" ng-show="$state=='open'"></i>
<img src="partials/loading_timer.gif" height="20" width="20" ng-show=" (hasActivSon($node) && $state=='close') || currentTask == $node.task">
</span>
1
0
r3029 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/config java/org/chorem/jtimer/storage java/org/chorem/jtimer/web resources webapp/js webapp/partials
by obruce@users.chorem.org 20 Aug '14
by obruce@users.chorem.org 20 Aug '14
20 Aug '14
Author: obruce
Date: 2014-08-20 10:19:42 +0200 (Wed, 20 Aug 2014)
New Revision: 3029
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3029
Log:
Rapport correction de la recherche avec tag et du get avec tag
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ReportResource.java
branches/ng-jtimer/src/main/resources/jtimer-default.properties
branches/ng-jtimer/src/main/webapp/js/controllers.js
branches/ng-jtimer/src/main/webapp/js/entities.js
branches/ng-jtimer/src/main/webapp/partials/reportModal.html
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java 2014-08-14 14:43:54 UTC (rev 3028)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java 2014-08-20 08:19:42 UTC (rev 3029)
@@ -167,26 +167,6 @@
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_BYDAY.getKey());
}
- public String getStorageQuerySelectReportByProjectAndTags(){
- return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_BYPROJECTANDTAG.getKey());
- }
-
- public String getStorageQuerySelectReportByYearAndTags(){
- return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_BYYEARANDTAG.getKey());
- }
-
- public String getStorageQuerySelectReportByMonthAndTags(){
- return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_BYMONTHANDTAG.getKey());
- }
-
- public String getStorageQuerySelectReportByWeekAndTags(){
- return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_BYWEEKANDTAG.getKey());
- }
-
- public String getStorageQuerySelectReportByDayAndTags(){
- return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_BYDAYANDTAG.getKey());
- }
-
public String getStorageQuerySelectAlarmOnDate(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_ALARM_ONDATE.getKey());
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java 2014-08-14 14:43:54 UTC (rev 3028)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java 2014-08-20 08:19:42 UTC (rev 3029)
@@ -184,36 +184,6 @@
"",
String.class
),
- JTIMER_STORAGE_SELECT_REPORT_BYPROJECTANDTAG(
- "jtimer.storage.select.report.byProjectAndTag",
- "requête de selection des taches minutées entre deux bornes filtrer par projet",
- "",
- String.class
- ),
- JTIMER_STORAGE_SELECT_REPORT_BYYEARANDTAG(
- "jtimer.storage.select.report.byYearAndTag",
- "requête de selection des taches minutées entre deux bornes filtrer par year",
- "",
- String.class
- ),
- JTIMER_STORAGE_SELECT_REPORT_BYMONTHANDTAG(
- "jtimer.storage.select.report.byMonthAndTag",
- "requête de selection des taches minutées entre deux bornes filtrer par month",
- "",
- String.class
- ),
- JTIMER_STORAGE_SELECT_REPORT_BYWEEKANDTAG(
- "jtimer.storage.select.report.byWeekAndTag",
- "requête de selection des taches minutées entre deux bornes filtrer par semaine",
- "",
- String.class
- ),
- JTIMER_STORAGE_SELECT_REPORT_BYDAYANDTAG(
- "jtimer.storage.select.report.byDayAndTag",
- "requête de selection des taches minutées entre deux bornes filtrer par jour",
- "",
- String.class
- ),
JTIMER_STORAGE_SELECT_ALARM_ONDATE(
"jtimer.storage.select.alarm.ondate",
"requête de selection des alarmes ",
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-08-14 14:43:54 UTC (rev 3028)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-08-20 08:19:42 UTC (rev 3029)
@@ -17,7 +17,6 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -232,8 +231,15 @@
try {
rs.first();
- String[] parentArray = (String[]) rs.getObject("path");
- path = Arrays.copyOf(parentArray, parentArray.length + 1);
+ Object[] parentArray = (Object[]) rs.getObject("path");
+ path = new String[parentArray.length + 1];
+
+ int cpt = 0;
+ for(Object s : parentArray){
+ parentArray[cpt] = s;
+ cpt++;
+ }
+
path[parentArray.length] = task.getTaskId();
}catch(JdbcSQLException eee){
@@ -365,6 +371,20 @@
task.setParent(rs.getString("parent"));
task.setRemoved(rs.getLong("removed"));
task.setDescription(rs.getString("description"));
+
+ Object[] obj = (Object[]) rs.getObject("tags");
+ String[] tag = new String[obj.length];
+
+ log.warn(ArrayUtils.toString(obj));
+ int cpt = 0;
+
+ for(Object s :obj){
+ tag[cpt] = (String)s;
+ cpt++;
+ }
+
+ task.setTags(tag);
+
task.setTodayTime(0);
task.setCreationDate(new java.util.Date((rs.getTimestamp("creationDate").getTime())));
task.setModificationDate(new java.util.Date(rs.getTimestamp("modificationDate").getTime()));
@@ -549,48 +569,6 @@
}
/**
- * Methode qui retourne les taches minutees entre deux bornes par projet
- * @param startDate la borne inferieur
- * @param endDate la borne superieur
- * @return un hashmap {key: Id, value: task}
- */
- public HashMap<String, ReportTask> getReportByProjectAndTags(Long startDate, Long endDate, String[] toReport, String[] wantedTags){
-
- HashMap<String, ReportTask> map = new HashMap<>();
-
- PreparedStatement statement = null;
-
- try{
- statement = getConnection().prepareStatement(config.getStorageQuerySelectReportByProjectAndTags());
-
- statement.setObject(1, new Date(startDate));
- statement.setObject(2, new Date(endDate));
- statement.setObject(3, toReport);
- statement.setObject(4, wantedTags);
-
- ResultSet rs = statement.executeQuery();
- while(rs.next()) {
-
- String name = rs.getString("name");
- String taskId = rs.getString("taskId");
- long totalDuration = rs.getLong("totalduration");
-
- ReportTask task = new ReportTask(name,taskId,totalDuration);
-
- map.put(taskId, task);
- }
-
- }catch(SQLException ex) {
- throw new StorageException("Can't get report", ex);
- } finally {
- closeStatement(statement);
- }
-
-
- return map;
- }
-
- /**
* Method that returns the collection of timed tasks for a time interval grouped by period
* @param startDate the start date
* @param endDate the end date
@@ -655,74 +633,6 @@
return res;
}
- /**
- * Method that returns the collection of timed tasks for a time interval grouped by period
- * @param startDate the start date
- * @param endDate the end date
- * @param toReport task to be reported
- * @return the collection of timed tasks
- */
- public HashMap<String,Set<ReportTask>> getReportByPeriodAndTags(Long startDate, Long endDate, String[] toReport,String[] tags, String type){
-
- HashMap<String,Set<ReportTask>> res = new HashMap<>();
- PreparedStatement statement = null;
-
- try{
- if("Year".equals(type)){
- statement = getConnection().prepareStatement(config.getStorageQuerySelectReportByYearAndTags());
- }else if("Month".equals(type)){
- statement = getConnection().prepareStatement(config.getStorageQuerySelectReportByMonthAndTags());
- }else if("Week".equals(type)){
- String sql = config.getStorageQuerySelectReportByWeekAndTags();
- statement = getConnection().prepareStatement(sql);
- }else{
- statement = getConnection().prepareStatement(config.getStorageQuerySelectReportByDayAndTags());
- }
-
- // les bornes
- statement.setObject(1, new Date(startDate));
- statement.setObject(2, new Date(endDate));
- statement.setObject(3, toReport);
- statement.setObject(4, tags);
-
- ResultSet rs = statement.executeQuery();
- while(rs.next()) {
- String period;
- if("Year".equals(type)){
- period = rs.getString("year");
- }else if("Month".equals(type)){
- period = rs.getString("month") +" - "+ rs.getString("year");
- }else if("Week".equals(type)){
- period = rs.getString("week") +" - "+ rs.getString("year");
- }else {
- period = rs.getString("day") + " - " + rs.getString("month") + " - " + rs.getString("year");
- }
-
- //Si le Year n'est pas présent
- if(res.get(period)==null) {
- res.put(period, new HashSet<ReportTask>());
- }
-
- String name = rs.getString("name");
- String taskId = rs.getString("taskId");
- long totalDuration = rs.getLong("totalduration");
-
- ReportTask task = new ReportTask(name,taskId,totalDuration);
-
- //On ajoute le resultat: year, set de reportTask
- res.get(period).add(task);
- }
-
- }catch(SQLException ex) {
- throw new StorageException("Can't get report", ex);
- } finally {
- closeStatement(statement);
- }
-
- return res;
- }
-
-
/** Update */
/**
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ReportResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ReportResource.java 2014-08-14 14:43:54 UTC (rev 3028)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ReportResource.java 2014-08-20 08:19:42 UTC (rev 3029)
@@ -2,6 +2,7 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.storage.Storage;
@@ -12,9 +13,7 @@
import org.restlet.resource.ResourceException;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
/**
* Created by olivia on 11/06/14.
@@ -43,20 +42,17 @@
@Post("json")
public Representation getReport(Representation representation) throws IOException {
// Les elements voulus par l'interface
- String[][] tmp;
String[] toReport;
- String[] wantedTags;
//On recupere les elements
String repr1 = representation.getText();
Gson gson = new Gson();
- tmp = gson.fromJson(repr1, String[][].class);
//On extrait les elements voulus
- toReport = tmp[0];
- wantedTags = tmp[1];
+ toReport = gson.fromJson(repr1, String[].class);
+ log.warn("les wanted " +ArrayUtils.toString(toReport));
- String json="[No data]";
+ String json="[]";
String type ="";
long startDate;
long endDate;
@@ -86,56 +82,20 @@
//On ne recupere que les elements interessants
gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
- if(wantedTags.length == 0) {
- if (type.equals("Project")) {
+ if (type.equals("Project")) {
- HashMap<String, ReportTask> storedTask = storage.getReportByProject(startDate, endDate, toReport);
- json = gson.toJson(storedTask, HashMap.class);
+ HashMap<String, ReportTask> storedTask = storage.getReportByProject(startDate, endDate, toReport);
+ json = gson.toJson(storedTask, HashMap.class);
- } else {
+ } else {
- HashMap storedTask = storage.getReportByPeriod(startDate, endDate, toReport, type);
- json = gson.toJson(storedTask, HashMap.class);
+ HashMap storedTask = storage.getReportByPeriod(startDate, endDate, toReport, type);
+ json = gson.toJson(storedTask, HashMap.class);
- }
- }else{
-
- if (type.equals("Project")) {
-
- HashMap<String, ReportTask> storedTask = storage.getReportByProjectAndTags(startDate, endDate, toReport, wantedTags);
- json = gson.toJson(storedTask, HashMap.class);
-
- } else {
-
- HashMap storedTask = storage.getReportByPeriodAndTags(startDate, endDate, toReport, wantedTags, type);
- json = gson.toJson(storedTask, HashMap.class);
-
- }
}
+ log.warn("ce qui ressort" +json);
return new StringRepresentation(json);
}
-
-
- /**
- * Methode qui détermine si l'id est dans la collection
- * @param id l'identifiant a trouver
- * @param list la list a parcourir
- * @return un booleen de presence
- */
- private boolean idIsInArray(String id,ArrayList<String> list){
- boolean res = false;
-
- Iterator iter = list.iterator();
- while(iter.hasNext()) {
- if (id.equals(iter.next())) {
- res = true;
- iter.remove();
- break;
- }
- }
-
- return res;
- }
}
Modified: branches/ng-jtimer/src/main/resources/jtimer-default.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-08-14 14:43:54 UTC (rev 3028)
+++ branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-08-20 08:19:42 UTC (rev 3029)
@@ -2,7 +2,7 @@
# jTimer default properties
###
# jTimer storage path
-jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/BDD2
+jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/BDDtag
###
# SQL properties
###
@@ -143,50 +143,6 @@
AND ARRAY_CONTAINS(?, TA.taskid) \
AND TA.removed = 0 \
GROUP BY TA.taskId , day, month, year
-jtimer.storage.select.report.byProjectAndTag=SELECT TA.*, sum(TI.duration) AS totalduration \
- FROM task TA, tasktime TI \
- WHERE TA.taskId = TI.taskid \
- AND TI.creationDate BETWEEN ? AND ? \
- AND ARRAY_CONTAINS(?, TA.taskid) \
- AND ARRAY_CONTAINS_ONE(TA.tags, ?) \
- AND TA.removed = 0 \
- GROUP BY TA.taskId
-jtimer.storage.select.report.byYearAndTag=SELECT YEAR(TI.creationDate) as year, TA.*, sum(TI.duration) AS totalduration \
- FROM task TA, tasktime TI \
- WHERE TA.taskId = TI.taskid \
- AND TI.creationDate BETWEEN ? AND ? \
- AND ARRAY_CONTAINS(TA.path, TA.taskid) \
- AND ARRAY_CONTAINS(?, TA.taskid) \
- AND ARRAY_CONTAINS_ONE(TA.tags, ?) \
- AND TA.removed = 0 \
- GROUP BY TA.taskId , year
-jtimer.storage.select.report.byMonthAndTag=SELECT MONTH(TI.creationDate) as month, YEAR(TI.creationDate) as year, TA.*, sum(TI.duration) AS totalduration \
- FROM task TA, tasktime TI \
- WHERE TA.taskId = TI.taskid \
- AND TI.creationDate BETWEEN ? AND ? \
- AND ARRAY_CONTAINS(TA.path, TA.taskid) \
- AND ARRAY_CONTAINS(?, TA.taskid) \
- AND ARRAY_CONTAINS_ONE(TA.tags, ?) \
- AND TA.removed = 0 \
- GROUP BY TA.taskId , month, year
-jtimer.storage.select.report.byWeekAndTag=SELECT WEEK(TI.creationDate) as week,YEAR(TI.creationDate) as year, TA.*, sum(TI.duration) AS totalduration \
- FROM task TA, tasktime TI \
- WHERE TA.taskId = TI.taskid \
- AND TI.creationDate BETWEEN ? AND ? \
- AND ARRAY_CONTAINS(TA.path, TA.taskid) \
- AND ARRAY_CONTAINS(?, TA.taskid) \
- AND ARRAY_CONTAINS_ONE(?, TA.tags) \
- AND TA.removed = 0 \
- GROUP BY TA.taskId , week, year
-jtimer.storage.select.report.byDayAndTag=SELECT EXTRACT(DAY FROM TI.creationDate) as day,MONTH(TI.creationDate) as month,YEAR(TI.creationDate) as year, TA.*, sum(TI.duration) AS totalduration \
- FROM task TA, tasktime TI \
- WHERE TA.taskId = TI.taskid \
- AND TI.creationDate BETWEEN ? AND ? \
- AND ARRAY_CONTAINS(TA.path, TA.taskid) \
- AND ARRAY_CONTAINS(?, TA.taskid) \
- AND ARRAY_CONTAINS_ONE(TA.tags, ?) \
- AND TA.removed = 0 \
- GROUP BY TA.taskId , day, month, year
jtimer.storage.select.alarm.ondate= SELECT * \
FROM taskalarm \
WHERE modificationDate > ?
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-14 14:43:54 UTC (rev 3028)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-20 08:19:42 UTC (rev 3029)
@@ -1540,6 +1540,7 @@
/**
* Method that return if the task has time or his subtasks
+ @return {bool}
*/
$scope.hasSelfOrChildTime= function(collection, node, bool){
@@ -1558,22 +1559,9 @@
return bool;
};
- $scope.hasTags = function(node, array){
- var bool = true;
-
- if(array){
-
- for (var i = 0, len = node.task.tags.length; i < len; i++) {
- if (!node.task.tags[i] in array) {
- bool = false
- break;
- }
- }
- }
-
- return bool;
- }
-
+ /**
+ * Fonction qui va supprimer les tags si on decoche
+ */
$scope.removeTags = function(){
$scope.tag.array = [];
$scope.generateReport();
@@ -1603,19 +1591,22 @@
/**
* Methode qui va reccursivement verifier les taches à repporter
*/
- var recurseGenerateChildReport = function(child){
+ var recurseGenerateChildReport = function(child, parentHasTag){
+ parentHasTag = parentHasTag || child.task.hasOneTag($scope.tag.array);
+
// On parcours les data pour maj
- angular.forEach(child.children, function(childnode){recurseGenerateChildReport(childnode)});
- if(child.task.isReported){
+ angular.forEach(child.children, function(childnode){recurseGenerateChildReport(childnode, parentHasTag)});
+
+ if( parentHasTag && child.task.isReported){
toReportTask.push(child.task.taskId);
}
}
- angular.forEach(tree.children, function(child){recurseGenerateChildReport(child)});
+ angular.forEach(tree.children, function(child){recurseGenerateChildReport(child,false)});
$http({method: "POST", url: "/rest/report",
- params:{start_Date : deb, end_Date : end, type : $scope.modal.radioModel}, data : angular.toJson([toReportTask, $scope.tag.array])})
+ params:{start_Date : deb, end_Date : end, type : $scope.modal.radioModel}, data : angular.toJson(toReportTask)})
.success(function(data){
if($scope.modal.radioModel=='Project'){
@@ -1892,9 +1883,6 @@
//on cree le temps
var res = new TaskTime(task,undefined,$scope.dateobj.date.getTime(),time);
- console.log("Nouveau temps ");
- console.log(res);
- console.log($scope.dateobj.date);
res["modificationDate"]=Date.now();
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-08-14 14:43:54 UTC (rev 3028)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-08-20 08:19:42 UTC (rev 3029)
@@ -425,7 +425,12 @@
this.isReported = true;
this.hidden = false;
this.alarms=[];
- this.tags = parentTags;
+ if(parentTags){
+ this.tags = parentTags;
+ }else{
+ this.tags = [];
+ }
+
this.syncOptions = {};
};
@@ -481,6 +486,32 @@
};
/**
+ * Indique si la tache contient un tag
+ * @return {boolean}
+ */
+Task.prototype.hasOneTag = function(array){
+
+ var bool = false;
+
+ if(array.length > 0){
+
+ for (var i = 0, len = this.tags.length; i < len; i++) {
+
+ for (var j = 0, len2 = array.length; j < len2; j++) {
+ if (this.tags[i] == array[j]) {
+ bool = true
+ }
+ }
+ }
+ }else{
+ bool = true;
+ }
+
+
+ return bool;
+};
+
+/**
* Permet de conserve une temps cree localement
* @param {Task} task
* @returns {TaskTime}
Modified: branches/ng-jtimer/src/main/webapp/partials/reportModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-08-14 14:43:54 UTC (rev 3028)
+++ branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-08-20 08:19:42 UTC (rev 3029)
@@ -211,7 +211,7 @@
</div>
</div>
</span >
- <span ng-if="!periodTaskData">
+ <span ng-if="periodTaskData== {}">
No timed task.
</span>
</alert>
1
0
r3028 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/io java/org/chorem/jtimer/storage java/org/chorem/jtimer/web resources webapp/js webapp/partials
by obruce@users.chorem.org 14 Aug '14
by obruce@users.chorem.org 14 Aug '14
14 Aug '14
Author: obruce
Date: 2014-08-14 16:43:54 +0200 (Thu, 14 Aug 2014)
New Revision: 3028
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3028
Log:
Ajout d'une page de settings et de l'import partiel ?\195?\160 l'ui
Changement des alertes
Added:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ImportResource.java
branches/ng-jtimer/src/main/webapp/partials/settings.html
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/DataHandler.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java
branches/ng-jtimer/src/main/resources/jtimer-default.properties
branches/ng-jtimer/src/main/webapp/js/app.js
branches/ng-jtimer/src/main/webapp/js/controllers.js
branches/ng-jtimer/src/main/webapp/js/entities.js
branches/ng-jtimer/src/main/webapp/js/service.js
branches/ng-jtimer/src/main/webapp/partials/alertModal.html
branches/ng-jtimer/src/main/webapp/partials/tasks.html
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/DataHandler.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/DataHandler.java 2014-08-08 15:02:24 UTC (rev 3027)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/DataHandler.java 2014-08-14 14:43:54 UTC (rev 3028)
@@ -46,6 +46,17 @@
this.storage = storage;
}
+ /**
+ * Methode qui va effectuer l'importation
+ */
+ public void migrateData(String data){
+ DATA_PATH = data;
+ migrateData();
+ }
+
+ /**
+ * Methode qui va effectuer l'importation
+ */
public void migrateData(){
Collection oldData;
Collection res = new HashSet();
@@ -60,15 +71,20 @@
OldTimerTask old = (OldTimerTask)iter.next();
reccursiveMigrate(old,"");
-
- log.info(old.toString());
}
}
+ /**
+ * Methode qui va transformer les anciens objets gtimer en objet webtimer et va les pousser dans la base
+ * Reccursive qui va passer sur chaque noeud
+ * @param old l'ancien objet
+ * @param father le pere de l'objet
+ */
protected void reccursiveMigrate( OldTimerTask old, String father){
// On reconstruit ce qu'on peut de notre objet
TimerTask task = new TimerTask(old,father);
+
//Persist la task
storage.addTask(task);
@@ -90,8 +106,14 @@
OldTimerAlert oldAlert = (OldTimerAlert)iter2.next();
+ String type = "";
+ if(oldAlert.getType() == OldTimerAlert.Type.REACH_DAILY_TIME){
+ type= "Total_Day_Time";
+ }else{
+ type= "Total_Time";
+ }
- TimerAlarm alarm = new TimerAlarm(task.getTaskId(), task.getName()+index, oldAlert.getType().toString(), oldAlert.getDuration());
+ TimerAlarm alarm = new TimerAlarm(task.getTaskId(), task.getName()+index, type, oldAlert.getDuration());
storage.addTaskAlarm(alarm);
index++;
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java 2014-08-08 15:02:24 UTC (rev 3027)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java 2014-08-14 14:43:54 UTC (rev 3028)
@@ -443,10 +443,12 @@
alertTaskFile));
// skip first line : "format: 1.2"
+ alertIn.readLine();
+
String line;
while ((line = alertIn.readLine()) != null) {
- line = line.trim();
+ line = line.trim(); //trime start and end whitespace
if (!line.isEmpty()) {
String alertType = line.substring(0, line.indexOf(' '));
String alertDuration = line.substring(
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-08-08 15:02:24 UTC (rev 3027)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-08-14 14:43:54 UTC (rev 3028)
@@ -40,9 +40,6 @@
private static final Log log = LogFactory.getLog(Storage.class);
- protected static final String TABLE_TASK = "task";
- protected static final String TABLE_TIME = "tasktime";
- protected static final String TABLE_ALARM = "taskalarm";
protected String TABLE_VERSION;
protected String STORAGE_PATH;
@@ -118,7 +115,7 @@
protected void closeConnection(Connection conn) throws SQLException {
if (conn != null) {
conn.close();
- conn = null;
+
}
}
@@ -198,33 +195,6 @@
return result;
}
- /** Query **/
-
- /**
- * Find all project. (task with no parent, parent = 0).
- *
- * @return all projects
- */
- public int getTasksCount() {
- int result = 0;
- PreparedStatement statement = null;
- try {
- statement = getConnection().prepareStatement(config.getStorageQuerySelectCountTask());
-
- ResultSet rs = statement.executeQuery();
- if (rs.next()) {
- result = rs.getInt(1);
- }
- } catch (SQLException ex) {
- throw new StorageException("Can't get task count", ex);
- } finally {
- closeStatement(statement);
- }
- return result;
- }
-
-
-
/* Insert */
/**
@@ -282,38 +252,10 @@
} finally {
closeStatement(statement);
}
- log.info("insert done");
}
-
/**
* Ajoute une periode pour une tache
- * @param task la tache qui va recevoir un temps
- * @param date la date de creation
- * @param uuid l'identifiant du temps
- * @param duration le duree de la periode
- */
- public void addTaskTime(TimerTask task, Date date, String uuid, long duration) {
- PreparedStatement statement = null;
- try {
- statement = getConnection().prepareStatement(config.getStorageQueryInsertTime());
-
- statement.setString(1, task.getTaskId());
- statement.setObject(2, new Date());
- statement.setString(3, uuid);
- statement.setLong(4, duration);
- statement.setObject(5, new Date());
- statement.setBoolean(6, false);
- statement.executeUpdate();
- } catch (SQLException ex) {
- throw new StorageException("Can't add task time", ex);
- } finally {
- closeStatement(statement);
- }
- }
-
- /**
- * Ajoute une periode pour une tache
* @param time le timertime a ajouter
*/
public void addTaskTime(TimerTime time) {
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ImportResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ImportResource.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ImportResource.java 2014-08-14 14:43:54 UTC (rev 3028)
@@ -0,0 +1,36 @@
+package org.chorem.jtimer.web;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.jtimer.io.DataHandler;
+import org.restlet.representation.Representation;
+import org.restlet.resource.Post;
+
+import java.io.IOException;
+
+/**
+ * Created by olivia on 11/08/14.
+ * <p/>
+ * Project name : jtimer
+ * <p/>
+ * Package name : org.chorem.jtimer.web
+ */
+public class ImportResource extends AbstractResource{
+
+ private static final Log log = LogFactory.getLog(ImportResource.class);
+
+ /**
+ * Methode qui cree une periode
+ * suite d'une requête de type POST
+ */
+ @Post("json")
+ public void importTasks(Representation representation) throws IOException {
+
+ if(representation.isAvailable()) {
+ DataHandler g = new DataHandler(storage);
+ g.migrateData();
+ //g.migrateData(representation.getText());
+ }
+ }
+
+}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java 2014-08-08 15:02:24 UTC (rev 3027)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java 2014-08-14 14:43:54 UTC (rev 3028)
@@ -5,7 +5,6 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.config.JtimerConfig;
import org.chorem.jtimer.entities.TodoList;
-import org.chorem.jtimer.io.DataHandler;
import org.chorem.jtimer.storage.Storage;
import org.restlet.Application;
import org.restlet.Context;
@@ -60,6 +59,7 @@
router.attach("/report", ReportResource.class);
router.attach("/tasks/alarm", AlarmsResource.class);
router.attach("/tasks/alarm/{taskId}", AlarmResource.class);
+ router.attach("/import", ImportResource.class);
@@ -79,10 +79,6 @@
Storage storage = new Storage(jtimerConf);
context.getAttributes().put(Storage.class.getName(), storage);
- DataHandler g = new DataHandler(storage);
- g.migrateData();
-
-
//initialisation de la todoList
todoList = TodoList.getInstance();
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java 2014-08-08 15:02:24 UTC (rev 3027)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java 2014-08-14 14:43:54 UTC (rev 3028)
@@ -4,7 +4,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.entities.TodoList;
-import org.chorem.jtimer.storage.Storage;
import org.restlet.data.MediaType;
import org.restlet.representation.Representation;
import org.restlet.representation.StringRepresentation;
@@ -19,7 +18,6 @@
private static final Log log = LogFactory.getLog(TaskResource.class);
- protected Storage storage;
protected TodoList todoList;
/**
@@ -28,9 +26,7 @@
*/
@Override
protected void doInit() throws ResourceException {
-
- storage = (Storage)getContext().getAttributes().get(Storage.class.getName());
-
+ super.doInit();
//On recupere la todoList courante
todoList = TodoList.getInstance();
@@ -73,7 +69,7 @@
/**
* Recupere la valeur de dispatch dans l'url
* TODO 04/06/14 obruce : remove this method when config will be available
- * @return
+ * @return if need to be dispatched
*/
private boolean getDispatch() {
boolean res;
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java 2014-08-08 15:02:24 UTC (rev 3027)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java 2014-08-14 14:43:54 UTC (rev 3028)
@@ -1,20 +1,11 @@
package org.chorem.jtimer.web;
import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.entities.TimerTask;
import org.chorem.jtimer.entities.TodoList;
-import org.chorem.jtimer.storage.Storage;
import org.restlet.data.MediaType;
import org.restlet.representation.Representation;
import org.restlet.representation.StringRepresentation;
@@ -24,16 +15,12 @@
import org.restlet.resource.ResourceException;
import java.io.IOException;
-import java.lang.reflect.Type;
import java.util.ArrayList;
-import java.util.Date;
public class TasksResource extends AbstractResource {
private static final Log log = LogFactory.getLog(TasksResource.class);
- protected Storage storage;
- protected GsonBuilder builder;
protected TodoList todoList;
protected boolean dispatch; //TODO 04/06/14 obruce : remove this parameter when config will be available
@@ -45,25 +32,9 @@
*/
@Override
protected void doInit() throws ResourceException {
- storage = (Storage) getContext().getAttributes().get(Storage.class.getName());
- // Register an adapter to manage the date types as long values
- builder = new GsonBuilder();
- builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
+ super.doInit();
- public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
- return new Date(json.getAsJsonPrimitive().getAsLong());
- }
-
- });
-
- builder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
- @Override
- public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) {
- return new JsonPrimitive(date.getTime());
- }
- });
-
//On recupere la todoList courante
todoList = TodoList.getInstance();
Modified: branches/ng-jtimer/src/main/resources/jtimer-default.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-08-08 15:02:24 UTC (rev 3027)
+++ branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-08-14 14:43:54 UTC (rev 3028)
@@ -2,7 +2,7 @@
# jTimer default properties
###
# jTimer storage path
-jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/BDDImport2
+jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/BDD2
###
# SQL properties
###
Modified: branches/ng-jtimer/src/main/webapp/js/app.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/app.js 2014-08-08 15:02:24 UTC (rev 3027)
+++ branches/ng-jtimer/src/main/webapp/js/app.js 2014-08-14 14:43:54 UTC (rev 3028)
@@ -306,12 +306,14 @@
/**
* Module de webtimer
**/
-angular.module('webtimer', ['webtimerFilters', 'ngRoute', 'ngAnimate', 'ui.bootstrap','serverAccessService', 'serverTimeService','serverReportService', 'serverAlarmService' ])
+angular.module('webtimer', ['webtimerFilters', 'ngRoute', 'ngAnimate', 'ui.bootstrap', 'settingsService',
+ 'serverAccessService', 'serverTimeService','serverReportService', 'serverAlarmService','importModule' ])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/tasks', {templateUrl: 'partials/tasks.html', controller: TasksCtrl}).
when('/about', {templateUrl: 'partials/about.html'}).
when('/contact', {templateUrl: 'partials/contact.html'}).
+ when('/settings', {templateUrl: 'partials/settings.html', controller: SettingsCtrl}).
otherwise({redirectTo: '/tasks'});
}])
.config(function (datepickerConfig, datepickerPopupConfig) {
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-08 15:02:24 UTC (rev 3027)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-14 14:43:54 UTC (rev 3028)
@@ -1,4 +1,4 @@
-function TasksCtrl($scope, $interval, $timeout, $q, serverTaskAccess, serverTimeAccess, serverAlarmAccess, serverReportAccess, $localStorage, $window, $document, $modal, wtWebsocket, jTimerWebsocket) {
+function TasksCtrl($scope, $interval, $timeout, $q, settings, serverTaskAccess, serverTimeAccess, serverAlarmAccess, serverReportAccess, $localStorage, $window, $document, $modal, wtWebsocket, jTimerWebsocket) {
// {Boolean} vrai si on est online
$scope.online = $window.navigator.onLine;
@@ -33,19 +33,19 @@
$scope.currentTaskDate = null;
// {String} le filtre d'affichage des noeuds (permet la recherche d'un noeud)
$scope.query = "";
- // {boolean} boolean qui permet de force le depliage complet de l'arbre s'il est vrai
- $scope.forceExpanded = false;
+ // {boolean} boolean qui permet de force le depliage complet de l'arbre s'il est vrai
+ $scope.forceExpanded = settings.forceExpanded;
// {boolean} boolean qui indique si la colonne NAME doit etre affichee
- $scope.showName = true;
+ $scope.showName = settings.showName;
// {boolean} boolean qui indique si la colonne TODAY doit etre affichee
- $scope.showToday = true;
+ $scope.showToday = settings.showToday;
// {boolean} boolean qui indique si la colonne TOTAL doit etre affichee
- $scope.showGlobal = true;
+ $scope.showGlobal = settings.showGlobal;
// {boolean} boolean qui indique si la colonne TAGS doit etre affichee
- $scope.showTags = true;
+ $scope.showTags = settings.showTags;
// {boolean} boolean qui indique si les taches masquees doivent etre affichees
- $scope.showHidden = false;
+ $scope.showHidden = settings.showHidden;
// {boolean} etat du client local (le serveur websocket)
$scope.webSocketClientOnline = false;
@@ -65,6 +65,10 @@
}
};
+ /**
+ * Notify the user with a html5 notification
+ * @param msg the message to display
+ */
var notifyUser=function (msg) {
// Let's check if the browser supports notifications
@@ -75,7 +79,7 @@
var notification = new Notification(
"Notification", {
body: msg,
- icon: ""
+ icon: "http://media.maginea.com/ld/products/00/00/66/29/LD0000662925_1.jpg"
});
@@ -90,7 +94,7 @@
var notification = new Notification(
"Notification", {
body: msg,
- icon: ""
+ icon: "http://media.maginea.com/ld/products/00/00/66/29/LD0000662925_1.jpg"
});
}
});
@@ -142,7 +146,20 @@
$scope.online = true;
}, false);
+ /**
+ * Methode qui parcours l'arbre pour vérifier si le noeud a un fils actif
+ * @param le noeud dont on va verifier les fils
+ */
+ $scope.hasActivSon = function(node){
+ res = false;
+ angular.forEach(node.children, function(child){
+ res = res || (child.task == $scope.currentTask) || $scope.hasActivSon(child);
+ });
+
+ return res;
+ };
+
/**
* Force la sauvegarde des datas
* @returns {undefined}cd
@@ -178,65 +195,54 @@
* Methode qui se lance toutes les minutes pour verifier les alamres des taches
*/
var checkAlarms = function(delay) {
+
+ launchDate = Date.now();
+
$interval(function() {
if ($scope.currentTask) {
- checkRecurseParent($scope.currentTask);
+ checkRecurseParent($scope.currentTask, launchDate);
}
-
+ delay = 0;
}, 60000-delay);
};
/**
- *
+ * Methode qui va recursivement aller modifier les alarmes des membres d'une même branche
* @param :task la tache
*/
- var checkRecurseParent = function(task){
+ var checkRecurseParent = function(task, date){
- var alarms= task.alarms;
- var index=0;
+ var alarms = task.alarms;
+ var index = 0;
var parent = $scope.data.tasks[task.parent];
angular.forEach(alarms, function(alarm){
+ alarm.launchDate = date;
- if(!alarm.type=="Total_Time" && !alarm.isToday()){
+ // Si l'alarme date d'un autre jour et qu'elle est periodique
+ if(!alarm.type == "Total_Time" && !alarm.isToday()){
alarm.setToday();
- alarm.remainingHour = alarm.limitHour;
- alarm.remainingMin = alarm.limitMin;
+ alarm.remainingTime = alarm.duration;
}
- if(alarm.remainingMin > 0){
- alarm.remainingMin -=1;
- }else if(alarm.remainingMin == 0){
- alarm.remainingMin = 59;
- alarm.remainingHour -=1;
- }
+ /* console.log(date);
+ console.log(date + alarm.remainingTime);
+ console.log(Date.now());
+ console.log(date + alarm.remainingTime < Date.now());*/
- var limit = alarm.limitHour*60 + alarm.limitMin;
- var remaining = alarm.remainingHour*60 + alarm.remainingMin;
-
- var res = ((limit-remaining)/limit)*100;
-
- if(res == 50 ){
- //$scope.currentTaskAlarmState="alarmOk";
- notifyUser("You've already spend half of the time on the task");
- }else if(res == 80){
- //$scope.currentTaskAlarmState="alarmInter";
- notifyUser("You only got 20% of your time");
- }
-
-
- if(alarm.remainingHour == 0 && alarm.remainingMin == 0){
- //console.log("Alarme lancée " +alarm.name +" de type "+ alarm.type + " par " + task.name );
+ if((alarm.remainingTime != -1) && (date + alarm.remainingTime < Date.now())){
+ //L'alarme a atteint son but
if(alarm.type=="Total_Time"){
alarms.splice(index,1);
+ }else{
+ alarm.remainingTime = -1;
}
- notifyUser("Alarms : "+ alarm.name +" end!");
-
+ notifyUser("Hey, "+ alarm.name +" has ended!");
}
index+=1;
});
@@ -253,7 +259,9 @@
*/
var timer = function() {
$interval(function() {
+ //On pousse les majs
pushTodoListToServ();
+ //On update les changements eventuels de la base
updateTasksFromServ();
updateTimesFromServer();
}, interval);
@@ -263,61 +271,16 @@
timer();
/**
- * Récupère les nouveaux elements du serveur et les ajoute a l'arbre pour l'affichage
- *
- */
- var initTasksFromServ = function(){
-
- serverTaskAccess.query({date : 0}, function (response) {
-
- angular.forEach(response, function (item) {
- //console.log(response);
- if((!(item.taskId in $scope.data.tasks)) && item.removed == 0){
-
- console.log( "Un element non present " + item.name + item.modificationDate);
- var newTask = new Task( item.name, item.taskId, item.parent, item.tags,item.description);
-
- if(item.parent == "" ){
-
- //Un noeud sans parent est ajouter à l'arbre du scope
- $scope.data.tasks[newTask.taskId] = newTask;
- save();
- if ($scope.tree) {
- $scope.tree.addChild($scope.createTreeNode(newTask));
- }
-
- }else{
- //Un noeud avec un parent est ajoute à l'arbre de son parent
- $scope.data.tasks[newTask.taskId] = newTask;
- save();
- }
- save();
- }
-
- });
-
- console.log("Task initialisé");
- //On change la date de dernier acces
- $scope.taskAccess = Date.now();
- $scope.todo.lastTaskAccess= $scope.taskAccess;
-
-
- save();
- });
-
- updateTimesFromServer();
- };
-
-
-
- /**
* Methode qui va chercher les mise à jour sur les taches
*
*/
var updateTasksFromServ = function(){
- serverTaskAccess.query({date : ($scope.taskAccess-delayAccess)}, function (response) {
+ //On revupere la promesse des taches ayant une date de modification > date
+ var prom = serverTaskAccess.query({date : ($scope.taskAccess-delayAccess)}).$promise;
+ prom.then(function (response) {
+
angular.forEach(response, function (item) {
//La tache existe
@@ -365,17 +328,17 @@
save();
}
- //Les temps sont recuperes du serveur
- getTimesFromServerWithTask(newTask);
+ //Les alarmes
+ getAlarmsFromServerWithTask(newTask);
save();
}
-
- getAlarmsFromServerWithTask(newTask);
}
});
});
+
+
//On change la date de dernier acces
$scope.taskAccess = Date.now();
$scope.todo.lastTaskAccess= $scope.taskAccess;
@@ -388,8 +351,10 @@
*/
var updateTimesFromServer = function(){
- serverTimeAccess.query({date : $scope.timeAccess-delayAccess}, function (response) {
+ var prom = serverTimeAccess.query({date : $scope.timeAccess-delayAccess}).$promise;
+ prom.then(function (response) {
+
angular.forEach(response, function (item) {
var editedTime = getTimeInArrayWithId($scope.data.times[item.taskId],item.timeId);
@@ -519,12 +484,14 @@
return res;
}
- serverAlarmAccess.query({taskId : task.taskId, date : $scope.timeAccess}, function (response) {
+ var prom = serverAlarmAccess.query({taskId : task.taskId, date : $scope.timeAccess}).$promise;
+ prom.then(function (response) {
+
angular.forEach(response, function (item) {
if(getAlarmInArrayWithId(task.alarms, item.alarmId) == undefined && !item.removed){
- //On cree le tasktime
+ //On cree le taskalarm
taskAlarm = new TaskAlarm(task, item.alarmId, item.name, item.type, item.modificationDate); //TODO
task.alarms.push(taskAlarm);
save();
@@ -717,6 +684,51 @@
});
};
+ var deleteTaskAndKeepTime = function(node,father){
+
+ //On parcours jusqu'en bas
+ angular.forEach(node.children, function(child){
+ deleteTaskAndKeepTime(child, father);
+ });
+
+ //On supprime la tache du serveur
+ var prom = serverTaskAccess.deleteTask({taskId: node.task.taskId, dispatch:true}).$promise;
+ prom.then(console.log("delete success" + node.task.taskId),
+ function(){
+ console.log("fail");
+ $scope.todo.stockedDeletedTasks.push(node.task.taskId);
+
+ });
+
+ if(!$scope.data.times[father]){
+ $scope.data.times[father]=[];
+ }
+
+ //On recree les temps du fils pour le pere
+ angular.forEach($scope.data.times[node.task.taskId], function(time){
+ time.taskId = father;
+ time.timeId = generateUUID();
+
+ $scope.data.times[father].push(time);
+ promT = serverTimeAccess.create({taskId: father,dispatch:true} , angular.toJson(time)).$promise;
+
+ promT.then(console.log("create time success" + node.task.taskId),
+ function(){
+ console.log("fail");
+ if(!$scope.todo.stockedNewTimes[node.task.taskId]){$scope.todo.stockedNewTimes[node.task.taskId] = []}
+ $scope.todo.stockedNewTimes[node.task.taskId].push(time);
+
+ });
+ });
+
+ //suppression de la tache
+ node.task.remove();
+ node.remove();
+ delete $scope.data.times[node.task.taskId];
+ delete $scope.data.tasks[node.task.taskId];
+ };
+
+
/**
* Supprime une tache (et ces sous taches recursivement)
* @param {type} task
@@ -752,60 +764,9 @@
});
};
- /**
- * methode pour faire la suppression recursivement
- * en gardant le temps de la tache et de ses parents dans le parent de la tache
- */
- var removeTaskRecurseKeepTime = function(tasks, father) {
+ // mark all task as removed
+ removeRecurse([node.task]);
- console.log("coucou1");
-
- angular.forEach(tasks, function(task) {
-
- var children = $scope.getChildren(task);
- removeTaskRecurseKeepTime(children,father);
-
- task.remove();
-
- delete $scope.data.tasks[task.taskId];
-
- if($scope.data.times[task.taskId]){
- if(!$scope.data.times[father]){
- $scope.data.times[father]=[];
- }
-
- // On attache les temps à la tache principal
- $scope.data.times[father]=$scope.data.times[father].concat($scope.data.times[task.taskId]);
-
- //TODO persistance
- }
-
- // On supprime les temps associes à la tache
- $scope.data.times[task.taskId] = [];
-
- console.log("coucou2");
-
- serverTaskAccess.deleteTask({taskId: task.taskId, dispatch:true}, function(){
- console.log("delete success" + task.taskId);
- },
- function(){
- console.log("fail");
- $scope.todo.stockedDeletedTasks.push(task.taskId);
-
- });
-
- node.remove();
- save();
- });
- };
-
- if(method = 1){
- // mark all task as removed
- removeRecurse([node.task]);
- }else{
- removeTaskRecurseKeepTime([node.task], node.task.taskId);
- }
-
// remove node in tree
node.remove();
save();
@@ -994,11 +955,26 @@
$scope.currentTask = task;
$scope.currentTaskDate = now;
+ //A voir pour mettre enlever quelques secondes en trop
checkAlarms(0);
} else {
$interval.cancel(checkAlarms);
+ var changeRemainingRecurse=function(task){
+ var parent = $scope.data.tasks[task.taskId];
+
+ angular.forEach(task.alarms, function(alarm){
+ alarm.remainingTime = alarm.launchDate + alarm.remainingTime - Date.now();
+ console.log(" il reste "+alarm.remainingTime);
+ });
+
+ if(parent){
+ changeRemainingRecurse(parent);
+ }
+ }
+
+
$scope.currentTask = null;
$scope.currentTaskDate = null;
}
@@ -1171,7 +1147,7 @@
$scope.removeTask(node, 1);
}else if(elem == 2){
// Suppression taches mais temps reportees au parent
- $scope.removeTask(node,2);
+ deleteTaskAndKeepTime(node, node.parent.task.taskId);
}else{
// Masque de la tache
$scope.hideTaskRecurse([node.task],true);
@@ -1199,14 +1175,13 @@
*/
var initControllerWithServ = function(){
//Si en ligne on envoie les donnees
- if ( $scope.online) {
- updateTasksFromServ();
- updateTimesFromServer();
- pushTodoListToServ();
- initTasksFromServ();
- }
+ updateTasksFromServ();
+ updateTimesFromServer();
+ pushTodoListToServ();
+
+
}
//force the first server connection
@@ -1290,10 +1265,15 @@
};
}
+/**
+ * Controller de la page de l'alarme
+ *
+ */
function AlertModalInstanceCtrl($scope,serverAlarmAccess){
+
task = $scope.task;
- totaltime = $scope.totaltime;
- todaytime = $scope.todaytime;
+ totaltime = $scope.totaltime; //le temps total
+ todaytime = $scope.todaytime; //le temps total pour la journee
$scope.alarm={name : "" , type : "Type"};
@@ -1305,6 +1285,7 @@
return ((ms / (1000*60)) % 60);
}
+ //pour l'affichage
$scope.valMinHour=function(){
var res;
if($scope.alarm.type=="Total_Time"){
@@ -1323,36 +1304,39 @@
}
return res;
}
-
+ //On affiche le temps minimal dans l'input
$scope.alarm.hour = $scope.valMinHour();
$scope.alarm.min = $scope.valMinMin();
- $scope.name = task.name;
+ //La liste de d'alarmes a afficher ng repeat
$scope.alarms = task.alarms;
-
-
+ /**
+ * Fait le calcul de progression
+ *
+ */
$scope.dynamicProgressBar = function(alarm){
var res = 0;
- var limit = alarm.limitHour*60 + alarm.limitMin;
- var remaining = alarm.remainingHour*60 + alarm.remainingMin;
+ var limit = alarm.duration;
+ var remaining = alarm.remainingTime;
res = ((limit-remaining)/limit)*100;
return res;
};
+ //On place le bon temps selon le type
$scope.dropdownType1= function(){
$scope.alarm.type = "Total_Day_Time";
- $scope.alarm.hour = $scope.valMinHour();
- $scope.alarm.min = $scope.valMinMin();
+ $scope.alarm.hour = $scope.valMinHour();
+ $scope.alarm.min = $scope.valMinMin();
}
$scope.dropdownType2 = function(){
$scope.alarm.type = "Total_Time";
- $scope.alarm.hour = $scope.valMinHour();
- $scope.alarm.min = $scope.valMinMin();
+ $scope.alarm.hour = $scope.valMinHour();
+ $scope.alarm.min = $scope.valMinMin();
}
/**
@@ -1368,48 +1352,32 @@
* Methode qui sauve l'alarme
*/
$scope.saveAlarm = function(){
+
if($scope.alarm.name== "" || $scope.alarm.type=="Type" ){
}else{
var min=$scope.alarm.min;
var hour=$scope.alarm.hour;
- if($scope.alarm.type=="Total_Time"){
- var prevHour = parseInt(msToHour(totaltime));
- var prevMin = parseInt(msToMin(totaltime));
+ var scopetime = min*60*1000 + hour*60*60*1000 ;
+ var remaining = scopetime;
- hour-=prevHour;
-
- if(min - prevMin<0){
- min = 59 +(min-prevMin);
- hour -=1;
- }else{
- min =min - prevMin;
- }
-
+ //SI c'est un temps total
+ if($scope.alarm.type=="Total_Time"){
+ remaining = scopetime-totaltime;
}else{
- var prevHour = parseInt(msToHour(todaytime));
- var prevMin = parseInt(msToMin(todaytime));
-
- hour-=prevHour;
-
- if(min - prevMin<0){
- min = 59 +(min-prevMin);
- hour -=1;
- }else{
- min =min - prevMin;
- }
+ remaining = scopetime-todaytime;
}
if($scope.alarm.hour > 0 || $scope.alarm.min> 0 ){
- var al = new TaskAlarm(task,undefined ,
- $scope.alarm.name,
- $scope.alarm.type,
- $scope.alarm.hour,
- $scope.alarm.min,
- hour,
- min);
+ var al = new TaskAlarm(task, //taskid
+ undefined , //alarmid
+ $scope.alarm.name, //name
+ $scope.alarm.type, //type
+ scopetime, //duration
+ remaining //remaining
+ ); //repeat
$scope.alarms.push(al);
@@ -1656,7 +1624,6 @@
}else{
- console.log(data);
$scope.periodTaskData={};
angular.forEach(data, function(array,period){
@@ -2078,8 +2045,26 @@
};
+function SettingsCtrl($scope, settings, importService){
+ $scope.settings=settings;
+ $scope.done = false;
+ $scope.import = function(path){
+ if(path){
+ importService.import({}, angular.toJson($scope.path));
+ $scope.done = true;
+ }
+ };
+ $scope.edit=function(){
+ $scope.done= false;
+ };
+
+}
+
+
+
+
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-08-08 15:02:24 UTC (rev 3027)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-08-14 14:43:54 UTC (rev 3028)
@@ -282,7 +282,6 @@
TreeNode.prototype.remove = function()
{
if (this.parent) {
-
var brothers = this.parent.children;
var match = brothers.indexOf(this);
@@ -508,7 +507,6 @@
}else{
this.time = time;
}
-
};
/**
@@ -565,7 +563,7 @@
* @param {Task} task la tache liee
* @returns {TaskAlarm}
*/
-var TaskAlarm = function (task,id, name, type, limitHour,limitMin, remainingHour, remainingMin,repeatF) {
+var TaskAlarm = function (task,id, name, type, duration, remaining,repeatF) {
this.taskId = task && task.taskId;
if(id == undefined){
@@ -579,10 +577,9 @@
this.date = today();
- this.limitHour = limitHour;
- this.limitMin = limitMin;
- this.remainingHour = remainingHour;
- this.remainingMin = remainingMin;
+ this.launchDate = null;
+ this.duration = duration;
+ this.remainingTime = remaining;
this.modificationDate = Date.now();
Modified: branches/ng-jtimer/src/main/webapp/js/service.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/service.js 2014-08-08 15:02:24 UTC (rev 3027)
+++ branches/ng-jtimer/src/main/webapp/js/service.js 2014-08-14 14:43:54 UTC (rev 3028)
@@ -68,4 +68,36 @@
}
);
}
-);
\ No newline at end of file
+);
+
+/**
+ * Service qui permet d'enclancher l'import des anciennes taches
+ */
+angular.module("importModule", ["ngResource"])
+.factory("importService", function ( $resource) {
+ // Encapsule l'acces au server
+ return $resource("/rest/import",{},
+ {
+ import: { method: 'POST' },
+ }
+ );
+ }
+);
+
+
+/**
+ * Service qui garde les settings
+ */
+angular.module('settingsService', []).factory("settings", function(){
+ var settings= {
+ forceExpanded : false,
+ showName : true,
+ showToday : true,
+ showGlobal : true,
+ showTags : true,
+ showHidden : false,
+ showAlarms : false, // not yet available
+ };
+
+ return settings;
+});
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/webapp/partials/alertModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/alertModal.html 2014-08-08 15:02:24 UTC (rev 3027)
+++ branches/ng-jtimer/src/main/webapp/partials/alertModal.html 2014-08-14 14:43:54 UTC (rev 3028)
@@ -12,28 +12,25 @@
</thead>
<div class="tbody">
- <!-- <div ng-bind-html="toHTML(htmlReport)"></div>
- $scope.toHTML = function (data) {
- return $sce.trustAsHtml(data);
- -->
-
<!--Portion d'ajout -->
<tr ng-repeat="(index,alarm) in alarms">
<td><i class="glyphicon glyphicon-minus-sign" ng-click="removeAlarm(index,alarm)"></i></td>
<td >{{alarm.name}}</td>
<td>{{alarm.type}}</td>
- <td>{{alarm.limitHour}}h: {{alarm.limitMin}}min</td>
+ <td>{{alarm.duration|time}}</td>
<td>
<progressbar value="dynamicProgressBar(alarm)"></progressbar>
</td>
+ <td></td>
</tr>
<tr>
<th>New:</th>
</tr>
<tr>
- <td><i class="glyphicon glyphicon-floppy-disk" ng-click="saveAlarm()"></i></td>
+ <td></td>
+
<td><input class='input-sm small_input' ng-model="alarm.name" placeholder="New Alert">
<i class="glyphicon glyphicon-edit color_red" ng-show="alarm.name==''"> </i>
<i class="glyphicon glyphicon-check color_green" ng-show="alarm.name!=''"> </i></td>
@@ -66,14 +63,8 @@
</td>
<td></td>
+ <td><i class="glyphicon glyphicon-floppy-disk" ng-click="saveAlarm()"></i></td>
</tr>
</div>
</table>
-
-<!--
-<div class="modal-footer">
- <button class="btn btn-default btn-sm" ng-click="cancel()">Cancel</button>
- <button class="btn btn-default btn-sm" ng-click="close()">Close</button>
-</div>
--->
\ No newline at end of file
Added: branches/ng-jtimer/src/main/webapp/partials/settings.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/settings.html (rev 0)
+++ branches/ng-jtimer/src/main/webapp/partials/settings.html 2014-08-14 14:43:54 UTC (rev 3028)
@@ -0,0 +1,38 @@
+<div id="header">
+ <a href='#/tasks' class='glyphicon glyphicon-arrow-left'>Home</a>
+</div>
+
+<h4>Interface Settings</h4>
+
+<b>Task tree:</b>
+<ul>
+
+ <li><input type='checkbox' ng-model= 'settings.forceExpanded'/> Keep tree opened</li>
+</ul>
+<b>Columns:</b>
+<ul>
+ <li><input type='checkbox' ng-model= 'settings.showName'/> Task name</li>
+ <li><input type='checkbox' ng-model= 'settings.showToday'/> Today time</li>
+ <li><input type='checkbox' ng-model= 'settings.showGlobal'/> Total time</li>
+ <li><input type='checkbox' ng-model= 'settings.showTags'/> Tags</li>
+ <li><input type='checkbox' ng-model= 'settings.showAlarms'/> Alarms</li>
+ <li><input type='checkbox' ng-model= 'settings.showHidden'/> Hidden tasks</li>
+</ul>
+
+<h4>Import gtimer data (zip):</h4>
+<b>Specify your file path:</b><br/>
+<form ng-submit="import(path)" ng-show="!done">
+ <p>
+ <!--<input type="file" name="datafile" accept=".zip" size="40"> -->
+ <input type="text" ng-model='path'/>
+ <input ng-if="path" type="submit" id="submit" value="Submit" />
+ </p>
+</form>
+<div ng-click="edit()" ng-show="done">
+ {{path}}
+</div>
+
+<!-- Footer -->
+<div id="footer">
+ <span class="center"><i class="fa fa-html5"></i> <a>WebTimer</a></span>
+</div>
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/webapp/partials/tasks.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-08-08 15:02:24 UTC (rev 3027)
+++ branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-08-14 14:43:54 UTC (rev 3028)
@@ -11,17 +11,10 @@
<!--Header partie droite-->
<span class="right">
<i class="glyphicon glyphicon-stop color_red" ng-show="currentTask" ng-click="timeTask(currentTask)">Stop </i>
- <i class="glyphicon glyphicon-cog" ng-click="reportPopup()">Report </i>
-
- <a class="glyphicon glyphicon-plus-sign" ng-click="showMenu = !showMenu"></a>
- <ul class="dropdown-menu" ng-class="{'menu-show': showMenu}">
- <li>Keep Tree opened <input type='checkbox' ng-model="forceExpanded"></li>
- <li>Name <input type='checkbox' ng-model='showName'/></li>
- <li>Today <input type='checkbox' ng-model='showToday'/></li>
- <li>Total <input type='checkbox' ng-model='showGlobal'/></li>
- <li>Tags <input type='checkbox' ng-model='showTags'/></li>
- <li>Hidden Tasks <input type='checkbox' ng-model='showHidden'/></li>
- </ul>
+ <i popover-placement="left" popover="Report " popover-trigger="mouseenter"
+ class="glyphicon glyphicon-cog" ng-click="reportPopup()"></i>
+ <a popover-placement="left" popover="Settings" popover-trigger="mouseenter" href="#/settings"
+ class="glyphicon glyphicon-list-alt" ></a>
<i class="glyphicon glyphicon-cloud" ng-class="{online: online, offline: !online}"></i>
</span>
</div>
@@ -41,7 +34,7 @@
<!-- Footer -->
<div id="footer">
<span class="left">{{currentDate()}}</span>
- <span class="center"><i class="fa fa-html5 color_red"></i> <a>WebTimer</a></span>
+ <span class="center"><i class="fa fa-html5"></i> WebTimer</span>
<span class="right">{{tree.getTime().today |time}} | {{tree.getTime().global | time}}</span>
</div>
@@ -76,7 +69,7 @@
<i style="font-size:10px" class="glyphicon glyphicon-ban-circle" ng-show="$state=='empty'"></i>
<i style="font-size:10px" class="glyphicon glyphicon-chevron-right" ng-click="$toggleState()" ng-show="$state=='close'"></i>
<i style="font-size:10px" class="glyphicon glyphicon-chevron-down" ng-click="$toggleState()" ng-show="$state=='open'"></i>
- <img src="partials/loading_timer.gif" height="20" width="20" ng-show="currentTask == $node.task">
+ <img src="partials/loading_timer.gif" height="20" width="20" ng-show=" (hasActivSon($node) && $state=='close') || currentTask == $node.task">
</span>
1
0
r3027 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer java/org/chorem/jtimer/config java/org/chorem/jtimer/entities java/org/chorem/jtimer/io java/org/chorem/jtimer/io/resources java/org/chorem/jtimer/storage java/org/chorem/jtimer/web resources webapp/css webapp/js webapp/partials
by obruce@users.chorem.org 08 Aug '14
by obruce@users.chorem.org 08 Aug '14
08 Aug '14
Author: obruce
Date: 2014-08-08 17:02:24 +0200 (Fri, 08 Aug 2014)
New Revision: 3027
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3027
Log:
Suppression des taches avec condition
Masquage des taches
Debut de l'import
Added:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/
branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/DataHandler.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/
branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/DailySortedMap.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/GTimerTimeUtil.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/OldTimerAlert.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/OldTimerProject.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/OldTimerTask.java
branches/ng-jtimer/src/main/webapp/partials/dialogModal.html
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerAlarm.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java
branches/ng-jtimer/src/main/resources/jtimer-default.properties
branches/ng-jtimer/src/main/webapp/css/app.css
branches/ng-jtimer/src/main/webapp/js/app.js
branches/ng-jtimer/src/main/webapp/js/controllers.js
branches/ng-jtimer/src/main/webapp/js/entities.js
branches/ng-jtimer/src/main/webapp/partials/reportModal.html
branches/ng-jtimer/src/main/webapp/partials/tasks.html
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java 2014-08-04 15:41:37 UTC (rev 3026)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java 2014-08-08 15:02:24 UTC (rev 3027)
@@ -209,6 +209,13 @@
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_TASK_WITHID.getKey());
}
+ /***/
+ public String getStorageQueryUpdateTimeID(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_TIME_CHANGEID.getKey());
+ }
+ public String getStorageQueryUpdateTimeIDWithDate(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_TIME_CHANGEIDWITHDATE.getKey());
+ }
public String getStorageQueryUpdateTaskPath(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_TASK_PATH.getKey());
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java 2014-08-04 15:41:37 UTC (rev 3026)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java 2014-08-08 15:02:24 UTC (rev 3027)
@@ -250,7 +250,18 @@
"",
String.class
),
-
+ JTIMER_STORAGE_UPDATE_TIME_CHANGEID(
+ "jtimer.storage.update.time.changeid",
+ "méthode qui va faire l'update de l'id d'une tâche",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_UPDATE_TIME_CHANGEIDWITHDATE(
+ "jtimer.storage.update.time.changeid.whithdate",
+ "méthode qui va faire l'update de l'id d'une tâche",
+ "",
+ String.class
+ ),
JTIMER_STORAGE_UPDATE_TASK_WITHID(
"jtimer.storage.update.task.withid",
"requête de mise à jour d'une taches avec un identifiant",
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerAlarm.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerAlarm.java 2014-08-04 15:41:37 UTC (rev 3026)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerAlarm.java 2014-08-08 15:02:24 UTC (rev 3027)
@@ -1,6 +1,7 @@
package org.chorem.jtimer.entities;
import java.util.Date;
+import java.util.UUID;
/**
* Created by olivia on 02/07/14.
@@ -29,31 +30,34 @@
/**ModificationDate*/
protected Date modificationDate;
- /** limit time in hour to spend on the task */
- protected int limitHour;
+ /** total duration */
+ long duration;
- /** limit time in min to spend on the task */
- protected int limitMin;
+ /** remaining time */
+ long remainingTime;
- /** passed time in hour to spend on the task */
- protected int remainingMin;
- /** passed time in min to spend on the task */
- protected int remainingHour;
-
/** date if alarm is removed */
protected long removed;
- public TimerAlarm(String taskId, String alarmId, String name, String type, Date modificationDate, int limitHour, int limitMin) {
+ public TimerAlarm(String taskId, String name, String type, long limit) {
this.taskId = taskId;
+ this.alarmId = UUID.randomUUID().toString();
+ this.name = name;
+ this.type = type;
+ this.modificationDate = new Date();
+ duration = limit;
+ remainingTime = limit;
+ }
+
+ public TimerAlarm(String taskId, String alarmId, String name, String type, Date modificationDate, long limit) {
+ this.taskId = taskId;
this.alarmId = alarmId;
this.name = name;
this.type = type;
this.modificationDate = modificationDate;
- this.limitHour = limitHour;
- this.limitMin = limitMin;
- this.remainingHour = limitHour;
- this.remainingMin =limitMin;
+ duration = limit;
+ remainingTime = limit;
}
public TimerAlarm() {
@@ -108,39 +112,22 @@
this.modificationDate = modificationDate;
}
- public int getLimitHour() {
- return limitHour;
+ public long getDuration() {
+ return duration;
}
- public void setLimitHour(int limitHour) {
- this.limitHour = limitHour;
+ public void setDuration(long duration) {
+ this.duration = duration;
}
- public int getLimitMin() {
- return limitMin;
+ public long getRemainingTime() {
+ return remainingTime;
}
- public void setLimitMin(int limitMin) {
- this.limitMin = limitMin;
+ public void setRemainingTime(long remainingTime) {
+ this.remainingTime = remainingTime;
}
- public int getRemainingMin() {
- return remainingMin;
- }
-
- public void setRemainingMin(int remainingMin) {
- this.remainingMin = remainingMin;
- }
-
- public int getRemainingHour() {
- return remainingHour;
- }
-
- public void setRemainingHour(int remainingHour) {
- this.remainingHour = remainingHour;
- }
-
-
@Override
public String toString() {
return "TimerAlarm{" +
@@ -149,10 +136,8 @@
", name='" + name + '\'' +
", type='" + type + '\'' +
", modificationDate=" + modificationDate +
- ", limitHour=" + limitHour +
- ", limitMin=" + limitMin +
- ", remainingMin=" + remainingMin +
- ", remainingHour=" + remainingHour +
+ ", limit=" + duration +
+ ", remaining=" + remainingTime +
", removed=" + removed +
'}';
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2014-08-04 15:41:37 UTC (rev 3026)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2014-08-08 15:02:24 UTC (rev 3027)
@@ -25,6 +25,8 @@
package org.chorem.jtimer.entities;
+import org.chorem.jtimer.io.resources.OldTimerTask;
+
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;
@@ -105,8 +107,44 @@
this.tags = null;
}
+ /**
+ * Constructor with name.
+ *
+ * @param name task name
+ */
+ public TimerTask( String name, String parent, String description) {
+ this();
+ this.name = name;
+ this.taskId = UUID.randomUUID().toString();
+ this.parent = parent;
+ this.description=description;
+ this.creationDate = new Date();
+ this.modificationDate = new Date();
+ this.removed = 0;
+ this.path = null;
+ this.tags = null;
+ }
/**
+ * Constructor with name.
+ *
+ * @param other an imported element
+ */
+ public TimerTask( OldTimerTask other, String parent) {
+ this();
+ this.name = other.getName();
+ this.taskId = other.getUuid();
+ this.parent = parent;
+ this.description="";
+ this.creationDate = other.getCreationDate();
+ this.modificationDate = new Date();
+ this.removed = other.isClosed()? 1 : 0 ;
+ this.path = null;
+ this.tags = null;
+ }
+
+
+ /**
* Set task uuid
*
* @param taskuuid task uuid
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/DataHandler.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/DataHandler.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/DataHandler.java 2014-08-08 15:02:24 UTC (rev 3027)
@@ -0,0 +1,123 @@
+package org.chorem.jtimer.io;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.jtimer.entities.TimerAlarm;
+import org.chorem.jtimer.entities.TimerTask;
+import org.chorem.jtimer.entities.TimerTime;
+import org.chorem.jtimer.io.resources.OldTimerAlert;
+import org.chorem.jtimer.io.resources.OldTimerTask;
+import org.chorem.jtimer.storage.Storage;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * This class will handle the migration of gtimer data to webtimer data
+ *
+ * Created by olivia on 07/08/14.
+ * <p/>
+ * Project name : jtimer
+ * <p/>
+ * Package name : org.chorem.jtimer.io
+ */
+public class DataHandler {
+
+ private static Log log = LogFactory.getLog(DataHandler.class);
+
+ /** Loader to load old data **/
+ GTimerDataLoader loader;
+
+ /** Le directory to save */
+ protected String saveDirectory = System.getProperty("user.home")
+ + File.separator + ".gtimer";
+
+
+ /** Old data path */
+ private String DATA_PATH = saveDirectory + File.separator +"backups" + File.separator +"backup-20140807100651.zip";
+
+ protected Storage storage;
+
+ public DataHandler(Storage storage){
+ this.loader = new GTimerDataLoader();
+ this.storage = storage;
+ }
+
+ public void migrateData(){
+ Collection oldData;
+ Collection res = new HashSet();
+
+ //On recupere les data du loader sous forme collection de sous tache
+ oldData = loader.extractOldData(DATA_PATH,"zip");
+
+ Iterator iter = oldData.iterator();
+
+ // On parcours les parents
+ while(iter.hasNext()){
+
+ OldTimerTask old = (OldTimerTask)iter.next();
+ reccursiveMigrate(old,"");
+
+ log.info(old.toString());
+ }
+ }
+
+ protected void reccursiveMigrate( OldTimerTask old, String father){
+
+ // On reconstruit ce qu'on peut de notre objet
+ TimerTask task = new TimerTask(old,father);
+ //Persist la task
+ storage.addTask(task);
+
+ //On recree temps, alarme et annotation
+ //Les temps
+ Iterator iter = old.getAllDaysAndTimes().keySet().iterator();
+ while(iter.hasNext()) {
+ Date key = (Date) iter.next();
+ long time = old.getAllDaysAndTimes().get(key);
+
+ TimerTime newTime = new TimerTime(task.getTaskId(), time, key );
+ storage.addTaskTime(newTime);
+ }
+
+ //Les alarmes
+ Iterator iter2 = old.getAlerts().iterator();
+ int index =1;
+ while(iter2.hasNext()) {
+
+ OldTimerAlert oldAlert = (OldTimerAlert)iter2.next();
+
+
+ TimerAlarm alarm = new TimerAlarm(task.getTaskId(), task.getName()+index, oldAlert.getType().toString(), oldAlert.getDuration());
+ storage.addTaskAlarm(alarm);
+
+ index++;
+ }
+
+ // Les annotations de la v1 sont transformées en sous tache avec des temps
+ Iterator iter3 = old.getAllDaysAnnotations().keySet().iterator();
+ while(iter3.hasNext()) {
+ Date key = (Date) iter3.next();
+ if(old.getAllDaysAndTimes().containsKey(key)){
+ // On cree une sous tache pour la tache representant old et on ajoute une descritpion
+ String annot = old.getAllDaysAnnotations().get(key);
+ TimerTask newTask = new TimerTask(annot, old.getUuid() ,"AnnotationV1");
+
+ //Persist la task
+ storage.addTask(newTask);
+
+ // On change la tache a qui appartient le temps pour le jour de old
+ storage.updateTimeId(newTask.getTaskId(), old.getUuid(), key);
+ }
+
+ }
+
+ // On parcours les enfants pour les migrer
+ for(OldTimerTask child : old.getSubTasks()) {
+ reccursiveMigrate(child, old.getUuid());
+ }
+ }
+}
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java 2014-08-08 15:02:24 UTC (rev 3027)
@@ -0,0 +1,639 @@
+package org.chorem.jtimer.io;
+
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.jtimer.io.resources.GTimerTimeUtil;
+import org.chorem.jtimer.io.resources.OldTimerAlert;
+import org.chorem.jtimer.io.resources.OldTimerProject;
+import org.chorem.jtimer.io.resources.OldTimerTask;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+/**
+ * Created by olivia on 07/08/14.
+ * Code interne repris de svn.chorem.org/jtimer/trunk/src/main/java/org/chorem/jtimer/io/GTimerIncrem…
+ * <p/>
+ * Project name : jtimer
+ * <p/>
+ * Package name : org.chorem.jtimer.io
+ */
+public class GTimerDataLoader {
+
+ private static Log log = LogFactory.getLog(GTimerDataLoader.class);
+
+ /**
+ * Separateur pour les sous taches.
+ *
+ * Utilise pour assurer une compatibilite avec gTimer, qui ne permet pas de
+ * stocker des sous taches.
+ */
+ protected static final String GTIMER_SUBTASK_SEPARATOR = "/";
+
+ /** Version du format de fichier. */
+ protected static final String GTIMER_FILE_VERSION = "1.2";
+
+ /** Extension project. */
+ protected static final String GTIMER_PROJECT_EXTENSION = "project";
+
+ /** Extension task. */
+ protected static final String GTIMER_TASK_EXTENSION = "task";
+
+ /** Extension annotation. */
+ protected static final String GTIMER_ANNOTATION_EXTENSION = "ann";
+
+ /** Extension alert. */
+ protected static final String GTIMER_ALERT_EXTENSION = "alert";
+
+
+ /** Empty gtimer project name. */
+ protected static final String GTIMER_EMPTY_PROJECT_NAME = "No project";
+
+ /**
+ * Save directory. Init with $user.home/.gtimer
+ */
+ protected String saveDirectory = System.getProperty("user.home")
+ + File.separator + ".gtimer";
+
+ public GTimerDataLoader(){
+
+ }
+
+ public Collection extractOldData(String oldDataPath, String type){
+
+ Collection res = null;
+
+ if(type.equals("zip")){
+
+ String path = saveDirectory + File.separator + "zipHelper";
+ //unzip
+ unzip(oldDataPath, path);
+ res = gTimerLoad(path);
+ //delete created folder
+ deleteFolder( path);
+
+ }else{
+ res = gTimerLoad(saveDirectory);
+ }
+
+ return res;
+ }
+
+ /**
+ * Load from gtimer file format.
+ *
+ * @return projects loaded
+ */
+ protected Collection<OldTimerProject> gTimerLoad(String folder) {
+
+ // map number => project
+ Map<String, OldTimerProject> mapNumberProject = new HashMap<>();
+
+ // probleme : il faut d'abord lire les "project" avant les task
+ // pour pouvoir fair l'association
+ // donc deux boucles
+
+ File gTimerFileDir = new File(folder);
+
+ // loop 1 , reading projects
+ // project file "0.project"
+ Pattern pPatronNommage = Pattern.compile("^(\\d+)\\."
+ + GTIMER_PROJECT_EXTENSION + "$");
+ for (File f : gTimerFileDir.listFiles()) {
+ if (f.isFile() && f.canRead()) {
+ Matcher m = pPatronNommage.matcher(f.getName());
+ if (m.find()) {
+ String number = m.group(1); // 1 = le chiffre
+
+ try {
+ int projectNumber = Integer.parseInt(number);
+
+ OldTimerProject p = getProjectFromFile(f);
+ if (p != null) {
+ p.setNumber(projectNumber);
+ mapNumberProject.put(number, p);
+ }
+ } catch (NumberFormatException e) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse " + f.getName()
+ + " as gtimer file", e);
+ }
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't read file", e);
+ }
+ }
+ }
+ }
+ }
+
+ // loop 2 , reading tasks
+ // task file "0.task"
+ pPatronNommage = Pattern.compile("^(\\d+)\\." + GTIMER_TASK_EXTENSION
+ + "$");
+
+ // map to remember tasks to manage after load
+ // sorted on / number in their name
+ SortedMap<OldTimerTask, OldTimerProject> taskToPostManaged = new TreeMap<>(
+ new Comparator<OldTimerTask>() {
+ @Override
+ public int compare(OldTimerTask t1, OldTimerTask t2) {
+
+ int numberOfSeparatorInT1 = t1.getName().split(
+ GTIMER_SUBTASK_SEPARATOR).length;
+ int numberOfSeparatorInT2 = t2.getName().split(
+ GTIMER_SUBTASK_SEPARATOR).length;
+
+ int compare = numberOfSeparatorInT1
+ - numberOfSeparatorInT2;
+
+ // seems to delete when return 0 ???
+ if (compare == 0) {
+ compare = -1;
+ }
+ return compare;
+ }
+ });
+
+ // now process each file
+ for (File f : gTimerFileDir.listFiles()) {
+ if (f.isFile() && f.canRead()) {
+ Matcher m = pPatronNommage.matcher(f.getName());
+ if (m.find()) {
+
+ // oui, annotations sur un numero de tache
+ String number = m.group(1);
+
+ try {
+ int taskNumber = Integer.parseInt(number);
+
+ OldTimerTask task = parseTaskFromFile(mapNumberProject, f,
+ taskToPostManaged);
+
+ if (task != null) {
+ task.setNumber(taskNumber);
+
+ parseAnnotations(task);
+ parseAlerts(task);
+ }
+ } catch (NumberFormatException e) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse " + f.getName()
+ + " as gtimer file", e);
+ }
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't parse task file", e);
+ }
+ }
+ }
+ }
+ }
+
+ // post process tasks
+ parseTaskFromSavedMap(taskToPostManaged);
+
+ // collection to return
+ return mapNumberProject.values();
+ }
+
+ /**
+ * Load a project in his file.
+ *
+ * @param projectFile project file
+ * @return a project
+ * @throws IOException if ioexception occurs
+ */
+ protected OldTimerProject getProjectFromFile(File projectFile)
+ throws IOException {
+
+ Properties prop = new Properties();
+ prop.load(new BufferedInputStream(new FileInputStream(projectFile)));
+
+ // log
+ if (log.isDebugEnabled()) {
+ log.debug("Load project (" + projectFile.getName() + ") : "
+ + prop.getProperty("Name"));
+ }
+
+ OldTimerProject p = null;
+ if (GTIMER_FILE_VERSION.equals(prop.get("Format"))) {
+ p = new OldTimerProject();
+ p.setName(prop.getProperty("Name"));
+
+ // manage creation timestamp (conversion to long)
+ try {
+ String creationTimeStamp = prop.getProperty("Created");
+ long timestampinms = Long.parseLong(creationTimeStamp) * 1000;
+ p.setCreationDate(new Date(timestampinms));
+ } catch (NumberFormatException e) {
+ if (log.isWarnEnabled()) {
+ log.warn("Invalid 'Created' timestamp", e);
+ }
+ p.setCreationDate(new Date(0));
+ }
+
+ p.setClosed(prop.getProperty("Options").equals("1"));
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("Invalid file format. Excepted " + GTIMER_FILE_VERSION
+ + ", found " + prop.get("Format"));
+ }
+ }
+ return p;
+ }
+
+ /**
+ * Parse task file.
+ *
+ * @param mapNumberProject map entre les projets reels et leur numero gtimer
+ * @param taskFile gtimer task file
+ * @param taskToManage sorted map to remember task to post process
+ * @return parsed task
+ * @throws IOException if ioexception occurs
+ */
+ protected OldTimerTask parseTaskFromFile(
+ Map<String, OldTimerProject> mapNumberProject, File taskFile,
+ SortedMap<OldTimerTask, OldTimerProject> taskToManage) throws IOException {
+
+ OldTimerTask t = null;
+
+ Pattern dataPattern = Pattern.compile("(\\d{4})(\\d{2})(\\d{2})");
+
+ Properties prop = new Properties();
+ prop.load(new BufferedInputStream(new FileInputStream(taskFile)));
+
+ if (GTIMER_FILE_VERSION.equals(prop.get("Format"))) {
+ t = new OldTimerTask();
+
+ // manage creation timestamp (convertion to long)
+ try {
+ String creationTimeStamp = prop.getProperty("Created");
+ long timestampinms = Long.parseLong(creationTimeStamp) * 1000;
+ t.setCreationDate(new Date(timestampinms));
+ } catch (NumberFormatException e) {
+ if (log.isWarnEnabled()) {
+ log.warn("Invalid 'Created' timestamp for " + taskFile, e);
+ }
+ t.setCreationDate(new Date(0));
+ }
+
+ t.setClosed(prop.getProperty("Options").equals("1"));
+
+ // name = task
+ // name = task/subtask1
+ // name = task/subtask1/subsubtask1
+ String gtimerTaskName = prop.getProperty("Name");
+ t.setName(gtimerTaskName);
+ // yes put all names
+ // will be corrected later
+
+ // log
+ if (log.isDebugEnabled()) {
+ log.debug("Load task (" + taskFile.getName() + ") : "
+ + gtimerTaskName);
+ }
+
+ // analyse des donnees (temps)
+ for (Object key : prop.keySet()) {
+ String sKey = (String) key;
+
+ // test if key format match
+ Matcher m = dataPattern.matcher(sKey);
+ if (m.find()) {
+ try {
+ Date keyDate = GTimerTimeUtil.yyyyMMdd2Date(sKey);
+ String timeString = (String) prop.get(sKey);
+ t.setTime(keyDate, Long.valueOf(timeString) * 1000);
+ } catch (NumberFormatException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert " + prop.get(sKey)
+ + " into long");
+ }
+ }
+ }
+ // else not data entry
+ }
+
+ // find associated project instance with number
+ String taskProjectNumber = (String) prop.get("Project");
+ OldTimerProject associatedProject = mapNumberProject
+ .get(taskProjectNumber);
+
+ // fix bug case task has no associated project
+ // can do that in gtimer
+ if (associatedProject == null && taskProjectNumber.equals("-1")) {
+ associatedProject = new OldTimerProject();
+ associatedProject.setName(GTIMER_EMPTY_PROJECT_NAME);
+ mapNumberProject.put(taskProjectNumber, associatedProject);
+ }
+
+ if (associatedProject != null) {
+ // used to correct bug #1636 : [jTimer] Bug du rechargement des
+ // sous taches
+ taskToManage.put(t, associatedProject);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Put " + t.getName() + ", "
+ + associatedProject.getName());
+ }
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("task " + t.getName()
+ + " is associated with a wrong project number "
+ + prop.get("Project"));
+ }
+ }
+
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("Invalid file format. Excepted " + GTIMER_FILE_VERSION
+ + ", found " + prop.get("Format"));
+ }
+ }
+
+ return t;
+ }
+
+ /**
+ * Try to find and load annotations from task.
+ *
+ * @param task task to load annotations
+ * @throws IOException if can't read ann file
+ */
+ protected void parseAnnotations(OldTimerTask task) throws IOException {
+ int taskNumber = task.getNumber();
+
+ File annotationsTaskFile = new File(saveDirectory + File.separator
+ + taskNumber + "." + GTIMER_ANNOTATION_EXTENSION);
+
+ if (annotationsTaskFile.exists()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Annotations found for task " + task.getName());
+ }
+
+ Properties prop = new Properties();
+ prop.load(new BufferedInputStream(new FileInputStream(
+ annotationsTaskFile)));
+
+ // analyse des donnees (temps)
+ for (Object key : prop.keySet()) {
+ String sKey = (String) key;
+
+ // test if key format match
+ try {
+
+ // key of annotation is in seconds
+ long timestamp = Long.parseLong(sKey);
+ Date dateTS = new Date(timestamp * 1000);
+
+ String annoText = (String) prop.get(sKey);
+
+ task.addAnnotation(dateTS, annoText);
+ } catch (NumberFormatException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert " + sKey + " into long");
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Find task alert and load it.
+ *
+ * This file can't be loaded by {@code Properties#load(java.io.InputStream)}.
+ * Constains duplicated keys.
+ *
+ * @param task task to load alert
+ * @throws IOException if can't read ann file
+ */
+ protected void parseAlerts(OldTimerTask task) throws IOException {
+ int taskNumber = task.getNumber();
+
+ File alertTaskFile = new File(saveDirectory + File.separator
+ + taskNumber + "." + GTIMER_ALERT_EXTENSION);
+
+ if (alertTaskFile.exists()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Alert found for task " + task.getName());
+ }
+
+ BufferedReader alertIn = new BufferedReader(new FileReader(
+ alertTaskFile));
+
+ // skip first line : "format: 1.2"
+ String line;
+ while ((line = alertIn.readLine()) != null) {
+
+ line = line.trim();
+ if (!line.isEmpty()) {
+ String alertType = line.substring(0, line.indexOf(' '));
+ String alertDuration = line.substring(
+ line.indexOf(' ') + 1, line.length());
+
+ try {
+ if ("reachtotaltime".equals(alertType)) {
+ Long duration = Long.parseLong(alertDuration) * 1000;
+ OldTimerAlert alert = new OldTimerAlert(
+ OldTimerAlert.Type.REACH_TOTAL_TIME, duration);
+ task.addAlert(alert);
+ } else if ("reachdailytime".equals(alertType)) {
+ Long duration = Long.parseLong(alertDuration) * 1000;
+ OldTimerAlert alert = new OldTimerAlert(
+ OldTimerAlert.Type.REACH_DAILY_TIME, duration);
+ task.addAlert(alert);
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("Unknow alert type " + alertType);
+ }
+ }
+ } catch (NumberFormatException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert " + alertDuration
+ + " into long");
+ }
+ }
+ }
+ }
+
+ alertIn.close();
+ }
+ }
+
+ /**
+ * Post process task to manage subtask loaded before parent task.
+ *
+ * @param taskToManage sorted map of those task
+ */
+ protected void parseTaskFromSavedMap(
+ SortedMap<OldTimerTask, OldTimerProject> taskToManage) {
+
+ // process each task
+ for (Map.Entry<OldTimerTask, OldTimerProject> entry : taskToManage.entrySet()) {
+ OldTimerTask currentTask = entry.getKey();
+ OldTimerProject associatedProject = entry.getValue();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Post process task " + currentTask.getName());
+ }
+
+ // process task name
+ String gTimerTaskname = currentTask.getName();
+ String[] tabTaskNames = gTimerTaskname
+ .split(GTIMER_SUBTASK_SEPARATOR);
+
+ // associated to project
+ if (tabTaskNames.length == 1) {
+ associatedProject.addTask(currentTask);
+
+ } else {
+ // tabTaskNames.length != 1
+ // sub task : add task to corresponding task
+
+ // correct task name
+ String realTaskName = tabTaskNames[tabTaskNames.length - 1];
+ currentTask.setName(realTaskName);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Converting task " + gTimerTaskname
+ + " in sub tasks");
+ }
+
+ OldTimerTask task = findTask(associatedProject, Arrays
+ .copyOfRange(tabTaskNames, 0, tabTaskNames.length - 1));
+ if (task != null) {
+ task.addTask(currentTask);
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("task " + Arrays.toString(tabTaskNames)
+ + " cannot be found, add task to project");
+ }
+
+ // add task to project, to not loose it
+ currentTask.setName(gTimerTaskname);
+ associatedProject.addTask(currentTask);
+ }
+ }
+ }
+ }
+
+ /**
+ * Find a task in task's subtask
+ *
+ * @param parentTask task
+ * @param taskNames names
+ * @return a task or <tt>null</tt>
+ */
+ protected OldTimerTask findTask(OldTimerTask parentTask, String[] taskNames) {
+
+ OldTimerTask result = null;
+
+ if (taskNames.length > 0) {
+ for (OldTimerTask task : parentTask.getSubTasks()) {
+ if (task.getName().equals(taskNames[0])) {
+ result = findTask(task, Arrays.copyOfRange(taskNames, 1,
+ taskNames.length));
+ }
+ }
+ } else {
+ result = parentTask;
+ }
+
+ return result;
+ }
+
+ /**
+ * Method that will unzip a specific zipFile in a folder
+ *
+ * @param zipFile the file to unzip
+ * @param outputFolder the path to the wanted folder
+ */
+ protected void unzip(String zipFile, String outputFolder){
+
+ try {
+ /** Buffer to read */
+ byte[] buffer = new byte[1024];
+
+ // Our folder to output to
+ File folder = new File(outputFolder);
+ if(!folder.exists()){
+ folder.mkdir();
+ }
+
+ // We get zip's content
+ ZipInputStream zip = new ZipInputStream(new FileInputStream(zipFile));
+
+ // We retrieve the zip's list
+ ZipEntry ze = zip.getNextEntry();
+
+ while(ze != null){
+
+ String fileName = ze.getName();
+ File newFile = new File(outputFolder + File.separator + fileName);
+
+ //create non existent parent folders
+ new File(newFile.getParent()).mkdirs();
+
+ FileOutputStream fos = new FileOutputStream(newFile);
+
+ int len;
+ while ((len = zip.read(buffer)) > 0) {
+ fos.write(buffer, 0, len);
+ }
+
+ fos.close();
+ ze = zip.getNextEntry();
+
+ if(log.isDebugEnabled()){
+ log.debug("unziped file: "+ newFile.getAbsoluteFile());
+ }
+ }
+
+ zip.closeEntry();
+ zip.close();
+
+ if(log.isDebugEnabled()){
+ log.debug("Unzip done!");
+ }
+
+ }catch(IOException e){
+ log.error(e);
+ }
+ }
+
+ /**
+ * Delete the specified folder
+ *
+ * @param folderPath the path to the folder
+ */
+ protected void deleteFolder(String folderPath){
+
+ try {
+ FileUtils.deleteDirectory(new File(folderPath));
+ } catch (IOException e) {
+ log.error("Couldn't manage folder : \n " + e);
+ }
+
+ }
+}
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/DailySortedMap.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/DailySortedMap.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/DailySortedMap.java 2014-08-08 15:02:24 UTC (rev 3027)
@@ -0,0 +1,284 @@
+package org.chorem.jtimer.io.resources;
+
+import java.util.Calendar;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * SortedMap that return a unique value for all date for a day.
+ *
+ * @see java.util.SortedMap
+ * @param <T> values type
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class DailySortedMap<T> extends TreeMap<Date, T> {
+
+ /** serialVersionUID */
+ private static final long serialVersionUID = 5736472379626976185L;
+
+ /**
+ * Constructs a new, empty tree map, using the natural ordering
+ * of its keys.
+ */
+ public DailySortedMap() {
+ }
+
+ /**
+ * Constructs a new, empty tree map, ordered according to
+ * the given comparator.
+ *
+ * @param comparator comparator
+ */
+ public DailySortedMap(Comparator<? super Date> comparator) {
+ super(comparator);
+ }
+
+ /**
+ * Constructs a new tree map containing the same mappings
+ * as the given map, ordered according to the natural ordering of its keys.
+ *
+ * @param m init map
+ */
+ public DailySortedMap(Map<? extends Date, ? extends T> m) {
+ super(m);
+ }
+
+ /**
+ * Constructs a new tree map containing the same mappings and
+ * using the same ordering as the specified sorted map.
+ *
+ * @param m init map
+ */
+ public DailySortedMap(SortedMap<Date, ? extends T> m) {
+ super(m);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Map.Entry<Date, T> ceilingEntry(Date key) {
+ Date dayKey = getDayDate(key);
+ Map.Entry<Date, T> result = super.ceilingEntry(dayKey);
+ return result;
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Date ceilingKey(Date key) {
+ Date dayKey = getDayDate(key);
+ Date result = super.ceilingKey(dayKey);
+ return result;
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ boolean result = false;
+
+ if (key instanceof Date) {
+ Date lDate = getDayDate((Date) key);
+ result = super.containsKey(lDate);
+ }
+
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Map.Entry<Date, T> floorEntry(Date key) {
+ Date dayKey = getDayDate(key);
+ Map.Entry<Date, T> result = super.floorEntry(dayKey);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Date floorKey(Date key) {
+ Date dayKey = getDayDate(key);
+ Date result = super.floorKey(dayKey);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public T get(Object key) {
+ T result = null;
+
+ if (key instanceof Date) {
+ Date lDate = getDayDate((Date) key);
+ result = super.get(lDate);
+ }
+
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NavigableMap<Date, T> headMap(Date toKey, boolean inclusive) {
+ Date dayKey = getDayDate(toKey);
+ NavigableMap<Date, T> result = super.headMap(dayKey, inclusive);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public SortedMap<Date, T> headMap(Date toKey) {
+ Date dayKey = getDayDate(toKey);
+ SortedMap<Date, T> result = super.headMap(dayKey);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Map.Entry<Date, T> higherEntry(Date key) {
+ Date dayKey = getDayDate(key);
+ Map.Entry<Date, T> result = super.higherEntry(dayKey);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Date higherKey(Date key) {
+ Date dayKey = getDayDate(key);
+ Date result = super.higherKey(dayKey);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Map.Entry<Date, T> lowerEntry(Date key) {
+ Date dayKey = getDayDate(key);
+ Map.Entry<Date, T> result = super.lowerEntry(dayKey);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Date lowerKey(Date key) {
+ Date dayKey = getDayDate(key);
+ Date result = super.lowerKey(dayKey);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public T put(Date key, T value) {
+ Date lDate = getDayDate(key);
+ T result = super.put(lDate, value);
+
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void putAll(Map<? extends Date, ? extends T> map) {
+ for (Map.Entry<? extends Date, ? extends T> entry : map.entrySet()) {
+ put(entry.getKey(), entry.getValue());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NavigableMap<Date, T> subMap(Date fromKey, boolean fromInclusive,
+ Date toKey, boolean toInclusive) {
+ Date fromDayKey = getDayDate(fromKey);
+ Date toDayKey = getDayDate(toKey);
+ NavigableMap<Date, T> result = super.subMap(fromDayKey, fromInclusive,
+ toDayKey, toInclusive);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public SortedMap<Date, T> subMap(Date fromKey, Date toKey) {
+ Date fromDayKey = getDayDate(fromKey);
+ Date toDayKey = getDayDate(toKey);
+ SortedMap<Date, T> result = super.subMap(fromDayKey, toDayKey);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NavigableMap<Date, T> tailMap(Date fromKey, boolean inclusive) {
+ Date fromDayKey = getDayDate(fromKey);
+ NavigableMap<Date, T> result = super.tailMap(fromDayKey, inclusive);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public SortedMap<Date, T> tailMap(Date fromKey) {
+ Date fromDayKey = getDayDate(fromKey);
+ SortedMap<Date, T> result = super.tailMap(fromDayKey);
+ return result;
+ }
+
+ /**
+ * Get date at 0h00:00.000.
+ *
+ * @param date date to convert
+ * @return day date
+ */
+ protected Date getDayDate(Date date) {
+ Date ldate = (Date) date.clone();
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(ldate);
+
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+
+ Date result = calendar.getTime();
+
+ return result;
+ }
+}
+
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/GTimerTimeUtil.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/GTimerTimeUtil.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/GTimerTimeUtil.java 2014-08-08 15:02:24 UTC (rev 3027)
@@ -0,0 +1,87 @@
+package org.chorem.jtimer.io.resources;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * Util class to manipulate gTimer date format.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$ By : $Author$
+ */
+public class GTimerTimeUtil {
+
+ /** Class log */
+ private static Log log = LogFactory.getLog(GTimerTimeUtil.class);
+
+ /** gtimer day string date format */
+ protected static final DateFormat GTIMERDATEFORMAT = new SimpleDateFormat(
+ "yyyyMMdd");
+
+ /**
+ * Protected constructor.
+ */
+ protected GTimerTimeUtil() {
+
+ }
+
+ /**
+ * Convert a yyyyMMdd date string to Calendar.
+ *
+ * @param dateAsString yyyyMMdd sting to convert
+ * @return {@link Date}
+ * @throws IllegalArgumentException
+ */
+ public static Date yyyyMMdd2Date(String dateAsString) {
+
+ int year, mouth, day;
+ Date date = null;
+
+ try {
+ String syear = dateAsString.substring(0, 4);
+ String smonth = dateAsString.substring(4, 6);
+ String sday = dateAsString.substring(6, 8);
+
+ year = Integer.parseInt(syear);
+ mouth = Integer.parseInt(smonth);
+ day = Integer.parseInt(sday);
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(Calendar.YEAR, year);
+ calendar.set(Calendar.MONTH, mouth - 1);
+ calendar.set(Calendar.DAY_OF_MONTH, day);
+
+ date = calendar.getTime();
+ } catch (NumberFormatException e) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse string " + dateAsString + " in yyyyMMdd format",
+ e);
+ }
+ throw new IllegalArgumentException("Can't parse string " + dateAsString
+ + " in yyyyMMdd format", e);
+ }
+
+ return date;
+ }
+
+ /**
+ * Convert a calendar to yyyyMMdd date string.
+ *
+ * @param date date to convert
+ * @return a string yyyyMMdd date
+ * @throws IllegalArgumentException
+ */
+ public static String date2yyyyMMdd(Date date) {
+
+ String dateAsString = GTIMERDATEFORMAT.format(date);
+
+ return dateAsString;
+ }
+}
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/OldTimerAlert.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/OldTimerAlert.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/OldTimerAlert.java 2014-08-08 15:02:24 UTC (rev 3027)
@@ -0,0 +1,133 @@
+package org.chorem.jtimer.io.resources;
+
+import java.io.Serializable;
+
+/**
+ * Alert.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class OldTimerAlert implements Serializable, Cloneable {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 584921087501157113L;
+
+ /**
+ * Alert type.
+ */
+ public enum Type {
+ REACH_DAILY_TIME,
+ REACH_TOTAL_TIME
+ }
+
+ /** Alert type. */
+ protected Type type;
+
+ /** Alert duration. (in ms) */
+ protected long duration;
+
+ /**
+ * Constructor.
+ */
+ public OldTimerAlert() {
+
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param type type
+ * @param duration duration (ms)
+ */
+ public OldTimerAlert(Type type, long duration) {
+ this();
+ this.type = type;
+ this.duration = duration;
+ }
+
+ /**
+ * Get alert type.
+ *
+ * @return the type
+ */
+ public Type getType() {
+ return type;
+ }
+
+ /**
+ * Set alert type.
+ *
+ * @param type the type to set
+ */
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ /**
+ * Get duration.
+ *
+ * @return the duration in seconds
+ */
+ public long getDuration() {
+ return duration;
+ }
+
+ /**
+ * Set duration.
+ *
+ * @param duration the duration to set (in seconds)
+ */
+ public void setDuration(long duration) {
+ this.duration = duration;
+ }
+
+ /*
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public OldTimerAlert clone() {
+ OldTimerAlert clone = null;
+ try {
+ clone = (OldTimerAlert)super.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new RuntimeException("Can't clone", e);
+ }
+ return clone;
+ }
+
+ /*
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ int result = 1;
+ result = 31 * result + (int) (duration ^ (duration >>> 32));
+ result = 31 * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ /*
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ boolean result = false;
+
+ if (obj instanceof OldTimerAlert) {
+ OldTimerAlert other = (OldTimerAlert) obj;
+
+ result = duration == other.duration;
+ if (type != null) {
+ result &= type.equals(other.type);
+ }
+ else {
+ result &= other.type == null;
+ }
+ }
+ return result;
+ }
+}
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/OldTimerProject.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/OldTimerProject.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/OldTimerProject.java 2014-08-08 15:02:24 UTC (rev 3027)
@@ -0,0 +1,66 @@
+package org.chorem.jtimer.io.resources;
+
+/**
+ * Represent a project.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class OldTimerProject extends OldTimerTask {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -8953488997256237790L;
+
+ /** Synchronized project name prefix. */
+ public static final String SYNCHRONIZED_PROJECT_NAME_PREFIX = "#";
+
+ /**
+ * Constructor.
+ */
+ public OldTimerProject() {
+ }
+
+ /**
+ * Constructor with name.
+ *
+ * @param name project name
+ */
+ public OldTimerProject(String name) {
+ super(name);
+ }
+
+ /**
+ * Is synchronized.
+ *
+ * @return the synchronize
+ */
+ public boolean isSynchronized() {
+
+ boolean sync = false;
+
+ if (name != null && name.startsWith(SYNCHRONIZED_PROJECT_NAME_PREFIX)) {
+ sync = true;
+ }
+
+ return sync;
+ }
+
+ /**
+ * Clone project.
+ *
+ * @return project copy
+ */
+ @Override
+ public OldTimerProject clone() {
+
+ // Can't use clone() from super class
+ // Result object have to be
+ OldTimerProject newProject = (OldTimerProject) super.clone();
+
+ return newProject;
+ }
+}
+
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/OldTimerTask.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/OldTimerTask.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/resources/OldTimerTask.java 2014-08-08 15:02:24 UTC (rev 3027)
@@ -0,0 +1,383 @@
+package org.chorem.jtimer.io.resources;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.UUID;
+
+
+
+/**
+ * Represents a task.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class OldTimerTask implements Cloneable,
+ Comparable<OldTimerTask>, Serializable {
+
+ /** serialVersionUID */
+ private static final long serialVersionUID = -7590755569706702695L;
+
+ /** Task uuid used to managed task equality. */
+ protected String uuid = UUID.randomUUID().toString();
+
+ /** Task number. */
+ protected int number;
+
+ /** Task name. */
+ protected String name;
+
+ /** Creation date. */
+ protected Date creationDate;
+
+ /** Closed task. */
+ protected boolean closed;
+
+ /**
+ * Parent Task.
+ * More convenient
+ */
+ protected OldTimerTask parent;
+
+ /**
+ * Map calendar of day -> time (ms). (ordered on keys)
+ */
+ protected SortedMap<Date, Long> allDaysTimes;
+
+ /**
+ * Map date -> annotation text.
+ */
+ protected SortedMap<Date, String> allDaysAnnotations;
+
+ /**
+ * Sub tasks.
+ */
+ protected List<OldTimerTask> subTasks;
+
+ /**
+ * Task alerts.
+ */
+ protected List<OldTimerAlert> alerts;
+
+ /**
+ * Constructor.
+ */
+ public OldTimerTask() {
+ allDaysTimes = new DailySortedMap<Long>();
+ // les annoation sont a la seconde pres
+ allDaysAnnotations = new TreeMap<Date, String>();
+ subTasks = new ArrayList<OldTimerTask>();
+ alerts = new ArrayList<OldTimerAlert>();
+
+ // wrong value to detect bug
+ number = -1;
+ }
+
+ /**
+ * Constructor with name.
+ *
+ * @param name task name
+ */
+ public OldTimerTask(String name) {
+ this();
+ this.name = name;
+ }
+
+ /**
+ * Get task number.
+ *
+ * @return the number
+ */
+ public int getNumber() {
+ return number;
+ }
+
+ /**
+ * Set task number.
+ *
+ * @param number the number to set
+ */
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ /**
+ * Get task name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set task name.
+ *
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get task creation date.
+ *
+ * @return task creation date
+ */
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ /**
+ * Set task creation date.
+ *
+ * @param creationDate creation date
+ */
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ /**
+ * Returns
+ *
+ * @return
+ */
+ public String getUuid() {
+ return uuid;
+ }
+
+ /**
+ * Get closed task state.
+ *
+ * @return <tt>true</tt> if task is closed
+ */
+ public boolean isClosed() {
+ return closed;
+ }
+
+ /**
+ * Set closed.
+ *
+ * @param closed closed
+ */
+ public void setClosed(boolean closed) {
+ this.closed = closed;
+ }
+
+ /**
+ * Get parent.
+ *
+ * Can be null if there is no parent.
+ *
+ * @return the parent
+ */
+ public OldTimerTask getParent() {
+ return parent;
+ }
+
+ /**
+ * Set parent.
+ *
+ * @param parent the parent to set
+ */
+ protected void setParent(OldTimerTask parent) {
+ // will cause an infinite loop
+ if (parent == this) {
+ throw new IllegalArgumentException("Parent can't be current task");
+ }
+ this.parent = parent;
+
+ }
+
+ /**
+ * Get task's subtasks.
+ *
+ * @return the subTasks
+ */
+ public List<OldTimerTask> getSubTasks() {
+ return subTasks;
+ }
+
+ /**
+ * Add task's subtask.
+ *
+ * Also add parent reference.
+ *
+ * @param t the task to add
+ * @return success flag
+ */
+ public boolean addTask(OldTimerTask t) {
+
+ // set parent
+ t.setParent(this);
+ boolean result = subTasks.add(t);
+ return result;
+ }
+
+ /**
+ * Add time.
+ *
+ * @param date date
+ * @param time time in ms
+ */
+ public void setTime(Date date, Long time) {
+ allDaysTimes.put(date, time);
+ }
+
+ /**
+ * Get time at date.
+ *
+ * @param date date
+ * @return time at specified date in ms
+ */
+ public long getTime(Date date) {
+ long result = 0;
+
+ Long t = allDaysTimes.get(date);
+ if (t != null) {
+ result = t.longValue();
+ }
+
+ return result;
+ }
+
+ /**
+ * Return all data. Sorted on date.
+ *
+ * @return total duration of all projects
+ */
+ public SortedMap<Date, Long> getAllDaysAndTimes() {
+ return allDaysTimes;
+ }
+
+ /**
+ * Add annotation.
+ *
+ * @param date date
+ * @param note note text
+ */
+ public void addAnnotation(Date date, String note) {
+ allDaysAnnotations.put(date, note);
+ }
+
+ /**
+ * Return all annotation, sorted on date.
+ *
+ * @return annotations
+ */
+ public SortedMap<Date, String> getAllDaysAnnotations() {
+ return allDaysAnnotations;
+ }
+
+ /**
+ * Add alert.
+ *
+ * @param alert
+ */
+ public void addAlert(OldTimerAlert alert) {
+ alerts.add(alert);
+ }
+
+ /**
+ * Get alert list.
+ *
+ * @return alerts
+ */
+ public List<OldTimerAlert> getAlerts() {
+ return alerts;
+ }
+
+ /**
+ * Set alert.
+ *
+ * @param alerts new alerts list
+ */
+ public void setAlert(List<OldTimerAlert> alerts) {
+ this.alerts = alerts;
+ }
+
+ /*
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return name + subTasks.toString();
+ }
+
+ /*
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ int result = uuid.hashCode();
+ return result;
+ }
+
+ /*
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object o) {
+
+ if (!(o instanceof OldTimerTask)) {
+ return false;
+ }
+
+ return uuid.equals(((OldTimerTask)o).uuid);
+ }
+
+ /**
+ * Clone task.
+ *
+ * @return task copy
+ */
+ @Override
+ public OldTimerTask clone() {
+
+ OldTimerTask task;
+
+ try {
+ task = (OldTimerTask) super.clone();
+
+ // copy date
+ task.creationDate = creationDate == null ? null
+ : (Date) creationDate.clone();
+
+ // make new list instance
+ task.allDaysTimes = new DailySortedMap<Long>(allDaysTimes);
+ task.allDaysAnnotations = new TreeMap<Date, String>(allDaysAnnotations);
+ task.subTasks = new ArrayList<OldTimerTask>(subTasks);
+ } catch (CloneNotSupportedException e) {
+ throw new RuntimeException("Can't clone", e);
+ }
+
+ return task;
+ }
+
+ /*
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo(OldTimerTask o) {
+
+ int result;
+
+ if (getName() == null) {
+ result = -1;
+ } else if (o.getName() == null) {
+ result = 1;
+ } else {
+ // sort on name
+ result = getName().compareTo(o.getName());
+ }
+
+ return result;
+ }
+}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-08-04 15:41:37 UTC (rev 3026)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-08-08 15:02:24 UTC (rev 3027)
@@ -184,19 +184,6 @@
}
- public static boolean containsOneTheGood(Object[] array1, Object[] array2){
- boolean result = ArrayUtils.isEmpty(array1) && ArrayUtils.isEmpty(array2);
- if (array1 != null && array2 != null) {
- //TODO 31/07/2014 obruce optimiser la methode regarder la taille du plus petit tableau
- for (Object o : array1) {
- result = ArrayUtils.contains(array2, o);
- if (result) {
- break;
- }
- }
- }
- return result;
- }
public static boolean containsOne(Object[] array1, Object[] array2){
boolean result = ArrayUtils.isEmpty(array1) && ArrayUtils.isEmpty(array2);
if (array1 != null && array2 != null) {
@@ -211,21 +198,6 @@
return result;
}
- public static boolean containsOneHack2(Object[] array1, Object[] array2){
- boolean result = ArrayUtils.isEmpty(array1) && ArrayUtils.isEmpty(array2);
- if (array1 != null && array2 != null) {
- //TODO 31/07/2014 obruce optimiser la methode regarder la taille du plus petit tableau
- for (Object o : array1) {
- result = ArrayUtils.contains(array2, o);
- if (result) {
- break;
- }
- }
- }
- System.out.println("###"+ArrayUtils.toString(array1)+"#######"+ArrayUtils.toString(array2)+"######## true ?" + result);
- return result;
- }
-
/** Query **/
/**
@@ -379,12 +351,10 @@
statement.setString(2, alarm.getAlarmId());
statement.setString(3, alarm.getName());
statement.setString(4, alarm.getType());
- statement.setInt(5, alarm.getLimitHour());
- statement.setInt(6, alarm.getLimitMin());
- statement.setInt(7, alarm.getRemainingHour());
- statement.setInt(8, alarm.getRemainingMin());
- statement.setObject(9, alarm.getModificationDate());
- statement.setLong(10, alarm.getRemoved());
+ statement.setLong(5, alarm.getDuration());
+ statement.setLong(6, alarm.getRemainingTime());
+ statement.setObject(7, alarm.getModificationDate());
+ statement.setLong(8, alarm.getRemoved());
statement.executeUpdate();
} catch (SQLException ex) {
@@ -543,10 +513,10 @@
alarm.setAlarmId(rs.getString("alarmId"));
alarm.setName(rs.getString("name"));
alarm.setType(rs.getString("type"));
- alarm.setLimitHour(rs.getInt("limitHour"));
+ /* alarm.setLimitHour(rs.getInt("limitHour"));
alarm.setLimitMin(rs.getInt("limitMin"));
alarm.setRemainingHour(rs.getInt("remainingHour"));
- alarm.setRemainingMin(rs.getInt("remainingMin"));
+ alarm.setRemainingMin(rs.getInt("remainingMin"));*/
alarm.setModificationDate(new Date(rs.getTimestamp("modificationDate").getTime()));
alarm.setRemoved(rs.getLong("removed"));
@@ -578,10 +548,8 @@
alarm.setAlarmId(rs.getString("alarmId"));
alarm.setName(rs.getString("name"));
alarm.setType(rs.getString("type"));
- alarm.setLimitHour(rs.getInt("limitHour"));
- alarm.setLimitMin(rs.getInt("limitMin"));
- alarm.setRemainingHour(rs.getInt("remainingHour"));
- alarm.setRemainingMin(rs.getInt("remainingMin"));
+ alarm.setRemainingTime(rs.getLong("remainingTime"));
+ alarm.setDuration(rs.getLong("duration"));
alarm.setModificationDate(new Date(rs.getLong("modificationDate")));
alarm.setRemoved(rs.getLong("removed"));
@@ -875,8 +843,8 @@
try {
statement = getConnection().prepareStatement(config.getStorageQueryUpdateAlarm());
- statement.setLong(1, t.getRemainingHour());
- statement.setLong(2, t.getRemainingMin());
+ /* statement.setLong(1, t.getRemainingHour());
+ statement.setLong(2, t.getRemainingMin());*/
statement.setLong(3, t.getRemoved());
statement.executeUpdate();
@@ -890,9 +858,9 @@
/**
* Methoque qui met à jour le path d'une tache
+ *
* @param taskId l'identifiant de la tache
* @param path l'array representant la tache et ses parents dans l'ordre parent -> enfant
- *
*/
public void updateTaskPath(String taskId, String[] path){
PreparedStatement statement = null;
@@ -910,7 +878,30 @@
}
+ /**
+ * Methode qui va changer l'id d'un temps à une date
+ * @param newId the new taskid
+ * @param oldId the old taskid
+ * @param date the date
+ */
+ public void updateTimeId(String newId,String oldId, Date date ){
+ PreparedStatement statement = null;
+ try {
+ //On update celui du fils
+ statement = getConnection().prepareStatement(config.getStorageQueryUpdateTimeIDWithDate());
+ statement.setString(1, newId);
+ statement.setString(2, oldId);
+ statement.setObject(3, date);
+ statement.executeUpdate();
+ }catch (SQLException ex) {
+ throw new StorageException("Can't modify alarm", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ }
+
+
/** Suppression de tuple **/
/**
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java 2014-08-04 15:41:37 UTC (rev 3026)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java 2014-08-08 15:02:24 UTC (rev 3027)
@@ -5,6 +5,7 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.config.JtimerConfig;
import org.chorem.jtimer.entities.TodoList;
+import org.chorem.jtimer.io.DataHandler;
import org.chorem.jtimer.storage.Storage;
import org.restlet.Application;
import org.restlet.Context;
@@ -76,9 +77,12 @@
//Initialisation du storage
Storage storage = new Storage(jtimerConf);
-
context.getAttributes().put(Storage.class.getName(), storage);
+ DataHandler g = new DataHandler(storage);
+ g.migrateData();
+
+
//initialisation de la todoList
todoList = TodoList.getInstance();
Modified: branches/ng-jtimer/src/main/resources/jtimer-default.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-08-04 15:41:37 UTC (rev 3026)
+++ branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-08-08 15:02:24 UTC (rev 3027)
@@ -2,7 +2,7 @@
# jTimer default properties
###
# jTimer storage path
-jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/BDDDevReu
+jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/BDDImport2
###
# SQL properties
###
@@ -42,10 +42,8 @@
alarmId VARCHAR(255) NOT NULL, \
name VARCHAR(255) NOT NULL, \
type VARCHAR(255) NOT NULL, \
- limitHour INTEGER, \
- limitMin INTEGER, \
- remainingMin INTEGER, \
- remainingHour INTEGER, \
+ duration LONG, \
+ remainingTime LONG, \
modificationDate Timestamp, \
removed LONG, \
PRIMARY KEY (taskId, alarmId), \
@@ -62,8 +60,8 @@
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
jtimer.storage.insert.time=INSERT INTO tasktime (taskid, creationDate, uuid, duration, modificationDate, removed) \
VALUES (?, ?, ?, ?, ?, ?)
-jtimer.storage.insert.alarm=INSERT INTO taskalarm (taskid, alarmId, name, type, limitHour, \
- limitMin, remainingHour, remainingMin, modificationDate, removed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+jtimer.storage.insert.alarm=INSERT INTO taskalarm (taskid, alarmId, name, type, duration, \
+ remainingTime, modificationDate, removed) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
###
#SELECT
jtimer.storage.select.table.name=SELECT table_name FROM information_schema.tables;
@@ -115,9 +113,8 @@
AND TA.removed = 0 \
GROUP BY TA.taskId
jtimer.storage.select.report.byYear=SELECT YEAR(TI.creationDate) as year, TA.*, sum(TI.duration) AS totalduration \
- FROM task TA, tasktime TI \
+ FROM task TA,(Select * FROM tasktime WHERE creationDate BETWEEN ? AND ?) TI \
WHERE TA.taskId = TI.taskid \
- AND TI.creationDate BETWEEN ? AND ? \
AND ARRAY_CONTAINS(TA.path, TA.taskid) \
AND ARRAY_CONTAINS(?, TA.taskid) \
AND TA.removed = 0 \
@@ -206,6 +203,12 @@
jtimer.storage.update.task.path=UPDATE task \
SET path=? \
WHERE taskId = ?
+jtimer.storage.update.time.changeid=UPDATE tasktime \
+ SET taskId=? \
+ WHERE taskId = ?
+jtimer.storage.update.time.changeid.whithdate=UPDATE tasktime \
+ SET taskId=? \
+ WHERE taskId = ? AND creationDate =?
jtimer.storage.update.task.withid=UPDATE task SET name=?, parent=?, hidden=?, description=?, modificationDate=?, tags=?, removed=? \
WHERE taskId = ?
jtimer.storage.update.time.withid=UPDATE tasktime SET creationDate=?, duration=?, modificationDate=?, removed = ? \
Modified: branches/ng-jtimer/src/main/webapp/css/app.css
===================================================================
--- branches/ng-jtimer/src/main/webapp/css/app.css 2014-08-04 15:41:37 UTC (rev 3026)
+++ branches/ng-jtimer/src/main/webapp/css/app.css 2014-08-08 15:02:24 UTC (rev 3027)
@@ -36,6 +36,17 @@
margin-bottom: 0;
}
+.taskBar{
+ position:absolute;
+ bottom:20px;
+ left:0;
+ width:100%;
+ height:30px;
+ z-index: 1000;
+
+ background:gray;
+}
+
div#footer{
position:absolute;
bottom:0;
Modified: branches/ng-jtimer/src/main/webapp/js/app.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/app.js 2014-08-04 15:41:37 UTC (rev 3026)
+++ branches/ng-jtimer/src/main/webapp/js/app.js 2014-08-08 15:02:24 UTC (rev 3027)
@@ -369,10 +369,10 @@
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', function() {
- var message = attrs.ngReallyMessage;
- if (message && confirm(message)) {
- scope.$apply(attrs.ngReallyClick);
- }
+ var message = attrs.ngReallyMessage;
+ if (message && confirm(message)) {
+ scope.$apply(attrs.ngReallyClick);
+ }
});
}
}
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-04 15:41:37 UTC (rev 3026)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-08 15:02:24 UTC (rev 3027)
@@ -44,6 +44,8 @@
$scope.showGlobal = true;
// {boolean} boolean qui indique si la colonne TAGS doit etre affichee
$scope.showTags = true;
+ // {boolean} boolean qui indique si les taches masquees doivent etre affichees
+ $scope.showHidden = false;
// {boolean} etat du client local (le serveur websocket)
$scope.webSocketClientOnline = false;
@@ -73,11 +75,12 @@
var notification = new Notification(
"Notification", {
body: msg,
- icon: "http://www.gizmodo.fr/wp-content/uploads/2013/05/Coin-coin.png"
+ icon: ""
});
}else if (Notification.permission !== 'denied') {
+ // On demande la permission
Notification.requestPermission(function (permission) {
if(!('permission' in Notification)) {
Notification.permission = "granted";
@@ -87,7 +90,7 @@
var notification = new Notification(
"Notification", {
body: msg,
- icon: "http://www.gizmodo.fr/wp-content/uploads/2013/05/Coin-coin.png"
+ icon: ""
});
}
});
@@ -687,13 +690,44 @@
node.addChild($scope.createTreeNode(newTask));
};
+ /**
+ * methode pour faire le masquage reccursivement recursivement
+ * en gardant le temps de la tache et de ses parents dans le parent de la tache
+ */
+ $scope.hideTaskRecurse = function(tasks,bool) {
+
+ angular.forEach(tasks, function(task) {
+ if(bool){
+ task.hide();
+ }else{
+ task.reveal();
+ }
+
+ serverTaskAccess.update({dispatch:true}, angular.toJson(task) ,function(){
+ console.log("update success" + task.taskId);
+ },
+ function(){
+ console.log("fail");
+ $scope.todo.stockedEditedTasks.push(node.task);
+ });
+
+ var children = $scope.getChildren(task);
+ $scope.hideTaskRecurse(children);
+ save();
+ });
+ };
+
/**
* Supprime une tache (et ces sous taches recursivement)
* @param {type} task
*/
- $scope.removeTask = function(node) {
- // methode pour faire la suppression recursivement
- var removeRecurse = function(tasks) {
+ $scope.removeTask = function(node, method) {
+
+ /**
+ * methode pour faire la suppression recursivement
+ */
+ var removeRecurse = function(tasks) {
+
angular.forEach(tasks, function(task) {
task.remove();
@@ -716,10 +750,62 @@
removeRecurse(children);
save();
});
+ };
+ /**
+ * methode pour faire la suppression recursivement
+ * en gardant le temps de la tache et de ses parents dans le parent de la tache
+ */
+ var removeTaskRecurseKeepTime = function(tasks, father) {
+
+ console.log("coucou1");
+
+ angular.forEach(tasks, function(task) {
+
+ var children = $scope.getChildren(task);
+ removeTaskRecurseKeepTime(children,father);
+
+ task.remove();
+
+ delete $scope.data.tasks[task.taskId];
+
+ if($scope.data.times[task.taskId]){
+ if(!$scope.data.times[father]){
+ $scope.data.times[father]=[];
+ }
+
+ // On attache les temps à la tache principal
+ $scope.data.times[father]=$scope.data.times[father].concat($scope.data.times[task.taskId]);
+
+ //TODO persistance
+ }
+
+ // On supprime les temps associes à la tache
+ $scope.data.times[task.taskId] = [];
+
+ console.log("coucou2");
+
+ serverTaskAccess.deleteTask({taskId: task.taskId, dispatch:true}, function(){
+ console.log("delete success" + task.taskId);
+ },
+ function(){
+ console.log("fail");
+ $scope.todo.stockedDeletedTasks.push(task.taskId);
+
+ });
+
+ node.remove();
+ save();
+ });
};
- // mark all task as removed
- removeRecurse([node.task]);
+
+ if(method = 1){
+ // mark all task as removed
+ removeRecurse([node.task]);
+ }else{
+ removeTaskRecurseKeepTime([node.task], node.task.taskId);
+ }
+
// remove node in tree
node.remove();
save();
@@ -796,8 +882,8 @@
* @returns {result}
*/
$scope.getRootTask = function () {
- var result = [];
- angular.forEach($scope.data.tasks, function (t) {
+ var result = [];
+ angular.forEach($scope.data.tasks, function (t) {
if (t.isRoot() && !t.isRemoved()) {
result.push(t);
}
@@ -1067,8 +1153,33 @@
}
});
- }
+ };
+ $scope.dialogPopup = function(node){
+
+ var modalInstance = $modal.open({
+ templateUrl: 'partials/dialogModal.html',
+ controller: DialogModalCtrl,
+ resolve: {}
+ });
+
+ modalInstance.result.then(
+ function(elem) {
+
+ if(elem == 1){
+ // Suppression temps et tache
+ $scope.removeTask(node, 1);
+ }else if(elem == 2){
+ // Suppression taches mais temps reportees au parent
+ $scope.removeTask(node,2);
+ }else{
+ // Masque de la tache
+ $scope.hideTaskRecurse([node.task],true);
+ }
+ }
+ );
+ };
+
$scope.reportPopup = function (){
var modalInstance = $modal.open({
@@ -1081,7 +1192,7 @@
}
}
});
- }
+ };
/**
*Méthode qui lance les actions à faires sur le serveur
@@ -1108,9 +1219,28 @@
}
+/**
+ * Controller pour le dialog de demande de suppression
+ *
+ * @param $scope
+ * @param $modalInstance
+ */
+function DialogModalCtrl($scope, $modalInstance){
+ $scope.supressTaskAndTime = function() {
+ $modalInstance.close(1);
+ };
+ $scope.supressTask = function() {
+ $modalInstance.close(2);
+ };
+ $scope.hideTask = function() {
+ $modalInstance.close(3);
+ };
+}
+
+
/**
* Controller de pour la modal d'option de tache.
*
@@ -1316,7 +1446,7 @@
*/
function ReportModalInstanceCtrl($scope, $modalInstance,$http, $sce, serverReportAccess, tree){
- $scope.modal={radioModel: "Year", showTime : true, tags : false};
+ $scope.modal={radioModel: "Year", showTime : true, tags : false, showHidden : false};
$scope.tree = tree;
$scope.tag = { array : [] };
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-08-04 15:41:37 UTC (rev 3026)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-08-08 15:02:24 UTC (rev 3027)
@@ -406,8 +406,7 @@
*/
var Task = function (name,taskId, parentTaskId, parentTags,description) {
- if(taskId == undefined)
- {
+ if(taskId == undefined){
this.taskId =generateUUID();
}else{
this.taskId = taskId;
@@ -416,8 +415,7 @@
this.modificationDate = Date.now();
this.removed = 0;
- if(parentTaskId == undefined)
- {
+ if(parentTaskId == undefined){
this.parent = "";
}else{
this.parent = parentTaskId;
@@ -426,6 +424,7 @@
this.name = name;
this.description = description;
this.isReported = true;
+ this.hidden = false;
this.alarms=[];
this.tags = parentTags;
this.syncOptions = {};
@@ -440,6 +439,22 @@
};
/**
+ * Marque la tache comme cachee
+ * @returns {undefined}
+ */
+Task.prototype.hide = function() {
+ this.hidden = true;
+};
+
+/**
+ * Marque la tache comme non cachee
+ * @returns {undefined}
+ */
+Task.prototype.reveal = function() {
+ this.hidden = false;
+};
+
+/**
* return vrai si la tache est supprimee
* @returns {boolean}
*/
Added: branches/ng-jtimer/src/main/webapp/partials/dialogModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/dialogModal.html (rev 0)
+++ branches/ng-jtimer/src/main/webapp/partials/dialogModal.html 2014-08-08 15:02:24 UTC (rev 3027)
@@ -0,0 +1,7 @@
+<h4>Supress options : </h4>
+
+<hr/>
+
+<button class="btn btn-default" ng-click="supressTaskAndTime()">Suppress task(and subtasks) and times</button>
+<button class="btn btn-default" ng-click="supressTask()">Suppess only the task (and subtasks)</button>
+<button class="btn btn-default" ng-click="hideTask()">Hide task</button>
Modified: branches/ng-jtimer/src/main/webapp/partials/reportModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-08-04 15:41:37 UTC (rev 3026)
+++ branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-08-08 15:02:24 UTC (rev 3027)
@@ -65,6 +65,10 @@
<input type="checkbox" ng-model="modal.showTime" />
</div>
<div>
+ <span>Show hidden tasks </span>
+ <input type="checkbox" ng-model="modal.showHidden" />
+ </div>
+ <div>
<span>Add tags </span>
<input type="checkbox" ng-model="modal.tags" ng-change="removeTags()"/>
</div>
@@ -93,7 +97,7 @@
<div class="tr" ng-class="{'current-row' : ($node.task === currentTask), 'selected-row' : ($node.task === selectedTask)}">
- <div class="td">
+ <div class="td" ng-show=" !$node.task.hidden || modal.showHidden">
<span class="spacer level{{$level}}"></span>
<!--Task state icon-->
@@ -103,7 +107,8 @@
<!--Project name-->
<input type="checkbox" ng-model="$node.task.isReported" ng-change="setChildrenCheckbox($node)">
- <span>{{$node.task.name}} </span>
+ <span ng-show=" !$node.task.hidden ">{{$node.task.name}} </span>
+ <span ng-show=" $node.task.hidden "><i>*{{$node.task.name}}* </i></span>
</div>
</div>
Modified: branches/ng-jtimer/src/main/webapp/partials/tasks.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-08-04 15:41:37 UTC (rev 3026)
+++ branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-08-08 15:02:24 UTC (rev 3027)
@@ -20,6 +20,7 @@
<li>Today <input type='checkbox' ng-model='showToday'/></li>
<li>Total <input type='checkbox' ng-model='showGlobal'/></li>
<li>Tags <input type='checkbox' ng-model='showTags'/></li>
+ <li>Hidden Tasks <input type='checkbox' ng-model='showHidden'/></li>
</ul>
<i class="glyphicon glyphicon-cloud" ng-class="{online: online, offline: !online}"></i>
</span>
@@ -37,14 +38,12 @@
</div>
-
-
<!-- Footer -->
<div id="footer">
<span class="left">{{currentDate()}}</span>
- <span class="center"><i class="fa fa-html5"></i> <a>WebTimer</a></span>
- <!--<span class="right">{{tree.getTime().today |time}} | {{tree.getTime().global | time}}</span>-->
- <span class="right">jTimer</span>
+ <span class="center"><i class="fa fa-html5 color_red"></i> <a>WebTimer</a></span>
+
+ <span class="right">{{tree.getTime().today |time}} | {{tree.getTime().global | time}}</span>
</div>
@@ -69,14 +68,14 @@
ng-click="setSelectedTask($node.task)"
ng-keydown="keyPressed($event)"><!--ng-dblclick="timeTask($node.task)"-->
- <div class="td" ng-show="showName">
+ <div class="td" ng-show="showName && (!$node.task.hidden || showHidden)">
<span class="spacer level{{$level}}"></span>
<!--Task state icon-->
- <span>
- <i class="glyphicon glyphicon-ban-circle" ng-show="$state=='empty'"></i>
- <i class="glyphicon glyphicon-plus-sign" ng-click="$toggleState()" ng-show="$state=='close'"></i>
- <i class="glyphicon glyphicon-minus-sign" ng-click="$toggleState()" ng-show="$state=='open'"></i>
+ <span >
+ <i style="font-size:10px" class="glyphicon glyphicon-ban-circle" ng-show="$state=='empty'"></i>
+ <i style="font-size:10px" class="glyphicon glyphicon-chevron-right" ng-click="$toggleState()" ng-show="$state=='close'"></i>
+ <i style="font-size:10px" class="glyphicon glyphicon-chevron-down" ng-click="$toggleState()" ng-show="$state=='open'"></i>
<img src="partials/loading_timer.gif" height="20" width="20" ng-show="currentTask == $node.task">
</span>
@@ -85,7 +84,8 @@
<form ng-submit="saveTask($node)" ng-show="$node.edit == 'name'" ng-blur="$node.edit == ''">
<input ng-model="$node.task.name" ng-blur="$node.edit == ''" >
</form>
- <span ng-click="editTask($node, 'name')" ng-show="$node.edit != 'name'">{{$node.task.name}} </span>
+ <span ng-click="editTask($node, 'name')" ng-show="$node.edit != 'name' && !$node.task.hidden ">{{$node.task.name}} </span>
+ <span ng-click="editTask($node, 'name')" ng-show="$node.edit != 'name' && $node.task.hidden "><i>*{{$node.task.name}}* </i></span>
<!-- Action button, add,remove activate task -->
@@ -95,16 +95,19 @@
</a>
<a class="btn btn-default btn-xs" ng-click="addSubTask($node)"><i class="glyphicon glyphicon-plus"></i></a>
<a class="btn btn-default btn-xs"
- ng-really-message="La suppression de cette tâche nécessite une confirmation. "
- ng-really-click="removeTask($node)" ng-show="$node.task != currentTask">
+ ng-click="dialogPopup($node)" ng-show="$node.task != currentTask">
<i class="glyphicon glyphicon-minus"></i>
</a>
<a class="btn btn-default btn-xs"
- ng-really-message="Voulez vous masquer cette tâche?"
- ng-really-click="" ng-show="$node.task != currentTask">
+ ng-really-message="Do you want to hide this task (and subtasks)?"
+ ng-really-click="hideTaskRecurse([$node.task],true)" ng-show="$node.task != currentTask && !$node.task.hidden">
<i class="glyphicon glyphicon-eye-close"></i>
</a>
+ <a class="btn btn-default btn-xs"
+ ng-click="hideTaskRecurse([$node.task],false)" ng-show="$node.task != currentTask && $node.task.hidden">
+ <i class="glyphicon glyphicon-eye-open"></i>
+ </a>
<a class="btn btn-default btn-xs" ng-click="optionPopup($node, $node.task.isRoot())">
<i class="glyphicon glyphicon-pencil" ></i>
@@ -113,17 +116,17 @@
</div>
<!-- Today time of the task -->
- <div class="td today" ng-show="showToday">
+ <div class="td today" ng-show="showToday && (!$node.task.hidden || showHidden)">
{{$node.getTime().today | time}}
</div>
<!-- Global time of the task -->
- <div class="td global" ng-show="showGlobal">
+ <div class="td global" ng-show="showGlobal && (!$node.task.hidden || showHidden)">
{{$node.getTime().global | time}}
</div>
<!-- Tag of the task -->
- <div class="td tags" ng-show="showTags" ng-click="editTask($node, 'tags')">
+ <div class="td tags" ng-show="showTags && (!$node.task.hidden || showHidden)" ng-click="editTask($node, 'tags')">
<form ng-submit="saveTask($node)" ng-show="$node.edit == 'tags'">
<input class="form-control input-sm" ng-model="$node.task.tags" ng-list>
</form>
@@ -148,7 +151,7 @@
<h3 class="modal-title">Inactivité détectée</h3>
</div>
<div class="modal-body">
- Vous êtes inactif depuis 42 minutes.
+ Vous êtes inactif depuis à définir minutes.
Choisissez une option pour reprendre ou arrêter la tâche.
</div>
<div class="modal-footer">
1
0
r3026 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/web webapp/js
by obruce@users.chorem.org 04 Aug '14
by obruce@users.chorem.org 04 Aug '14
04 Aug '14
Author: obruce
Date: 2014-08-04 17:41:37 +0200 (Mon, 04 Aug 2014)
New Revision: 3026
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3026
Log:
Fix controller
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java
branches/ng-jtimer/src/main/webapp/js/controllers.js
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java 2014-08-04 14:28:50 UTC (rev 3025)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java 2014-08-04 15:41:37 UTC (rev 3026)
@@ -46,7 +46,7 @@
public Representation getTask() {
String taskId = (String)getRequest().getAttributes().get("taskId");
Gson gson = new Gson();
- String json = gson.toJson(Long.valueOf(taskId).longValue());
+ String json = gson.toJson(taskId);
return new StringRepresentation( json , MediaType.APPLICATION_JSON);
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java 2014-08-04 14:28:50 UTC (rev 3025)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java 2014-08-04 15:41:37 UTC (rev 3026)
@@ -179,13 +179,6 @@
todoList.pushUpdatedTask(repr1);
log.info("on dispatch update");
}
-
}
-
-
-
}
-
-
-
}
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-04 14:28:50 UTC (rev 3025)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-04 15:41:37 UTC (rev 3026)
@@ -571,10 +571,10 @@
//On change la date au dernier acces
task["modificationDate"]=Date.now();
- serverTaskAccess.create({dispatch:true}, angular.toJson(task), //TODO obruce 04/06/14 dispatch a enlever
+ serverTaskAccess.update({dispatch:true}, angular.toJson(task), //TODO obruce 04/06/14 dispatch a enlever
function(){
console.log("persist task success" + task);
- $scope.todo.stockedNewTasks.shift();
+ $scope.todo.stockedEditedTasks.shift();
},
function(){
console.log("fail");
@@ -859,8 +859,8 @@
$scope.saveTask = function(node) {
node.edit = null;
- serverTaskAccess.update({taskId: node.task.taskId, dispatch:true}, function(){
- console.log("delete success" + task.taskId);
+ serverTaskAccess.update({dispatch:true}, angular.toJson(node.task) ,function(){
+ console.log("update success" + node.task.taskId);
},
function(){
console.log("fail");
1
0
r3025 - in branches/ng-jtimer/src/main/webapp: css js partials
by obruce@users.chorem.org 04 Aug '14
by obruce@users.chorem.org 04 Aug '14
04 Aug '14
Author: obruce
Date: 2014-08-04 16:28:50 +0200 (Mon, 04 Aug 2014)
New Revision: 3025
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3025
Log:
Report: changement dans l'interface
Modified:
branches/ng-jtimer/src/main/webapp/css/app.css
branches/ng-jtimer/src/main/webapp/js/controllers.js
branches/ng-jtimer/src/main/webapp/js/entities.js
branches/ng-jtimer/src/main/webapp/partials/contact.html
branches/ng-jtimer/src/main/webapp/partials/reportModal.html
branches/ng-jtimer/src/main/webapp/partials/tasks.html
Modified: branches/ng-jtimer/src/main/webapp/css/app.css
===================================================================
--- branches/ng-jtimer/src/main/webapp/css/app.css 2014-08-04 12:39:19 UTC (rev 3024)
+++ branches/ng-jtimer/src/main/webapp/css/app.css 2014-08-04 14:28:50 UTC (rev 3025)
@@ -390,6 +390,10 @@
padding-left: 10px;
}
+.paded-top{
+ padding-top: 10px;
+}
+
.divYScrolable {
overflow-y:scroll;
height:170px;
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-04 12:39:19 UTC (rev 3024)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-04 14:28:50 UTC (rev 3025)
@@ -12,14 +12,12 @@
$scope.taskAccess = $scope.todo.lastTaskAccess;
$scope.timeAccess = $scope.todo.lastTimeAccess;
- //
- $scope.currentTaskAlarmState="no-alarm";
-
//interval de conec
- var interval = 30000; //TODO: obruce 05-05-14 decider d'un intervalle interessant
+ var interval = 60000; //TODO: obruce 05-05-14 decider d'un intervalle interessant
// periode de delais = 3 periode +1msec
var delayAccess = interval + 1;
+
// {TreeNode} l'arbre regenere automatiquement lorsque les donnees changent
$scope.tree;
// {Array of Function} les listeners qui surveille l'ajout de nouveau temps, et qui les ajoutes dans l'arbre
@@ -31,9 +29,6 @@
// {Task} la tache en cours de timing
$scope.currentTask = null;
- // {Array of TaskId} la tache en cours de timing
- $scope.activeTask = [];
-
// {Date in millis} le temps pour la tache en cours de timing
$scope.currentTaskDate = null;
// {String} le filtre d'affichage des noeuds (permet la recherche d'un noeud)
@@ -68,6 +63,38 @@
}
};
+ var notifyUser=function (msg) {
+
+ // Let's check if the browser supports notifications
+ if (!("Notification" in window)) {
+ alert("This browser does not support desktop notification");
+
+ }else if (Notification.permission === "granted") {
+ var notification = new Notification(
+ "Notification", {
+ body: msg,
+ icon: "http://www.gizmodo.fr/wp-content/uploads/2013/05/Coin-coin.png"
+
+ });
+
+ }else if (Notification.permission !== 'denied') {
+ Notification.requestPermission(function (permission) {
+ if(!('permission' in Notification)) {
+ Notification.permission = "granted";
+ }
+
+ if (permission === "granted") {
+ var notification = new Notification(
+ "Notification", {
+ body: msg,
+ icon: "http://www.gizmodo.fr/wp-content/uploads/2013/05/Coin-coin.png"
+ });
+ }
+ });
+ }
+ }
+
+
/**
* Methode qui retourne la date de derniere mise a jour(serveur)
* @returns moment
@@ -189,14 +216,14 @@
var limit = alarm.limitHour*60 + alarm.limitMin;
var remaining = alarm.remainingHour*60 + alarm.remainingMin;
- res = ((limit-remaining)/limit)*100;
+ var res = ((limit-remaining)/limit)*100;
- if(res < 50 ){
- $scope.currentTaskAlarmState="alarmOk";
- }else if(res < 80){
- $scope.currentTaskAlarmState="alarmInter";
- }else{
- $scope.currentTaskAlarmState="alarmDanger";
+ if(res == 50 ){
+ //$scope.currentTaskAlarmState="alarmOk";
+ notifyUser("You've already spend half of the time on the task");
+ }else if(res == 80){
+ //$scope.currentTaskAlarmState="alarmInter";
+ notifyUser("You only got 20% of your time");
}
@@ -205,10 +232,8 @@
if(alarm.type=="Total_Time"){
alarms.splice(index,1);
}
- $window.alert('Alarme déclenchée: '+alarm.name + '\nVotre alarme va être désactivée.');
+ notifyUser("Alarms : "+ alarm.name +" end!");
- $scope.currentTaskAlarmState="no-alarm";
-
}
index+=1;
});
@@ -247,7 +272,7 @@
if((!(item.taskId in $scope.data.tasks)) && item.removed == 0){
console.log( "Un element non present " + item.name + item.modificationDate);
- var newTask = new Task( item.name, item.taskId, item.parent);
+ var newTask = new Task( item.name, item.taskId, item.parent, item.tags,item.description);
if(item.parent == "" ){
@@ -314,7 +339,7 @@
console.log("Nouvelle tache" +item.name);
- var newTask = new Task( item.name, item.taskId, item.parent);
+ var newTask = new Task( item.name, item.taskId, item.parent, item.tags,item.description);
if(item.parent == "" ){
@@ -515,7 +540,7 @@
//On supprime de la base les taches sotckees pour suppression
angular.forEach($scope.todo.stockedDeletedTasks, function(task){
- serverTaskAccess.deleteTask({taskId: task,dispatch:true},
+ serverTaskAccess.deleteTask({taskId: task,dispatch:true},
function(){
console.log("delete success" + task);
$scope.todo.stockedDeletedTasks.shift();
@@ -524,12 +549,12 @@
console.log("fail");
});
});
+
//On ajoute au serveur les taches stockees pour l'ajout
angular.forEach($scope.todo.stockedNewTasks, function(task){
//On change la date au dernier acces
task['modificationDate']= Date.now();
-
serverTaskAccess.create({dispatch:true}, angular.toJson(task), //TODO obruce 04/06/14 dispatch a enlever
function(){
console.log("persist task success" + task);
@@ -537,21 +562,24 @@
},
function(){
console.log("fail");
- });
+ }
+ );
});
+
//On ajoute au serveur les taches stockees pour l'ajout
angular.forEach($scope.todo.stockedEditedTasks, function(task){
+
//On change la date au dernier acces
task["modificationDate"]=Date.now();
-
- serverTaskAccess.update({dispatch:true},angular.toJson(task), //TODO
+ serverTaskAccess.create({dispatch:true}, angular.toJson(task), //TODO obruce 04/06/14 dispatch a enlever
function(){
- console.log("update task success" + task);
- $scope.todo.stockedEditedTasks.shift();
+ console.log("persist task success" + task);
+ $scope.todo.stockedNewTasks.shift();
},
function(){
console.log("fail");
- });
+ });
+
});
//On ajoute les nouveaux temps au serveur
@@ -559,15 +587,15 @@
angular.forEach(times, function(time){
//On change la date au dernier acces
time["modificationDate"]=Date.now();
+ serverTimeAccess.create({taskId: task,dispatch:true} , angular.toJson(time),
+ function(){
+ console.log("persist time success" + task);
+ $scope.todo.stockedNewTimes[task].shift();
+ },
+ function(){
+ console.log("fail");
+ });
- serverTimeAccess.create({taskId: task,dispatch:true} , angular.toJson(time),
- function(){
- console.log("persist time success" + task);
- $scope.todo.stockedNewTimes[task].shift();
- },
- function(){
- console.log("fail");
- });
});
});
@@ -576,37 +604,36 @@
angular.forEach(times, function(time){
time["modificationDate"]=Date.now();
-
serverTimeAccess.update({taskId: task,dispatch:true}, angular.toJson(time),
- function(){
- console.log("update time success" + task);
- $scope.todo.stockedEditedTimes[task].shift();
- },
- function(){
- console.log("fail");
- });
- });
+ function(){
+ console.log("update time success" + task);
+ $scope.todo.stockedEditedTimes[task].shift();
+ },
+ function(){
+ console.log("fail");
+ });
+ });
});
//On supprime de la base les taches sotckees pour suppression
angular.forEach($scope.todo.stockedDeletedTimes, function(times,task){
angular.forEach(times, function(time){
+ time["modificationDate"]=Date.now();
serverTimeAccess.deleteTime({taskId: time,dispatch:true},
- function(){
- console.log("delete time success" + task);
- $scope.todo.stockedDeletedTimes[task].shift();
- },
- function(){
- console.log("fail");
- });
+ function(){
+ console.log("delete time success" + task);
+ $scope.todo.stockedDeletedTimes[task].shift();
+ },
+ function(){
+ console.log("fail");
+ }
+ );
});
});
save();
}
-
-
/**
* Ajoute une tache root
*/
@@ -640,7 +667,7 @@
*/
$scope.addSubTask = function(node) {
var task = node.task;
- var newTask = new Task("New task", undefined,task.taskId);
+ var newTask = new Task("New task", undefined,task.taskId, task.tags);
$scope.data.tasks[newTask.taskId] = newTask;
//On synchronise la tache creer
@@ -666,7 +693,7 @@
*/
$scope.removeTask = function(node) {
// methode pour faire la suppression recursivement
- var removeRecurse = function(tasks) {
+ var removeRecurse = function(tasks) {
angular.forEach(tasks, function(task) {
task.remove();
@@ -685,7 +712,6 @@
});
-
var children = $scope.getChildren(task);
removeRecurse(children);
save();
@@ -833,8 +859,14 @@
$scope.saveTask = function(node) {
node.edit = null;
+ serverTaskAccess.update({taskId: node.task.taskId, dispatch:true}, function(){
+ console.log("delete success" + task.taskId);
+ },
+ function(){
+ console.log("fail");
+ $scope.todo.stockedEditedTasks.push(node.task);
+ });
- $scope.todo.stockedEditedTasks.push(node.task);
save();
};
@@ -851,8 +883,17 @@
var taskTime = $scope.getRecentTaskTime($scope.currentTask);
taskTime.addTime(now - $scope.currentTaskDate);
- if(!$scope.todo.stockedNewTimes[task.taskId]){$scope.todo.stockedNewTimes[task.taskId]=[];}
- $scope.todo.stockedNewTimes[task.taskId].push(taskTime);
+ //On pousse la tache
+ serverTimeAccess.create({taskId: task.taskId,dispatch:true} , angular.toJson(taskTime),
+ function(){
+ console.log("persist time success" + task);
+ },
+ function(){
+ console.log("fail");
+ if(!$scope.todo.stockedNewTimes[task.taskId]){$scope.todo.stockedNewTimes[task.taskId]=[];}
+ $scope.todo.stockedNewTimes[task.taskId].push(taskTime);
+ }
+ );
}
//si ce n'est la la tache courante actuel
if ($scope.currentTask !== task) {
@@ -1050,6 +1091,7 @@
if ( $scope.online) {
updateTasksFromServ();
updateTimesFromServer();
+
pushTodoListToServ();
initTasksFromServ();
}
@@ -1274,8 +1316,9 @@
*/
function ReportModalInstanceCtrl($scope, $modalInstance,$http, $sce, serverReportAccess, tree){
- $scope.modal={radioModel: "Year", showTime : true};
+ $scope.modal={radioModel: "Year", showTime : true, tags : false};
$scope.tree = tree;
+ $scope.tag = { array : [] };
/**
@@ -1364,8 +1407,42 @@
};
/**
- *
+ * Method that returns the total time for a task
*/
+ $scope.getTotalPeriodTime = function(node, res, period){
+
+ angular.forEach(node.children, function(child){
+
+ //if there is time on the child we add it, else we try to look on the child's child
+ if($scope.periodTaskData[period][child.task.taskId]){
+ res+= $scope.periodTaskData[period][child.task.taskId];
+ }else{
+ res+= $scope.getTotalPeriodTime(child,0, period);
+ }
+ });
+
+ return res;
+ };
+
+ $scope.getTotalForAllPeriod=function(period){
+ var res = 0;
+
+ res+=$scope.getTotalPeriodTime(tree, res, period);
+
+ return res;
+ };
+
+ $scope.getTotalForAllProject=function(){
+ var res = 0;
+
+ res+=$scope.getTotalProjectTime(tree, res);
+
+ return res;
+ };
+
+ /**
+ * Method that return if the task has time or his subtasks
+ */
$scope.hasSelfOrChildTime= function(collection, node, bool){
if(!bool){
@@ -1383,25 +1460,28 @@
return bool;
};
+ $scope.hasTags = function(node, array){
+ var bool = true;
- /**
- * Method that returns the total time for a task
- */
- $scope.getTotalPeriodTime = function(node, res, period){
+ if(array){
- angular.forEach(node.children, function(child){
-
- //if there is time on the child we add it, else we try to look on the child's child
- if($scope.taskData[period][child.task.taskId]){
- res+= $scope.taskData[period][child.task.taskId];
- }else{
- res+= $scope.getTotalPeriodTime(child,0, period);
+ for (var i = 0, len = node.task.tags.length; i < len; i++) {
+ if (!node.task.tags[i] in array) {
+ bool = false
+ break;
}
- });
+ }
+ }
- return res;
- };
+ return bool;
+ }
+ $scope.removeTags = function(){
+ $scope.tag.array = [];
+ $scope.generateReport();
+ }
+
+
/**
* Methode de generation du rapport
*
@@ -1420,6 +1500,11 @@
$scope.reportedTask = [];
$scope.reportWeek = {};
+ $scope.taskData={};
+
+ /**
+ * Methode qui va reccursivement verifier les taches à repporter
+ */
var recurseGenerateChildReport = function(child){
// On parcours les data pour maj
@@ -1432,15 +1517,17 @@
angular.forEach(tree.children, function(child){recurseGenerateChildReport(child)});
$http({method: "POST", url: "/rest/report",
- params:{start_Date : deb, end_Date : end, type : $scope.modal.radioModel}, data : angular.toJson(toReportTask)})
+ params:{start_Date : deb, end_Date : end, type : $scope.modal.radioModel}, data : angular.toJson([toReportTask, $scope.tag.array])})
.success(function(data){
if($scope.modal.radioModel=='Project'){
+
$scope.taskData = data;
+
}else{
console.log(data);
- $scope.taskData={};
+ $scope.periodTaskData={};
angular.forEach(data, function(array,period){
@@ -1463,9 +1550,9 @@
}
- $scope.taskData[period]={};
+ $scope.periodTaskData[period]={};
angular.forEach(array, function(task){
- $scope.taskData[period][task.taskId]=task.selftime;
+ $scope.periodTaskData[period][task.taskId]=task.selftime;
});
});
}
@@ -1677,6 +1764,7 @@
*
*/
$scope.removeTime = function(ind, item){
+
if(!$scope.todo.stockedDeletedTimes[item.taskId]){
$scope.todo.stockedDeletedTimes[item.taskId] = []
};
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-08-04 12:39:19 UTC (rev 3024)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-08-04 14:28:50 UTC (rev 3025)
@@ -404,7 +404,7 @@
* @param {type} parentTaskId l'identifiant de la tache parente
* @returns {Task}
*/
-var Task = function (name,taskId, parentTaskId) {
+var Task = function (name,taskId, parentTaskId, parentTags,description) {
if(taskId == undefined)
{
@@ -424,10 +424,10 @@
}
this.name = name;
- this.description = "";
+ this.description = description;
this.isReported = true;
this.alarms=[];
- this.tags = [];
+ this.tags = parentTags;
this.syncOptions = {};
};
Modified: branches/ng-jtimer/src/main/webapp/partials/contact.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/contact.html 2014-08-04 12:39:19 UTC (rev 3024)
+++ branches/ng-jtimer/src/main/webapp/partials/contact.html 2014-08-04 14:28:50 UTC (rev 3025)
@@ -1 +1 @@
-jtimer-users(a)listes.chorem.org
+jtimer-users(a)listes.chorem.org
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/webapp/partials/reportModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-08-04 12:39:19 UTC (rev 3024)
+++ branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-08-04 14:28:50 UTC (rev 3025)
@@ -1,5 +1,5 @@
<div>
- <h2>Report :</h2>
+ <h3>Report :</h3>
</div>
<hr/>
@@ -9,7 +9,7 @@
<!-- Datepicker div -->
<div style="border:1px solid black; display : inline-block;vertical-align: top;margin-left:1px;margin-right:1px;">
<h4><u>Option :</u></h4>
- From :
+ <span>From :</span>
<div style="margin-left:2px;" ng-controller="ReportDatePickerCtrl" class="row">
<div class="col-md-6">
<p class="input-group medium_input">
@@ -64,11 +64,23 @@
<span>Show times </span>
<input type="checkbox" ng-model="modal.showTime" />
</div>
+ <div>
+ <span>Add tags </span>
+ <input type="checkbox" ng-model="modal.tags" ng-change="removeTags()"/>
+ </div>
+ <div class="tags" ng-show="modal.tags">
+ <input class="form-control input-sm" ng-model="tag.array" ng-list>
+
+ <span class="label label-info" ng-repeat="tag in tag.array">{{tag}}</span>
+ <button class="btn btn-default btn-sm" ng-click="generateReport()">Generate</button>
+ </div>
+
+
<hr/>
<div>
- <h4><u>Projet :</u></h4>
+ <h4><u>Projects :</u></h4>
<!--la div de l'arbre-->
<div>
@@ -110,10 +122,10 @@
<alert type="info" >
<span contenteditable="true" ng-if="isGenerated" >
- <h4><b>Report :</b></h4>
+
<div ng-if="modal.radioModel=='Project'">
-
+ <h4>Projet :</h4>
<div>
<div class='table'>
@@ -140,7 +152,7 @@
</div>
- <div class="td" ng-show="$node.task.isRoot()" >
+ <div class="td" ng-show="$node.task.isRoot() && modal.showTime" >
<span class="spacer level{{$level}}"></span>
<b> Total : {{getTotalProjectTime($node,0) |time }} </b>
@@ -148,46 +160,53 @@
</div>
</div>
</div>
+ Total: {{getTotalForAllProject()|time}}
</div>
</div>
<!--Report by week/year/month/day -->
<div ng-if="modal.radioModel=='Week' || modal.radioModel=='Year' || modal.radioModel=='Month'|| modal.radioModel=='Day'">
- <div ng-repeat="(period, tasks) in taskData">
- <b> {{modal.radioModel}} : {{period}} </b>
+ <div ng-repeat="(period, tasks) in periodTaskData">
+ <h4> {{modal.radioModel}} : {{period}} </h4>
<div class='table'>
<div class="tbody"
wt-tree-repeat="tree | orderBy:'task.name'"
wt-force-open="true">
- <div class="tr" ng-show="hasSelfOrChildTime(taskData[period],$node,false) || ($node.task.isRoot() && getTotalPeriodTime($node,0, period) != 0 ) ">
+ <div class="tr" ng-show="hasSelfOrChildTime(periodTaskData[period],$node,false) || ($node.task.isRoot() && getTotalPeriodTime($node,0, period) != 0 ) ">
- <div class="td" >
+ <!-- If root task -->
+ <div class="td paded-top" ng-if="$node.task.isRoot()" >
<span class="spacer level{{$level}}"></span>
- <b ng-if="$node.task.isRoot()">Projet : {{$node.task.name}}</b>
- <span ng-if="!$node.task.isRoot()">{{$node.task.name}} </span>
+ <b>Projet : {{$node.task.name}}</b>
</div >
- <div class="td" ng-show="!$node.task.isRoot() && taskData[period][$node.task.taskId] && modal.showTime" >
+ <div class="td paded-top" ng-show="$node.task.isRoot() && modal.showTime" >
<span class="spacer level{{$level}}"></span>
- <span>{{tasks[$node.task.taskId] |time }} </span>
-
+ <b>Total : {{getTotalPeriodTime($node,0,period) |time }} </b>
</div>
- <div class="td" ng-show="$node.task.isRoot()" >
+ <div class="td" ng-if="!$node.task.isRoot()" >
<span class="spacer level{{$level}}"></span>
- <b> Total : {{getTotalPeriodTime($node,0,period) |time }} </b>
+ <span>{{$node.task.name}} </span>
+ </div >
+ <div class="td" ng-show="!$node.task.isRoot() && periodTaskData[period][$node.task.taskId] && modal.showTime" >
+ <span class="spacer level{{$level}}"></span>
+ <span>{{tasks[$node.task.taskId] |time }} </span>
+
</div>
</div>
</div>
</div>
+ Total: {{getTotalForAllPeriod(period)|time}}
+ <hr/>
</div>
</div>
</span >
- <span ng-if="!taskData">
+ <span ng-if="!periodTaskData">
No timed task.
</span>
</alert>
@@ -199,6 +218,5 @@
<div class="modal-footer">
- <button class="btn btn-primary" ng-click="generateReport()">Generate</button>
<button class="btn btn-primary" ng-click="close()">Close</button>
</div>
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/webapp/partials/tasks.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-08-04 12:39:19 UTC (rev 3024)
+++ branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-08-04 14:28:50 UTC (rev 3025)
@@ -8,9 +8,10 @@
</span>
- <!--Header partie droite -->
+ <!--Header partie droite-->
<span class="right">
- <a class="glyphicon glyphicon-cog" ng-click="reportPopup()">Report </a>
+ <i class="glyphicon glyphicon-stop color_red" ng-show="currentTask" ng-click="timeTask(currentTask)">Stop </i>
+ <i class="glyphicon glyphicon-cog" ng-click="reportPopup()">Report </i>
<a class="glyphicon glyphicon-plus-sign" ng-click="showMenu = !showMenu"></a>
<ul class="dropdown-menu" ng-class="{'menu-show': showMenu}">
@@ -43,7 +44,7 @@
<span class="left">{{currentDate()}}</span>
<span class="center"><i class="fa fa-html5"></i> <a>WebTimer</a></span>
<!--<span class="right">{{tree.getTime().today |time}} | {{tree.getTime().global | time}}</span>-->
- <span class="right">Last update : {{getLastMajDate()}}</span>
+ <span class="right">jTimer</span>
</div>
@@ -76,10 +77,7 @@
<i class="glyphicon glyphicon-ban-circle" ng-show="$state=='empty'"></i>
<i class="glyphicon glyphicon-plus-sign" ng-click="$toggleState()" ng-show="$state=='close'"></i>
<i class="glyphicon glyphicon-minus-sign" ng-click="$toggleState()" ng-show="$state=='open'"></i>
- <img ng-class="{'no-alarm' : (currentTaskAlarmState =='no-alarm'),
- 'alarmOk': (currentTaskAlarmState =='alarmOk'),
- 'alarmInter' : (currentTaskAlarmState =='alarmInter'),
- 'alarmDanger': (currentTaskAlarmState =='alarmDanger')}" src="partials/loading_timer.gif" height="20" width="20" ng-show="currentTask == $node.task">
+ <img src="partials/loading_timer.gif" height="20" width="20" ng-show="currentTask == $node.task">
</span>
@@ -102,6 +100,12 @@
<i class="glyphicon glyphicon-minus"></i>
</a>
+ <a class="btn btn-default btn-xs"
+ ng-really-message="Voulez vous masquer cette tâche?"
+ ng-really-click="" ng-show="$node.task != currentTask">
+ <i class="glyphicon glyphicon-eye-close"></i>
+ </a>
+
<a class="btn btn-default btn-xs" ng-click="optionPopup($node, $node.task.isRoot())">
<i class="glyphicon glyphicon-pencil" ></i>
</a>
1
0
r3024 - in branches/ng-jtimer/src/main: go java/org/chorem/jtimer/config java/org/chorem/jtimer/entities java/org/chorem/jtimer/storage java/org/chorem/jtimer/web resources
by obruce@users.chorem.org 04 Aug '14
by obruce@users.chorem.org 04 Aug '14
04 Aug '14
Author: obruce
Date: 2014-08-04 14:39:19 +0200 (Mon, 04 Aug 2014)
New Revision: 3024
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3024
Log:
changement connection storage, ajout dans les config
Modified:
branches/ng-jtimer/src/main/go/ui.go
branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ReportResource.java
branches/ng-jtimer/src/main/resources/jtimer-default.properties
Modified: branches/ng-jtimer/src/main/go/ui.go
===================================================================
--- branches/ng-jtimer/src/main/go/ui.go 2014-08-01 14:59:12 UTC (rev 3023)
+++ branches/ng-jtimer/src/main/go/ui.go 2014-08-04 12:39:19 UTC (rev 3024)
@@ -22,7 +22,7 @@
}
binary, _ := exec.LookPath("chromium")
- return exec.Command(binary, "--app=http://localhost:8080",
+ return exec.Command(binary, "--app=http://localhost:8081",
"--user-data-dir=" + usr.HomeDir + "/.jtimer/chromium")
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java 2014-08-01 14:59:12 UTC (rev 3023)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java 2014-08-04 12:39:19 UTC (rev 3024)
@@ -127,6 +127,10 @@
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_PARENT_TASK.getKey());
}
+ public String getStorageQueryCreateAliasContainsOne (){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_CREATE_ALIAS_CONTAINSONE.getKey());
+ }
+
public String getStorageQuerySelectTimedTask(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_TIMED_TASK.getKey());
}
@@ -163,21 +167,26 @@
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_BYDAY.getKey());
}
- public String getStorageQuerySelectReportTasks(){
- return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_TIMEDTASKS.getKey());
+ public String getStorageQuerySelectReportByProjectAndTags(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_BYPROJECTANDTAG.getKey());
}
- public String getStorageQuerySelectReportRootTask(){
- return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_ROOTTASK.getKey());
+
+ public String getStorageQuerySelectReportByYearAndTags(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_BYYEARANDTAG.getKey());
}
- public String getStorageQuerySelectReportWeekTimedTasks(){
- return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_WEEK_TIMEDTASKS.getKey());
+
+ public String getStorageQuerySelectReportByMonthAndTags(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_BYMONTHANDTAG.getKey());
}
- public String getStorageQuerySelectReportYearTimedTasks(){
- return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_YEAR_TIMEDTASKS.getKey());
+
+ public String getStorageQuerySelectReportByWeekAndTags(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_BYWEEKANDTAG.getKey());
}
- public String getStorageQuerySelectReportMonthTimedTasks(){
- return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_MONTH_TIMEDTASKS.getKey());
+
+ public String getStorageQuerySelectReportByDayAndTags(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_BYDAYANDTAG.getKey());
}
+
public String getStorageQuerySelectAlarmOnDate(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_ALARM_ONDATE.getKey());
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java 2014-08-01 14:59:12 UTC (rev 3023)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java 2014-08-04 12:39:19 UTC (rev 3024)
@@ -52,6 +52,12 @@
"",
String.class
),
+ JTIMER_STORAGE_CREATE_ALIAS_CONTAINSONE(
+ "jtimer.storage.alias.containsone" ,
+ "requête qui va créer l'alias pour la fonction vérifiant les elements",
+ "",
+ String.class
+ ),
JTIMER_STORAGE_CREATE_TABLE_TASK(
"jtimer.storage.create.table.task",
"requête de création la table des tâches",
@@ -178,33 +184,33 @@
"",
String.class
),
- JTIMER_STORAGE_SELECT_REPORT_TIMEDTASKS(
- "jtimer.storage.select.report.timedtasks",
- "requête de selection des taches minutées entre deux bornes",
+ JTIMER_STORAGE_SELECT_REPORT_BYPROJECTANDTAG(
+ "jtimer.storage.select.report.byProjectAndTag",
+ "requête de selection des taches minutées entre deux bornes filtrer par projet",
"",
String.class
),
- JTIMER_STORAGE_SELECT_REPORT_ROOTTASK(
- "jtimer.storage.select.report.roottasks",
- "requête de selection des taches root",
+ JTIMER_STORAGE_SELECT_REPORT_BYYEARANDTAG(
+ "jtimer.storage.select.report.byYearAndTag",
+ "requête de selection des taches minutées entre deux bornes filtrer par year",
"",
String.class
),
- JTIMER_STORAGE_SELECT_REPORT_WEEK_TIMEDTASKS(
- "jtimer.storage.select.report.week.timedtasks",
- "requête de selection des taches minutees sur une semaine",
+ JTIMER_STORAGE_SELECT_REPORT_BYMONTHANDTAG(
+ "jtimer.storage.select.report.byMonthAndTag",
+ "requête de selection des taches minutées entre deux bornes filtrer par month",
"",
String.class
),
- JTIMER_STORAGE_SELECT_REPORT_YEAR_TIMEDTASKS(
- "jtimer.storage.select.report.year.timedtasks",
- "requête de selection des taches minutees sur une annee",
+ JTIMER_STORAGE_SELECT_REPORT_BYWEEKANDTAG(
+ "jtimer.storage.select.report.byWeekAndTag",
+ "requête de selection des taches minutées entre deux bornes filtrer par semaine",
"",
String.class
),
- JTIMER_STORAGE_SELECT_REPORT_MONTH_TIMEDTASKS(
- "jtimer.storage.select.report.month.timedtasks",
- "requête de selection des taches minutees sur un mois",
+ JTIMER_STORAGE_SELECT_REPORT_BYDAYANDTAG(
+ "jtimer.storage.select.report.byDayAndTag",
+ "requête de selection des taches minutées entre deux bornes filtrer par jour",
"",
String.class
),
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2014-08-01 14:59:12 UTC (rev 3023)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2014-08-04 12:39:19 UTC (rev 3024)
@@ -58,6 +58,9 @@
/**ModificationDate*/
protected Date modificationDate;
+ /** Description */
+ protected String description;
+
/** Closed task. */
protected boolean closed;
@@ -70,8 +73,12 @@
/** date if task is removed */
protected long removed;
+ /** Array of ordered parent */
protected String[] path;
+ /** Array of ordered tags */
+ protected String[] tags;
+
/**
* Constructor.
*/
@@ -90,20 +97,15 @@
this.name = name;
this.taskId = UUID.randomUUID().toString();
this.parent = "";
+ this.description="";
this.creationDate = new Date();
this.modificationDate = new Date();
this.removed = 0;
this.path = null;
+ this.tags = null;
}
- public Date getCreationDate() {
- return creationDate;
- }
- public void setCreationDate(Date creationDate) {
- this.creationDate = creationDate;
- }
-
/**
* Set task uuid
*
@@ -211,6 +213,35 @@
public void setRemoved(long removed) {this.removed = removed;}
+
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public void setPath(String[] path) {
+ this.path = path;
+ }
+
+ public void setTags(String[] tags) {
+ this.tags = tags;
+ }
+
+ public String[] getTags() {
+ return this.tags;
+ }
+
@Override
public String toString() {
String res ="TimerTask {" +
@@ -221,16 +252,25 @@
", closed=" + closed +
", todayTime=" + todayTime +
", totalTime=" + totalTime +
- ", removed=" + removed +'}';
+ ", removed=" + removed +
+ ", path=[" ;
- if(path != null)
- res += ",path= " + path.toString();
+ if(path != null){
+ for (String o : path) {
+ res += o + ", ";
+ }
- return res;
+ }
+ res += "], tags=[";
+ if( tags != null) {
+ for (String o : tags) {
+ res += o + ", ";
+ }
+ }
+ return res+"]}";
+
}
- public void setPath(String[] path) {
- this.path = path;
- }
+
}
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-08-01 14:59:12 UTC (rev 3023)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-08-04 12:39:19 UTC (rev 3024)
@@ -1,5 +1,6 @@
package org.chorem.jtimer.storage;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.config.JtimerConfig;
@@ -82,33 +83,42 @@
}
protected Connection getConnection() throws SQLException {
+ if (connection == null) {
+ synchronized (Storage.class) {
+ if (connection == null) {
+ //TODO obruce 07/2014 mettre un pool de connection et pas d'autocommit
+ if (log.isInfoEnabled()) {
+ log.info("Opening connection to database : " + STORAGE_PATH);
+ }
+ Connection conn = DriverManager.getConnection("jdbc:h2:" + STORAGE_PATH, "sa",
+ "");
+ conn.setAutoCommit(true);
- if (log.isInfoEnabled()) {
- log.info("Opening connection to database : " + STORAGE_PATH);
- }
- Connection conn = DriverManager.getConnection("jdbc:h2:" + STORAGE_PATH, "sa",
- "");
- conn.setAutoCommit(true);
+ //TODO modifier pour que ce soit fait une seule fois au demarrage de l'application
+ // test to create schema if it not already exists
+ boolean schemaExists = false; //schemaExists(conn);
+ if (!schemaExists) {
+ if (log.isInfoEnabled()) {
+ log.info("Creating new database schema");
+ }
- // test to create schema if it not already exists
- boolean schemaExists = schemaExists(conn);
- if (!schemaExists) {
- if (log.isInfoEnabled()) {
- log.info("Creating new database schema");
+ createSchema(conn);
+
+ // set new version in schema
+ Statement statement = conn.createStatement();
+ statement.executeUpdate(config.getStorageQueryInsertVersionNumber());
+ }
+ connection = conn;
+ }
}
- createSchema(conn);
-
- // set new version in schema
- Statement statement = conn.createStatement();
- statement.executeUpdate(config.getStorageQueryInsertVersionNumber());
}
-
- return conn;
+ return connection;
}
protected void closeConnection(Connection conn) throws SQLException {
if (conn != null) {
conn.close();
+ conn = null;
}
}
@@ -156,13 +166,16 @@
protected void createSchema(Connection conn) {
Statement statement = null;
try {
+
statement = conn.createStatement();
+ statement.executeUpdate(config.getStorageQueryCreateAliasContainsOne());
statement.executeUpdate(config.getStorageQueryCreateTableVersion());
statement.executeUpdate(config.getStorageQueryCreateTableTask());
statement.executeUpdate(config.getStorageQueryCreateTableTime());
statement.executeUpdate(config.getStorageQueryCreateTableAlarm());
+
} catch (SQLException ex) {
throw new StorageException("Can't create schema", ex);
} finally {
@@ -171,6 +184,48 @@
}
+ public static boolean containsOneTheGood(Object[] array1, Object[] array2){
+ boolean result = ArrayUtils.isEmpty(array1) && ArrayUtils.isEmpty(array2);
+ if (array1 != null && array2 != null) {
+ //TODO 31/07/2014 obruce optimiser la methode regarder la taille du plus petit tableau
+ for (Object o : array1) {
+ result = ArrayUtils.contains(array2, o);
+ if (result) {
+ break;
+ }
+ }
+ }
+ return result;
+ }
+ public static boolean containsOne(Object[] array1, Object[] array2){
+ boolean result = ArrayUtils.isEmpty(array1) && ArrayUtils.isEmpty(array2);
+ if (array1 != null && array2 != null) {
+ //TODO 31/07/2014 obruce optimiser la methode regarder la taille du plus petit tableau
+ for (Object o : array1) {
+ result = ArrayUtils.contains(array2, o);
+ if (result) {
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ public static boolean containsOneHack2(Object[] array1, Object[] array2){
+ boolean result = ArrayUtils.isEmpty(array1) && ArrayUtils.isEmpty(array2);
+ if (array1 != null && array2 != null) {
+ //TODO 31/07/2014 obruce optimiser la methode regarder la taille du plus petit tableau
+ for (Object o : array1) {
+ result = ArrayUtils.contains(array2, o);
+ if (result) {
+ break;
+ }
+ }
+ }
+ System.out.println("###"+ArrayUtils.toString(array1)+"#######"+ArrayUtils.toString(array2)+"######## true ?" + result);
+ return result;
+ }
+
/** Query **/
/**
@@ -182,7 +237,7 @@
int result = 0;
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQuerySelectCountTask());
+ statement = getConnection().prepareStatement(config.getStorageQuerySelectCountTask());
ResultSet rs = statement.executeQuery();
if (rs.next()) {
@@ -209,23 +264,25 @@
PreparedStatement statement2;
try {
- statement = connection.prepareStatement(config.getStorageQueryInsertTask());
+ statement = getConnection().prepareStatement(config.getStorageQueryInsertTask());
statement.setString(1, task.getName());
statement.setString(2, task.getParent());
statement.setString(3, task.getTaskId());
statement.setBoolean(4, task.isClosed());
- statement.setString(5, null /*project.getNote()*/);
+ statement.setString(5, task.getDescription());
statement.setObject(6, task.getCreationDate());
statement.setObject(7, task.getModificationDate());
statement.setLong(8,task.getRemoved());
+ //statement.setObject(9,task.getTags());
+
statement.executeUpdate();
- String[] array;
+ String[] path;
//On recupere le path du parent
if(!task.getParent().equals("")) {
- statement2 = connection.prepareStatement(config.getStorageQuerySelectPath());
+ statement2 = getConnection().prepareStatement(config.getStorageQuerySelectPath());
//On insere l'identifiant du parent
statement2.setString(1, task.getParent());
@@ -234,17 +291,18 @@
try {
rs.first();
String[] parentArray = (String[]) rs.getObject("path");
- array = Arrays.copyOf(parentArray, parentArray.length + 1);
- array[parentArray.length] = task.getTaskId();
+ path = Arrays.copyOf(parentArray, parentArray.length + 1);
+ path[parentArray.length] = task.getTaskId();
+
}catch(JdbcSQLException eee){
log.error(eee);
- array = new String[]{task.getTaskId()};
+ path = new String[]{task.getTaskId()};
}
} else {
- array = new String[]{task.getTaskId()};
+ path = new String[]{task.getTaskId()};
}
- updateTaskPath(task.getTaskId(), array);
+ updateTaskPath(task.getTaskId(), path);
} catch (SQLException ex) {
@@ -266,7 +324,7 @@
public void addTaskTime(TimerTask task, Date date, String uuid, long duration) {
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQueryInsertTime());
+ statement = getConnection().prepareStatement(config.getStorageQueryInsertTime());
statement.setString(1, task.getTaskId());
statement.setObject(2, new Date());
@@ -289,7 +347,7 @@
public void addTaskTime(TimerTime time) {
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQueryInsertTime());
+ statement = getConnection().prepareStatement(config.getStorageQueryInsertTime());
statement.setString(1, time.getTaskId());
statement.setObject(2, time.getCreationDate());
@@ -315,7 +373,7 @@
public void addTaskAlarm(TimerAlarm alarm) {
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQueryInsertAlarm());
+ statement = getConnection().prepareStatement(config.getStorageQueryInsertAlarm());
statement.setString(1, alarm.getTaskId());
statement.setString(2, alarm.getAlarmId());
@@ -346,7 +404,7 @@
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQuerySelectTaskTimeWithDate());
+ statement = getConnection().prepareStatement(config.getStorageQuerySelectTaskTimeWithDate());
statement.setObject(1, new Date(date));
ResultSet rs = statement.executeQuery();
@@ -382,7 +440,7 @@
PreparedStatement statement2 = null;
try {
- statement = connection.prepareStatement(config.getStorageQuerySelectTimedTask());
+ statement = getConnection().prepareStatement(config.getStorageQuerySelectTimedTask());
statement.setObject(1, new Date(date));
log.debug(statement.toString());
@@ -394,9 +452,7 @@
task.setName(rs.getString("name"));
task.setParent(rs.getString("parent"));
task.setRemoved(rs.getLong("removed"));
-
-
-
+ task.setDescription(rs.getString("description"));
task.setTodayTime(0);
task.setCreationDate(new java.util.Date((rs.getTimestamp("creationDate").getTime())));
task.setModificationDate(new java.util.Date(rs.getTimestamp("modificationDate").getTime()));
@@ -405,7 +461,7 @@
}
// not timed tasks
- statement2 = connection.prepareStatement(config.getStorageQuerySelectNotTimedTask());
+ statement2 = getConnection().prepareStatement(config.getStorageQuerySelectNotTimedTask());
statement2.setObject(1, new Date(date));
rs = statement2.executeQuery();
@@ -414,11 +470,13 @@
task.setName(rs.getString("name"));
task.setTaskId(rs.getString("taskId"));
task.setParent(rs.getString("parent"));
+ task.setDescription(rs.getString("description"));
task.setCreationDate(new java.util.Date((rs.getTimestamp("creationDate").getTime())));
task.setModificationDate(new java.util.Date(rs.getTimestamp("modificationDate").getTime()));
task.setRemoved(rs.getLong("removed"));
task.setTodayTime(0);
task.setTotalTime(0);
+
tasks.add(task);
}
} catch (SQLException ex) {
@@ -440,7 +498,7 @@
List<TimerTime> times = new ArrayList<>();
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQuerySelectNotRemovedTaskTime());
+ statement = getConnection().prepareStatement(config.getStorageQuerySelectNotRemovedTaskTime());
statement.setString(1, taskid);
statement.setObject(2, new Date(date));
@@ -475,7 +533,7 @@
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQuerySelectAlarmOnDate());
+ statement = getConnection().prepareStatement(config.getStorageQuerySelectAlarmOnDate());
statement.setObject(1, new Date(date));
ResultSet rs = statement.executeQuery();
@@ -509,7 +567,7 @@
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQuerySelectAlarmWithTaskID());
+ statement = getConnection().prepareStatement(config.getStorageQuerySelectAlarmWithTaskID());
statement.setObject(1, new Date(date));
statement.setString(2, taskId);
@@ -544,19 +602,20 @@
* @param endDate la borne superieur
* @return un hashmap {key: Id, value: task}
*/
- public HashMap<String, ReportTask> getReportByProject(Long startDate, Long endDate, String[] toReport){
+ public HashMap<String, ReportTask> getReportByProject(Long startDate, Long endDate, String[] toReport ){
HashMap<String, ReportTask> map = new HashMap<>();
PreparedStatement statement = null;
try{
- statement = connection.prepareStatement(config.getStorageQuerySelectReportByProject());
+ statement = getConnection().prepareStatement(config.getStorageQuerySelectReportByProject());
statement.setObject(1, new Date(startDate));
statement.setObject(2, new Date(endDate));
statement.setObject(3, toReport);
+
ResultSet rs = statement.executeQuery();
while(rs.next()) {
@@ -580,40 +639,35 @@
}
/**
- * Methode qui retourne les taches minutees entre deux bornes par jour
- * @param startDate borne inferieur
+ * Methode qui retourne les taches minutees entre deux bornes par projet
+ * @param startDate la borne inferieur
* @param endDate la borne superieur
- * @return un hashmap {key: parentId, value: array of task}
+ * @return un hashmap {key: Id, value: task}
*/
- public HashMap<String,Set<ReportTask>> getReportByDay(Long startDate, Long endDate, String[] toReport){
- HashMap<String,Set<ReportTask>> res = new HashMap<>();
+ public HashMap<String, ReportTask> getReportByProjectAndTags(Long startDate, Long endDate, String[] toReport, String[] wantedTags){
+
+ HashMap<String, ReportTask> map = new HashMap<>();
+
PreparedStatement statement = null;
try{
- statement = connection.prepareStatement(config.getStorageQuerySelectReportByDay());
- // les bornes
+ statement = getConnection().prepareStatement(config.getStorageQuerySelectReportByProjectAndTags());
+
statement.setObject(1, new Date(startDate));
statement.setObject(2, new Date(endDate));
statement.setObject(3, toReport);
+ statement.setObject(4, wantedTags);
ResultSet rs = statement.executeQuery();
while(rs.next()) {
- String period = rs.getString("day")+" - " +rs.getString("month") +" - "+ rs.getString("year");
-
- //Si le Year n'est pas présent
- if(res.get(period)==null) {
- res.put(period, new HashSet<ReportTask>());
- }
-
String name = rs.getString("name");
String taskId = rs.getString("taskId");
long totalDuration = rs.getLong("totalduration");
ReportTask task = new ReportTask(name,taskId,totalDuration);
- //On ajoute le resultat: year, set de reportTask
- res.get(period).add(task);
+ map.put(taskId, task);
}
}catch(SQLException ex) {
@@ -622,62 +676,33 @@
closeStatement(statement);
}
- return res;
+
+ return map;
}
/**
- * Methode qui retourne les taches minutees entre deux bornes par semaine
- * @param startDate borne inferieur
- * @param endDate la borne superieur
- * @return un hashmap {key: parentId, value: array of task}
+ * Method that returns the collection of timed tasks for a time interval grouped by period
+ * @param startDate the start date
+ * @param endDate the end date
+ * @param toReport task to be reported
+ * @return the collection of timed tasks
*/
- public HashMap<String,Set<ReportTask>> getReportByWeek(Long startDate, Long endDate, String[] toReport){
+ public HashMap<String,Set<ReportTask>> getReportByPeriod(Long startDate, Long endDate, String[] toReport, String type){
+
HashMap<String,Set<ReportTask>> res = new HashMap<>();
PreparedStatement statement = null;
try{
- statement = connection.prepareStatement(config.getStorageQuerySelectReportByWeek());
- // les bornes
- statement.setObject(1, new Date(startDate));
- statement.setObject(2, new Date(endDate));
- statement.setObject(3, toReport);
-
- ResultSet rs = statement.executeQuery();
- while(rs.next()) {
-
- String period = rs.getString("week") +" - "+ rs.getString("year");
-
- //Si le Year n'est pas présent
- if(res.get(period)==null) {
- res.put(period, new HashSet<ReportTask>());
- }
-
- String name = rs.getString("name");
- String taskId = rs.getString("taskId");
- long totalDuration = rs.getLong("totalduration");
-
- ReportTask task = new ReportTask(name,taskId,totalDuration);
-
- //On ajoute le resultat: year, set de reportTask
- res.get(period).add(task);
+ if("Year".equals(type)){
+ statement = getConnection().prepareStatement(config.getStorageQuerySelectReportByYear());
+ }else if("Month".equals(type)){
+ statement = getConnection().prepareStatement(config.getStorageQuerySelectReportByMonth());
+ }else if("Week".equals(type)){
+ statement = getConnection().prepareStatement(config.getStorageQuerySelectReportByWeek());
+ }else{
+ statement = getConnection().prepareStatement(config.getStorageQuerySelectReportByDay());
}
- }catch(SQLException ex) {
- throw new StorageException("Can't get report", ex);
- } finally {
- closeStatement(statement);
- }
-
- return res;
- }
-
- public HashMap<String,Set<ReportTask>> getReportByMonth(Long startDate, Long endDate, String[] toReport){
-
- HashMap<String,Set<ReportTask>> res = new HashMap<>();
- PreparedStatement statement = null;
-
- try{
- statement = connection.prepareStatement(config.getStorageQuerySelectReportByMonth());
// les bornes
statement.setObject(1, new Date(startDate));
statement.setObject(2, new Date(endDate));
@@ -685,9 +710,17 @@
ResultSet rs = statement.executeQuery();
while(rs.next()) {
+ String period;
+ if("Year".equals(type)){
+ period = rs.getString("year");
+ }else if("Month".equals(type)){
+ period = rs.getString("month") +" - "+ rs.getString("year");
+ }else if("Week".equals(type)){
+ period = rs.getString("week") +" - "+ rs.getString("year");
+ }else {
+ period = rs.getString("day") + " - " + rs.getString("month") + " - " + rs.getString("year");
+ }
- String period = rs.getString("month") +" - "+ rs.getString("year");
-
//Si le Year n'est pas présent
if(res.get(period)==null) {
res.put(period, new HashSet<ReportTask>());
@@ -713,32 +746,51 @@
}
/**
- * Method that returns the collection of timed tasks
+ * Method that returns the collection of timed tasks for a time interval grouped by period
* @param startDate the start date
* @param endDate the end date
* @param toReport task to be reported
* @return the collection of timed tasks
*/
- public HashMap<String,Set<ReportTask>> getReportByYear(Long startDate, Long endDate, String[] toReport){
+ public HashMap<String,Set<ReportTask>> getReportByPeriodAndTags(Long startDate, Long endDate, String[] toReport,String[] tags, String type){
HashMap<String,Set<ReportTask>> res = new HashMap<>();
PreparedStatement statement = null;
try{
- statement = connection.prepareStatement(config.getStorageQuerySelectReportByYear());
+ if("Year".equals(type)){
+ statement = getConnection().prepareStatement(config.getStorageQuerySelectReportByYearAndTags());
+ }else if("Month".equals(type)){
+ statement = getConnection().prepareStatement(config.getStorageQuerySelectReportByMonthAndTags());
+ }else if("Week".equals(type)){
+ String sql = config.getStorageQuerySelectReportByWeekAndTags();
+ statement = getConnection().prepareStatement(sql);
+ }else{
+ statement = getConnection().prepareStatement(config.getStorageQuerySelectReportByDayAndTags());
+ }
+
// les bornes
statement.setObject(1, new Date(startDate));
statement.setObject(2, new Date(endDate));
statement.setObject(3, toReport);
+ statement.setObject(4, tags);
ResultSet rs = statement.executeQuery();
while(rs.next()) {
+ String period;
+ if("Year".equals(type)){
+ period = rs.getString("year");
+ }else if("Month".equals(type)){
+ period = rs.getString("month") +" - "+ rs.getString("year");
+ }else if("Week".equals(type)){
+ period = rs.getString("week") +" - "+ rs.getString("year");
+ }else {
+ period = rs.getString("day") + " - " + rs.getString("month") + " - " + rs.getString("year");
+ }
- String year = rs.getString("year");
-
//Si le Year n'est pas présent
- if(res.get(year)==null) {
- res.put(year, new HashSet<ReportTask>());
+ if(res.get(period)==null) {
+ res.put(period, new HashSet<ReportTask>());
}
String name = rs.getString("name");
@@ -748,7 +800,7 @@
ReportTask task = new ReportTask(name,taskId,totalDuration);
//On ajoute le resultat: year, set de reportTask
- res.get(year).add(task);
+ res.get(period).add(task);
}
}catch(SQLException ex) {
@@ -770,16 +822,17 @@
public void modifyTask(TimerTask task) {
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQueryUpdateTask());
+ statement = getConnection().prepareStatement(config.getStorageQueryUpdateTask());
statement.setString(1, task.getName()); //name
statement.setString(2, task.getParent()); //parent
statement.setBoolean(3, task.isClosed()); //hidden
- statement.setString(4, null /*project.getNote()*/);//note
+ statement.setString(4, task.getDescription());//note
statement.setObject(5, task.getModificationDate()); //modificationDate
+ statement.setObject(6,task.getTags());
- statement.setLong(6,task.getRemoved());
- statement.setString(7, task.getTaskId()); //taskId
+ statement.setLong(7,task.getRemoved());
+ statement.setString(8, task.getTaskId()); //taskId
statement.executeUpdate();
} catch (SQLException ex) {
@@ -796,7 +849,7 @@
public void modifyTime(TimerTime t) {
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQueryUpdateTime());
+ statement = getConnection().prepareStatement(config.getStorageQueryUpdateTime());
statement.setObject(1, t.getCreationDate());
statement.setLong(2, t.getTime());
@@ -820,7 +873,7 @@
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQueryUpdateAlarm());
+ statement = getConnection().prepareStatement(config.getStorageQueryUpdateAlarm());
statement.setLong(1, t.getRemainingHour());
statement.setLong(2, t.getRemainingMin());
@@ -838,15 +891,15 @@
/**
* Methoque qui met à jour le path d'une tache
* @param taskId l'identifiant de la tache
- * @param array l'array representant la tache et ses parents dans l'ordre parent -> enfant
+ * @param path l'array representant la tache et ses parents dans l'ordre parent -> enfant
*
*/
- public void updateTaskPath(String taskId, String[] array){
+ public void updateTaskPath(String taskId, String[] path){
PreparedStatement statement = null;
try {
//On update celui du fils
- statement = connection.prepareStatement(config.getStorageQueryUpdateTaskPath());
- statement.setObject(1, array);
+ statement = getConnection().prepareStatement(config.getStorageQueryUpdateTaskPath());
+ statement.setObject(1, path);
statement.setString(2, taskId);
statement.executeUpdate();
}catch (SQLException ex) {
@@ -868,7 +921,7 @@
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQueryDeleteTime());
+ statement = getConnection().prepareStatement(config.getStorageQueryDeleteTime());
statement.setString(1, timeId);
statement.executeUpdate();
} catch (SQLException ex) {
@@ -886,7 +939,7 @@
public void deleteTaskWithId(String taskId) {
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQueryDeleteTask());
+ statement = getConnection().prepareStatement(config.getStorageQueryDeleteTask());
statement.setString(1, taskId);
statement.executeUpdate();
} catch (SQLException ex) {
@@ -907,7 +960,7 @@
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQueryUpdateTimeToRemove());
+ statement = getConnection().prepareStatement(config.getStorageQueryUpdateTimeToRemove());
statement.setLong(1, time);
statement.setObject(2, new Date(time));
@@ -929,7 +982,7 @@
public void removeTaskWithId(String taskId, long time) {
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQueryUpdateTaskToRemove());
+ statement = getConnection().prepareStatement(config.getStorageQueryUpdateTaskToRemove());
statement.setLong(1, time);
statement.setObject(2, new Date(time));
@@ -948,7 +1001,7 @@
public void removeAlarmWithId(String alarmId, long time) {
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement(config.getStorageQueryUpdateAlarmToRemove());
+ statement = getConnection().prepareStatement(config.getStorageQueryUpdateAlarmToRemove());
statement.setLong(1, time);
statement.setObject(2, new Date(time));
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ReportResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ReportResource.java 2014-08-01 14:59:12 UTC (rev 3023)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ReportResource.java 2014-08-04 12:39:19 UTC (rev 3024)
@@ -15,7 +15,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.Set;
/**
* Created by olivia on 11/06/14.
@@ -44,12 +43,18 @@
@Post("json")
public Representation getReport(Representation representation) throws IOException {
// Les elements voulus par l'interface
+ String[][] tmp;
String[] toReport;
+ String[] wantedTags;
+ //On recupere les elements
String repr1 = representation.getText();
Gson gson = new Gson();
- toReport = gson.fromJson(repr1, String[].class);
+ tmp = gson.fromJson(repr1, String[][].class);
+ //On extrait les elements voulus
+ toReport = tmp[0];
+ wantedTags = tmp[1];
String json="[No data]";
String type ="";
@@ -81,102 +86,38 @@
//On ne recupere que les elements interessants
gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
- if(type.equals("Project")) {
+ if(wantedTags.length == 0) {
+ if (type.equals("Project")) {
- HashMap<String, ReportTask> storedTask = storage.getReportByProject(startDate, endDate,toReport);
- json = gson.toJson(storedTask, HashMap.class);
+ HashMap<String, ReportTask> storedTask = storage.getReportByProject(startDate, endDate, toReport);
+ json = gson.toJson(storedTask, HashMap.class);
- }else if(type.equals("Day")){
+ } else {
- HashMap storedTask = storage.getReportByDay(startDate, endDate, toReport);
- json = gson.toJson(storedTask, HashMap.class);
+ HashMap storedTask = storage.getReportByPeriod(startDate, endDate, toReport, type);
+ json = gson.toJson(storedTask, HashMap.class);
- }else if(type.equals("Month")){
+ }
+ }else{
- HashMap storedTask = storage.getReportByMonth(startDate, endDate, toReport);
- json = gson.toJson(storedTask, HashMap.class);
+ if (type.equals("Project")) {
- }else if(type.equals("Week")){
+ HashMap<String, ReportTask> storedTask = storage.getReportByProjectAndTags(startDate, endDate, toReport, wantedTags);
+ json = gson.toJson(storedTask, HashMap.class);
- HashMap storedTask = storage.getReportByWeek(startDate, endDate, toReport);
- json = gson.toJson(storedTask, HashMap.class);
+ } else {
- }else if(type.equals("Year")){
+ HashMap storedTask = storage.getReportByPeriodAndTags(startDate, endDate, toReport, wantedTags, type);
+ json = gson.toJson(storedTask, HashMap.class);
- HashMap storedTask = storage.getReportByYear(startDate, endDate,toReport);
- json = gson.toJson(storedTask, HashMap.class);
-
+ }
}
return new StringRepresentation(json);
}
- /**
- * Method that sorts in a array a mapped tree
- * @param map the map to sort
- * @param rt the current task
- * @param res the tree array
- */
- private void recursivSortTask(HashMap<String,Set<ReportTask>> map, ReportTask rt, ArrayList<ReportTask> res ){
- if(map.containsKey(rt.getTaskId())) {
- for (ReportTask child : map.get(rt.getTaskId())) {
- //On attache le parent
- child.setRtParent(rt);
-
- //Appel recursif sur les enfants
- recursivSortTask(map, child, res);
-
- //Si le noeud enfant est a du temps alors on l'ajoute
- if(child.getSelftime()!= (long) 0 || child.getChildtime()!= (long) 0){
- rt.addChild(child);
- rt.addChildTime(child.getSelftime());
- }
- }
- }
-
- if(rt.getParentId().equals("") && rt.getChildtime() != 0){
- res.add(rt);
- }
- }
-
/**
- * Methode reccursive qui enleve les elements indesirables
- * @param toCheck la liste a verifiee
- * @param wanted la liste d'identifiant voulu
- */
- private void recursiveRemoveUnreportedTask(ArrayList<ReportTask> toCheck, ArrayList<String> wanted){
- //iterator sur l'arraylist a checker
- Iterator<ReportTask> iter = toCheck.iterator();
-
- while(iter.hasNext()) {
- //Le noeud courant
- ReportTask repT= iter.next();
-
- //Le noeud a des enfants
- if(!repT.getSubtasks().isEmpty()) {
- //On va supprimer les noeuds non souhaites dans les enfants
- recursiveRemoveUnreportedTask(repT.getSubtasks(), wanted);
- }
- //On vérifie si dans la liste des elements voulus
- if(!idIsInArray(repT.getTaskId(),wanted) ){
- if(repT.hasParent()) {
- repT.getRtParent().removeChildTime(repT.getSelftime());
- //repT.setSelfTime((long)0);
-
- }
- if(repT.getChildtime() == 0){
- iter.remove();
- }
-
-
- }
-
- }
-
- }
-
- /**
* Methode qui détermine si l'id est dans la collection
* @param id l'identifiant a trouver
* @param list la list a parcourir
Modified: branches/ng-jtimer/src/main/resources/jtimer-default.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-08-01 14:59:12 UTC (rev 3023)
+++ branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-08-04 12:39:19 UTC (rev 3024)
@@ -2,7 +2,7 @@
# jTimer default properties
###
# jTimer storage path
-jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/BDDNNe
+jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/BDDDevReu
###
# SQL properties
###
@@ -13,8 +13,8 @@
jtimer.storage.table.alarm=taskalarm
###
#CREATE SCHEMA
-jtimer.storage.create.table.version=CREATE TABLE version (version VARCHAR(10))
-jtimer.storage.create.table.task=CREATE TABLE task \
+jtimer.storage.create.table.version=CREATE TABLE IF NOT EXISTS version (version VARCHAR(10))
+jtimer.storage.create.table.task=CREATE TABLE IF NOT EXISTS task \
(taskId VARCHAR(255) NOT NULL, \
name VARCHAR(255) NOT NULL, \
parent VARCHAR(255), \
@@ -22,10 +22,11 @@
modificationDate Timestamp, \
hidden BOOLEAN, \
path ARRAY, \
- note TEXT, \
+ description TEXT, \
+ tags ARRAY, \
removed LONG, \
PRIMARY KEY (taskId))
-jtimer.storage.create.table.time=CREATE TABLE tasktime \
+jtimer.storage.create.table.time=CREATE TABLE IF NOT EXISTS tasktime \
(taskid VARCHAR(255) NOT NULL, \
creationDate Timestamp, \
uuid varchar(255) unique, \
@@ -36,7 +37,7 @@
FOREIGN KEY (taskid) \
REFERENCES task (taskId) \
ON DELETE CASCADE)
-jtimer.storage.create.alarm=CREATE TABLE taskalarm \
+jtimer.storage.create.alarm=CREATE TABLE IF NOT EXISTS taskalarm \
(taskId VARCHAR(255) NOT NULL, \
alarmId VARCHAR(255) NOT NULL, \
name VARCHAR(255) NOT NULL, \
@@ -52,9 +53,12 @@
REFERENCES task (taskId) \
ON DELETE CASCADE)
####
+#ALIAS
+jtimer.storage.alias.containsone=CREATE ALIAS IF NOT EXISTS ARRAY_CONTAINS_ONE FOR "org.chorem.jtimer.storage.Storage.containsOne";
+####
#INSERT
jtimer.storage.insert.version.number=INSERT INTO VERSION VALUES('2.0')
-jtimer.storage.insert.task=INSERT INTO task (name, parent, taskId, hidden, note,creationDate, modificationDate, removed) \
+jtimer.storage.insert.task=INSERT INTO task (name, parent, taskId, hidden, description,creationDate, modificationDate, removed) \
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
jtimer.storage.insert.time=INSERT INTO tasktime (taskid, creationDate, uuid, duration, modificationDate, removed) \
VALUES (?, ?, ?, ?, ?, ?)
@@ -142,30 +146,50 @@
AND ARRAY_CONTAINS(?, TA.taskid) \
AND TA.removed = 0 \
GROUP BY TA.taskId , day, month, year
-jtimer.storage.select.report.roottasks=SELECT * \
- FROM task \
- WHERE (taskId not in (SELECT taskid FROM tasktime) AND removed = 0 )
-jtimer.storage.select.report.week.timedtasks=SELECT WEEK(TI.creationDate) as week, YEAR(TI.creationDate) as year, TA.* , sum(TI.duration) AS totalduration \
- FROM task TA, tasktime TI \
- WHERE TA.taskId = TI.taskid \
+jtimer.storage.select.report.byProjectAndTag=SELECT TA.*, sum(TI.duration) AS totalduration \
+ FROM task TA, tasktime TI \
+ WHERE TA.taskId = TI.taskid \
AND TI.creationDate BETWEEN ? AND ? \
+ AND ARRAY_CONTAINS(?, TA.taskid) \
+ AND ARRAY_CONTAINS_ONE(TA.tags, ?) \
AND TA.removed = 0 \
- GROUP BY TA.taskId, week, year \
- ORDER BY TA.creationDate DESC
-jtimer.storage.select.report.year.timedtasks=SELECT YEAR(TI.creationDate) as year, TA.* , sum(TI.duration) AS totalduration \
- FROM task TA, tasktime TI \
- WHERE TA.taskId = TI.taskid \
+ GROUP BY TA.taskId
+jtimer.storage.select.report.byYearAndTag=SELECT YEAR(TI.creationDate) as year, TA.*, sum(TI.duration) AS totalduration \
+ FROM task TA, tasktime TI \
+ WHERE TA.taskId = TI.taskid \
AND TI.creationDate BETWEEN ? AND ? \
+ AND ARRAY_CONTAINS(TA.path, TA.taskid) \
+ AND ARRAY_CONTAINS(?, TA.taskid) \
+ AND ARRAY_CONTAINS_ONE(TA.tags, ?) \
AND TA.removed = 0 \
- GROUP BY TA.taskId, year \
- ORDER BY TA.creationDate DESC
-jtimer.storage.select.report.month.timedtasks=SELECT MONTH(TI.creationDate) as month, YEAR(TI.creationDate) as year, TA.* , sum(TI.duration) AS totalduration \
- FROM task TA, tasktime TI \
- WHERE TA.taskId = TI.taskid \
+ GROUP BY TA.taskId , year
+jtimer.storage.select.report.byMonthAndTag=SELECT MONTH(TI.creationDate) as month, YEAR(TI.creationDate) as year, TA.*, sum(TI.duration) AS totalduration \
+ FROM task TA, tasktime TI \
+ WHERE TA.taskId = TI.taskid \
AND TI.creationDate BETWEEN ? AND ? \
+ AND ARRAY_CONTAINS(TA.path, TA.taskid) \
+ AND ARRAY_CONTAINS(?, TA.taskid) \
+ AND ARRAY_CONTAINS_ONE(TA.tags, ?) \
AND TA.removed = 0 \
- GROUP BY TA.taskId, year, month \
- ORDER BY TA.creationDate DESC
+ GROUP BY TA.taskId , month, year
+jtimer.storage.select.report.byWeekAndTag=SELECT WEEK(TI.creationDate) as week,YEAR(TI.creationDate) as year, TA.*, sum(TI.duration) AS totalduration \
+ FROM task TA, tasktime TI \
+ WHERE TA.taskId = TI.taskid \
+ AND TI.creationDate BETWEEN ? AND ? \
+ AND ARRAY_CONTAINS(TA.path, TA.taskid) \
+ AND ARRAY_CONTAINS(?, TA.taskid) \
+ AND ARRAY_CONTAINS_ONE(?, TA.tags) \
+ AND TA.removed = 0 \
+ GROUP BY TA.taskId , week, year
+jtimer.storage.select.report.byDayAndTag=SELECT EXTRACT(DAY FROM TI.creationDate) as day,MONTH(TI.creationDate) as month,YEAR(TI.creationDate) as year, TA.*, sum(TI.duration) AS totalduration \
+ FROM task TA, tasktime TI \
+ WHERE TA.taskId = TI.taskid \
+ AND TI.creationDate BETWEEN ? AND ? \
+ AND ARRAY_CONTAINS(TA.path, TA.taskid) \
+ AND ARRAY_CONTAINS(?, TA.taskid) \
+ AND ARRAY_CONTAINS_ONE(TA.tags, ?) \
+ AND TA.removed = 0 \
+ GROUP BY TA.taskId , day, month, year
jtimer.storage.select.alarm.ondate= SELECT * \
FROM taskalarm \
WHERE modificationDate > ?
@@ -182,7 +206,7 @@
jtimer.storage.update.task.path=UPDATE task \
SET path=? \
WHERE taskId = ?
-jtimer.storage.update.task.withid=UPDATE task SET name=?, parent=?, hidden=?, note=?, modificationDate=?, removed=? \
+jtimer.storage.update.task.withid=UPDATE task SET name=?, parent=?, hidden=?, description=?, modificationDate=?, tags=?, removed=? \
WHERE taskId = ?
jtimer.storage.update.time.withid=UPDATE tasktime SET creationDate=?, duration=?, modificationDate=?, removed = ? \
WHERE uuid = ?
1
0
Author: echatellier
Date: 2014-08-01 16:59:12 +0200 (Fri, 01 Aug 2014)
New Revision: 3023
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3023
Log:
Some bash fonction are used
Modified:
branches/ng-jtimer/run.sh
Modified: branches/ng-jtimer/run.sh
===================================================================
--- branches/ng-jtimer/run.sh 2014-07-29 08:40:59 UTC (rev 3022)
+++ branches/ng-jtimer/run.sh 2014-08-01 14:59:12 UTC (rev 3023)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
if [ -z "$GOPATH" ]; then
echo "Please define \$GOPATH first"
1
0