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
- 639 discussions
Author: obruce
Date: 2014-07-03 16:41:29 +0200 (Thu, 03 Jul 2014)
New Revision: 3012
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3012
Log:
controller, alarmpartial : changement correction
Modified:
branches/ng-jtimer/src/main/webapp/js/controllers.js
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-07-03 14:39:22 UTC (rev 3011)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-07-03 14:41:29 UTC (rev 3012)
@@ -379,6 +379,33 @@
}
+ /**
+ * 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 getObjectInArrayWithId= function(array, id){
var res;
@@ -404,33 +431,7 @@
return res;
}
- /**
- * Methode qui recupere les alarmes pour une tache
- */
- var getAlarmsFromServerWithTask = function(task){
- serverAlarmAccess.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();
- });
- }
-
-
/**
* Methode qui retourne l'existence d'un element dans un array
*/
1
0
03 Jul '14
Author: obruce
Date: 2014-07-03 16:39:22 +0200 (Thu, 03 Jul 2014)
New Revision: 3011
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3011
Log:
controller, alarmpartial : changement
Modified:
branches/ng-jtimer/src/main/webapp/js/controllers.js
branches/ng-jtimer/src/main/webapp/partials/alertModal.html
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-07-03 13:12:30 UTC (rev 3010)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-07-03 14:39:22 UTC (rev 3011)
@@ -379,33 +379,6 @@
}
- /**
- * 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 getObjectInArrayWithId= function(array, id){
var res;
@@ -431,7 +404,33 @@
return res;
}
+ /**
+ * Methode qui recupere les alarmes pour une tache
+ */
+ var getAlarmsFromServerWithTask = function(task){
+ serverAlarmAccess.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();
+ });
+ }
+
+
/**
* Methode qui retourne l'existence d'un element dans un array
*/
@@ -780,7 +779,7 @@
task : function(){
return node.task;
},
- time : function(){
+ totaltime : function(){
var res=0;
@@ -800,6 +799,28 @@
console.log(res);
return res;
+ },
+ todaytime : function(){
+ var res=0;
+
+ var recChildren = function(noeud){
+ angular.forEach($scope.data.times[noeud.task.taskId], function(t){
+ if(t.isToday()){
+ res+=t.time;
+ }
+ });
+
+ if(noeud.children){
+ angular.forEach(noeud.children, function(child){
+ recChildren(child);
+ });
+ }
+
+ }
+ recChildren(node);
+
+ console.log(res);
+ return res;
}
}
});
@@ -1045,8 +1066,12 @@
};
}
-function AlertModalInstanceCtrl($scope, $modalInstance, serverAlarmAccess, task, time){
+function AlertModalInstanceCtrl($scope, $modalInstance, serverAlarmAccess, task, totaltime, todaytime){
+ console.log(totaltime +" " +todaytime)
+
+ $scope.alarm={name : "" , type : "Type"};
+
var msToHour=function(ms){
return ((ms / (1000*60*60)) % 24);
}
@@ -1056,20 +1081,33 @@
}
$scope.valMinHour=function(){
- return parseInt(msToHour(time));
+ var res;
+ if($scope.alarm.type=="Total_Time"){
+ res = parseInt(msToHour(totaltime));
+ }else{
+ res = parseInt(msToHour(todaytime));
+ }
+ return res;
}
$scope.valMinMin=function(){
- return parseInt(msToMin(time));
+ var res;
+ if($scope.alarm.type=="Total_Time"){
+ res = parseInt(msToMin(totaltime));
+ }else{
+ res = parseInt(msToMin(todaytime));
+ }
+ return res;
}
- $scope.alarm={name : "" , type : "Type", hour : $scope.valMinHour(), min : $scope.valMinMin()};
+ $scope.alarm.hour = $scope.valMinHour();
+ $scope.alarm.min = $scope.valMinMin();
$scope.name = task.name;
$scope.alarms = task.alarms;
- $scope.dynamic = function(alarm){
+ $scope.dynamicProgressBar = function(alarm){
var res = 0;
var limit = alarm.limitHour*60 + alarm.limitMin;
@@ -1082,10 +1120,14 @@
$scope.dropdownType1= function(){
$scope.alarm.type = "Total_Day_Time";
+ $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();
}
/**
@@ -1102,16 +1144,15 @@
if($scope.alarm.name== "" || $scope.alarm.type=="Type" ){
}else{
- console.log("save " +time);
- minusPreviousTime(time, $scope.alarm.hour, $scope.alarm.min);
+ if($scope.alarm.type=="Total_Time"){
+ minusPreviousTime(totaltime, $scope.alarm.hour, $scope.alarm.min);
+ }else{
+ minusPreviousTime(todaytime, $scope.alarm.hour, $scope.alarm.min);
+ }
- console.log("apres minus " +$scope.alarm.hour + " "+$scope.alarm.min);
-
if($scope.alarm.hour > 0 || $scope.alarm.min> 0 ){
- console.log($scope.alarm.hour + " "+$scope.alarm.min);
-
var al = new TaskAlarm(task,undefined ,
$scope.alarm.name,
$scope.alarm.type,
@@ -1131,7 +1172,6 @@
//On remet les elements affiches a la valeur par defaut
$scope.alarm.name= "";
$scope.alarm.type="Type";
- //$scope.alarm.date= new Date();
$scope.alarm.hour = 0;
$scope.alarm.min = 0;
}
Modified: branches/ng-jtimer/src/main/webapp/partials/alertModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/alertModal.html 2014-07-03 13:12:30 UTC (rev 3010)
+++ branches/ng-jtimer/src/main/webapp/partials/alertModal.html 2014-07-03 14:39:22 UTC (rev 3011)
@@ -22,47 +22,46 @@
<!--Portion d'ajout -->
<tr ng-repeat="(index,alarm) in alarms">
- <th><i class="glyphicon glyphicon-minus-sign" ng-click="removeAlert(index,alarm)"></i></th>
+ <td><i class="glyphicon glyphicon-minus-sign" ng-click="removeAlert(index,alarm)"></i></td>
- <th>{{alarm.name}}</th>
- <th>{{alarm.type}}</th>
- <th>{{alarm.limitHour}}h: {{alarm.limitMin}}min</th>
- <th>
- <progressbar value="dynamic(alarm)"></progressbar>
- </th>
- <th></th>
+ <td >{{alarm.name}}</td>
+ <td>{{alarm.type}}</td>
+ <td>{{alarm.limitHour}}h: {{alarm.limitMin}}min</td>
+ <td>
+ <progressbar value="dynamicProgressBar(alarm)"></progressbar>
+ </td>
</tr>
<tr>
-
- <th>Nouveau:</th>
+ <th>New:</th>
</tr>
-
<tr>
-
- <th></th>
- <th><input class='input-sm small_input' ng-model="alarm.name" placeholder="New Alert">
+ <td><i class="glyphicon glyphicon-floppy-disk" ng-click="saveAlarm()"></i></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></th>
- <th>
+ <i class="glyphicon glyphicon-check color_green" ng-show="alarm.name!=''"> </i></td>
+ <td>
<div class="btn-group" dropdown is-open="status.isopen">
<button type="button" class="btn btn-primary dropdown-toggle">
{{alarm.type}} <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
- <li ng-click="dropdownType1()">Total_Time_In_a_Day</li>
+ <li ng-click="dropdownType1()">Total_Day_Time</li>
<li ng-click="dropdownType2()">Total_Time</li>
</ul>
</div>
<i class="glyphicon glyphicon-edit color_red" ng-show="alarm.type=='Type'"> </i>
<i class="glyphicon glyphicon-check color_green"ng-show="alarm.type!='Type'"> </i>
- </th>
- <th>
+ </td>
+ <td>
<!--<timepicker ng-model="alarm.date" ng-change="changed()"
hour-step="1" minute-step="1" show-meridian="ismeridian">
</timepicker>-->
- <div ng-if="alarm.type!='Total_Time'">
+ <div ng-if="alarm.type=='Type'">
+ </div>
+
+ <div ng-if="alarm.type=='Total_Day_Time'">
<input type="number" step="1" min="{{valMinHour()}}" max="23" ng-model="alarm.hour">h:
<input type="number" step="1" min="{{valMinMin()}}" max="59" ng-model="alarm.min">m
</div>
@@ -72,9 +71,8 @@
<input class="xsmall_input" type="number" step="1" min="{{valMinMin()}}" max="59" ng-model="alarm.min">m
</div>
- </th>
- <th></th>
- <th><i class="glyphicon glyphicon-ok green" ng-click="saveAlarm()"></i></th>
+ </td>
+ <td></td>
</tr>
</div>
1
0
r3010 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/config java/org/chorem/jtimer/entities java/org/chorem/jtimer/storage java/org/chorem/jtimer/web resources webapp/css webapp/js webapp/partials
by obruce@users.chorem.org 03 Jul '14
by obruce@users.chorem.org 03 Jul '14
03 Jul '14
Author: obruce
Date: 2014-07-03 15:12:30 +0200 (Thu, 03 Jul 2014)
New Revision: 3010
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3010
Log:
ui-serveur: persist alarm, correction modal
Added:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerAlarm.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmsResource.java
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/AbstractResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.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/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/config/JtimerConfig.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -91,6 +91,10 @@
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_CREATE_TABLE_TIME.getKey());
}
+ public String getStorageQueryCreateTableAlarm(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_CREATE_TABLE_ALARM.getKey());
+ }
+
public String getStorageQueryInsertVersionNumber(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_INSERT_VERSION_NUMBER.getKey());
}
@@ -103,6 +107,10 @@
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_INSERT_TIME.getKey());
}
+ public String getStorageQueryInsertAlarm(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_INSERT_ALARM.getKey());
+ }
+
public String getStorageQuerySelectTableName(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_TABLE_NAME.getKey());
}
@@ -132,15 +140,33 @@
public String getStorageQuerySelectReportRootTask(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_ROOTTASK.getKey());
}
+
+ public String getStorageQuerySelectAlarmOnDate(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_ALARM_ONDATE.getKey());
+ }
+
+ public String getStorageQuerySelectAlarmWithTaskID(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_ALARM_WITHTASKID.getKey());
+ }
public String getStorageQueryDeleteTime(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_DELETE_TIME_WITHID.getKey());
}
+
+ public String getStorageQueryDeleteAlarm(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_DELETE_ALARM_WITHID.getKey());
+ }
+
public String getStorageQueryDeleteTask(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_DELETE_TASK_WITHID.getKey());
}
public String getStorageQueryUpdateTask(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_TASK_WITHID.getKey());
}
+
+ public String getStorageQueryUpdateAlarm(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_ALARM_WITHID.getKey());
+ }
+
public String getStorageQueryUpdateTime(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_TIME_WITHID.getKey());
}
@@ -150,4 +176,7 @@
public String getStorageQueryUpdateTimeToRemove(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_TIME_FORREMOVE.getKey());
}
+ public String getStorageQueryUpdateAlarmToRemove(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_ALARM_FORREMOVE.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-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -40,6 +40,12 @@
"tasktime",
String.class
),
+ JTIMER_STORAGE_TABLE_ALARM(
+ "jtimer.storage.table.alarm",
+ "le nom de la table des version",
+ "tasktime",
+ String.class
+ ),
JTIMER_STORAGE_CREATE_TABLE_VERSION(
"jtimer.storage.create.table.version",
"requête de création la table des version",
@@ -58,6 +64,12 @@
"",
String.class
),
+ JTIMER_STORAGE_CREATE_TABLE_ALARM(
+ "jtimer.storage.create.alarm",
+ "requête de création la table des alarmes",
+ "",
+ String.class
+ ),
JTIMER_STORAGE_INSERT_VERSION_NUMBER(
"jtimer.storage.insert.version.number",
"requête d'insertion dans la table des versions",
@@ -76,6 +88,12 @@
"",
String.class
),
+ JTIMER_STORAGE_INSERT_ALARM(
+ "jtimer.storage.insert.alarm",
+ "requête d'insertion dans la table des alarmes",
+ "",
+ String.class
+ ),
JTIMER_STORAGE_SELECT_TABLE_NAME(
"jtimer.storage.select.table.name",
"requête de selection des noms dans le table name",
@@ -130,6 +148,18 @@
"",
String.class
),
+ JTIMER_STORAGE_SELECT_ALARM_ONDATE(
+ "jtimer.storage.select.alarm.ondate",
+ "requête de selection des alarmes ",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_SELECT_ALARM_WITHTASKID(
+ "jtimer.storage.select.alarm.fortask",
+ "requête de selection des alarmes d'une tâches",
+ "",
+ String.class
+ ),
JTIMER_STORAGE_DELETE_TIME_WITHID(
"jtimer.storage.delete.time.withid",
"requête de suppression d'un temps avec un identifiant",
@@ -142,6 +172,12 @@
"",
String.class
),
+ JTIMER_STORAGE_DELETE_ALARM_WITHID(
+ "jtimer.storage.delete.alarm.withid",
+ "requête de suppression d'une tâches avec un identifiant",
+ "",
+ String.class
+ ),
JTIMER_STORAGE_UPDATE_TASK_WITHID(
"jtimer.storage.update.task.withid",
"requête de mise à jour d'une taches avec un identifiant",
@@ -154,6 +190,12 @@
"",
String.class
),
+ JTIMER_STORAGE_UPDATE_ALARM_WITHID(
+ "jtimer.storage.update.alarm.withid",
+ "requête de mise à jour d'une alarme avec un identifiant",
+ "",
+ String.class
+ ),
JTIMER_STORAGE_UPDATE_TASK_FORREMOVE(
"jtimer.storage.update.task.forremove",
"requête de de changement de statut (remove) d'une tâches avec un identifiant",
@@ -165,7 +207,13 @@
"requête de de changement de statut (remove) d'un temps avec un identifiant",
"",
String.class
- );
+ ),JTIMER_STORAGE_UPDATE_ALARM_FORREMOVE(
+ "jtimer.storage.update.alarm.forremove",
+ "requête de de changement de statut (remove) d'une alarme avec un identifiant",
+ "",
+ String.class
+ )
+ ;
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerAlarm.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerAlarm.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerAlarm.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -0,0 +1,159 @@
+package org.chorem.jtimer.entities;
+
+import java.util.Date;
+
+/**
+ * Created by olivia on 02/07/14.
+ *
+ * Classe qui represente les alarmes sur les taches
+ *
+ * <p/>
+ * Project name : jtimer
+ * <p/>
+ * Package name : org.chorem.jtimer.entities
+ */
+public class TimerAlarm {
+
+ /** Task uuid */
+ protected String taskId;
+
+ /** Alarm uuid */
+ protected String alarmId;
+
+ /** Alarm name. */
+ protected String name;
+
+ /** Alarm type. */
+ protected String type;
+
+ /**ModificationDate*/
+ protected Date modificationDate;
+
+ /** limit time in hour to spend on the task */
+ protected int limitHour;
+
+ /** limit time in min to spend on the task */
+ protected int limitMin;
+
+ /** 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) {
+ 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;
+ }
+
+ public TimerAlarm() {
+
+ }
+
+ public long getRemoved() {
+ return removed;
+ }
+
+ public void setRemoved(long removed) {
+ this.removed = removed;
+ }
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public String getAlarmId() {
+ return alarmId;
+ }
+
+ public void setAlarmId(String alarmId) {
+ this.alarmId = alarmId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public Date getModificationDate() {
+ return modificationDate;
+ }
+
+ public void setModificationDate(Date modificationDate) {
+ this.modificationDate = modificationDate;
+ }
+
+ public int getLimitHour() {
+ return limitHour;
+ }
+
+ public void setLimitHour(int limitHour) {
+ this.limitHour = limitHour;
+ }
+
+ public int getLimitMin() {
+ return limitMin;
+ }
+
+ public void setLimitMin(int limitMin) {
+ this.limitMin = limitMin;
+ }
+
+ 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{" +
+ "taskId='" + taskId + '\'' +
+ ", alarmId='" + alarmId + '\'' +
+ ", name='" + name + '\'' +
+ ", type='" + type + '\'' +
+ ", modificationDate=" + modificationDate +
+ ", limitHour=" + limitHour +
+ ", limitMin=" + limitMin +
+ ", remainingMin=" + remainingMin +
+ ", remainingHour=" + remainingHour +
+ ", removed=" + removed +
+ '}';
+ }
+}
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-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -3,6 +3,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.config.JtimerConfig;
+import org.chorem.jtimer.entities.TimerAlarm;
import org.chorem.jtimer.entities.TimerTask;
import org.chorem.jtimer.entities.TimerTime;
import org.chorem.jtimer.utils.ReportTask;
@@ -36,6 +37,7 @@
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;
@@ -155,6 +157,7 @@
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);
@@ -189,62 +192,10 @@
return result;
}
- /**
- * Query that returns not removed tasks
- * @return tasks arraylist of tasks
- */
- public ArrayList<TimerTask> getTasks(Long date) {
- ArrayList<TimerTask> tasks = new ArrayList<>();
- PreparedStatement statement = null;
- PreparedStatement statement2 = null;
- try {
- statement = connection.prepareStatement(config.getStorageQuerySelectTimedTask());
- statement.setLong(1, date);
- log.debug(statement.toString());
- ResultSet rs = statement.executeQuery();
- while (rs.next()) {
- TimerTask task = new TimerTask();
- task.setTaskId(rs.getString("taskId"));
- task.setName(rs.getString("name"));
- task.setParent(rs.getString("parent"));
- task.setRemoved(rs.getLong("removed"));
- task.setTodayTime(0);
- task.setCreationDate(new java.util.Date(rs.getLong("creationDate")));
- task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
- task.setTotalTime(rs.getLong("totalduration"));
- tasks.add(task);
- }
+ /* Insert */
- // not timed tasks
- statement2 = connection.prepareStatement(config.getStorageQuerySelectNotTimedTask());
- statement2.setLong(1, date);
-
- rs = statement2.executeQuery();
- while (rs.next()) {
- TimerTask task = new TimerTask();
- task.setName(rs.getString("name"));
- task.setTaskId(rs.getString("taskId"));
- task.setParent(rs.getString("parent"));
- task.setCreationDate(new java.util.Date(rs.getLong("creationDate")));
- task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
- task.setRemoved(rs.getLong("removed"));
- task.setTodayTime(0);
- task.setTotalTime(0);
- tasks.add(task);
- }
- } catch (SQLException ex) {
- throw new StorageException("Can't get task", ex);
- } finally {
- closeStatement(statement);
- closeStatement(statement2);
- }
- return tasks;
- }
-
- /* Insert, Update, Delete */
-
public void addTask(TimerTask task) {
PreparedStatement statement = null;
try {
@@ -267,46 +218,7 @@
log.info("insert done");
}
- public void modifyTask(TimerTask task) {
- PreparedStatement statement = null;
- try {
- statement = connection.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.setLong(5, task.getModificationDate().getTime()); //modificationDate
-
- statement.setLong(6,task.getRemoved());
- statement.setString(7, task.getTaskId()); //taskId
-
- statement.executeUpdate();
- } catch (SQLException ex) {
- throw new StorageException("Can't modify task", ex);
- } finally {
- closeStatement(statement);
- }
- }
-
- public void modifyTime(TimerTime t) {
- PreparedStatement statement = null;
- try {
- statement = connection.prepareStatement(config.getStorageQueryUpdateTime());
-
- statement.setLong(1, t.getCreationDate().getTime());
- statement.setLong(2, t.getTime());
- statement.setLong(3, t.getModificationDate().getTime()); //modificationDate
- statement.setLong(4, t.getRemoved());
- statement.setString(5, t.getTimeId() );
- statement.executeUpdate();
- } catch (SQLException ex) {
- throw new StorageException("Can't modify time", ex);
- } finally {
- closeStatement(statement);
- }
- }
-
/**
* Ajoute une periode pour une tache
* @param task la tache qui va recevoir un temps
@@ -357,13 +269,36 @@
}
+ /** Select */
+ /**
+ * Ajoute une alarme pour une tache
+ * @param alarm le timeralarm a ajouter
+ */
+ public void addTaskAlarm(TimerAlarm alarm) {
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement(config.getStorageQueryInsertAlarm());
- public void setAnnotation(TimerTask task, Date date, String annotation) {
+ statement.setString(1, alarm.getTaskId());
+ 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.setLong(9, alarm.getModificationDate().getTime());
+ statement.setLong(10, alarm.getRemoved());
+ statement.executeUpdate();
+ } catch (SQLException ex) {
+ throw new StorageException("Can't add task alarm", ex);
+ } finally {
+ closeStatement(statement);
+ }
}
-
/**
* Query that returns every task's times
* @return times hashMap(key: taskId, value: times)
@@ -401,7 +336,60 @@
return times;
}
+ /**
+ * Query that returns not removed tasks
+ * @return tasks arraylist of tasks
+ */
+ public ArrayList<TimerTask> getTasks(Long date) {
+ ArrayList<TimerTask> tasks = new ArrayList<>();
+ PreparedStatement statement = null;
+ PreparedStatement statement2 = null;
+ try {
+ statement = connection.prepareStatement(config.getStorageQuerySelectTimedTask());
+ statement.setLong(1, date);
+ log.debug(statement.toString());
+
+ ResultSet rs = statement.executeQuery();
+ while (rs.next()) {
+ TimerTask task = new TimerTask();
+ task.setTaskId(rs.getString("taskId"));
+ task.setName(rs.getString("name"));
+ task.setParent(rs.getString("parent"));
+ task.setRemoved(rs.getLong("removed"));
+ task.setTodayTime(0);
+ task.setCreationDate(new java.util.Date(rs.getLong("creationDate")));
+ task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
+ task.setTotalTime(rs.getLong("totalduration"));
+ tasks.add(task);
+ }
+
+ // not timed tasks
+ statement2 = connection.prepareStatement(config.getStorageQuerySelectNotTimedTask());
+ statement2.setLong(1, date);
+
+ rs = statement2.executeQuery();
+ while (rs.next()) {
+ TimerTask task = new TimerTask();
+ task.setName(rs.getString("name"));
+ task.setTaskId(rs.getString("taskId"));
+ task.setParent(rs.getString("parent"));
+ task.setCreationDate(new java.util.Date(rs.getLong("creationDate")));
+ task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
+ task.setRemoved(rs.getLong("removed"));
+ task.setTodayTime(0);
+ task.setTotalTime(0);
+ tasks.add(task);
+ }
+ } catch (SQLException ex) {
+ throw new StorageException("Can't get task", ex);
+ } finally {
+ closeStatement(statement);
+ closeStatement(statement2);
+ }
+ return tasks;
+ }
+
/**
* Query that returns every tasks for a specified task
* @return tasks arraylist of tasks
@@ -435,6 +423,80 @@
return times;
}
+
+ /**
+ * Methode qui retourne toutes les alarmes dans la base
+ * @param date
+ * @return
+ */
+ public ArrayList<TimerAlarm> getAlarms(Long date) {
+ ArrayList<TimerAlarm> alarms = new ArrayList<>();
+ PreparedStatement statement = null;
+
+ try {
+ statement = connection.prepareStatement(config.getStorageQuerySelectAlarmOnDate());
+ statement.setLong(1, date);
+
+ ResultSet rs = statement.executeQuery();
+ while (rs.next()) {
+ TimerAlarm alarm = new TimerAlarm();
+ alarm.setTaskId(rs.getString("taskid"));
+ 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.setModificationDate(new Date(rs.getLong("modificationDate")));
+ alarm.setRemoved(rs.getLong("removed"));
+
+ alarms.add(alarm);
+
+ }
+ } catch (SQLException ex) {
+ throw new StorageException("Can't get alarm", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ return alarms;
+ }
+
+
+ public ArrayList<TimerAlarm> getAlarms(String taskId, Long date) {
+ ArrayList<TimerAlarm> alarms = new ArrayList<>();
+ PreparedStatement statement = null;
+
+ try {
+ statement = connection.prepareStatement(config.getStorageQuerySelectAlarmWithTaskID());
+ statement.setLong(1, date);
+ statement.setString(2, taskId);
+
+ ResultSet rs = statement.executeQuery();
+ while (rs.next()) {
+ TimerAlarm alarm = new TimerAlarm();
+ alarm.setTaskId(rs.getString("taskid"));
+ 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.setModificationDate(new Date(rs.getLong("modificationDate")));
+ alarm.setRemoved(rs.getLong("removed"));
+
+ alarms.add(alarm);
+
+ }
+ } catch (SQLException ex) {
+ throw new StorageException("Can't get time", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ return alarms;
+ }
+
public HashMap<String, ArrayList<ReportTask>> getReportByProject(Long startDate, Long endDate){
HashMap map = new HashMap();
@@ -490,6 +552,81 @@
}
+ /** Update */
+
+ /**
+ * Update the specified task
+ * @param task the task to be updated
+ */
+ public void modifyTask(TimerTask task) {
+ PreparedStatement statement = null;
+ try {
+ statement = connection.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.setLong(5, task.getModificationDate().getTime()); //modificationDate
+
+ statement.setLong(6,task.getRemoved());
+ statement.setString(7, task.getTaskId()); //taskId
+
+ statement.executeUpdate();
+ } catch (SQLException ex) {
+ throw new StorageException("Can't modify task", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ }
+
+ /**
+ * Update the specified time
+ * @param t the time to be updated
+ */
+ public void modifyTime(TimerTime t) {
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement(config.getStorageQueryUpdateTime());
+
+ statement.setLong(1, t.getCreationDate().getTime());
+ statement.setLong(2, t.getTime());
+ statement.setLong(3, t.getModificationDate().getTime()); //modificationDate
+ statement.setLong(4, t.getRemoved());
+ statement.setString(5, t.getTimeId() );
+ statement.executeUpdate();
+ } catch (SQLException ex) {
+ throw new StorageException("Can't modify time", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ }
+
+
+ /**
+ * Update the specified alarm
+ * @param t the alarm to be updated
+ */
+ public void modifyAlarm(TimerAlarm t) {
+
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement(config.getStorageQueryUpdateAlarm());
+
+ statement.setLong(1, t.getRemainingHour());
+ statement.setLong(2, t.getRemainingMin());
+ statement.setLong(3, t.getRemoved());
+
+ statement.executeUpdate();
+ } catch (SQLException ex) {
+ throw new StorageException("Can't modify alarm", ex);
+ } finally {
+ closeStatement(statement);
+ }
+
+ }
+
+
/** Suppression de tuple **/
/**
@@ -577,4 +714,21 @@
}
+ public void removeAlarmWithId(String alarmId, long time) {
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement(config.getStorageQueryUpdateAlarmToRemove());
+
+ statement.setLong(1, time);
+ statement.setLong(2, time);
+ statement.setString(3, alarmId);
+
+ statement.executeUpdate();
+ } catch (SQLException ex) {
+ throw new StorageException("Can't delete alarm", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ }
+
}
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AbstractResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AbstractResource.java 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AbstractResource.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -1,10 +1,23 @@
package org.chorem.jtimer.web;
+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.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.jtimer.storage.Storage;
import org.restlet.resource.Options;
+import org.restlet.resource.ResourceException;
import org.restlet.resource.ServerResource;
+import java.lang.reflect.Type;
+import java.util.Date;
+
/**
* Created by olivia on 11/06/14.
* <p/>
@@ -16,7 +29,40 @@
private static final Log log = LogFactory.getLog(AbstractResource.class);
+ protected Storage storage;
+ protected GsonBuilder builder;
+
/**
+ * Methode qui initialis la resource
+ * @throws org.restlet.resource.ResourceException
+ */
+ @Override
+ protected void doInit() throws ResourceException {
+ storage = (Storage)getContext().getAttributes().get(Storage.class.getName());
+
+ builder = new GsonBuilder();
+
+ // Register an adapter to manage the date types as long values
+ //GSON builder to format dates
+ builder = new GsonBuilder();
+ builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
+
+ 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());
+ }
+ });
+
+ }
+
+ /**
* Called when option requests are catched
* Needed to avoid cross origin
*/
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmResource.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmResource.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -0,0 +1,130 @@
+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.entities.TimerAlarm;
+import org.restlet.data.MediaType;
+import org.restlet.representation.Representation;
+import org.restlet.representation.StringRepresentation;
+import org.restlet.resource.Delete;
+import org.restlet.resource.Get;
+import org.restlet.resource.Post;
+import org.restlet.resource.Put;
+import org.restlet.resource.ResourceException;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by olivia on 01/07/14.
+ * <p/>
+ * Project name : jtimer
+ * <p/>
+ * Package name : org.chorem.jtimer.web
+ */
+public class AlarmResource extends AbstractResource {
+
+ private static final Log log = LogFactory.getLog(AlarmResource.class);
+
+ /**
+ * Methode qui initialis la resource
+ * @throws org.restlet.resource.ResourceException
+ */
+ @Override
+ protected void doInit() throws ResourceException {
+ super.doInit();
+ }
+
+ /**
+ * Methode qui retourne la representation de la liste des alarmes
+ * Suite a une requete de type GET
+ *
+ * @return la representation
+ */
+ @Get("json")
+ public Representation getAlarmForATask() {
+
+ Long date = (long) 0;
+ try{
+ date = Long.valueOf(getQuery().getValues("date"));
+ }
+ catch(Exception e){
+ date = (long) 0;
+ }
+
+ String taskId = (String)getRequest().getAttributes().get("taskId");
+ List<TimerAlarm> timerAlarms = storage.getAlarms(taskId, date);
+
+ Gson gson = builder.create();
+ String json = gson.toJson(timerAlarms);
+
+ return new StringRepresentation(json, MediaType.APPLICATION_JSON);
+ }
+
+ /**
+ * Methode qui supprime un element de la base
+ * suite d'une requête de type DELETE
+ *
+ */
+ @Delete
+ public void deleteAlarm() {
+
+
+ String alarmId = (String)getRequest().getAttributes().get("alarmId");
+ storage.removeAlarmWithId(alarmId, new Date().getTime());
+
+ }
+
+ /**
+ * Methode qui cree une periode
+ * suite d'une requête de type POST
+ */
+ @Post("json")
+ public void createAlarm(Representation representation) throws IOException {
+
+ if(representation.isAvailable()) {
+ Gson gson = builder.create();
+
+ //On reconstruit l'element avec la representation
+ String jsonRepr = representation.getText();
+ TimerAlarm newAlarm = gson.fromJson(jsonRepr, TimerAlarm.class);
+
+ log.info(newAlarm.toString());
+
+ if (log.isInfoEnabled()) {
+ log.info("L'alarme suivante est cree : " + newAlarm.toString());
+ }
+
+ storage.addTaskAlarm(newAlarm);
+
+ }
+ }
+
+ /**
+ * Methode qui met à jour une tache
+ * suite d'une requête de type PUT
+ */
+ @Put("json")
+ public void updateAlarm(Representation representation) throws IOException{
+
+ if(representation.isAvailable()) {
+
+
+
+ Gson gson = builder.create();
+ String jsonRepr = representation.getText();
+ TimerAlarm t = gson.fromJson(jsonRepr, TimerAlarm.class);
+
+ if (log.isInfoEnabled()) {
+ log.info("La periode suivante est en maj : " + t.toString());
+ }
+
+ storage.modifyAlarm(t);
+ }
+
+ }
+
+
+}
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmsResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmsResource.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmsResource.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -0,0 +1,62 @@
+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.entities.TimerAlarm;
+import org.restlet.data.MediaType;
+import org.restlet.representation.Representation;
+import org.restlet.representation.StringRepresentation;
+import org.restlet.resource.Get;
+import org.restlet.resource.ResourceException;
+
+import java.util.ArrayList;
+
+/**
+ * Created by olivia on 01/07/14.
+ * <p/>
+ * Project name : jtimer
+ * <p/>
+ * Package name : org.chorem.jtimer.web
+ */
+public class AlarmsResource extends AbstractResource{
+
+ private static final Log log = LogFactory.getLog(AlarmsResource.class);
+
+ /**
+ * Methode qui initialis la resource
+ * @throws org.restlet.resource.ResourceException
+ */
+ @Override
+ protected void doInit() throws ResourceException {
+ super.doInit();
+ }
+
+ /**
+ * Methode qui retourne la representation de la liste des alarmes
+ * Suite a une requete de type GET
+ *
+ * @return la representation
+ */
+ @Get("json")
+ public Representation getAlarmForATask() {
+
+ Long date = (long) 0;
+
+ try {
+ date = Long.valueOf(getQuery().getValues("date"));
+ } catch (Exception e) {
+ date = (long) 0;
+ }
+
+ Gson gson = builder.create();
+ ArrayList<TimerAlarm> timerAlarms = storage.getAlarms(date);
+
+
+
+ String json = gson.toJson(timerAlarms);
+
+ return new StringRepresentation(json, MediaType.APPLICATION_JSON);
+ }
+
+}
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-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -57,7 +57,8 @@
router.attach("/tasks/time/{taskId}", TimeResource.class);
router.attach("/tasks/time", TimesResource.class);
router.attach("/report", ReportResource.class);
- //router.attach("/tiers", TiersServerResource.class);
+ router.attach("/tasks/alarm", AlarmsResource.class);
+ router.attach("/tasks/alarm/{taskId}", AlarmResource.class);
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -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.tuple.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.entities.TimerTime;
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;
@@ -25,7 +16,6 @@
import org.restlet.resource.ResourceException;
import java.io.IOException;
-import java.lang.reflect.Type;
import java.util.Date;
import java.util.List;
@@ -33,10 +23,6 @@
private static final Log log = LogFactory.getLog(TimeResource.class);
- /** Builder for serialisation deserialisation */
- private GsonBuilder builder;
- /** H2 storage instance */
- protected Storage storage;
/** Todolist instance */
protected TodoList todoList;
@@ -50,28 +36,8 @@
@Override
protected void doInit() throws ResourceException {
- //GSON builder to format dates
+ super.doInit();
- builder = new GsonBuilder();
- builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
-
- 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());
- }
- });
-
-
- storage = (Storage)getContext().getAttributes().get(Storage.class.getName());
todoList = TodoList.getInstance();
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -1,27 +1,16 @@
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.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.entities.TimerTime;
-import org.chorem.jtimer.storage.Storage;
import org.restlet.data.MediaType;
import org.restlet.representation.Representation;
import org.restlet.representation.StringRepresentation;
import org.restlet.resource.Get;
import org.restlet.resource.ResourceException;
-import java.lang.reflect.Type;
import java.util.ArrayList;
-import java.util.Date;
/**
* Created by olivia on 21/05/14.
@@ -29,8 +18,6 @@
public class TimesResource extends AbstractResource {
private static final Log log = LogFactory.getLog(TaskResource.class);
- protected Storage storage;
- protected GsonBuilder builder;
/**
* Methode qui initialis la resource
@@ -38,30 +25,7 @@
*/
@Override
protected void doInit() throws ResourceException {
- storage = (Storage)getContext().getAttributes().get(Storage.class.getName());
-
- builder = new GsonBuilder();
- // Register an adapter to manage the date types as long values
- //GSON builder to format dates
-
- builder = new GsonBuilder();
- builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
-
- 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());
- }
- });
-
+ super.doInit();
}
/**
Modified: branches/ng-jtimer/src/main/resources/jtimer-default.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-07-03 13:12:30 UTC (rev 3010)
@@ -2,7 +2,7 @@
# jTimer default properties
###
# jTimer storage path
-jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimerNew
+jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/newWithAlarm
###
# SQL properties
###
@@ -10,7 +10,7 @@
jtimer.storage.table.task=task
jtimer.storage.table.time=tasktime
jtimer.storage.table.version=version
-jtimer.storage.table.alert=taskalert
+jtimer.storage.table.alarm=taskalarm
###
#CREATE SCHEMA
jtimer.storage.create.table.version=CREATE TABLE version (version VARCHAR(10))
@@ -35,19 +35,30 @@
FOREIGN KEY (taskid) \
REFERENCES task (taskId) \
ON DELETE CASCADE)
-jtimer.storage.create.alert=CREATE TABLE taskalert \
- (taskid VARCHAR(255) NOT NULL, \
+jtimer.storage.create.alarm=CREATE TABLE taskalarm \
+ (taskId VARCHAR(255) NOT NULL, \
+ alarmId VARCHAR(255) NOT NULL, \
name VARCHAR(255) NOT NULL, \
type VARCHAR(255) NOT NULL, \
- limitDate LONG, \
+ limitHour INTEGER, \
+ limitMin INTEGER, \
+ remainingMin INTEGER, \
+ remainingHour INTEGER, \
modificationDate LONG, \
- repeatFrequence VARCHAR(255), \
- PRIMARY KEY (taskId, name))
+ removed LONG, \
+ PRIMARY KEY (taskId, alarmId), \
+ FOREIGN KEY (taskid) \
+ REFERENCES task (taskId) \
+ ON DELETE CASCADE)
####
#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) VALUES (?, ?, ?, ?, ?,?, ?, ?)
-jtimer.storage.insert.time=INSERT INTO tasktime (taskid, date, uuid, duration, modificationDate, removed) VALUES (?, ?, ?, ?, ?, ?)
+jtimer.storage.insert.task=INSERT INTO task (name, parent, taskId, hidden, note,creationDate, modificationDate, removed) \
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
+jtimer.storage.insert.time=INSERT INTO tasktime (taskid, date, uuid, duration, modificationDate, removed) \
+ VALUES (?, ?, ?, ?, ?, ?)
+jtimer.storage.insert.alarm=INSERT INTO taskalarm (taskid, alarmId, name, type, limitHour, \
+ limitMin, remainingHour, remainingMin, modificationDate, removed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
###
#SELECT
jtimer.storage.select.table.name=SELECT table_name FROM information_schema.tables;
@@ -85,17 +96,28 @@
jtimer.storage.select.report.roottasks=SELECT * \
FROM task \
WHERE (taskId not in (SELECT taskid FROM tasktime) AND removed = 0 )
+jtimer.storage.select.alarm.ondate= SELECT * \
+ FROM taskalarm \
+ WHERE modificationDate > ?
+jtimer.storage.select.alarm.fortask= SELECT * \
+ FROM taskalarm \
+ WHERE removed = 0 AND modificationDate > ? AND taskId = ?
###
#DELETE
jtimer.storage.delete.time.withid=DELETE FROM tasktime WHERE uuid = ?
jtimer.storage.delete.task.withid=DELETE FROM task WHERE taskId = ?
+jtimer.storage.delete.alarm.withid=DELETE FROM taskalarm WHERE alarmId = ?
###
#UPDATE
jtimer.storage.update.task.withid=UPDATE task SET name=?, parent=?, hidden=?, note=?, modificationDate=?, removed=? \
WHERE taskId = ?
jtimer.storage.update.time.withid=UPDATE tasktime SET date=?, duration=?, modificationDate=?, removed = ? \
WHERE uuid = ?
+jtimer.storage.update.alarm.withid=UPDATE tasktime SET remainingHour=?, remainingMin=?, modificationDate=?, removed = ? \
+ WHERE alarmid = ?
jtimer.storage.update.task.forremove=UPDATE task SET removed = ?, modificationDate = ? \
WHERE taskId = ?
jtimer.storage.update.time.forremove=UPDATE tasktime SET removed = ?, modificationDate = ? \
WHERE uuid = ?
+jtimer.storage.update.alarm.forremove=UPDATE tasktime SET removed = ?, modificationDate = ? \
+ WHERE alarmid = ?
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/webapp/css/app.css
===================================================================
--- branches/ng-jtimer/src/main/webapp/css/app.css 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/webapp/css/app.css 2014-07-03 13:12:30 UTC (rev 3010)
@@ -272,4 +272,12 @@
.medium_input{
width : 200px;
+}
+
+.color_red{
+ color : red;
+}
+
+.color_green{
+ color : green;
}
\ 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-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/webapp/js/app.js 2014-07-03 13:12:30 UTC (rev 3010)
@@ -306,7 +306,7 @@
/**
* Module de webtimer
**/
-angular.module('webtimer', ['webtimerFilters', 'ngRoute', 'ngAnimate', 'ui.bootstrap','serverAccessService', 'serverTimeService','serverReportService' ])
+angular.module('webtimer', ['webtimerFilters', 'ngRoute', 'ngAnimate', 'ui.bootstrap','serverAccessService', 'serverTimeService','serverReportService', 'serverAlarmService' ])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/tasks', {templateUrl: 'partials/tasks.html', controller: TasksCtrl}).
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-07-03 13:12:30 UTC (rev 3010)
@@ -1,4 +1,4 @@
-function TasksCtrl($scope, $interval, $timeout, $q, serverTaskAccess, serverTimeAccess, serverReportAccess, $localStorage, $window, $document, $modal, wtWebsocket, jTimerWebsocket) {
+function TasksCtrl($scope, $interval, $timeout, $q, serverTaskAccess, serverTimeAccess, serverAlarmAccess, serverReportAccess, $localStorage, $window, $document, $modal, wtWebsocket, jTimerWebsocket) {
// {Boolean} vrai si on est online
$scope.online = $window.navigator.onLine;
@@ -172,23 +172,23 @@
if(!alarm.type=="Total_Time" && !alarm.isToday()){
alarm.setToday();
- alarm.passedHour = alarm.limitHour;
- alarm.passedMin = alarm.limitMin;
+ alarm.remainingHour = alarm.limitHour;
+ alarm.remainingMin = alarm.limitMin;
}
- if(alarm.passedMin > 0){
- alarm.passedMin -=1;
- }else if(alarm.passedMin == 0){
- alarm.passedMin = 59;
- alarm.passedHour -=1;
+ if(alarm.remainingMin > 0){
+ alarm.remainingMin -=1;
+ }else if(alarm.remainingMin == 0){
+ alarm.remainingMin = 59;
+ alarm.remainingHour -=1;
}
- if(alarm.passedHour == 0 && alarm.passedMin == 0){
+ if(alarm.remainingHour == 0 && alarm.remainingMin == 0){
//console.log("Alarme lancée " +alarm.name +" de type "+ alarm.type + " par " + task.name );
if(alarm.type=="Total_Time"){
alarms.splice(index,1);
}
- alert('Alarme déclenchée, '+alarm.name + ' ce message va s\'auto détruire!\n');
+ alert('Alarme déclenchée: '+alarm.name + '\nVotre alarme va être désactivée.');
}
index+=1;
});
@@ -771,14 +771,35 @@
};
/** Methode qui va tenter d'envoyer la tâche vers le serveur */
- $scope.alarmPopup = function(task){
+ $scope.alarmPopup = function(node){
var modalInstance = $modal.open({
templateUrl: 'partials/alertModal.html',
controller: AlertModalInstanceCtrl,
resolve: {
task : function(){
- return task;
+ return node.task;
+ },
+ time : function(){
+ var res=0;
+
+
+ var recChildren = function(noeud){
+ angular.forEach($scope.data.times[noeud.task.taskId], function(t){
+ res+=t.time;
+ });
+
+ if(noeud.children){
+ angular.forEach(noeud.children, function(child){
+ recChildren(child);
+ });
+ }
+
+ }
+ recChildren(node);
+
+ console.log(res);
+ return res;
}
}
});
@@ -1024,21 +1045,37 @@
};
}
-function AlertModalInstanceCtrl($scope, $modalInstance, task){
+function AlertModalInstanceCtrl($scope, $modalInstance, serverAlarmAccess, task, time){
- $scope.alarm={name : "" , type : "Type", hour : 0, min : 0};
+ var msToHour=function(ms){
+ return ((ms / (1000*60*60)) % 24);
+ }
+ var msToMin=function(ms){
+ return ((ms / (1000*60)) % 60);
+ }
+
+ $scope.valMinHour=function(){
+ return parseInt(msToHour(time));
+ }
+ $scope.valMinMin=function(){
+ return parseInt(msToMin(time));
+ }
+
+ $scope.alarm={name : "" , type : "Type", hour : $scope.valMinHour(), min : $scope.valMinMin()};
+
$scope.name = task.name;
$scope.alarms = task.alarms;
+
$scope.dynamic = function(alarm){
var res = 0;
var limit = alarm.limitHour*60 + alarm.limitMin;
- var passed = alarm.passedHour*60 + alarm.passedMin;
+ var remaining = alarm.remainingHour*60 + alarm.remainingMin;
- res = ((limit-passed)/limit)*100;
+ res = ((limit-remaining)/limit)*100;
return res;
};
@@ -1062,21 +1099,60 @@
* Methode qui sauve l'alarme
*/
$scope.saveAlarm = function(){
- if($scope.alarm.name== "" || $scope.alarm.type=="Type"){
+ if($scope.alarm.name== "" || $scope.alarm.type=="Type" ){
+ }else{
+ console.log("save " +time);
+ minusPreviousTime(time, $scope.alarm.hour, $scope.alarm.min);
- }else{
- $scope.alarms.push(new TaskAlarm(task, $scope.alarm.name, $scope.alarm.type, $scope.alarm.hour, $scope.alarm.min));
+ console.log("apres minus " +$scope.alarm.hour + " "+$scope.alarm.min);
- $scope.alarm.name= "";
- $scope.alarm.type="Type";
- //$scope.alarm.date= new Date();
- $scope.alarm.hour = 0;
- $scope.alarm.min = 0;
+ if($scope.alarm.hour > 0 || $scope.alarm.min> 0 ){
+
+ console.log($scope.alarm.hour + " "+$scope.alarm.min);
+
+ var al = new TaskAlarm(task,undefined ,
+ $scope.alarm.name,
+ $scope.alarm.type,
+ $scope.alarm.hour,
+ $scope.alarm.min);
+
+ $scope.alarms.push(al);
+
+ serverAlarmAccess.create({alarmId : al.alarmId }, angular.toJson(al),
+ function(){
+ console.log("persist alarm success");
+ },
+ function(){
+ console.log("fail");
+ });
+
+ //On remet les elements affiches a la valeur par defaut
+ $scope.alarm.name= "";
+ $scope.alarm.type="Type";
+ //$scope.alarm.date= new Date();
+ $scope.alarm.hour = 0;
+ $scope.alarm.min = 0;
+ }
}
}
+ var minusPreviousTime= function(previousTime, hour, min){
+ var prevHour = msToHour(previousTime);
+ var prevMin = msToMin(previousTime);
+
+ hour-=prevHour;
+
+ if(min - prevMin<0){
+ min = 59 +(min-prevMin);
+ hour -=1;
+ }
+ }
+
+
+
+
$scope.close = function() {
$modalInstance.close();
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-07-03 13:12:30 UTC (rev 3010)
@@ -73,6 +73,7 @@
this.stockedEditedTimes = {};
// {Array of TaskID} la file de temps attendant la synchronisation avec le serveur
this.stockedDeletedTimes = {};
+
};
@@ -527,8 +528,15 @@
* @param {Task} task la tache liee
* @returns {TaskAlarm}
*/
-var TaskAlarm = function (task, name, type, limitHour,limitMin, repeatF) {
+var TaskAlarm = function (task,id, name, type, limitHour,limitMin, repeatF) {
this.taskId = task && task.taskId;
+
+ if(id == undefined){
+ this.alarmId = generateUUID();
+ }else{
+ this.alarmId = id;
+ }
+
this.name = name;
this.type = type;
@@ -536,9 +544,11 @@
this.limitHour = limitHour;
this.limitMin = limitMin;
- this.passedHour = limitHour;
- this.passedMin = limitMin;
+ this.remainingHour = limitHour;
+ this.remainingMin = limitMin;
+ this.modificationDate = Date.now();
+
this.Frequence = repeatF;
};
Modified: branches/ng-jtimer/src/main/webapp/js/service.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/service.js 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/webapp/js/service.js 2014-07-03 13:12:30 UTC (rev 3010)
@@ -1,3 +1,6 @@
+/**
+ * Service qui permet un échange restfull des taches
+ */
angular.module("serverAccessService", ["ngResource"])
.factory("serverTaskAccess", function ( $resource) {
// Encapsule l'acces au server
@@ -15,6 +18,9 @@
}
);
+/**
+ * Service qui permet un échange restfull des temps
+ */
angular.module("serverTimeService", ["ngResource"])
.factory("serverTimeAccess", function ( $resource) {
// Encapsule l'acces au server
@@ -32,6 +38,9 @@
}
);
+/**
+ * Service qui permet un échange restfull des rapports
+ */
angular.module("serverReportService", ["ngResource"])
.factory("serverReportAccess", function ( $resource) {
// Encapsule l'acces au server
@@ -41,4 +50,22 @@
}
);
}
+);
+
+/**
+ * Service qui permet un échange restfull des alarmes
+ */
+angular.module("serverAlarmService", ["ngResource"])
+.factory("serverAlarmAccess", function ( $resource) {
+ // Encapsule l'acces au server
+ return $resource("/rest/tasks/alarm/:alarmId",{},
+ {
+ query : {method:'GET', isArray:true},
+ get : {method: 'GET', isArray: false},
+ update: {method: "PUT"},
+ create: { method: 'POST' },
+ deleteAlarm: { method: 'DELETE' }
+ }
+ );
+ }
);
\ 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-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/webapp/partials/alertModal.html 2014-07-03 13:12:30 UTC (rev 3010)
@@ -33,12 +33,17 @@
<th></th>
</tr>
+ <tr>
+ <th>Nouveau:</th>
+ </tr>
+
<tr>
+
<th></th>
<th><input class='input-sm small_input' ng-model="alarm.name" placeholder="New Alert">
- <i class="glyphicon glyphicon-edit" ng-show="alarm.name==''"> </i>
- <i class="glyphicon glyphicon-check" ng-show="alarm.name!=''"> </i></th>
+ <i class="glyphicon glyphicon-edit color_red" ng-show="alarm.name==''"> </i>
+ <i class="glyphicon glyphicon-check color_green" ng-show="alarm.name!=''"> </i></th>
<th>
<div class="btn-group" dropdown is-open="status.isopen">
<button type="button" class="btn btn-primary dropdown-toggle">
@@ -49,8 +54,8 @@
<li ng-click="dropdownType2()">Total_Time</li>
</ul>
</div>
- <i class="glyphicon glyphicon-edit" ng-show="alarm.type=='Type'"> </i>
- <i class="glyphicon glyphicon-check" ng-show="alarm.type!='Type'"> </i>
+ <i class="glyphicon glyphicon-edit color_red" ng-show="alarm.type=='Type'"> </i>
+ <i class="glyphicon glyphicon-check color_green"ng-show="alarm.type!='Type'"> </i>
</th>
<th>
<!--<timepicker ng-model="alarm.date" ng-change="changed()"
@@ -58,18 +63,18 @@
</timepicker>-->
<div ng-if="alarm.type!='Total_Time'">
- <input type="number" step="1" min="0" max="23" ng-model="alarm.hour">h:
- <input type="number" step="1" min="0" max="59" ng-model="alarm.min">m
+ <input type="number" step="1" min="{{valMinHour()}}" max="23" ng-model="alarm.hour">h:
+ <input type="number" step="1" min="{{valMinMin()}}" max="59" ng-model="alarm.min">m
</div>
<div ng-if="alarm.type=='Total_Time'">
- <input class="xsmall_input" type="number" step="1" min="0" max="" ng-model="alarm.hour">h:
- <input class="xsmall_input" type="number" step="1" min="0" max="" ng-model="alarm.min">m
+ <input class="xsmall_input" type="number" step="1" min="{{valMinHour()}}" max="" ng-model="alarm.hour">h:
+ <input class="xsmall_input" type="number" step="1" min="{{valMinMin()}}" max="59" ng-model="alarm.min">m
</div>
</th>
<th></th>
- <th><i class="glyphicon glyphicon-ok" ng-click="saveAlarm()"></i></th>
+ <th><i class="glyphicon glyphicon-ok green" ng-click="saveAlarm()"></i></th>
</tr>
</div>
@@ -77,6 +82,6 @@
<div class="modal-footer">
- <button class="btn btn-primary" ng-click="cancel()">Cancel</button>
+ <!--<button class="btn btn-primary" ng-click="cancel()">Cancel</button>-->
<button class="btn btn-primary" ng-click="close()">Close</button>
</div>
Modified: branches/ng-jtimer/src/main/webapp/partials/tasks.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-07-03 13:12:30 UTC (rev 3010)
@@ -91,7 +91,7 @@
ng-show="!$node.task.isRoot() ">
<i class="glyphicon glyphicon-pencil" ></i>
</a>
- <a class="btn btn-default btn-xs" ng-click="alarmPopup($node.task)">
+ <a class="btn btn-default btn-xs" ng-click="alarmPopup($node)">
<i class="glyphicon glyphicon-bell" ></i>
</a>
</span>
1
0
r3009 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/storage resources webapp/css webapp/js webapp/partials
by obruce@users.chorem.org 01 Jul '14
by obruce@users.chorem.org 01 Jul '14
01 Jul '14
Author: obruce
Date: 2014-07-01 17:47:05 +0200 (Tue, 01 Jul 2014)
New Revision: 3009
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3009
Log:
interface alarm
Added:
branches/ng-jtimer/src/main/webapp/partials/alertModal.html
Modified:
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/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/tasks.html
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-06-27 09:46:09 UTC (rev 3008)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-07-01 15:47:05 UTC (rev 3009)
@@ -36,7 +36,7 @@
protected static final String TABLE_TASK = "task";
protected static final String TABLE_TIME = "tasktime";
- protected static final String TABLE_VERSION = "version";
+ protected String TABLE_VERSION;
protected String STORAGE_PATH;
protected JtimerConfig config;
@@ -47,6 +47,7 @@
this.config = conf;
this.STORAGE_PATH = config.getStoragePath();
+ this.TABLE_VERSION = config.getStorageTableVersion();
try {
if (log.isDebugEnabled()) {
Modified: branches/ng-jtimer/src/main/resources/jtimer-default.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-06-27 09:46:09 UTC (rev 3008)
+++ branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-07-01 15:47:05 UTC (rev 3009)
@@ -10,6 +10,7 @@
jtimer.storage.table.task=task
jtimer.storage.table.time=tasktime
jtimer.storage.table.version=version
+jtimer.storage.table.alert=taskalert
###
#CREATE SCHEMA
jtimer.storage.create.table.version=CREATE TABLE version (version VARCHAR(10))
@@ -34,6 +35,14 @@
FOREIGN KEY (taskid) \
REFERENCES task (taskId) \
ON DELETE CASCADE)
+jtimer.storage.create.alert=CREATE TABLE taskalert \
+ (taskid VARCHAR(255) NOT NULL, \
+ name VARCHAR(255) NOT NULL, \
+ type VARCHAR(255) NOT NULL, \
+ limitDate LONG, \
+ modificationDate LONG, \
+ repeatFrequence VARCHAR(255), \
+ PRIMARY KEY (taskId, name))
####
#INSERT
jtimer.storage.insert.version.number=INSERT INTO VERSION VALUES('2.0')
Modified: branches/ng-jtimer/src/main/webapp/css/app.css
===================================================================
--- branches/ng-jtimer/src/main/webapp/css/app.css 2014-06-27 09:46:09 UTC (rev 3008)
+++ branches/ng-jtimer/src/main/webapp/css/app.css 2014-07-01 15:47:05 UTC (rev 3009)
@@ -262,6 +262,10 @@
margin : auto;
}
+.xsmall_input{
+ width : 50px;
+}
+
.small_input{
width : 100px;
}
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-06-27 09:46:09 UTC (rev 3008)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-07-01 15:47:05 UTC (rev 3009)
@@ -142,6 +142,64 @@
refresh();
/**
+ * Methode qui se lance toutes les minutes pour verifier les alamres des taches
+ */
+ var checkAlarms = function() {
+ $timeout(function() {
+
+ if ($scope.currentTask) {
+
+ checkRecurseParent($scope.currentTask);
+ }
+
+ checkAlarms();
+ }, 60000);
+ };
+ checkAlarms();
+
+ /**
+ *
+ * @param :task la tache
+ */
+ var checkRecurseParent = function(task){
+
+ var alarms= task.alarms;
+ var index=0;
+ var parent = $scope.data.tasks[task.parent];
+
+ angular.forEach(alarms, function(alarm){
+
+
+ if(!alarm.type=="Total_Time" && !alarm.isToday()){
+ alarm.setToday();
+ alarm.passedHour = alarm.limitHour;
+ alarm.passedMin = alarm.limitMin;
+ }
+
+ if(alarm.passedMin > 0){
+ alarm.passedMin -=1;
+ }else if(alarm.passedMin == 0){
+ alarm.passedMin = 59;
+ alarm.passedHour -=1;
+ }
+
+ if(alarm.passedHour == 0 && alarm.passedMin == 0){
+ //console.log("Alarme lancée " +alarm.name +" de type "+ alarm.type + " par " + task.name );
+ if(alarm.type=="Total_Time"){
+ alarms.splice(index,1);
+ }
+ alert('Alarme déclenchée, '+alarm.name + ' ce message va s\'auto détruire!\n');
+ }
+ index+=1;
+ });
+
+
+ if(task.parent != ""){
+ checkRecurseParent(parent);
+ }
+ };
+
+ /**
* Timer qui joue des actions sur un interval donné
* @returns {promise}
*/
@@ -246,7 +304,6 @@
}
}else{
- //Un noeud avec un parent est ajoute à l'arbre de son parent
//On ajoute le node à l'arbre
if ($scope.tree.getNode(item.parent)) {
@@ -714,10 +771,22 @@
};
/** Methode qui va tenter d'envoyer la tâche vers le serveur */
- $scope.persistToServ = function(task){
+ $scope.alarmPopup = function(task){
- };
+ var modalInstance = $modal.open({
+ templateUrl: 'partials/alertModal.html',
+ controller: AlertModalInstanceCtrl,
+ resolve: {
+ task : function(){
+ return task;
+ }
+ }
+ });
+ modalInstance.result.then(function (item) {
+ });
+ }
+
/**
* Active/desactive le comptage de temps pour une tache
* @param {type} task
@@ -913,9 +982,6 @@
}
}
});
-
- modalInstance.result.then(function (item) {
- });
}
/**
@@ -958,6 +1024,66 @@
};
}
+function AlertModalInstanceCtrl($scope, $modalInstance, task){
+
+ $scope.alarm={name : "" , type : "Type", hour : 0, min : 0};
+
+ $scope.name = task.name;
+ $scope.alarms = task.alarms;
+
+
+ $scope.dynamic = function(alarm){
+ var res = 0;
+
+ var limit = alarm.limitHour*60 + alarm.limitMin;
+ var passed = alarm.passedHour*60 + alarm.passedMin;
+
+ res = ((limit-passed)/limit)*100;
+
+ return res;
+ };
+
+ $scope.dropdownType1= function(){
+ $scope.alarm.type = "Total_Day_Time";
+ }
+
+ $scope.dropdownType2 = function(){
+ $scope.alarm.type = "Total_Time";
+ }
+
+ /**
+ * Methode qui supprime un element du tableau d'alerte
+ */
+ $scope.removeAlert = function(index,a){
+ $scope.alarms.splice(index, 1);
+ }
+
+ /**
+ * Methode qui sauve l'alarme
+ */
+ $scope.saveAlarm = function(){
+ if($scope.alarm.name== "" || $scope.alarm.type=="Type"){
+
+
+
+ }else{
+ $scope.alarms.push(new TaskAlarm(task, $scope.alarm.name, $scope.alarm.type, $scope.alarm.hour, $scope.alarm.min));
+
+ $scope.alarm.name= "";
+ $scope.alarm.type="Type";
+ //$scope.alarm.date= new Date();
+ $scope.alarm.hour = 0;
+ $scope.alarm.min = 0;
+ }
+ }
+
+ $scope.close = function() {
+
+ $modalInstance.close();
+ };
+}
+
+
function ReportModalInstanceCtrl($scope, $modalInstance,$http, $sce, serverReportAccess, tree){
$scope.tree = tree;
@@ -976,6 +1102,10 @@
return $sce.trustAsHtml(data);
}
+ /**
+ * Methode de generation du rapport
+ *
+ */
$scope.generateReport= function(){
$scope.obj.startDate.setHours(0,0,0,0);
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-06-27 09:46:09 UTC (rev 3008)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-07-01 15:47:05 UTC (rev 3009)
@@ -403,6 +403,7 @@
this.name = name;
this.description = "";
this.isReported = true;
+ this.alarms=[];
this.tags = [];
this.syncOptions = {};
};
@@ -521,7 +522,37 @@
return this;
};
+/**
+ * Permet de conserver une alarme
+ * @param {Task} task la tache liee
+ * @returns {TaskAlarm}
+ */
+var TaskAlarm = function (task, name, type, limitHour,limitMin, repeatF) {
+ this.taskId = task && task.taskId;
+ this.name = name;
+ this.type = type;
+ this.date = today();
+
+ this.limitHour = limitHour;
+ this.limitMin = limitMin;
+ this.passedHour = limitHour;
+ this.passedMin = limitMin;
+
+ this.Frequence = repeatF;
+
+};
+
+TaskAlarm.prototype.isToday = function() {
+ var result = this.date === today();
+ return result;
+};
+
+TaskAlarm.prototype.setToday = function() {
+ this.date=today();
+};
+
+
/**
* Represente une note pour une tache
* @param {Task} task
Added: branches/ng-jtimer/src/main/webapp/partials/alertModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/alertModal.html (rev 0)
+++ branches/ng-jtimer/src/main/webapp/partials/alertModal.html 2014-07-01 15:47:05 UTC (rev 3009)
@@ -0,0 +1,82 @@
+<h3>Les alarmes pour {{name}} :</h3>
+
+<hr/>
+
+<table class='table'>
+ <thead>
+ <tr>
+ <th></th>
+ <th>Name</th>
+ <th>Type</th>
+ <th>Limit time</th>
+ <th>Progress</th>
+ <th></th>
+ </tr>
+ </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">
+ <th><i class="glyphicon glyphicon-minus-sign" ng-click="removeAlert(index,alarm)"></i></th>
+
+ <th>{{alarm.name}}</th>
+ <th>{{alarm.type}}</th>
+ <th>{{alarm.limitHour}}h: {{alarm.limitMin}}min</th>
+ <th>
+ <progressbar value="dynamic(alarm)"></progressbar>
+ </th>
+ <th></th>
+ </tr>
+
+
+ <tr>
+ <th></th>
+ <th><input class='input-sm small_input' ng-model="alarm.name" placeholder="New Alert">
+ <i class="glyphicon glyphicon-edit" ng-show="alarm.name==''"> </i>
+ <i class="glyphicon glyphicon-check" ng-show="alarm.name!=''"> </i></th>
+ <th>
+ <div class="btn-group" dropdown is-open="status.isopen">
+ <button type="button" class="btn btn-primary dropdown-toggle">
+ {{alarm.type}} <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu" role="menu">
+ <li ng-click="dropdownType1()">Total_Time_In_a_Day</li>
+ <li ng-click="dropdownType2()">Total_Time</li>
+ </ul>
+ </div>
+ <i class="glyphicon glyphicon-edit" ng-show="alarm.type=='Type'"> </i>
+ <i class="glyphicon glyphicon-check" ng-show="alarm.type!='Type'"> </i>
+ </th>
+ <th>
+ <!--<timepicker ng-model="alarm.date" ng-change="changed()"
+ hour-step="1" minute-step="1" show-meridian="ismeridian">
+
+ </timepicker>-->
+ <div ng-if="alarm.type!='Total_Time'">
+ <input type="number" step="1" min="0" max="23" ng-model="alarm.hour">h:
+ <input type="number" step="1" min="0" max="59" ng-model="alarm.min">m
+ </div>
+
+ <div ng-if="alarm.type=='Total_Time'">
+ <input class="xsmall_input" type="number" step="1" min="0" max="" ng-model="alarm.hour">h:
+ <input class="xsmall_input" type="number" step="1" min="0" max="" ng-model="alarm.min">m
+ </div>
+
+ </th>
+ <th></th>
+ <th><i class="glyphicon glyphicon-ok" ng-click="saveAlarm()"></i></th>
+ </tr>
+ </div>
+
+</table>
+
+
+<div class="modal-footer">
+ <button class="btn btn-primary" ng-click="cancel()">Cancel</button>
+ <button class="btn btn-primary" ng-click="close()">Close</button>
+</div>
Modified: branches/ng-jtimer/src/main/webapp/partials/tasks.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-06-27 09:46:09 UTC (rev 3008)
+++ branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-07-01 15:47:05 UTC (rev 3009)
@@ -37,7 +37,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">Dernière mise à jour: {{getLastMajDate()}}</span>
+ <span class="right">Last update : {{getLastMajDate()}}</span>
</div>
@@ -69,11 +69,12 @@
<i class="glyphicon glyphicon-minus-sign" ng-click="$toggleState()" ng-show="$state=='open'"></i>
<!--Project name visible and editable -->
- <form ng-submit="saveTask($node)" ng-show="$node.edit == 'name'">
+ <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>
+
<!-- Action button, add,remove activate task -->
<span class="btn-group action">
<a class="btn btn-default btn-xs" ng-click="timeTask($node.task)" ng-show="$level > 1">
@@ -90,8 +91,8 @@
ng-show="!$node.task.isRoot() ">
<i class="glyphicon glyphicon-pencil" ></i>
</a>
- <a class="btn btn-default btn-xs" ng-click="persistToServ($node.task)">
- <i class="glyphicon glyphicon-floppy-disk" ></i>
+ <a class="btn btn-default btn-xs" ng-click="alarmPopup($node.task)">
+ <i class="glyphicon glyphicon-bell" ></i>
</a>
</span>
</div>
1
0
r3008 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/storage java/org/chorem/jtimer/utils java/org/chorem/jtimer/web webapp/js webapp/partials
by obruce@users.chorem.org 27 Jun '14
by obruce@users.chorem.org 27 Jun '14
27 Jun '14
Author: obruce
Date: 2014-06-27 11:46:09 +0200 (Fri, 27 Jun 2014)
New Revision: 3008
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3008
Log:
controller et serveur : module de rapport
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheHandler.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ReportResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java
branches/ng-jtimer/src/main/webapp/js/controllers.js
branches/ng-jtimer/src/main/webapp/partials/reportModal.html
branches/ng-jtimer/src/main/webapp/partials/reportNestedTask.html
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-06-25 16:08:07 UTC (rev 3007)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-06-27 09:46:09 UTC (rev 3008)
@@ -434,7 +434,7 @@
return times;
}
- public HashMap getReportByProject(Long startDate, Long endDate){
+ public HashMap<String, ArrayList<ReportTask>> getReportByProject(Long startDate, Long endDate){
HashMap map = new HashMap();
PreparedStatement statement = null;
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheHandler.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheHandler.java 2014-06-25 16:08:07 UTC (rev 3007)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheHandler.java 2014-06-27 09:46:09 UTC (rev 3008)
@@ -39,17 +39,17 @@
}
//un enfant
- if(!t.getParent().equals("")){
+ if(!t.getParentId().equals("")){
log.info("enfant");
//On ajoute l'enfant à la map
ArrayList tmp = new ArrayList();
- if(childMap.get(t.parent) != null){
- tmp=childMap.get(t.parent);
+ if(childMap.get(t.parentId) != null){
+ tmp=childMap.get(t.parentId);
}
tmp.add(t);
- childMap.put(t.parent, tmp);
+ childMap.put(t.parentId, tmp);
iter.remove();
}
}
@@ -58,7 +58,7 @@
while(iter.hasNext()) {
ReportTask t = (ReportTask)iter.next();
- if(t.getTime().isNotTimed()){
+ if(t.getSelftime() == 0){
iter.remove();
}
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.java 2014-06-25 16:08:07 UTC (rev 3007)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.java 2014-06-27 09:46:09 UTC (rev 3008)
@@ -1,5 +1,9 @@
package org.chorem.jtimer.utils;
+import com.google.gson.annotations.Expose;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import java.util.ArrayList;
/**
@@ -11,28 +15,34 @@
*/
public class ReportTask {
+ protected static final Log log = LogFactory.getLog(ReportTask.class);
+
/** Le nom de la tache*/
- protected String name;
- protected String taskId;
- protected String parent;
- protected long time;
- protected boolean isReported;
+ @Expose protected String name;
+ @Expose protected String taskId;
+ @Expose protected String parentId;
- protected ArrayList subtasks;
+ protected ReportTask rtParent; //to be omitted in serialization
+ @Expose protected long selftime;
+ @Expose protected long childtime;
+
+ @Expose protected ArrayList<ReportTask> subtasks;
+
/**
* Constructeur
* @param name le nom
* @param taskId l'identifiant
* @param parent l'identifiant du parent
- * @param time le temps
+ * @param selftime le temps
*/
- public ReportTask(String name, String taskId, String parent, long time){
+ public ReportTask(String name, String taskId, String parent, long selftime){
this.taskId = taskId;
this.name = name;
- this.parent = parent;
- this.time = time;
- this.isReported = false;
+ this.parentId = parent;
+ this.selftime = selftime;
+ this.childtime = 0;
+ this.rtParent = null;
this.subtasks = new ArrayList();
}
@@ -40,9 +50,34 @@
/** Ajout */
public void addChild(ReportTask t){
this.subtasks.add(t);
- this.time+= t.getTime();
}
+
+ /**
+ * Ajout de temps d'un enfant
+ */
+ public void addChildTime(long t){
+
+ if(hasParent()) {
+
+ rtParent.addChildTime(t);
+ }
+ this.childtime +=t;
+ }
+
+
+ /**
+ * Ajout de temps d'un enfant
+ */
+ public void removeChildTime(long t){
+
+ if(hasParent()) {
+
+ rtParent.removeChildTime(t);
+ }
+ this.childtime -=t;
+ }
+
/**Getter */
public String getTaskId() {
@@ -53,30 +88,43 @@
return name;
}
- public String getParent() {
- return parent;
+ public String getParentId() {
+ return parentId;
}
- public long getTime() {
- return time;
+
+ public ReportTask getRtParent() {
+ return rtParent;
}
- public boolean isReported() {
- return isReported;
+ public void setRtParent(ReportTask reportTask) {
+ this.rtParent = reportTask;
}
- public void setReported(boolean isReported) {
- this.isReported = isReported;
+ public boolean hasParent(){ return this.rtParent != null;}
+
+ public long getSelftime() {
+ return selftime;
}
+ public long getChildtime() {
+ return childtime;
+ }
+
+ public ArrayList<ReportTask> getSubtasks() {
+ return subtasks;
+ }
+
+
@Override
public String toString() {
return "ReportTask{" +
"name='" + name + '\'' +
", taskId='" + taskId + '\'' +
- ", parent='" + parent + '\'' +
- ", time=" + time +
- ", subtasks=" + subtasks.toString() +
+ ", parent='" + parentId + '\'' +
+ ", selftime=" + selftime +
+ ", childtime=" + childtime +
+ ", subtasks=" + subtasks +
'}';
}
}
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-06-25 16:08:07 UTC (rev 3007)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ReportResource.java 2014-06-27 09:46:09 UTC (rev 3008)
@@ -1,6 +1,7 @@
package org.chorem.jtimer.web;
import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.storage.Storage;
@@ -14,6 +15,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
/**
* Created by olivia on 11/06/14.
@@ -30,6 +32,7 @@
@Override
protected void doInit() throws ResourceException {
+
storage = (Storage) getContext().getAttributes().get(Storage.class.getName());
}
/**
@@ -44,7 +47,7 @@
if(representation.isAvailable()) {
String repr1 = representation.getText();
- Gson gson =new Gson();
+ Gson gson = new Gson();
toReport = gson.fromJson(repr1, ArrayList.class);
}
@@ -72,19 +75,20 @@
//MustacheReport report = new MustacheReport(getContext());
//res = report.createByProjectMustache(type, startDate, endDate,reprArray);
- Gson gson = new Gson();
- HashMap storedTask = storage.getReportByProject(startDate, endDate);
- ArrayList res = new ArrayList();
+ //On ne recupere que les elements interessants
+ Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
+ HashMap<String, ArrayList<ReportTask>> storedTask = storage.getReportByProject(startDate, endDate);
+ ArrayList<ReportTask> res = new ArrayList<>(); //l'arraylist de resultat
+
//On recree l'arbre
- for(ReportTask rt: (ArrayList<ReportTask>)storedTask.get("")){
- reccursivSortTask(storedTask, rt, res );
+ for(ReportTask rt: storedTask.get("")){
+ recursivSortTask(storedTask, rt, res );
}
//On enleve les éléments non voulus
+ recursiveRemoveUnreportedTask(res,toReport);
-
-
String json = gson.toJson(res, ArrayList.class);
return new StringRepresentation(json, MediaType.TEXT_HTML);
@@ -96,22 +100,69 @@
* @param rt the current task
* @param res the tree array
*/
- private void reccursivSortTask(HashMap map, ReportTask rt, ArrayList res ){
+ private void recursivSortTask(HashMap<String,ArrayList<ReportTask>> map, ReportTask rt, ArrayList<ReportTask> res ){
if(map.containsKey(rt.getTaskId())) {
- for (ReportTask child : (ArrayList<ReportTask>) map.get(rt.getTaskId())) {
- reccursivSortTask(map, child, res);
+ for (ReportTask child : map.get(rt.getTaskId())) {
+ child.setRtParent(rt);
+ log.info(child.getName() + " setparent " +rt.getName());
- if(child.getTime() != (long) 0){
+ recursivSortTask(map, child, res);
+
+ if(child.getSelftime()!= (long) 0 || child.getChildtime()!= (long) 0){
+ log.info(rt.getName() + " enfante car != 0 : " +child.getName());
rt.addChild(child);
+ rt.addChildTime(child.getSelftime());
}
-
}
}
- if(rt.getParent() == "" && rt.getTime() != 0){
+ 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<ReportTask> iter = toCheck.iterator();
+
+ while(iter.hasNext()) {
+ ReportTask repT= iter.next();
+
+ if(!repT.getSubtasks().isEmpty()) {
+ recursiveRemoveUnreportedTask(repT.getSubtasks(), wanted);
+ }
+ if(!idIsInArray(repT.getTaskId(),wanted)){
+ repT.getRtParent().removeChildTime(repT.getSelftime());
+ 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
+ * @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/java/org/chorem/jtimer/web/RestApplication.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java 2014-06-25 16:08:07 UTC (rev 3007)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java 2014-06-27 09:46:09 UTC (rev 3008)
@@ -94,7 +94,6 @@
protected class TodoTask extends java.util.TimerTask{
@Override
public void run() {
- log.info("Passage dans le run");
if(connected){
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-06-25 16:08:07 UTC (rev 3007)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-06-27 09:46:09 UTC (rev 3008)
@@ -1003,9 +1003,12 @@
$scope.htmlReport = data;
angular.forEach(data, function(d){
- console.log(d);
- $scope.reportedTask.push({name : d.name, time : d.time})
- })
+ $scope.reportedTask.push({
+ name : d.name,
+ selftime : d.selftime,
+ childtime : d.childtime,
+ subtasks : d.subtasks})
+ });
}
);
}
@@ -1031,24 +1034,22 @@
/**Check all checkbox*/
$scope.checkAll= function(){
- angular.forEach(tree.children, function(child){
- recurseChildEncapsulated(child,encapFonc(child, true))
- });
+ recurseChildEncapsulated(tree, true);
+
};
/**Uncheck all checkbox*/
$scope.uncheckAll= function(){
- angular.forEach(tree.children, function(child){
- recurseChildEncapsulated(child,encapFonc(child, false))
- });
+ recurseChildEncapsulated(tree,false);
};
/**
* Reccursion sur l'arbre
*/
- var recurseChildEncapsulated = function(child, encapsulated){
+ var recurseChildEncapsulated = function(child, bool){
angular.forEach(child.children, function(childnode){
- recurseChildEncapsulated(childnode, encapFonc(child, true))
+ recurseChildEncapsulated(childnode, bool)
+ encapFonc(childnode, bool)
});
}
Modified: branches/ng-jtimer/src/main/webapp/partials/reportModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-06-25 16:08:07 UTC (rev 3007)
+++ branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-06-27 09:46:09 UTC (rev 3008)
@@ -7,7 +7,7 @@
<div >
<!-- Datepicker div -->
- <div style="border:1px solid black; display : inline-block;vertical-align: top;margin-left:2px;">
+ <div style="border:1px solid black; display : inline-block;vertical-align: top;margin-left:1px;margin-right:1px;">
<h4><u>Option :</u></h4>
De :
<div style="margin-left:2px;" ng-controller="ReportDatePickerCtrl" class="row">
@@ -22,7 +22,7 @@
</div>
A :
- <div style="margin-left:2px;" class="row" ng-controller="ReportDatePickerCtrl">
+ <div style="margin-left:1px;margin-right:1px;" class="row" ng-controller="ReportDatePickerCtrl">
<div class="col-md-6">
<p class="input-group medium_input">
<input type="text" class="form-control" datepicker-popup="{{format}}" ng-model="obj.endDate" is-open="opened" min-date="obj.startDate" max-date="maxDate" ng-required="true" close-text="Close" />
@@ -77,15 +77,22 @@
<div style="display : inline-block; vertical-align: top; width : 350px">
<alert type="info" >
- <span>
- <h4>Projet :</h4>
- <div ng-repeat="task in reportedTask">
- {{task.name}} : {{task.time|time}}
- <div ng-repeat="subtask in task.subtasks" ng-include="reportNestedTask.html">
- {{subtask.name}} : {{subtask.time|time}}
+ <span ng-show="!reportTask.length" >
+ <h4><b>Génération du rapport :</b></h4>
+ <div ng-repeat="task in reportedTask" >
+ <b>Projet : {{task.name}} </b>
+
+ <div style="margin-left : 10px" ng-repeat="subtask in task.subtasks" ng-include="'./partials/reportNestedTask.html'">
+
</div>
+ Temps total : {{task.childtime|time}}
+ <hr/>
</div>
+ </span >
+
+ <span ng-show="reportedTask.length == 0" >
+ Pas de tâches sur cette période.
</span>
</alert>
Modified: branches/ng-jtimer/src/main/webapp/partials/reportNestedTask.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/reportNestedTask.html 2014-06-25 16:08:07 UTC (rev 3007)
+++ branches/ng-jtimer/src/main/webapp/partials/reportNestedTask.html 2014-06-27 09:46:09 UTC (rev 3008)
@@ -1,5 +1,8 @@
-<div ng-repeat="task in subtasks">
- {{task.name}} : {{task.time|time}}
- <div ng-repeat="subtask in subtasks" ng-include="reportNestedTask.html"></div>
-</div>
\ No newline at end of file
+<div style="display : block" >
+ <div style="min-width : 100px; max-width : 110px; display : inline-block;">-{{subtask.name}}</div>
+ <div style="min-width : 100px; max-width : 150px; display : inline-block;" ng-show="subtask.selftime != 0">{{subtask.selftime|time}} </div>
+</div>
+<div style="margin-left : 10px"
+ ng-repeat="subtask in subtask.subtasks" ng-include="'./partials/reportNestedTask.html'">
+</div>
1
0
r3007 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/storage java/org/chorem/jtimer/utils java/org/chorem/jtimer/web resources webapp/js webapp/partials
by obruce@users.chorem.org 25 Jun '14
by obruce@users.chorem.org 25 Jun '14
25 Jun '14
Author: obruce
Date: 2014-06-25 18:08:07 +0200 (Wed, 25 Jun 2014)
New Revision: 3007
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3007
Log:
construction arbre serveur +json du rapport + d?\195?\169but pr?\195?\169sentation rapport dans l'interface
Added:
branches/ng-jtimer/src/main/webapp/partials/reportNestedTask.html
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheHandler.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheReport.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.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/service.js
branches/ng-jtimer/src/main/webapp/partials/reportModal.html
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-06-24 13:20:34 UTC (rev 3006)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-06-25 16:08:07 UTC (rev 3007)
@@ -15,6 +15,7 @@
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
/**
@@ -433,9 +434,9 @@
return times;
}
- public List getReportByProject(Long startDate, Long endDate){
+ public HashMap getReportByProject(Long startDate, Long endDate){
- List list = new ArrayList<ReportTask>();
+ HashMap map = new HashMap();
PreparedStatement statement = null;
PreparedStatement statement2 = null;
try{
@@ -446,8 +447,17 @@
ResultSet rs = statement.executeQuery();
while(rs.next()){
- list.add(new ReportTask(rs.getString("task"),rs.getString("taskid"),
- rs.getString("parent") , rs.getLong("totalduration"), rs.getLong("creationDate")));
+ ReportTask task = new ReportTask(rs.getString("name"),
+ rs.getString("taskId"),
+ rs.getString("parent"),
+ rs.getLong("totalduration"));
+
+ ArrayList tmp = new ArrayList();
+ if(map.containsKey(rs.getString("parent"))){
+ tmp = (ArrayList) map.get(rs.getString("parent"));
+ }
+ tmp.add(task);
+ map.put(rs.getString("parent"), tmp);
}
// not timed tasks
@@ -455,8 +465,17 @@
rs = statement2.executeQuery();
while(rs.next()){
- list.add(new ReportTask(rs.getString("name"), rs.getString("taskId"),
- rs.getString("parent"), (long) 0, rs.getLong("creationDate")));
+ ReportTask task = new ReportTask(rs.getString("name"),
+ rs.getString("taskId"),
+ rs.getString("parent"),
+ (long) 0);
+
+ ArrayList tmp = new ArrayList();
+ if(map.containsKey(rs.getString("parent"))){
+ tmp = (ArrayList) map.get(rs.getString("parent"));
+ }
+ tmp.add(task);
+ map.put(rs.getString("parent"), tmp);
}
}catch(SQLException ex) {
@@ -466,7 +485,7 @@
closeStatement(statement2);
}
- return list;
+ return map;
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheHandler.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheHandler.java 2014-06-24 13:20:34 UTC (rev 3006)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheHandler.java 2014-06-25 16:08:07 UTC (rev 3007)
@@ -19,6 +19,8 @@
protected static final Log log = LogFactory.getLog(MustacheReport.class);
+ protected ArrayList reprArray;
+
List<ReportTask> tasks;
List tasks() {
@@ -68,9 +70,11 @@
/**
* Constructeur
* @param mustacheList la liste des taches
+ * @param reprArray
*/
- public MustacheHandler(List<ReportTask> mustacheList){
+ public MustacheHandler(List mustacheList, ArrayList reprArray){
this.tasks = mustacheList;
+ this.reprArray = reprArray;
log.debug(mustacheList);
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheReport.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheReport.java 2014-06-24 13:20:34 UTC (rev 3006)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheReport.java 2014-06-25 16:08:07 UTC (rev 3007)
@@ -10,6 +10,7 @@
import java.io.IOException;
import java.io.StringWriter;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -41,7 +42,7 @@
* Methode qui cree une moustache
* @throws IOException
*/
- public String createByProjectMustache(String type, long start, long end) throws IOException {
+ public String createByProjectMustache(String type, long start, long end, ArrayList reprArray) throws IOException {
log.info("create a Mustache by project");
MustacheFactory mf = new DefaultMustacheFactory();
@@ -49,10 +50,10 @@
//On recupere les taches
- mustacheList = storage.getReportByProject(start, end);
+ //mustacheList = storage.getReportByProject(start, end);
StringWriter sw = new StringWriter();
- mustache.execute(sw, new MustacheHandler(mustacheList)).flush();
+ mustache.execute(sw, new MustacheHandler(mustacheList,reprArray)).flush();
return sw.toString();
}
@@ -63,9 +64,6 @@
MustacheFactory mf = new DefaultMustacheFactory();
Mustache mustache = mf.compile("ByWeek_template.mustache");
-
- storage.getReportByWeek(start, end);
-
StringWriter sw = new StringWriter();
//mustache.execute(sw, MustacheHandler.getByWeekReport());
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.java 2014-06-24 13:20:34 UTC (rev 3006)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.java 2014-06-25 16:08:07 UTC (rev 3007)
@@ -1,10 +1,6 @@
package org.chorem.jtimer.utils;
-import org.chorem.jtimer.utils.Resource.ReportTime;
-
import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
/**
* Created by olivia on 16/06/14.
@@ -19,10 +15,10 @@
protected String name;
protected String taskId;
protected String parent;
- protected ReportTime time;
- protected List subtasks;
+ protected long time;
+ protected boolean isReported;
- protected Date creationDate;
+ protected ArrayList subtasks;
/**
* Constructeur
@@ -31,12 +27,12 @@
* @param parent l'identifiant du parent
* @param time le temps
*/
- public ReportTask(String name, String taskId, String parent, long time,long date){
- this.creationDate = new Date(date);
+ public ReportTask(String name, String taskId, String parent, long time){
this.taskId = taskId;
this.name = name;
this.parent = parent;
- this.time = new ReportTime(time);
+ this.time = time;
+ this.isReported = false;
this.subtasks = new ArrayList();
}
@@ -44,7 +40,7 @@
/** Ajout */
public void addChild(ReportTask t){
this.subtasks.add(t);
- this.time.addTime(t.getTime());
+ this.time+= t.getTime();
}
/**Getter */
@@ -61,10 +57,18 @@
return parent;
}
- public ReportTime getTime() {
+ public long getTime() {
return time;
}
+ public boolean isReported() {
+ return isReported;
+ }
+
+ public void setReported(boolean isReported) {
+ this.isReported = isReported;
+ }
+
@Override
public String toString() {
return "ReportTask{" +
@@ -72,7 +76,7 @@
", taskId='" + taskId + '\'' +
", parent='" + parent + '\'' +
", time=" + time +
- ", subtasks=" + subtasks +
+ ", subtasks=" + subtasks.toString() +
'}';
}
}
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-06-24 13:20:34 UTC (rev 3006)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ReportResource.java 2014-06-25 16:08:07 UTC (rev 3007)
@@ -1,14 +1,19 @@
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.utils.MustacheReport;
+import org.chorem.jtimer.storage.Storage;
+import org.chorem.jtimer.utils.ReportTask;
import org.restlet.data.MediaType;
import org.restlet.representation.Representation;
import org.restlet.representation.StringRepresentation;
-import org.restlet.resource.Get;
+import org.restlet.resource.Post;
+import org.restlet.resource.ResourceException;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
/**
* Created by olivia on 11/06/14.
@@ -21,17 +26,29 @@
protected static final Log log = LogFactory.getLog(ReportResource.class);
+ protected Storage storage;
+
+ @Override
+ protected void doInit() throws ResourceException {
+ storage = (Storage) getContext().getAttributes().get(Storage.class.getName());
+ }
/**
* Methode qui retourne la representation du rapport
* Suite a une requete de type GET
*
* @return representation du rapport
*/
- @Get
- public Representation getReport() throws IOException {
+ @Post("json")
+ public Representation getReport(Representation representation) throws IOException {
+ ArrayList toReport = new ArrayList();
+ if(representation.isAvailable()) {
+ String repr1 = representation.getText();
+ Gson gson =new Gson();
+ toReport = gson.fromJson(repr1, ArrayList.class);
+ }
+
String type ="BY_PROJECT";
- String res="";
long startDate = (long) 0;
long endDate = Long.MAX_VALUE;
@@ -52,13 +69,49 @@
}
- MustacheReport report = new MustacheReport(getContext());
+ //MustacheReport report = new MustacheReport(getContext());
+ //res = report.createByProjectMustache(type, startDate, endDate,reprArray);
+ Gson gson = new Gson();
+ HashMap storedTask = storage.getReportByProject(startDate, endDate);
+ ArrayList res = new ArrayList();
- res = report.createByProjectMustache(type, startDate, endDate);
- log.info("Ce qui est produit " + res);
+ //On recree l'arbre
+ for(ReportTask rt: (ArrayList<ReportTask>)storedTask.get("")){
+ reccursivSortTask(storedTask, rt, res );
+ }
+ //On enleve les éléments non voulus
- return new StringRepresentation(res, MediaType.TEXT_HTML);
+
+
+ String json = gson.toJson(res, ArrayList.class);
+
+ return new StringRepresentation(json, MediaType.TEXT_HTML);
}
-}
\ No newline at end of file
+
+ /**
+ * 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 reccursivSortTask(HashMap map, ReportTask rt, ArrayList res ){
+
+ if(map.containsKey(rt.getTaskId())) {
+ for (ReportTask child : (ArrayList<ReportTask>) map.get(rt.getTaskId())) {
+ reccursivSortTask(map, child, res);
+
+ if(child.getTime() != (long) 0){
+ rt.addChild(child);
+ }
+
+ }
+ }
+
+ if(rt.getParent() == "" && rt.getTime() != 0){
+ res.add(rt);
+ }
+ }
+}
+
Modified: branches/ng-jtimer/src/main/resources/jtimer-default.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-06-24 13:20:34 UTC (rev 3006)
+++ branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-06-25 16:08:07 UTC (rev 3007)
@@ -65,17 +65,17 @@
WHERE TA.taskId = TI.taskid \
AND TA.removed > 0 \
GROUP BY TA.taskId
-jtimer.storage.select.report.timedtasks=SELECT TA.taskId AS taskid, TA.name AS task, TA.parent AS parent, \
- TA.creationDate AS creationDate, sum(TI.duration) AS totalduration \
+jtimer.storage.select.report.timedtasks=SELECT TA.* , sum(TI.duration) AS totalduration \
FROM task TA, tasktime TI \
WHERE TA.taskId = TI.taskid \
AND TA.creationDate > ? \
AND TA.creationDate < ? \
+ AND TA.removed = 0 \
GROUP BY TA.taskId \
ORDER BY TA.creationDate DESC
jtimer.storage.select.report.roottasks=SELECT * \
FROM task \
- WHERE (taskId not in (SELECT taskid FROM tasktime) AND parent = '' )
+ WHERE (taskId not in (SELECT taskid FROM tasktime) AND removed = 0 )
###
#DELETE
jtimer.storage.delete.time.withid=DELETE FROM tasktime WHERE uuid = ?
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-06-24 13:20:34 UTC (rev 3006)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-06-25 16:08:07 UTC (rev 3007)
@@ -1,4 +1,4 @@
-function TasksCtrl($scope, $interval, $timeout, $q, serverTaskAccess, serverTimeAccess, $localStorage, $window, $document, $modal, wtWebsocket, jTimerWebsocket) {
+function TasksCtrl($scope, $interval, $timeout, $q, serverTaskAccess, serverTimeAccess, serverReportAccess, $localStorage, $window, $document, $modal, wtWebsocket, jTimerWebsocket) {
// {Boolean} vrai si on est online
$scope.online = $window.navigator.onLine;
@@ -764,8 +764,6 @@
return moment().format("HH:mm DD/MM/YYYY");
};
- console.log(jTimerWebsocket);
-
jTimerWebsocket.subscribe({
message: function(data) {
//var jsData = JSON.parse(data);
@@ -960,7 +958,7 @@
};
}
-function ReportModalInstanceCtrl($scope, $modalInstance,$http, $sce, tree){
+function ReportModalInstanceCtrl($scope, $modalInstance,$http, $sce, serverReportAccess, tree){
$scope.tree = tree;
@@ -986,24 +984,79 @@
var deb =($scope.obj.startDate).getTime();
var end =($scope.obj.endDate).getTime();
- //TODO obruce envoyer les taches à reporter
- $http({method: "GET", url: "/rest/report",
- params:{start_Date : deb, end_Date : end}})
+ toReportTask = [];
+ $scope.reportedTask = [];
+
+ var recurseGenerateChildReport = function(child){
+
+ angular.forEach(child.children, function(childnode){recurseGenerateChildReport(childnode)});
+ if(child.task.isReported){
+ toReportTask.push(child.task.taskId);
+ }
+ }
+
+ angular.forEach(tree.children, function(child){recurseGenerateChildReport(child)});
+
+ $http({method: "POST", url: "/rest/report",
+ params:{start_Date : deb, end_Date : end}, data : angular.toJson(toReportTask)})
.success(function(data){
- $scope.htmlReport = data;// data should be text string here (only if the server response is text/plain)
+
+ $scope.htmlReport = data;
+ angular.forEach(data, function(d){
+ console.log(d);
+ $scope.reportedTask.push({name : d.name, time : d.time})
+ })
}
);
}
-
+ /**
+ * Methode qui check les box du parent jusqu'aux enfants
+ * @param node le noeud concerné
+ */
$scope.setChildrenCheckbox = function(node){
- angular.forEach(node.children, function(child) {
+ var recurseReportChild = function(child){
+
+ angular.forEach(child.children, function(childnode){
+ recurseReportChild(childnode)
+ });
child.task.isReported = node.task.isReported;
+ }
+
+ angular.forEach(node.children, function(child){
+ recurseReportChild(child)
});
}
- //TODO obruce faire un check et uncheck all
+ /**Check all checkbox*/
+ $scope.checkAll= function(){
+ angular.forEach(tree.children, function(child){
+ recurseChildEncapsulated(child,encapFonc(child, true))
+ });
+ };
+
+ /**Uncheck all checkbox*/
+ $scope.uncheckAll= function(){
+ angular.forEach(tree.children, function(child){
+ recurseChildEncapsulated(child,encapFonc(child, false))
+ });
+ };
+
+ /**
+ * Reccursion sur l'arbre
+ */
+ var recurseChildEncapsulated = function(child, encapsulated){
+ angular.forEach(child.children, function(childnode){
+ recurseChildEncapsulated(childnode, encapFonc(child, true))
+ });
+ }
+
+ /**Fonction encapsule*/
+ var encapFonc = function(child, bool){
+ child.task.isReported= bool;
+ }
+
$scope.close = function() {
$modalInstance.close();
};
Modified: branches/ng-jtimer/src/main/webapp/js/service.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/service.js 2014-06-24 13:20:34 UTC (rev 3006)
+++ branches/ng-jtimer/src/main/webapp/js/service.js 2014-06-25 16:08:07 UTC (rev 3007)
@@ -37,7 +37,7 @@
// Encapsule l'acces au server
return $resource("/rest/report",{},
{
- get : {method: 'GET', isArray: false},
+ getReport : {method: 'POST'},
}
);
}
Modified: branches/ng-jtimer/src/main/webapp/partials/reportModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-06-24 13:20:34 UTC (rev 3006)
+++ branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-06-25 16:08:07 UTC (rev 3007)
@@ -67,6 +67,9 @@
</div>
</div>
+
+ <button class="btn btn-primary" ng-click="checkAll()">Check All</button>
+ <button class="btn btn-primary" ng-click="uncheckAll()">Unckeck All</button>
</div>
</div>
@@ -75,7 +78,14 @@
<alert type="info" >
<span>
- <div ng-bind-html="toHTML(htmlReport)"></div>
+ <h4>Projet :</h4>
+ <div ng-repeat="task in reportedTask">
+ {{task.name}} : {{task.time|time}}
+ <div ng-repeat="subtask in task.subtasks" ng-include="reportNestedTask.html">
+ {{subtask.name}} : {{subtask.time|time}}
+ </div>
+
+ </div>
</span>
</alert>
@@ -86,7 +96,6 @@
-
<div class="modal-footer">
<button class="btn btn-primary" ng-click="generateReport()">Générer</button>
<button class="btn btn-primary" ng-click="close()">Fermer</button>
Added: branches/ng-jtimer/src/main/webapp/partials/reportNestedTask.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/reportNestedTask.html (rev 0)
+++ branches/ng-jtimer/src/main/webapp/partials/reportNestedTask.html 2014-06-25 16:08:07 UTC (rev 3007)
@@ -0,0 +1,5 @@
+<div ng-repeat="task in subtasks">
+ {{task.name}} : {{task.time|time}}
+ <div ng-repeat="subtask in subtasks" ng-include="reportNestedTask.html"></div>
+
+</div>
\ No newline at end of file
1
0
r3006 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/storage java/org/chorem/jtimer/web resources webapp/js webapp/partials
by obruce@users.chorem.org 24 Jun '14
by obruce@users.chorem.org 24 Jun '14
24 Jun '14
Author: obruce
Date: 2014-06-24 15:20:34 +0200 (Tue, 24 Jun 2014)
New Revision: 3006
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3006
Log:
correction config + checkbox rapport
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.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/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/storage/Storage.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-06-23 15:38:30 UTC (rev 3005)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-06-24 13:20:34 UTC (rev 3006)
@@ -152,7 +152,7 @@
statement.executeUpdate(config.getStorageQueryCreateTableVersion());
statement.executeUpdate(config.getStorageQueryCreateTableTask());
- statement.executeUpdate(config.getStorageQueryDeleteTime());
+ statement.executeUpdate(config.getStorageQueryCreateTableTime());
} catch (SQLException ex) {
throw new StorageException("Can't create schema", ex);
@@ -199,6 +199,8 @@
statement = connection.prepareStatement(config.getStorageQuerySelectTimedTask());
statement.setLong(1, date);
+ log.debug(statement.toString());
+
ResultSet rs = statement.executeQuery();
while (rs.next()) {
TimerTask task = new TimerTask();
@@ -260,6 +262,7 @@
} finally {
closeStatement(statement);
}
+ log.info("insert done");
}
public void modifyTask(TimerTask task) {
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-06-23 15:38:30 UTC (rev 3005)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java 2014-06-24 13:20:34 UTC (rev 3006)
@@ -84,7 +84,7 @@
date = Long.valueOf(getQuery().getValues("date"));
} catch (Exception e) {
if(log.isErrorEnabled()){
- log.error("enttities.getTasks date revenu null");
+ log.warn("entities.getTasks REST date null");
}
}
ArrayList<TimerTask> timerTasks;
Modified: branches/ng-jtimer/src/main/resources/jtimer-default.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-06-23 15:38:30 UTC (rev 3005)
+++ branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-06-24 13:20:34 UTC (rev 3006)
@@ -2,7 +2,7 @@
# jTimer default properties
###
# jTimer storage path
-jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer8081
+jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimerNew
###
# SQL properties
###
@@ -38,19 +38,19 @@
#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) VALUES (?, ?, ?, ?, ?,?, ?, ?)
-jtimer.storage.insert.time=INSERT INTO tasktime (taskid, date, uuid, duration, modificationDate, removed) VALUES(?, ?, ?, ?, ?, ?)
+jtimer.storage.insert.time=INSERT INTO tasktime (taskid, date, uuid, duration, modificationDate, removed) VALUES (?, ?, ?, ?, ?, ?)
###
#SELECT
jtimer.storage.select.table.name=SELECT table_name FROM information_schema.tables;
jtimer.storage.select.count.task=SELECT count(*) FROM task WHERE removed = 0
jtimer.storage.select.timed.task=SELECT TA.*, sum(TI.duration) AS totalduration \
FROM task TA, tasktime TI \
- WHERE TA.taskId = TI.taskid \
- AND TA.modificationDate > ? \
- GROUP BY TA.taskId
+ WHERE TA.taskId = TI.taskid \
+ AND TA.modificationDate > ? \
+ GROUP BY TA.taskId
jtimer.storage.select.nottimed.task=SELECT * \
FROM task \
- WHERE (taskId not in (SELECT taskid FROM task)) \
+ WHERE (taskId not in (SELECT taskid FROM tasktime)) \
AND task.modificationDate > ?
jtimer.storage.select.time.withdate=SELECT TA.taskId AS mytask, TI.* \
FROM task TA, tasktime TI \
@@ -66,16 +66,16 @@
AND TA.removed > 0 \
GROUP BY TA.taskId
jtimer.storage.select.report.timedtasks=SELECT TA.taskId AS taskid, TA.name AS task, TA.parent AS parent, \
- TA.creationDate AS creationDate, sum(TI.duration) AS totalduration \
+ TA.creationDate AS creationDate, sum(TI.duration) AS totalduration \
FROM task TA, tasktime TI \
- WHERE TA.taskId = TI.taskid\
+ WHERE TA.taskId = TI.taskid \
AND TA.creationDate > ? \
AND TA.creationDate < ? \
GROUP BY TA.taskId \
ORDER BY TA.creationDate DESC
jtimer.storage.select.report.roottasks=SELECT * \
FROM task \
- WHERE (taskId not in (SELECT taskid FROM task) AND parent = '' )
+ WHERE (taskId not in (SELECT taskid FROM tasktime) AND parent = '' )
###
#DELETE
jtimer.storage.delete.time.withid=DELETE FROM tasktime WHERE uuid = ?
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-06-23 15:38:30 UTC (rev 3005)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-06-24 13:20:34 UTC (rev 3006)
@@ -909,8 +909,11 @@
var modalInstance = $modal.open({
templateUrl: 'partials/reportModal.html',
controller: ReportModalInstanceCtrl,
-
-
+ resolve: {
+ tree : function(){
+ return $scope.tree;
+ }
+ }
});
modalInstance.result.then(function (item) {
@@ -957,8 +960,10 @@
};
}
-function ReportModalInstanceCtrl($scope, $modalInstance,$http, $sce){
+function ReportModalInstanceCtrl($scope, $modalInstance,$http, $sce, tree){
+ $scope.tree = tree;
+
$scope.obj={
startDate : new Date(),
endDate : new Date()
@@ -967,7 +972,7 @@
$scope.obj.endDate.setHours(23,59,59,999);
$scope.radioModel = '5';
- $scope.htmlReport="";
+ $scope.htmlReport="Générer un rapport";
$scope.toHTML = function (data) {
return $sce.trustAsHtml(data);
@@ -980,6 +985,8 @@
var deb =($scope.obj.startDate).getTime();
var end =($scope.obj.endDate).getTime();
+
+ //TODO obruce envoyer les taches à reporter
$http({method: "GET", url: "/rest/report",
params:{start_Date : deb, end_Date : end}})
.success(function(data){
@@ -989,8 +996,13 @@
}
- $scope.changeFonc= function(){
+ $scope.setChildrenCheckbox = function(node){
+
+ angular.forEach(node.children, function(child) {
+ child.task.isReported = node.task.isReported;
+ });
}
+ //TODO obruce faire un check et uncheck all
$scope.close = function() {
$modalInstance.close();
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-06-23 15:38:30 UTC (rev 3005)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-06-24 13:20:34 UTC (rev 3006)
@@ -402,6 +402,7 @@
this.name = name;
this.description = "";
+ this.isReported = true;
this.tags = [];
this.syncOptions = {};
};
Modified: branches/ng-jtimer/src/main/webapp/partials/reportModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-06-23 15:38:30 UTC (rev 3005)
+++ branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-06-24 13:20:34 UTC (rev 3006)
@@ -1,14 +1,16 @@
<div>
- <h2>Option du rapport :</h2>
+ <h2>Rapport :</h2>
</div>
<hr/>
<div >
+
<!-- Datepicker div -->
- <div style="display : inline-block;vertical-align: top;">
+ <div style="border:1px solid black; display : inline-block;vertical-align: top;margin-left:2px;">
+ <h4><u>Option :</u></h4>
De :
- <div ng-controller="ReportDatePickerCtrl" class="row">
+ <div style="margin-left:2px;" ng-controller="ReportDatePickerCtrl" class="row">
<div class="col-md-6">
<p class="input-group medium_input">
<input type="text" class="form-control" datepicker-popup="{{format}}" ng-model="obj.startDate" is-open="opened" min-date="minDate" max-date="obj.endDate" ng-required="true" close-text="Close" />
@@ -20,7 +22,7 @@
</div>
A :
- <div class="row" ng-controller="ReportDatePickerCtrl">
+ <div style="margin-left:2px;" class="row" ng-controller="ReportDatePickerCtrl">
<div class="col-md-6">
<p class="input-group medium_input">
<input type="text" class="form-control" datepicker-popup="{{format}}" ng-model="obj.endDate" is-open="opened" min-date="obj.startDate" max-date="maxDate" ng-required="true" close-text="Close" />
@@ -30,13 +32,43 @@
</p>
</div>
</div>
-
+ <hr/>
<div>
+ <h4><u>Projet :</u></h4>
- </div>
+ <!--la div de l'arbre-->
+ <div>
+ <div class='table'>
+ <!-- Div du body wt-tree-repeat Angular js directive in app.js-->
+ <div class="tbody"
+ wt-tree-repeat="tree | orderBy:'task.name'"
+ wt-force-open="query || forceExpanded">
+ <div class="tr" ng-class="{'current-row' : ($node.task === currentTask), 'selected-row' : ($node.task === selectedTask)}">
+ <!--ng-click="setSelectedTask($node.task)"
+ ng-keydown="keyPressed($event)">ng-dblclick="timeTask($node.task)"-->
+ <div class="td">
+ <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>
+
+ <!--Project name visible and editable -->
+ <input type="checkbox" ng-model="$node.task.isReported" ng-change="setChildrenCheckbox($node)">
+ <span>{{$node.task.name}} </span>
+
+ </div>
+ </div>
+ </div>
+ </div>
+
+ </div>
+ </div>
+
</div>
<div style="display : inline-block; vertical-align: top; width : 350px">
@@ -53,7 +85,9 @@
</div>
+
+
<div class="modal-footer">
- <button class="btn btn-primary" ng-click="generateReport()">Generer</button>
+ <button class="btn btn-primary" ng-click="generateReport()">Générer</button>
<button class="btn btn-primary" ng-click="close()">Fermer</button>
</div>
\ No newline at end of file
1
0
r3005 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/config java/org/chorem/jtimer/storage java/org/chorem/jtimer/web resources webapp/js
by obruce@users.chorem.org 23 Jun '14
by obruce@users.chorem.org 23 Jun '14
23 Jun '14
Author: obruce
Date: 2014-06-23 17:38:30 +0200 (Mon, 23 Jun 2014)
New Revision: 3005
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3005
Log:
requ?\195?\170te sql mise dans les propri?\195?\169t?\195?\169s avec nuiton config
Removed:
branches/ng-jtimer/src/main/resources/jtimer-query.properties
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/RestApplication.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java
branches/ng-jtimer/src/main/resources/jtimer-default.properties
branches/ng-jtimer/src/main/webapp/js/controllers.js
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-06-20 16:07:12 UTC (rev 3004)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java 2014-06-23 15:38:30 UTC (rev 3005)
@@ -42,7 +42,6 @@
}
-
public JtimerConfig(String configFileName) throws Exception {
try {
@@ -61,6 +60,7 @@
}
appConfig = defaultConfig;
}
+
} catch (Exception e) {
throw new Exception("Can't read property file");
}
@@ -74,4 +74,80 @@
public String getStoragePath(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_PATH.getKey());
}
+
+ public String getStorageTableTask(){return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_TABLE_TASK.getKey());}
+ public String getStorageTableTime(){return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_TABLE_TIME.getKey());}
+ public String getStorageTableVersion(){return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_TABLE_VERSION.getKey());}
+
+ public String getStorageQueryCreateTableVersion(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_CREATE_TABLE_VERSION.getKey());
+ }
+
+ public String getStorageQueryCreateTableTask(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_CREATE_TABLE_TASK.getKey());
+ }
+
+ public String getStorageQueryCreateTableTime(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_CREATE_TABLE_TIME.getKey());
+ }
+
+ public String getStorageQueryInsertVersionNumber(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_INSERT_VERSION_NUMBER.getKey());
+ }
+
+ public String getStorageQueryInsertTask(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_INSERT_TASK.getKey());
+ }
+
+ public String getStorageQueryInsertTime(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_INSERT_TIME.getKey());
+ }
+
+ public String getStorageQuerySelectTableName(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_TABLE_NAME.getKey());
+ }
+
+ public String getStorageQuerySelectCountTask(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_COUNT_TASK.getKey());
+ }
+
+ public String getStorageQuerySelectTimedTask(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_TIMED_TASK.getKey());
+ }
+ public String getStorageQuerySelectNotTimedTask(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_NOTTIMED_TASK.getKey());
+ }
+ public String getStorageQuerySelectTaskTimeWithDate(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_TIME_WITHDATE.getKey());
+ }
+ public String getStorageQuerySelectNotRemovedTaskTime(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_NOTREMOVED_TASKTIME.getKey());
+ }
+ public String getStorageQuerySelectRemovedTaskTime(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REMOVED_TASKTIME.getKey());
+ }
+ public String getStorageQuerySelectReportTasks(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_TIMEDTASKS.getKey());
+ }
+ public String getStorageQuerySelectReportRootTask(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_ROOTTASK.getKey());
+ }
+ public String getStorageQueryDeleteTime(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_DELETE_TIME_WITHID.getKey());
+ }
+ public String getStorageQueryDeleteTask(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_DELETE_TASK_WITHID.getKey());
+ }
+ public String getStorageQueryUpdateTask(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_TASK_WITHID.getKey());
+ }
+ public String getStorageQueryUpdateTime(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_TIME_WITHID.getKey());
+ }
+ public String getStorageQueryUpdateTaskToRemove(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_TASK_FORREMOVE.getKey());
+ }
+ public String getStorageQueryUpdateTimeToRemove(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_TIME_FORREMOVE.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-06-20 16:07:12 UTC (rev 3004)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java 2014-06-23 15:38:30 UTC (rev 3005)
@@ -10,6 +10,7 @@
* Package name : org.chorem.jtimer.config
*/
public enum JtimerConfigOption implements ConfigOptionDef {
+ /**Storage**/
JTIMER_STORAGE_PATH(
"jtimer.storage.path",
"chemin qui indique où se trouve le stockage",
@@ -19,8 +20,155 @@
"jtimer.storage.credentials",
"indique les éléments dont on a besoin pour s'authentifier à la base",
"",
- String.class);
+ String.class
+ ),
+ JTIMER_STORAGE_TABLE_TASK(
+ "jtimer.storage.table.task",
+ "le nom de la table des tâches",
+ "task",
+ String.class
+ ),
+ JTIMER_STORAGE_TABLE_TIME(
+ "jtimer.storage.table.time",
+ "le nom de la table des temps",
+ "tasktime",
+ String.class
+ ),
+ JTIMER_STORAGE_TABLE_VERSION(
+ "jtimer.storage.table.version",
+ "le nom de la table des version",
+ "tasktime",
+ String.class
+ ),
+ JTIMER_STORAGE_CREATE_TABLE_VERSION(
+ "jtimer.storage.create.table.version",
+ "requête de création la table des version",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_CREATE_TABLE_TASK(
+ "jtimer.storage.create.table.task",
+ "requête de création la table des tâches",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_CREATE_TABLE_TIME(
+ "jtimer.storage.create.table.time",
+ "requête de création la table des temps",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_INSERT_VERSION_NUMBER(
+ "jtimer.storage.insert.version.number",
+ "requête d'insertion dans la table des versions",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_INSERT_TASK(
+ "jtimer.storage.insert.task",
+ "requête d'insertion dans la table des tâches",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_INSERT_TIME(
+ "jtimer.storage.insert.time",
+ "requête d'insertion dans la table des temps",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_SELECT_TABLE_NAME(
+ "jtimer.storage.select.table.name",
+ "requête de selection des noms dans le table name",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_SELECT_COUNT_TASK(
+ "jtimer.storage.select.count.task",
+ "requête comptant le nombre de tâches dans le stockaqe",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_SELECT_TIMED_TASK(
+ "jtimer.storage.select.timed.task",
+ "requête de selection des tâches minutées",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_SELECT_NOTTIMED_TASK(
+ "jtimer.storage.select.nottimed.task",
+ "requête de selection des tâches non minutées",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_SELECT_TIME_WITHDATE(
+ "jtimer.storage.select.time.withdate",
+ "requête de récupération de tous les temps",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_SELECT_NOTREMOVED_TASKTIME(
+ "jtimer.storage.select.notremoved.tasktime",
+ "requête de selection des temps de tâches non supprimés",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_SELECT_REMOVED_TASKTIME(
+ "jtimer.storage.select.removed.tasktime",
+ "requête de selection des temps de tâches non supprimés",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_SELECT_REPORT_TIMEDTASKS(
+ "jtimer.storage.select.report.timedtasks",
+ "requête de selection des taches minutées entre deux bornes",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_SELECT_REPORT_ROOTTASK(
+ "jtimer.storage.select.report.roottasks",
+ "requête de selection des taches root",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_DELETE_TIME_WITHID(
+ "jtimer.storage.delete.time.withid",
+ "requête de suppression d'un temps avec un identifiant",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_DELETE_TASK_WITHID(
+ "jtimer.storage.delete.task.withid",
+ "requête de suppression d'une tâches avec un identifiant",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_UPDATE_TASK_WITHID(
+ "jtimer.storage.update.task.withid",
+ "requête de mise à jour d'une taches avec un identifiant",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_UPDATE_TIME_WITHID(
+ "jtimer.storage.update.time.withid",
+ "requête de mise à jour d'un temps avec un identifiant",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_UPDATE_TASK_FORREMOVE(
+ "jtimer.storage.update.task.forremove",
+ "requête de de changement de statut (remove) d'une tâches avec un identifiant",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_UPDATE_TIME_FORREMOVE(
+ "jtimer.storage.update.time.forremove",
+ "requête de de changement de statut (remove) d'un temps avec un identifiant",
+ "",
+ String.class
+ );
+
+
public final String key;
public final String description;
public String defaultValue;
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-06-20 16:07:12 UTC (rev 3004)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-06-23 15:38:30 UTC (rev 3005)
@@ -2,6 +2,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.jtimer.config.JtimerConfig;
import org.chorem.jtimer.entities.TimerTask;
import org.chorem.jtimer.entities.TimerTime;
import org.chorem.jtimer.utils.ReportTask;
@@ -14,9 +15,7 @@
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
/**
* Implementation du stockage des taches en base de données basée sur h2.
@@ -39,12 +38,14 @@
protected static final String TABLE_VERSION = "version";
protected String STORAGE_PATH;
+ protected JtimerConfig config;
protected Connection connection;
- public Storage(String path) {
+ public Storage(JtimerConfig conf) {
- this.STORAGE_PATH = path;
+ this.config = conf;
+ this.STORAGE_PATH = config.getStoragePath();
try {
if (log.isDebugEnabled()) {
@@ -91,7 +92,7 @@
// set new version in schema
Statement statement = conn.createStatement();
- statement.executeUpdate("INSERT INTO VERSION VALUES('2.0')");
+ statement.executeUpdate(config.getStorageQueryInsertVersionNumber());
}
return conn;
@@ -124,7 +125,7 @@
Statement statement = null;
try {
statement = conn.createStatement();
- ResultSet rs = statement.executeQuery("SELECT table_name FROM information_schema.tables;");
+ ResultSet rs = statement.executeQuery(config.getStorageQuerySelectTableName());
while (rs.next()) {
String name = rs.getString(1);
if (TABLE_VERSION.equalsIgnoreCase(name)) {
@@ -148,30 +149,11 @@
Statement statement = null;
try {
statement = conn.createStatement();
- statement.executeUpdate("CREATE TABLE " + TABLE_VERSION +
- "(version VARCHAR(10))");
- statement.executeUpdate("CREATE TABLE " + TABLE_TASK +
- "(taskId VARCHAR(255) NOT NULL," +
- " name VARCHAR(255) NOT NULL," +
- " parent VARCHAR(255)," +
- " creationDate LONG, " +
- " modificationDate LONG, " +
- " hidden BOOLEAN," +
- " note TEXT," +
- " removed LONG," +
- " PRIMARY KEY (taskId))");
- statement.executeUpdate("CREATE TABLE " + TABLE_TIME +
- "(taskid VARCHAR(255) NOT NULL," +
- " date LONG," +
- " uuid varchar(255) unique," +
- " duration LONG," +
- " modificationDate LONG," +
- " removed LONG," +
- " PRIMARY KEY (taskid, date, uuid)," +
- " FOREIGN KEY (taskid)" +
- " REFERENCES " + TABLE_TASK +"(taskId)" +
- " ON DELETE CASCADE" +
- ")");
+
+ statement.executeUpdate(config.getStorageQueryCreateTableVersion());
+ statement.executeUpdate(config.getStorageQueryCreateTableTask());
+ statement.executeUpdate(config.getStorageQueryDeleteTime());
+
} catch (SQLException ex) {
throw new StorageException("Can't create schema", ex);
} finally {
@@ -191,8 +173,8 @@
int result = 0;
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement("SELECT count(*) FROM " + TABLE_TASK
- + " WHERE removed = 0");
+ statement = connection.prepareStatement(config.getStorageQuerySelectCountTask());
+
ResultSet rs = statement.executeQuery();
if (rs.next()) {
result = rs.getInt(1);
@@ -214,65 +196,9 @@
PreparedStatement statement = null;
PreparedStatement statement2 = null;
try {
- statement = connection.prepareStatement("SELECT TA.*, sum(TI.duration) AS totalduration FROM " +
- TABLE_TASK + " TA, " + TABLE_TIME + " TI" +
- " WHERE TA.taskId = TI.taskid" +
- " AND TA.modificationDate >" +date +
- " GROUP BY TA.taskId");
- ResultSet rs = statement.executeQuery();
- while (rs.next()) {
- TimerTask task = new TimerTask();
- task.setTaskId(rs.getString("taskId"));
- task.setName(rs.getString("name"));
- task.setParent(rs.getString("parent"));
- task.setRemoved(rs.getLong("removed"));
- task.setTodayTime(0);
- task.setCreationDate(new java.util.Date(rs.getLong("creationDate")));
- task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
- task.setTotalTime(rs.getLong("totalduration"));
- tasks.add(task);
- }
+ statement = connection.prepareStatement(config.getStorageQuerySelectTimedTask());
+ statement.setLong(1, date);
- // not timed tasks
- statement2 = connection.prepareStatement("SELECT * FROM " + TABLE_TASK +
- " WHERE (taskId not in (SELECT taskid FROM " + TABLE_TIME + "))" +
- " AND "+ TABLE_TASK +".modificationDate >" +date);
- rs = statement2.executeQuery();
- while (rs.next()) {
- TimerTask task = new TimerTask();
- task.setName(rs.getString("name"));
- task.setTaskId(rs.getString("taskId"));
- task.setParent(rs.getString("parent"));
- task.setCreationDate(new java.util.Date(rs.getLong("creationDate")));
- task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
- task.setRemoved(rs.getLong("removed"));
- task.setTodayTime(0);
- task.setTotalTime(0);
- tasks.add(task);
- }
- } catch (SQLException ex) {
- throw new StorageException("Can't get task", ex);
- } finally {
- closeStatement(statement);
- closeStatement(statement2);
- }
- return tasks;
- }
-
- /**
- * Query that returns not removed tasks
- * @return tasks arraylist of tasks
- */
- public ArrayList<TimerTask> getRemovedTasks(Long date) {
- ArrayList<TimerTask> tasks = new ArrayList<>();
- PreparedStatement statement = null;
- PreparedStatement statement2 = null;
- try {
- statement = connection.prepareStatement("SELECT TA.*, sum(TI.duration) AS totalduration FROM " +
- TABLE_TASK + " TA, " + TABLE_TIME + " TI" +
- " WHERE TA.taskId = TI.taskid" +
- " AND TA.removed > 0"+
- " GROUP BY TA.taskId");
ResultSet rs = statement.executeQuery();
while (rs.next()) {
TimerTask task = new TimerTask();
@@ -288,9 +214,9 @@
}
// not timed tasks
- statement2 = connection.prepareStatement("SELECT * FROM " + TABLE_TASK +
- " WHERE (taskId not in (SELECT taskid FROM " + TABLE_TIME + "))" +
- " AND "+ TABLE_TASK +".modificationDate >" +date);
+ statement2 = connection.prepareStatement(config.getStorageQuerySelectNotTimedTask());
+ statement2.setLong(1, date);
+
rs = statement2.executeQuery();
while (rs.next()) {
TimerTask task = new TimerTask();
@@ -313,15 +239,12 @@
return tasks;
}
-
/* Insert, Update, Delete */
public void addTask(TimerTask task) {
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement("INSERT INTO " +
- TABLE_TASK + "(name, parent, taskId, hidden, note,creationDate, modificationDate, removed)" +
- " VALUES (?, ?, ?, ?, ?,?, ?, ?)");
+ statement = connection.prepareStatement(config.getStorageQueryInsertTask());
statement.setString(1, task.getName());
statement.setString(2, task.getParent());
statement.setString(3, task.getTaskId());
@@ -342,9 +265,8 @@
public void modifyTask(TimerTask task) {
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement("UPDATE " +
- TABLE_TASK + " SET name=?, parent=?, hidden=?, note=?, modificationDate=?, removed=?" +
- " WHERE taskId = ?");
+ statement = connection.prepareStatement(config.getStorageQueryUpdateTask());
+
statement.setString(1, task.getName()); //name
statement.setString(2, task.getParent()); //parent
statement.setBoolean(3, task.isClosed()); //hidden
@@ -365,9 +287,8 @@
public void modifyTime(TimerTime t) {
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement("UPDATE " +
- TABLE_TIME + " SET date=?, duration=?, modificationDate=?, removed = ?" +
- " WHERE uuid = ?");
+ statement = connection.prepareStatement(config.getStorageQueryUpdateTime());
+
statement.setLong(1, t.getCreationDate().getTime());
statement.setLong(2, t.getTime());
statement.setLong(3, t.getModificationDate().getTime()); //modificationDate
@@ -391,9 +312,7 @@
public void addTaskTime(TimerTask task, Date date, String uuid, long duration) {
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement("INSERT INTO " + TABLE_TIME +
- "(taskid, date, uuid, duration, modificationDate, removed)" +
- " VALUES(?, ?, ?, ?, ?, ?)");
+ statement = connection.prepareStatement(config.getStorageQueryInsertTime());
statement.setString(1, task.getTaskId());
statement.setLong(2, date.getTime());
@@ -416,9 +335,7 @@
public void addTaskTime(TimerTime time) {
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement("INSERT INTO " + TABLE_TIME +
- "(taskid, date, uuid, duration, modificationDate, removed)" +
- " VALUES(?, ?, ?, ?, ?, ?)");
+ statement = connection.prepareStatement(config.getStorageQueryInsertTime());
statement.setString(1, time.getTaskId());
statement.setLong(2, time.getCreationDate().getTime());
@@ -452,13 +369,11 @@
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement("SELECT TA.taskId AS mytask, TI.* FROM " +
- TABLE_TASK + " TA, "+ TABLE_TIME + " TI" +
- " WHERE TA.taskId = TI.taskid" +
- " AND TI.modificationDate >" +date);
+ statement = connection.prepareStatement(config.getStorageQuerySelectTaskTimeWithDate());
- ResultSet rs = statement.executeQuery();
+ statement.setLong(1, date);
+ ResultSet rs = statement.executeQuery();
while (rs.next()) {
TimerTime time = new TimerTime();
@@ -491,11 +406,10 @@
List<TimerTime> times = new ArrayList<>();
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement("SELECT TI.*" +
- " FROM " + TABLE_TASK + " TA, "+ TABLE_TIME + " TI" +
- " WHERE TA.taskId = TI.taskid AND TA.taskId = '" +taskid +"' " +
- " AND TA.removed = 0" +
- " AND TI.modificationDate >" +date);
+ statement = connection.prepareStatement(config.getStorageQuerySelectNotRemovedTaskTime());
+ statement.setString(1, taskid);
+ statement.setLong(2, date);
+
ResultSet rs = statement.executeQuery();
while (rs.next()) {
TimerTime time = new TimerTime();
@@ -522,16 +436,11 @@
PreparedStatement statement = null;
PreparedStatement statement2 = null;
try{
- statement = connection.prepareStatement(
- "SELECT TA.taskId AS taskid, TA.name AS task, TA.parent AS parent," +
- " TA.creationDate AS creationDate, sum(TI.duration) AS totalduration" +
- " FROM " + TABLE_TASK+" TA," + TABLE_TIME +" TI" +
- " WHERE TA.taskId = TI.taskid" +
- " AND TA.creationDate >" + startDate +
- " AND TA.creationDate <" + endDate +
- " GROUP BY TA.taskId" +
- " ORDER BY TA.creationDate DESC");
+ statement = connection.prepareStatement(config.getStorageQuerySelectReportTasks());
+ statement.setLong(1, startDate);
+ statement.setLong(2, endDate);
+
ResultSet rs = statement.executeQuery();
while(rs.next()){
list.add(new ReportTask(rs.getString("task"),rs.getString("taskid"),
@@ -539,10 +448,7 @@
}
// not timed tasks
- statement2 = connection.prepareStatement("SELECT * FROM " + TABLE_TASK +
- " WHERE (taskId not in (SELECT taskid FROM " + TABLE_TIME + ")" +
- " AND parent = '' )"
- );
+ statement2 = connection.prepareStatement(config.getStorageQuerySelectReportRootTask());
rs = statement2.executeQuery();
while(rs.next()){
@@ -560,75 +466,7 @@
return list;
}
- public Map getReportByWeek(Long startDate, Long endDate){
- //treemap car date implemente comparable
- HashMap<Integer, ArrayList> byWeekTasks = new HashMap<Integer, ArrayList>();
- PreparedStatement statement = null;
- PreparedStatement statement2 = null;
-
- try{
- statement = connection.prepareStatement(
- "SELECT WEEK(FROM_UNIXTIME(creationDate)) AS numWeek, TA.taskId AS taskid, TA.name AS task, TA.parent AS parent," +
- " TA.creationDate AS creationDate, sum(TI.duration) AS totalduration" +
- " FROM " + TABLE_TASK+" TA," + TABLE_TIME +" TI" +
- " WHERE TA.taskId = TI.taskid" +
- " AND TA.creationDate >" + startDate +
- " AND TA.creationDate <" + endDate +
- " GROUP BY TA.taskId, numWeek " +
- " ORDER BY creationDate DESC");
-
-
- ResultSet rs = statement.executeQuery();
- while(rs.next()){
- Integer numWeek = rs.getInt("numWeek");
- ArrayList tasks;
- if(byWeekTasks.containsKey(numWeek)){
- tasks = byWeekTasks.get(numWeek);
- }else{
- tasks = new ArrayList();
- }
- tasks.add(new ReportTask(rs.getString("task"),rs.getString("taskid"),
- rs.getString("parent") , rs.getLong("totalduration"), rs.getLong("creationDate")));
-
- byWeekTasks.put(numWeek, tasks);
- }
-
- // not timed tasks
- statement2 = connection.prepareStatement("SELECT * FROM " + TABLE_TASK +
- " WHERE (taskId not in (SELECT taskid FROM " + TABLE_TIME + ")" +
- " AND parent = '' )"
- );
-
- rs = statement2.executeQuery();
- while(rs.next()){
- ArrayList tasks;
-
- if(byWeekTasks.containsKey(0)){
- tasks = byWeekTasks.get(0);
- }else{
- tasks = new ArrayList();
- }
- tasks.add(new ReportTask(rs.getString("name"), rs.getString("taskId"),
- rs.getString("parent"), (long) 0, rs.getLong("creationDate")));
-
- byWeekTasks.put(0, tasks);
- }
-
-
- }catch(SQLException ex) {
- throw new StorageException("Can't get report", ex);
- } finally {
- closeStatement(statement);
- closeStatement(statement2);
- }
-
- log.info("le map " + byWeekTasks.toString());
-
- return byWeekTasks;
- }
-
-
/** Suppression de tuple **/
/**
@@ -639,8 +477,7 @@
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement("DELETE FROM " +
- TABLE_TIME + " WHERE uuid = ?");
+ statement = connection.prepareStatement(config.getStorageQueryDeleteTime());
statement.setString(1, timeId);
statement.executeUpdate();
} catch (SQLException ex) {
@@ -658,8 +495,7 @@
public void deleteTaskWithId(String taskId) {
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement("DELETE FROM " +
- TABLE_TASK + " WHERE taskId = ?");
+ statement = connection.prepareStatement(config.getStorageQueryDeleteTask());
statement.setString(1, taskId);
statement.executeUpdate();
} catch (SQLException ex) {
@@ -680,11 +516,11 @@
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement("UPDATE " +
- TABLE_TIME + " SET removed = "+time+", modificationDate =" +time +
- " WHERE uuid = ?");
+ statement = connection.prepareStatement(config.getStorageQueryUpdateTimeToRemove());
- statement.setString(1, timeId);
+ statement.setLong(1, time);
+ statement.setLong(2, time);
+ statement.setString(3, timeId);
statement.executeUpdate();
} catch (SQLException ex) {
throw new StorageException("Can't delete time", ex);
@@ -702,10 +538,11 @@
public void removeTaskWithId(String taskId, long time) {
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement("UPDATE " +
- TABLE_TASK + " SET removed = "+time+", modificationDate =" +time +
- " WHERE taskId = '"+taskId +"'");
+ statement = connection.prepareStatement(config.getStorageQueryUpdateTaskToRemove());
+ statement.setLong(1, time);
+ statement.setLong(2, time);
+ statement.setString(3, taskId);
statement.executeUpdate();
} catch (SQLException ex) {
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-06-20 16:07:12 UTC (rev 3004)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java 2014-06-23 15:38:30 UTC (rev 3005)
@@ -74,7 +74,7 @@
jtimerConf = new JtimerConfig();
//Initialisation du storage
- Storage storage = new Storage(jtimerConf.getStoragePath());
+ Storage storage = new Storage(jtimerConf);
context.getAttributes().put(Storage.class.getName(), storage);
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java 2014-06-20 16:07:12 UTC (rev 3004)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java 2014-06-23 15:38:30 UTC (rev 3005)
@@ -65,7 +65,7 @@
}
/**
- * Methode qui retourne la representation de la liste de toutes les temps
+ * Methode qui retourne la representation de la liste de tous les temps
* Suite a une requete de type GET
*
* @return
Modified: branches/ng-jtimer/src/main/resources/jtimer-default.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-06-20 16:07:12 UTC (rev 3004)
+++ branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-06-23 15:38:30 UTC (rev 3005)
@@ -3,4 +3,90 @@
###
# jTimer storage path
jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer8081
-
+###
+# SQL properties
+###
+#TABLE
+jtimer.storage.table.task=task
+jtimer.storage.table.time=tasktime
+jtimer.storage.table.version=version
+###
+#CREATE SCHEMA
+jtimer.storage.create.table.version=CREATE TABLE version (version VARCHAR(10))
+jtimer.storage.create.table.task=CREATE TABLE task \
+ (taskId VARCHAR(255) NOT NULL, \
+ name VARCHAR(255) NOT NULL, \
+ parent VARCHAR(255), \
+ creationDate LONG, \
+ modificationDate LONG, \
+ hidden BOOLEAN, \
+ note TEXT, \
+ removed LONG, \
+ PRIMARY KEY (taskId))
+jtimer.storage.create.table.time=CREATE TABLE tasktime \
+ (taskid VARCHAR(255) NOT NULL, \
+ date LONG, \
+ uuid varchar(255) unique, \
+ duration LONG, \
+ modificationDate LONG, \
+ removed LONG, \
+ PRIMARY KEY (taskid, date, uuid), \
+ FOREIGN KEY (taskid) \
+ REFERENCES task (taskId) \
+ ON DELETE CASCADE)
+####
+#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) VALUES (?, ?, ?, ?, ?,?, ?, ?)
+jtimer.storage.insert.time=INSERT INTO tasktime (taskid, date, uuid, duration, modificationDate, removed) VALUES(?, ?, ?, ?, ?, ?)
+###
+#SELECT
+jtimer.storage.select.table.name=SELECT table_name FROM information_schema.tables;
+jtimer.storage.select.count.task=SELECT count(*) FROM task WHERE removed = 0
+jtimer.storage.select.timed.task=SELECT TA.*, sum(TI.duration) AS totalduration \
+ FROM task TA, tasktime TI \
+ WHERE TA.taskId = TI.taskid \
+ AND TA.modificationDate > ? \
+ GROUP BY TA.taskId
+jtimer.storage.select.nottimed.task=SELECT * \
+ FROM task \
+ WHERE (taskId not in (SELECT taskid FROM task)) \
+ AND task.modificationDate > ?
+jtimer.storage.select.time.withdate=SELECT TA.taskId AS mytask, TI.* \
+ FROM task TA, tasktime TI \
+ WHERE TA.taskId = TI.taskid AND TI.modificationDate > ?
+jtimer.storage.select.notremoved.tasktime=SELECT TI.* \
+ FROM task TA, tasktime TI \
+ WHERE TA.taskId = TI.taskid AND TA.taskId = '?' \
+ AND TA.removed = 0 \
+ AND TI.modificationDate > ?
+jtimer.storage.select.removed.tasktime=SELECT TA.*, sum(TI.duration) AS totalduration \
+ FROM task TA, tasktime TI \
+ WHERE TA.taskId = TI.taskid \
+ AND TA.removed > 0 \
+ GROUP BY TA.taskId
+jtimer.storage.select.report.timedtasks=SELECT TA.taskId AS taskid, TA.name AS task, TA.parent AS parent, \
+ TA.creationDate AS creationDate, sum(TI.duration) AS totalduration \
+ FROM task TA, tasktime TI \
+ WHERE TA.taskId = TI.taskid\
+ AND TA.creationDate > ? \
+ AND TA.creationDate < ? \
+ GROUP BY TA.taskId \
+ ORDER BY TA.creationDate DESC
+jtimer.storage.select.report.roottasks=SELECT * \
+ FROM task \
+ WHERE (taskId not in (SELECT taskid FROM task) AND parent = '' )
+###
+#DELETE
+jtimer.storage.delete.time.withid=DELETE FROM tasktime WHERE uuid = ?
+jtimer.storage.delete.task.withid=DELETE FROM task WHERE taskId = ?
+###
+#UPDATE
+jtimer.storage.update.task.withid=UPDATE task SET name=?, parent=?, hidden=?, note=?, modificationDate=?, removed=? \
+ WHERE taskId = ?
+jtimer.storage.update.time.withid=UPDATE tasktime SET date=?, duration=?, modificationDate=?, removed = ? \
+ WHERE uuid = ?
+jtimer.storage.update.task.forremove=UPDATE task SET removed = ?, modificationDate = ? \
+ WHERE taskId = ?
+jtimer.storage.update.time.forremove=UPDATE tasktime SET removed = ?, modificationDate = ? \
+ WHERE uuid = ?
Deleted: branches/ng-jtimer/src/main/resources/jtimer-query.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-query.properties 2014-06-20 16:07:12 UTC (rev 3004)
+++ branches/ng-jtimer/src/main/resources/jtimer-query.properties 2014-06-23 15:38:30 UTC (rev 3005)
@@ -1,49 +0,0 @@
-###
-# This file contains all sql queries
-###
-#TABLE
-TABLE_TASK=task
-TABLE_TIME=tasktime
-TABLE_VERSION=version
-###
-#CREATE SCHEMA
-CREATE_TABLE_VERSION=CREATE TABLE version (version VARCHAR(10))
-CREATE_TABLE_TASK=CREATE TABLE task \
- (taskId VARCHAR(255) NOT NULL, \
- name VARCHAR(255) NOT NULL, \
- parent VARCHAR(255), \
- creationDate LONG, \
- modificationDate LONG, \
- hidden BOOLEAN, \
- note TEXT, \
- removed LONG, \
- PRIMARY KEY (taskId))
-CREATE_TABLE_TIME=CREATE TABLE time \
- (taskid VARCHAR(255) NOT NULL, \
- date LONG, \
- uuid varchar(255) unique, \
- duration LONG, \
- modificationDate LONG, \
- removed LONG, \
- PRIMARY KEY (taskid, date, uuid), \
- FOREIGN KEY (taskid) \
- REFERENCES task (taskId) \
- ON DELETE CASCADE)
-####
-#INSERT
-INSERT_VERSION_NUMBER=INSERT INTO VERSION VALUES('2.0')
-INSERT_TASK=INSERT INTO ? (name, parent, taskId, hidden, note,creationDate, modificationDate, removed)" VALUES (?, ?, ?, ?, ?,?, ?, ?)
-INSERT_TIME=INSERT INTO ? (taskid, date, uuid, duration, modificationDate, removed) VALUES(?, ?, ?, ?, ?, ?)
-###
-#SELECT
-SELECT_TIMED_TASK="SELECT TA.*, sum(TI.duration) AS totalduration \
- FROM ? TA, ? TI \
- WHERE TA.taskId = TI.taskid \
- AND TA.modificationDate > ? \
- GROUP BY TA.taskId
-SELECT_NOTTIMED_TASK=SELECT * \
- FROM ? \
- WHERE (taskId not in (SELECT taskid FROM ?)) \
- AND ?.modificationDate > ?
-###
-#DELETE
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-06-20 16:07:12 UTC (rev 3004)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-06-23 15:38:30 UTC (rev 3005)
@@ -909,15 +909,8 @@
var modalInstance = $modal.open({
templateUrl: 'partials/reportModal.html',
controller: ReportModalInstanceCtrl,
- resolve: {
- times : function () {
- return angular.copy($scope.data.times);
- },
- tasks : function () {
- return angular.copy($scope.data.tasks);
- }
- }
+
});
modalInstance.result.then(function (item) {
1
0
r3004 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/storage java/org/chorem/jtimer/utils java/org/chorem/jtimer/utils/Resource java/org/chorem/jtimer/web resources webapp/js webapp/partials
by obruce@users.chorem.org 20 Jun '14
by obruce@users.chorem.org 20 Jun '14
20 Jun '14
Author: obruce
Date: 2014-06-20 18:07:12 +0200 (Fri, 20 Jun 2014)
New Revision: 3004
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3004
Log:
changement pour le mustache
debut properties pour requete du storage
Added:
branches/ng-jtimer/src/main/resources/jtimer-query.properties
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheReport.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/Resource/ReportTime.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/resources/subtasks.mustache
branches/ng-jtimer/src/main/webapp/js/app.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/storage/Storage.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-06-19 07:51:49 UTC (rev 3003)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-06-20 16:07:12 UTC (rev 3004)
@@ -14,7 +14,9 @@
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* Implementation du stockage des taches en base de données basée sur h2.
@@ -521,7 +523,8 @@
PreparedStatement statement2 = null;
try{
statement = connection.prepareStatement(
- "SELECT TA.taskId AS taskid, TA.name AS task, TA.parent AS parent, sum(TI.duration) AS totalduration" +
+ "SELECT TA.taskId AS taskid, TA.name AS task, TA.parent AS parent," +
+ " TA.creationDate AS creationDate, sum(TI.duration) AS totalduration" +
" FROM " + TABLE_TASK+" TA," + TABLE_TIME +" TI" +
" WHERE TA.taskId = TI.taskid" +
" AND TA.creationDate >" + startDate +
@@ -531,7 +534,8 @@
ResultSet rs = statement.executeQuery();
while(rs.next()){
- list.add(new ReportTask(rs.getString("task"),rs.getString("taskid"), rs.getString("parent") , rs.getLong("totalduration")));
+ list.add(new ReportTask(rs.getString("task"),rs.getString("taskid"),
+ rs.getString("parent") , rs.getLong("totalduration"), rs.getLong("creationDate")));
}
// not timed tasks
@@ -542,7 +546,8 @@
rs = statement2.executeQuery();
while(rs.next()){
- list.add(new ReportTask(rs.getString("name"), rs.getString("taskId"),rs.getString("parent"), (long) 0));
+ list.add(new ReportTask(rs.getString("name"), rs.getString("taskId"),
+ rs.getString("parent"), (long) 0, rs.getLong("creationDate")));
}
}catch(SQLException ex) {
@@ -555,7 +560,75 @@
return list;
}
+ public Map getReportByWeek(Long startDate, Long endDate){
+ //treemap car date implemente comparable
+ HashMap<Integer, ArrayList> byWeekTasks = new HashMap<Integer, ArrayList>();
+ PreparedStatement statement = null;
+ PreparedStatement statement2 = null;
+
+ try{
+ statement = connection.prepareStatement(
+ "SELECT WEEK(FROM_UNIXTIME(creationDate)) AS numWeek, TA.taskId AS taskid, TA.name AS task, TA.parent AS parent," +
+ " TA.creationDate AS creationDate, sum(TI.duration) AS totalduration" +
+ " FROM " + TABLE_TASK+" TA," + TABLE_TIME +" TI" +
+ " WHERE TA.taskId = TI.taskid" +
+ " AND TA.creationDate >" + startDate +
+ " AND TA.creationDate <" + endDate +
+ " GROUP BY TA.taskId, numWeek " +
+ " ORDER BY creationDate DESC");
+
+
+ ResultSet rs = statement.executeQuery();
+ while(rs.next()){
+ Integer numWeek = rs.getInt("numWeek");
+ ArrayList tasks;
+ if(byWeekTasks.containsKey(numWeek)){
+ tasks = byWeekTasks.get(numWeek);
+ }else{
+ tasks = new ArrayList();
+ }
+ tasks.add(new ReportTask(rs.getString("task"),rs.getString("taskid"),
+ rs.getString("parent") , rs.getLong("totalduration"), rs.getLong("creationDate")));
+
+ byWeekTasks.put(numWeek, tasks);
+ }
+
+ // not timed tasks
+ statement2 = connection.prepareStatement("SELECT * FROM " + TABLE_TASK +
+ " WHERE (taskId not in (SELECT taskid FROM " + TABLE_TIME + ")" +
+ " AND parent = '' )"
+ );
+
+ rs = statement2.executeQuery();
+ while(rs.next()){
+ ArrayList tasks;
+
+ if(byWeekTasks.containsKey(0)){
+ tasks = byWeekTasks.get(0);
+ }else{
+ tasks = new ArrayList();
+ }
+ tasks.add(new ReportTask(rs.getString("name"), rs.getString("taskId"),
+ rs.getString("parent"), (long) 0, rs.getLong("creationDate")));
+
+ byWeekTasks.put(0, tasks);
+ }
+
+
+ }catch(SQLException ex) {
+ throw new StorageException("Can't get report", ex);
+ } finally {
+ closeStatement(statement);
+ closeStatement(statement2);
+ }
+
+ log.info("le map " + byWeekTasks.toString());
+
+ return byWeekTasks;
+ }
+
+
/** Suppression de tuple **/
/**
@@ -624,7 +697,7 @@
/**
* Methode qui va va modifier l'attribut removed d'un timertask a l'aide de son identifiant
* @param taskId l'identifiant de la tache
- * @param time
+ * @param time le temps ou a lieu la modif
*/
public void removeTaskWithId(String taskId, long time) {
PreparedStatement statement = null;
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheReport.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheReport.java 2014-06-19 07:51:49 UTC (rev 3003)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheReport.java 2014-06-20 16:07:12 UTC (rev 3004)
@@ -24,6 +24,7 @@
protected static final Log log = LogFactory.getLog(MustacheReport.class);
protected Context context;
+ protected Storage storage;
protected List mustacheList;
@@ -33,6 +34,7 @@
*/
public MustacheReport(Context context){
this.context = context;
+ storage = (Storage) context.getAttributes().get(Storage.class.getName());
}
/**
@@ -41,12 +43,12 @@
*/
public String createByProjectMustache(String type, long start, long end) throws IOException {
- log.info("create a Mustache "+start + " " +end);
+ log.info("create a Mustache by project");
MustacheFactory mf = new DefaultMustacheFactory();
Mustache mustache = mf.compile("ByProject.mustache");
//On recupere les taches
- Storage storage = (Storage) context.getAttributes().get(Storage.class.getName());
+
mustacheList = storage.getReportByProject(start, end);
StringWriter sw = new StringWriter();
@@ -56,7 +58,17 @@
}
- public String createByDayMustache(String type, long startDate, long endDate) {
- return null;
+ public String createByWeekMustache(String type, long start, long end) {
+ log.info("create a Mustache by week");
+ MustacheFactory mf = new DefaultMustacheFactory();
+ Mustache mustache = mf.compile("ByWeek_template.mustache");
+
+
+ storage.getReportByWeek(start, end);
+
+ StringWriter sw = new StringWriter();
+ //mustache.execute(sw, MustacheHandler.getByWeekReport());
+
+ return sw.toString();
}
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.java 2014-06-19 07:51:49 UTC (rev 3003)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.java 2014-06-20 16:07:12 UTC (rev 3004)
@@ -3,6 +3,7 @@
import org.chorem.jtimer.utils.Resource.ReportTime;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
/**
@@ -21,6 +22,8 @@
protected ReportTime time;
protected List subtasks;
+ protected Date creationDate;
+
/**
* Constructeur
* @param name le nom
@@ -28,7 +31,8 @@
* @param parent l'identifiant du parent
* @param time le temps
*/
- public ReportTask(String name, String taskId, String parent, long time){
+ public ReportTask(String name, String taskId, String parent, long time,long date){
+ this.creationDate = new Date(date);
this.taskId = taskId;
this.name = name;
this.parent = parent;
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/Resource/ReportTime.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/Resource/ReportTime.java 2014-06-19 07:51:49 UTC (rev 3003)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/Resource/ReportTime.java 2014-06-20 16:07:12 UTC (rev 3004)
@@ -1,5 +1,6 @@
package org.chorem.jtimer.utils.Resource;
+
/**
* Created by olivia on 18/06/14.
* <p/>
@@ -24,6 +25,7 @@
* @param milliseconds time in ms
*/
public ReportTime(long milliseconds){
+
this.ms =milliseconds;
changeSecMinHours();
changeSecMinHoursString();
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-06-19 07:51:49 UTC (rev 3003)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ReportResource.java 2014-06-20 16:07:12 UTC (rev 3004)
@@ -54,6 +54,7 @@
MustacheReport report = new MustacheReport(getContext());
+
res = report.createByProjectMustache(type, startDate, endDate);
log.info("Ce qui est produit " + res);
Modified: branches/ng-jtimer/src/main/resources/jtimer-default.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-06-19 07:51:49 UTC (rev 3003)
+++ branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-06-20 16:07:12 UTC (rev 3004)
@@ -2,5 +2,5 @@
# jTimer default properties
###
# jTimer storage path
-jtimer.storage.path=/tmp/jtimer/jtimer8081
+jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer8081
Added: branches/ng-jtimer/src/main/resources/jtimer-query.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-query.properties (rev 0)
+++ branches/ng-jtimer/src/main/resources/jtimer-query.properties 2014-06-20 16:07:12 UTC (rev 3004)
@@ -0,0 +1,49 @@
+###
+# This file contains all sql queries
+###
+#TABLE
+TABLE_TASK=task
+TABLE_TIME=tasktime
+TABLE_VERSION=version
+###
+#CREATE SCHEMA
+CREATE_TABLE_VERSION=CREATE TABLE version (version VARCHAR(10))
+CREATE_TABLE_TASK=CREATE TABLE task \
+ (taskId VARCHAR(255) NOT NULL, \
+ name VARCHAR(255) NOT NULL, \
+ parent VARCHAR(255), \
+ creationDate LONG, \
+ modificationDate LONG, \
+ hidden BOOLEAN, \
+ note TEXT, \
+ removed LONG, \
+ PRIMARY KEY (taskId))
+CREATE_TABLE_TIME=CREATE TABLE time \
+ (taskid VARCHAR(255) NOT NULL, \
+ date LONG, \
+ uuid varchar(255) unique, \
+ duration LONG, \
+ modificationDate LONG, \
+ removed LONG, \
+ PRIMARY KEY (taskid, date, uuid), \
+ FOREIGN KEY (taskid) \
+ REFERENCES task (taskId) \
+ ON DELETE CASCADE)
+####
+#INSERT
+INSERT_VERSION_NUMBER=INSERT INTO VERSION VALUES('2.0')
+INSERT_TASK=INSERT INTO ? (name, parent, taskId, hidden, note,creationDate, modificationDate, removed)" VALUES (?, ?, ?, ?, ?,?, ?, ?)
+INSERT_TIME=INSERT INTO ? (taskid, date, uuid, duration, modificationDate, removed) VALUES(?, ?, ?, ?, ?, ?)
+###
+#SELECT
+SELECT_TIMED_TASK="SELECT TA.*, sum(TI.duration) AS totalduration \
+ FROM ? TA, ? TI \
+ WHERE TA.taskId = TI.taskid \
+ AND TA.modificationDate > ? \
+ GROUP BY TA.taskId
+SELECT_NOTTIMED_TASK=SELECT * \
+ FROM ? \
+ WHERE (taskId not in (SELECT taskid FROM ?)) \
+ AND ?.modificationDate > ?
+###
+#DELETE
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/resources/subtasks.mustache
===================================================================
--- branches/ng-jtimer/src/main/resources/subtasks.mustache 2014-06-19 07:51:49 UTC (rev 3003)
+++ branches/ng-jtimer/src/main/resources/subtasks.mustache 2014-06-20 16:07:12 UTC (rev 3004)
@@ -1,6 +1,9 @@
<div style="margin-left:2em;">
{{#subtasks}}
- -{{name}} temps : {{time.hh}}:{{time.mm}}:{{time.ss}}
+ <div style="display : block" >
+ <div style="min-width : 100px; max-width : 110px; display : inline-block;">-{{name}} :</div>
+ <div style="min-width : 100px; max-width : 150px; display : inline-block;">{{time.hh}}:{{time.mm}}:{{time.ss}} </div>
+ </div>
{{> subtasks}}
{{/subtasks}}
</div>
\ 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-06-19 07:51:49 UTC (rev 3003)
+++ branches/ng-jtimer/src/main/webapp/js/app.js 2014-06-20 16:07:12 UTC (rev 3004)
@@ -373,4 +373,19 @@
});
}
}
-}]);
\ No newline at end of file
+}]);
+
+/*angular.module('webtimer').directive('focusMe', function($timeout) {
+ return {
+ link: function($scope, element, attrs) {
+ $scope.$watch(attrs.focusMe, function(value) {
+ if(value === true) {
+ $timeout(function() {
+ element[0].focus();
+ $scope[attrs.focusMe] = true;
+ });
+ }
+ });
+ }
+ };
+});*/
Modified: branches/ng-jtimer/src/main/webapp/partials/reportModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-06-19 07:51:49 UTC (rev 3003)
+++ branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-06-20 16:07:12 UTC (rev 3004)
@@ -1,11 +1,12 @@
<div>
- <h2>Option du rapport:</h2>
+ <h2>Option du rapport :</h2>
</div>
<hr/>
-<div>
- <div>
+<div >
+ <!-- Datepicker div -->
+ <div style="display : inline-block;vertical-align: top;">
De :
<div ng-controller="ReportDatePickerCtrl" class="row">
<div class="col-md-6">
@@ -30,27 +31,21 @@
</div>
</div>
- <p>
-
- </p>
+ <div>
- <div class="btn-group" ng-show="false">
- <label class="btn btn-primary" ng-change="changeFonc()" ng-model="radioModel" btn-radio="'1'">Jour</label>
- <label class="btn btn-primary" ng-change="changeFonc()" ng-model="radioModel" btn-radio="'2'">Semaine</label>
- <label class="btn btn-primary" ng-change="changeFonc()" ng-model="radioModel" btn-radio="'3'">Mois</label>
- <label class="btn btn-primary" ng-change="changeFonc()" ng-model="radioModel" btn-radio="'4'">Année</label>
- <label class="btn btn-primary" ng-change="changeFonc()" ng-model="radioModel" btn-radio="'5'">Projet</label>
</div>
- <p>
-
- </p>
+
+
</div>
- <div>
+ <div style="display : inline-block; vertical-align: top; width : 350px">
<alert type="info" >
- <div ng-bind-html="toHTML(htmlReport)"></div>
+ <span>
+ <div ng-bind-html="toHTML(htmlReport)"></div>
+ </span>
+
</alert>
</div>
Modified: branches/ng-jtimer/src/main/webapp/partials/tasks.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-06-19 07:51:49 UTC (rev 3003)
+++ branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-06-20 16:07:12 UTC (rev 3004)
@@ -1,8 +1,8 @@
<div id="header">
<!--Header partie gauche -->
<span class='left form-inline'>
- <input class='search-query form-group form-control input-sm small_input' ng-model="query" placeholder="Search">
- <form ng-submit="addTask()">
+ <input class='search-query form-group form-control input-sm small_input' style="display : inline-block;" ng-model="query" placeholder="Search">
+ <form style="display : inline-block;" ng-submit="addTask()">
<input class='search-query form-group form-control input-sm small_input' ng-model="name" placeholder="New Task">
</form>
@@ -70,7 +70,7 @@
<!--Project name visible and editable -->
<form ng-submit="saveTask($node)" ng-show="$node.edit == 'name'">
- <input ng-model="$node.task.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>
1
0
r3003 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/entities java/org/chorem/jtimer/storage java/org/chorem/jtimer/utils java/org/chorem/jtimer/utils/Resource java/org/chorem/jtimer/web resources webapp/js webapp/partials
by obruce@users.chorem.org 19 Jun '14
by obruce@users.chorem.org 19 Jun '14
19 Jun '14
Author: obruce
Date: 2014-06-19 09:51:49 +0200 (Thu, 19 Jun 2014)
New Revision: 3003
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3003
Log:
changement du modal, et des entit?\195?\169s avec le rapport
Added:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/Resource/
branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/Resource/ReportTime.java
branches/ng-jtimer/src/main/resources/ByWeek_template.mustache
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/java/org/chorem/jtimer/utils/MustacheHandler.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ReportResource.java
branches/ng-jtimer/src/main/resources/ByProject.mustache
branches/ng-jtimer/src/main/resources/subtasks.mustache
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-06-17 16:02:11 UTC (rev 3002)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2014-06-19 07:51:49 UTC (rev 3003)
@@ -53,6 +53,9 @@
protected String name;
/** Creation date. */
+ protected Date creationDate;
+
+ /**ModificationDate*/
protected Date modificationDate;
/** Closed task. */
@@ -85,24 +88,18 @@
this.name = name;
this.taskId = UUID.randomUUID().toString();
this.parent = "";
+ this.creationDate = new Date();
this.modificationDate = new Date();
this.removed = 0;
}
- /**
- * Constructor with name.
- *
- * @param name task name
- */
- public TimerTask( String name, long datetime) {
- this();
- this.name = name;
- this.taskId = UUID.randomUUID().toString();
- this.parent = "";
- this.modificationDate = new Date(datetime);
- this.removed = 0;
+ public Date getCreationDate() {
+ return creationDate;
}
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
/**
* Set task uuid
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-06-17 16:02:11 UTC (rev 3002)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-06-19 07:51:49 UTC (rev 3003)
@@ -152,6 +152,7 @@
"(taskId VARCHAR(255) NOT NULL," +
" name VARCHAR(255) NOT NULL," +
" parent VARCHAR(255)," +
+ " creationDate LONG, " +
" modificationDate LONG, " +
" hidden BOOLEAN," +
" note TEXT," +
@@ -224,6 +225,7 @@
task.setParent(rs.getString("parent"));
task.setRemoved(rs.getLong("removed"));
task.setTodayTime(0);
+ task.setCreationDate(new java.util.Date(rs.getLong("creationDate")));
task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
task.setTotalTime(rs.getLong("totalduration"));
tasks.add(task);
@@ -239,6 +241,7 @@
task.setName(rs.getString("name"));
task.setTaskId(rs.getString("taskId"));
task.setParent(rs.getString("parent"));
+ task.setCreationDate(new java.util.Date(rs.getLong("creationDate")));
task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
task.setRemoved(rs.getLong("removed"));
task.setTodayTime(0);
@@ -276,6 +279,7 @@
task.setParent(rs.getString("parent"));
task.setRemoved(rs.getLong("removed"));
task.setTodayTime(0);
+ task.setCreationDate(new java.util.Date(rs.getLong("creationDate")));
task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
task.setTotalTime(rs.getLong("totalduration"));
tasks.add(task);
@@ -291,6 +295,7 @@
task.setName(rs.getString("name"));
task.setTaskId(rs.getString("taskId"));
task.setParent(rs.getString("parent"));
+ task.setCreationDate(new java.util.Date(rs.getLong("creationDate")));
task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
task.setRemoved(rs.getLong("removed"));
task.setTodayTime(0);
@@ -313,15 +318,16 @@
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("INSERT INTO " +
- TABLE_TASK + "(name, parent, taskId, hidden, note, modificationDate, removed)" +
- " VALUES (?, ?, ?, ?, ?, ?, ?)");
+ TABLE_TASK + "(name, parent, taskId, hidden, note,creationDate, modificationDate, removed)" +
+ " VALUES (?, ?, ?, ?, ?,?, ?, ?)");
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.setLong(6, task.getModificationDate().getTime());
- statement.setLong(7,task.getRemoved());
+ statement.setLong(6, task.getCreationDate().getTime());
+ statement.setLong(7, task.getModificationDate().getTime());
+ statement.setLong(8,task.getRemoved());
statement.executeUpdate();
} catch (SQLException ex) {
@@ -518,9 +524,10 @@
"SELECT TA.taskId AS taskid, TA.name AS task, TA.parent AS parent, sum(TI.duration) AS totalduration" +
" FROM " + TABLE_TASK+" TA," + TABLE_TIME +" TI" +
" WHERE TA.taskId = TI.taskid" +
- " AND TA.modificationDate >" + startDate +
- " AND TA.modificationDate <" + endDate +
- " GROUP BY TA.taskId");
+ " AND TA.creationDate >" + startDate +
+ " AND TA.creationDate <" + endDate +
+ " GROUP BY TA.taskId" +
+ " ORDER BY TA.creationDate DESC");
ResultSet rs = statement.executeQuery();
while(rs.next()){
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheHandler.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheHandler.java 2014-06-17 16:02:11 UTC (rev 3002)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/MustacheHandler.java 2014-06-19 07:51:49 UTC (rev 3003)
@@ -23,7 +23,7 @@
List tasks() {
//On tri les taches avant de les envoyer au template
- HashMap<String, ArrayList<ReportTask>> map = new HashMap<String,ArrayList<ReportTask>>();
+ HashMap<String, ArrayList<ReportTask>> childMap = new HashMap<String,ArrayList<ReportTask>>();
Iterator iter = tasks.iterator();
while(iter.hasNext()) {
@@ -31,8 +31,8 @@
ReportTask t = (ReportTask)iter.next();
//un enfant dans map
- if(map.containsKey(t.getTaskId())){
- for(ReportTask task :map.get(t.getTaskId()))
+ if(childMap.containsKey(t.getTaskId())){
+ for(ReportTask task :childMap.get(t.getTaskId()))
t.addChild(task);
}
@@ -42,16 +42,25 @@
//On ajoute l'enfant à la map
ArrayList tmp = new ArrayList();
- if(map.get(t.parent) != null){
- tmp=map.get(t.parent);
+ if(childMap.get(t.parent) != null){
+ tmp=childMap.get(t.parent);
}
tmp.add(t);
- map.put(t.parent, tmp);
+ childMap.put(t.parent, tmp);
iter.remove();
}
}
+ iter = tasks.iterator();
+ while(iter.hasNext()) {
+ ReportTask t = (ReportTask)iter.next();
+
+ if(t.getTime().isNotTimed()){
+ iter.remove();
+ }
+ }
+
return tasks;
}
@@ -62,6 +71,7 @@
*/
public MustacheHandler(List<ReportTask> mustacheList){
this.tasks = mustacheList;
+ log.debug(mustacheList);
}
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.java 2014-06-17 16:02:11 UTC (rev 3002)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/ReportTask.java 2014-06-19 07:51:49 UTC (rev 3003)
@@ -1,5 +1,7 @@
package org.chorem.jtimer.utils;
+import org.chorem.jtimer.utils.Resource.ReportTime;
+
import java.util.ArrayList;
import java.util.List;
@@ -16,7 +18,7 @@
protected String name;
protected String taskId;
protected String parent;
- protected long time;
+ protected ReportTime time;
protected List subtasks;
/**
@@ -30,7 +32,7 @@
this.taskId = taskId;
this.name = name;
this.parent = parent;
- this.time = time;
+ this.time = new ReportTime(time);
this.subtasks = new ArrayList();
}
@@ -38,7 +40,7 @@
/** Ajout */
public void addChild(ReportTask t){
this.subtasks.add(t);
- this.time += t.getTime();
+ this.time.addTime(t.getTime());
}
/**Getter */
@@ -55,7 +57,7 @@
return parent;
}
- public long getTime() {
+ public ReportTime getTime() {
return time;
}
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/Resource/ReportTime.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/Resource/ReportTime.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/utils/Resource/ReportTime.java 2014-06-19 07:51:49 UTC (rev 3003)
@@ -0,0 +1,84 @@
+package org.chorem.jtimer.utils.Resource;
+
+/**
+ * Created by olivia on 18/06/14.
+ * <p/>
+ * Project name : jtimer
+ * <p/>
+ * Package name : org.chorem.jtimer.utils.Resource
+ */
+public class ReportTime {
+
+ protected String ss;
+ protected String mm;
+ protected String hh;
+
+ protected int seconds;
+ protected int minutes;
+ protected int hours;
+
+ protected long ms;
+
+ /**
+ * Constructor
+ * @param milliseconds time in ms
+ */
+ public ReportTime(long milliseconds){
+ this.ms =milliseconds;
+ changeSecMinHours();
+ changeSecMinHoursString();
+ }
+
+ /**
+ * Method that adds a reporttime to an other
+ * @param other a reportTime
+ */
+ public void addTime(ReportTime other){
+ ms += other.ms;
+ changeSecMinHours();
+ changeSecMinHoursString();
+ }
+
+ /**
+ * Changes the HH/MM/SS string
+ */
+ private void changeSecMinHoursString() {
+ //temps
+ if(seconds<10){
+ ss = "0"+seconds;
+ }else{
+ ss = String.valueOf(seconds) ;
+ }
+
+ //minutes
+ if(minutes<10){
+ mm = "0"+minutes;
+ }else{
+ mm = String.valueOf(minutes);
+ }
+
+ //hours
+ if(hours<10){
+ hh = "0"+hours;
+ }else{
+ hh = String.valueOf(hours);
+ }
+ }
+
+ /**
+ * Changes the hour/min/sec with de current ms
+ */
+ private void changeSecMinHours() {
+ this.seconds = (int) (this.ms / 1000) % 60 ;
+ this.minutes = (int) ((this.ms / (1000*60)) % 60);
+ this.hours = (int) ((this.ms / (1000*60*60)) % 24);
+ }
+
+ /**
+ * Return true if the task has no time
+ * @return booleen
+ */
+ public boolean isNotTimed() {
+ return this.ms==(long) 0;
+ }
+}
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-06-17 16:02:11 UTC (rev 3002)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ReportResource.java 2014-06-19 07:51:49 UTC (rev 3003)
@@ -41,12 +41,12 @@
log.info("type non present dans l'url" + e);
}
try {
- startDate = Long.valueOf(getQuery().getValues("startDate"));
+ startDate = Long.valueOf(getQuery().getValues("start_Date"));
} catch (Exception e) {
log.info("type non present dans l'url" + e);
}
try {
- endDate = Long.valueOf(getQuery().getValues("endDate"));
+ endDate = Long.valueOf(getQuery().getValues("end_Date"));
} catch (Exception e) {
log.info("type non present dans l'url" + e);
}
@@ -57,11 +57,7 @@
res = report.createByProjectMustache(type, startDate, endDate);
log.info("Ce qui est produit " + res);
- res = report.createByDayMustache(type, startDate, endDate);
- log.info("Ce qui est produit " + res);
-
-
- return new StringRepresentation(res, MediaType.TEXT_JAVASCRIPT);
+ return new StringRepresentation(res, MediaType.TEXT_HTML);
}
}
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/resources/ByProject.mustache
===================================================================
--- branches/ng-jtimer/src/main/resources/ByProject.mustache 2014-06-17 16:02:11 UTC (rev 3002)
+++ branches/ng-jtimer/src/main/resources/ByProject.mustache 2014-06-19 07:51:49 UTC (rev 3003)
@@ -1,13 +1,21 @@
-Rapport:
-========
+<div>
+ <h3>
+ Rapport:
+ </h3>
+</div>
<hr/>
+<div>
+ {{#tasks}}
+ <b>Projet : {{name}}</b>
-{{#tasks}}
-<b>Projet : {{name}}</b>
+ {{>subtasks}}
-{{>subtasks}}
+ Temps total : {{time.hh}}:{{time.mm}}:{{time.ss}}
-Temps total : {{time}}|time
+ <hr/>
+ {{/tasks}}
-<hr/>
-{{/tasks}}
+ {{^tasks}}
+ Pas de tâches sur cette période.
+ {{/tasks}}
+</div>
\ No newline at end of file
Added: branches/ng-jtimer/src/main/resources/ByWeek_template.mustache
===================================================================
--- branches/ng-jtimer/src/main/resources/ByWeek_template.mustache (rev 0)
+++ branches/ng-jtimer/src/main/resources/ByWeek_template.mustache 2014-06-19 07:51:49 UTC (rev 3003)
@@ -0,0 +1,7 @@
+Rapport
+=======
+
+{{#weeks}}
+ Semaine : {{day}}
+ {{>ByProject}}
+{{/weeks}}
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/resources/subtasks.mustache
===================================================================
--- branches/ng-jtimer/src/main/resources/subtasks.mustache 2014-06-17 16:02:11 UTC (rev 3002)
+++ branches/ng-jtimer/src/main/resources/subtasks.mustache 2014-06-19 07:51:49 UTC (rev 3003)
@@ -1,4 +1,6 @@
-{{#subtasks}}
- -{{name}} temps : {{time}}|time
- {{> subtasks}}
-{{/subtasks}}
\ No newline at end of file
+<div style="margin-left:2em;">
+ {{#subtasks}}
+ -{{name}} temps : {{time.hh}}:{{time.mm}}:{{time.ss}}
+ {{> subtasks}}
+ {{/subtasks}}
+</div>
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-06-17 16:02:11 UTC (rev 3002)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-06-19 07:51:49 UTC (rev 3003)
@@ -964,44 +964,34 @@
};
}
-function ReportModalInstanceCtrl($scope, $modalInstance, times, tasks, serverReportAccess){
+function ReportModalInstanceCtrl($scope, $modalInstance,$http, $sce){
$scope.obj={
startDate : new Date(),
- endDate : new Date(),
- report:[]
+ endDate : new Date()
};
+ $scope.obj.endDate.setHours(23,59,59,999);
+
$scope.radioModel = '5';
$scope.htmlReport="";
- /*$scope.generateReport= function(){
- report = [];
+ $scope.toHTML = function (data) {
+ return $sce.trustAsHtml(data);
+ }
- angular.forEach(times, function(timeArray,task){
+ $scope.generateReport= function(){
- var res={};
- res.time = -1;
- angular.forEach(timeArray, function(time){
+ $scope.obj.startDate.setHours(0,0,0,0);
+ $scope.obj.endDate.setHours(23,59,59,999);
- if(time.creationDate >= $scope.obj.startDate.getTime() && time.creationDate <= $scope.obj.endDate.getTime()){
- res.time = res.time + time.time;
- res.task = tasks[task].name;
- }
- });
- if(res.time != -1 ){
- $scope.obj.report.push(res);
- }
- });
-
-
- }*/
-
- $scope.generateReport= function(){
- serverReportAccess.get({}, function(response){
- console.log(response);
- $scope.htmlReport = response;
- }
+ var deb =($scope.obj.startDate).getTime();
+ var end =($scope.obj.endDate).getTime();
+ $http({method: "GET", url: "/rest/report",
+ params:{start_Date : deb, end_Date : end}})
+ .success(function(data){
+ $scope.htmlReport = data;// data should be text string here (only if the server response is text/plain)
+ }
);
}
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-06-17 16:02:11 UTC (rev 3002)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-06-19 07:51:49 UTC (rev 3003)
@@ -390,7 +390,7 @@
}else{
this.taskId = taskId;
}
-
+ this.creationDate = Date.now();
this.modificationDate = Date.now();
this.removed = 0;
Modified: branches/ng-jtimer/src/main/webapp/partials/reportModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-06-17 16:02:11 UTC (rev 3002)
+++ branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-06-19 07:51:49 UTC (rev 3003)
@@ -50,13 +50,7 @@
<div>
<alert type="info" >
- <!--Rapport :<br/>
- =========
- <div ng-repeat="elem in obj.report">
- {{elem.task}} : {{elem.time | time}}
- </div>-->
- {{htmlReport}}
-
+ <div ng-bind-html="toHTML(htmlReport)"></div>
</alert>
</div>
1
0