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
May 2014
- 3 participants
- 31 discussions
r2992 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/storage webapp/js webapp/partials
by obruce@users.chorem.org 28 May '14
by obruce@users.chorem.org 28 May '14
28 May '14
Author: obruce
Date: 2014-05-28 11:38:19 +0200 (Wed, 28 May 2014)
New Revision: 2992
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2992
Log:
correction du timeModal et du storage
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
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/tasks.html
branches/ng-jtimer/src/main/webapp/partials/timeModal.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-05-28 08:05:18 UTC (rev 2991)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-28 09:38:19 UTC (rev 2992)
@@ -295,9 +295,10 @@
statement.setBoolean(3, task.isClosed()); //hidden
statement.setString(4, null /*project.getNote()*/);//note
statement.setLong(5, task.getModificationDate().getTime()); //modificationDate
- statement.setString(6, task.getTaskId()); //taskId
- statement.setBoolean(7,task.getRemoved());
+ statement.setBoolean(6,task.getRemoved());
+ statement.setString(7, task.getTaskId()); //taskId
+
statement.executeUpdate();
} catch (SQLException ex) {
throw new StorageException("Can't modify task", ex);
@@ -315,8 +316,8 @@
statement.setLong(1, t.getCreationDate().getTime());
statement.setLong(2, t.getTime());
statement.setLong(3, t.getModificationDate().getTime()); //modificationDate
- statement.setString(4, t.getTimeId() );
- statement.setBoolean(5, t.getRemoved());
+ statement.setBoolean(4, t.getRemoved());
+ statement.setString(5, t.getTimeId() );
statement.executeUpdate();
} catch (SQLException ex) {
throw new StorageException("Can't modify time", ex);
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-28 08:05:18 UTC (rev 2991)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-28 09:38:19 UTC (rev 2992)
@@ -13,7 +13,7 @@
$scope.timeAccess = $scope.todo.lastTimeAccess;
//interval de conec
- var interval = 20000; //TODO: obruce 05-05-14 decider d'un intervalle interessant
+ var interval = 30000; //TODO: obruce 05-05-14 decider d'un intervalle interessant
// periode de delais = 3 periode +1msec
var delayAccess = 2 * interval +1;
@@ -119,7 +119,42 @@
$localStorage.setTodo("todo", $scope.todo);
};
+
+
/**
+ * Timer qui met les temps a jour toutes les secondes si une tache est
+ * active
+ * @returns {undefined}
+ */
+ var refresh = function() {
+ $timeout(function() {
+ if ($scope.currentTask) {
+ var now = Date.now();
+ var taskTime = $scope.getRecentTaskTime($scope.currentTask);
+ taskTime.addTime(now - $scope.currentTaskDate);
+ $scope.currentTaskDate = now;
+ save();
+ }
+
+ refresh();
+ }, 1000);
+ };
+ refresh();
+
+ /**
+ * Timer qui joue des actions sur un interval donné
+ * @returns {promise}
+ */
+ var timer = function() {
+ $interval(function() {
+ pushTodoListToServ();
+ updateTasksFromServ();
+ updateTimesFromServer();
+ }, interval);
+ };
+ timer();
+
+ /**
* Récupère les nouveaux elements du serveur et les ajoute a l'arbre pour l'affichage
*
*/
@@ -157,7 +192,7 @@
});
- console.log("Je suis dans le get tasks");
+ console.log("Task initialisé");
//On change la date de dernier acces
$scope.taskAccess = Date.now();
$scope.todo.lastTaskAccess= $scope.taskAccess;
@@ -184,8 +219,7 @@
//La tache existe
if(item.taskId in $scope.data.tasks){
- console.log("Tache existe");
- //console.log(item);
+ console.log("Tache existe"+item);
//On cherche le node et on le met à jour
var tmp = $scope.tree.getNode(item.taskId);
@@ -200,8 +234,7 @@
}else if(!item.isremoved){
- console.log("Nouvelle tache");
- console.log(item);
+ console.log("Nouvelle tache" +item);
var newTask = new Task( item.name, item.taskId, item.parent);
@@ -249,30 +282,29 @@
serverTimeAccess.query({date : $scope.timeAccess-delayAccess}, function (response) {
angular.forEach(response, function (item) {
- //le temps n'existe pas
- console.log("Changement d'une periode");
- console.log(item);
var editedTime = getObjectInArrayWithId($scope.data.times[item.taskId],item.timeId);
- if(editedTime == undefined){
+ if(editedTime){
+ if(!item.isremoved){
+ console.log("Temps existe donc remplacé");
+ //Le temps existe
+ var editedTime = getObjectInArrayWithId($scope.data.times[item.taskId],item.timeId);
+ editedTime.time = item.time;
+ editedTime.creationDate = item.creationDate;
- console.log("le temps n'existe pas");
- if(!$scope.data.times[item.taskId]){$scope.data.times[item.taskId] = []}
+ save();
+ }
- taskTime = new TaskTime($scope.data.tasks[item.taskId], item.timeId, item.creationDate, item.time);
- $scope.data.times[item.taskId].push(taskTime);
+ }else if(!item.isremoved){
+ console.log("le temps n'existe pas");
+ //init de l'array des temps de la tache
+ if(!$scope.data.times[item.taskId]){$scope.data.times[item.taskId] = []}
- save();
+ taskTime = new TaskTime($scope.data.tasks[item.taskId], item.timeId, item.creationDate, item.time);
+ $scope.data.times[item.taskId].push(taskTime);
- }else{
- console.log("Temps existe donc remplacé");
- //Le temps existe
- var editedTime = getObjectInArrayWithId($scope.data.times[item.taskId],item.timeId);
- editedTime.time = item.time;
- editedTime.creationDate = item.creationDate;
-
- save();
+ save();
}
//On change la date de dernier acces
@@ -300,13 +332,13 @@
*/
var getTimesFromServerWithTask = function(task){
- if(!$scope.data.times[task.taskId]){$scope.data.times[task.taskId] = []}
-
serverTimeAccess.query({taskId : task.taskId, date : $scope.timeAccess}, function (response) {
angular.forEach(response, function (item) {
- if(!(existInObject($scope.data.times,item.timeId,task.taskId)) && !(existInObject($scope.todo.stockedDeletedTimes, item.timeId, task.taskId))){
+ 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);
@@ -324,7 +356,7 @@
* Methode qui retourne l'existence d'un element dans un array
*/
var existInObject = function(object, item, pos){
- return (object[pos]) && (item in object[pos]);
+ return (object[pos]) && (item in object[pos]);
};
/**
@@ -335,7 +367,7 @@
//On supprime de la base les taches sotckees pour suppression
angular.forEach($scope.todo.stockedDeletedTasks, function(task){
- serverTaskAccess.delete({taskId: task},
+ serverTaskAccess.deleteTask({taskId: task},
function(){
console.log("delete success" + task);
$scope.todo.stockedDeletedTasks.shift();
@@ -384,7 +416,6 @@
function(){
console.log("persist time success" + task);
$scope.todo.stockedNewTimes[task].shift();
- console.log($scope.todo.stockedNewTimes[task]);
},
function(){
console.log("fail");
@@ -412,7 +443,7 @@
//On supprime de la base les taches sotckees pour suppression
angular.forEach($scope.todo.stockedDeletedTimes, function(times,task){
angular.forEach(times, function(time){
- serverTimeAccess.delete({taskId: time},
+ serverTimeAccess.deleteTime({taskId: time},
function(){
console.log("delete time success" + task);
$scope.todo.stockedDeletedTimes[task].shift();
@@ -429,41 +460,6 @@
/**
- * Timer qui met les temps a jour toutes les secondes si une tache est
- * active
- * @returns {undefined}
- */
- var refresh = function() {
- $timeout(function() {
- if ($scope.currentTask) {
- var now = Date.now();
- var taskTime = $scope.getRecentTaskTime($scope.currentTask);
- taskTime.addTime(now - $scope.currentTaskDate);
- $scope.currentTaskDate = now;
- save();
- }
- refresh();
- }, 1000);
- };
- refresh();
-
- /**
- * Timer qui joue des actions sur un interval donné
- * @returns {promise}
- */
- var timer = function() {
- $interval(function() {
-
- pushTodoListToServ();
- updateTasksFromServ();
- updateTimesFromServer();
-
-
- }, interval);
- };
- timer();
-
- /**
* Ajoute une tache root
*/
$scope.addTask = function() {
@@ -532,7 +528,7 @@
delete $scope.todo.stockedNewTimes[task.taskId];
- serverTaskAccess.delete({taskId: task.taskId}, function(){
+ serverTaskAccess.deleteTask({taskId: task.taskId}, function(){
console.log("delete success" + task.taskId);
},
function(){
@@ -728,6 +724,7 @@
$scope.currentTask = null;
$scope.currentTaskDate = null;
}
+
save();
};
@@ -797,13 +794,17 @@
$scope.popup = function (node){
//Task identifier
var id = node.task.taskId;
+ var data;
var modalInstance = $modal.open({
templateUrl: 'partials/timeModal.html',
controller: ModalInstanceCtrl,
resolve: {
- taskTimes : function(){
- return $scope.data.times[id];
+ taskTimes : function () {
+ return angular.copy($scope.data);
+ },
+ indent : function () {
+ return id;
}
}
@@ -814,6 +815,7 @@
if(item.index != -1){
if(item.action=='Modification'){
//On met la valeur à jour
+
$scope.data.times[id][item.index].changeCreationDate(item.creationDate);
$scope.data.times[id][item.index].changeDuration(item.time);
@@ -840,17 +842,27 @@
}
if(item.action == 'Suppression'){
-
- if(!$scope.todo.stockedDeletedTimes[id]){$scope.todo.stockedDeletedTimes[id] = []};
+ // init de l'objet
+ if(!$scope.todo.stockedDeletedTimes[id]){
+ $scope.todo.stockedDeletedTimes[id] = []
+ };
+ //on pousse l'objet à supprimer
$scope.todo.stockedDeletedTimes[id].push($scope.data.times[id][item.index].timeId);
$scope.data.times[id].splice(item.index,1);
- console.log( $scope.data.times[id]);
+ if($scope.data.times[id]==[]){
+ delete $scope.data.times[id];
+ }
save();
}
-
+ data = $scope.data.times;
}
});
+
+ modalInstance.result.finally(function() {
+ console.log("finally");
+ });
+
}
/**
@@ -894,13 +906,10 @@
}
+function ModalInstanceCtrl($scope, $modalInstance, taskTimes,indent) {
-
-var ModalInstanceCtrl = function ($scope, $modalInstance, taskTimes) {
-
-
// Les temps de la tache
- $scope.times = taskTimes;
+ $scope.times = taskTimes.times[indent];
$scope.dateobj={aTime : new Date(), date : new Date(),};
//L'objet retourner
@@ -913,8 +922,12 @@
$scope.activTime = null;
//Choix d'action
- $scope.periodAction1 =function(){$scope.obj.action = "Ajout"; $scope.act};
- $scope.periodAction2 = function(){$scope.obj.action = "Modification";};
+ $scope.periodAction1 = function(){
+ $scope.obj.action = "Ajout";
+ };
+ $scope.periodAction2 = function(){
+ $scope.obj.action = "Modification";
+ };
$scope.periodAction3 = function(){$scope.obj.action = "Suppression";};
//Pour l'affichage
@@ -947,9 +960,13 @@
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
+
+ $scope.$on('$destroy', function() {
+ console.log('Modal scope should be destroyed.');
+ });
};
-var datePickerCtrl = function($scope){
+function DatePickerCtrl($scope){
$scope.dateMaxPicker= new Date();
@@ -971,7 +988,7 @@
-var radioTimeCtrl = function ($scope){
+function RadioTimeCtrl($scope){
//Activated button radio
$scope.radioModel = 'Left';
@@ -980,8 +997,6 @@
$scope.hstep = 1;
$scope.mstep = 1;
- $scope.obj.index= null;
-
/*
* Méthode déclancher quand l'heure change dans le timepicker
* Change l'objet du controller principal
@@ -1011,9 +1026,6 @@
//Empeche de depasser 23:59
$scope.dateobj.aTime = maxDate;
$scope.obj.time = maxDate.getTime() - $scope.obj.creationDate;
- console.log($scope.obj.time);
- console.log(maxDate);
-
}
}
}
@@ -1026,7 +1038,9 @@
$scope.dateobj.aTime = new Date($scope.obj.creationDate + $scope.obj.time);
}
}
-};
+}
+
+
Modified: branches/ng-jtimer/src/main/webapp/js/service.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/service.js 2014-05-28 08:05:18 UTC (rev 2991)
+++ branches/ng-jtimer/src/main/webapp/js/service.js 2014-05-28 09:38:19 UTC (rev 2992)
@@ -6,7 +6,7 @@
query : {method:'GET', isArray:true},
get : {method: 'GET',isArray: false},
update: {method: "PUT"},
- delete: { method: 'DELETE' },
+ deleteTask: { method: 'DELETE' },
create: { method: 'POST' }
@@ -23,7 +23,8 @@
query : {method:'GET', isArray:true},
get : {method: 'GET', isArray: false},
update: {method: "PUT"},
- create: { method: 'POST' }
+ create: { method: 'POST' },
+ deleteTime: { method: 'DELETE' }
}
Modified: branches/ng-jtimer/src/main/webapp/partials/tasks.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-05-28 08:05:18 UTC (rev 2991)
+++ branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-05-28 09:38:19 UTC (rev 2992)
@@ -27,15 +27,15 @@
<!-- Websocket information -->
<div id="alerts">
<div class="alert alert-warning" ng-if="!webSocketClientOnline">
- <span class="glyphicon glyphicon-warning-sign"></span> Impossible de contacter le client local pour la gestion de l'inactivité.
- <a href="#" target="_blank">Télécharger le client local</a>.
+ <span class="icon-warning-sign"></span> Impossible de contacter le client local pour la gestion de l'inactivité.
+ <a target="_blank">Télécharger le client local</a>.
</div>
</div>
<!-- Footer -->
<div id="footer">
<span class="left">{{currentDate()}}</span>
- <span class="center"><i class="fa fa-html5"></i> <a href="#">WebTimer</a></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>
</div>
@@ -76,17 +76,17 @@
<!-- Action button, add,remove activate task -->
<span class="btn-group action">
- <a class="btn btn-default btn-xs" href="" ng-click="timeTask($node.task)" ng-show="$level > 1">
+ <a class="btn btn-default btn-xs" ng-click="timeTask($node.task)" ng-show="$level > 1">
<i class="glyphicon" ng-class="{'glyphicon-play' : ($node.task != currentTask), 'glyphicon-stop' : ($node.task == currentTask)}"></i>
</a>
- <a class="btn btn-default btn-xs" href="" ng-click="addSubTask($node)"><i class="glyphicon glyphicon-plus"></i></a>
- <a class="btn btn-default btn-xs" href=""
+ <a class="btn btn-default btn-xs" ng-click="addSubTask($node)"><i class="glyphicon glyphicon-plus"></i></a>
+ <a class="btn btn-default btn-xs"
ng-really-message="La suppression de cette tâche nécessite une confirmation. "
ng-really-click="removeTask($node)" ng-show="$node.task != currentTask">
<i class="glyphicon glyphicon-minus"></i>
</a>
- <a class="btn btn-default btn-xs" href="" ng-click="popup($node)"
+ <a class="btn btn-default btn-xs" ng-click="popup($node)"
ng-show="!$node.task.isRoot() ">
<i class="glyphicon glyphicon-pencil" ></i>
</a>
Modified: branches/ng-jtimer/src/main/webapp/partials/timeModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/timeModal.html 2014-05-28 08:05:18 UTC (rev 2991)
+++ branches/ng-jtimer/src/main/webapp/partials/timeModal.html 2014-05-28 09:38:19 UTC (rev 2992)
@@ -6,9 +6,9 @@
Action à faire sur la tâche: <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
- <li><a href="#" ng-click="periodAction1()">Ajouter une periode</a></li>
- <li><a href="#" ng-click="periodAction2()">Modifier une periode</a></li>
- <li><a href="#" ng-click="periodAction3()">Supprimer une periode</a></li>
+ <li><a ng-click="periodAction1()">Ajouter une periode</a></li>
+ <li><a ng-click="periodAction2()">Modifier une periode</a></li>
+ <li><a ng-click="periodAction3()">Supprimer une periode</a></li>
</ul>
</div>
@@ -24,7 +24,7 @@
<li ng-repeat="(index,item) in times" >
- <a href="#" ng-click="select(item, index)">
+ <a ng-click="select(item, index)">
Début : {{getStartTime(item)}} - Durée : {{getStopTime(item)| time}}
</a>
@@ -38,11 +38,11 @@
<hr/>
<div class ="timepick">
- <div ng-controller="datePickerCtrl" style="display:inline-block; min-height:290px;">
+ <div ng-controller="DatePickerCtrl" style="display:inline-block; min-height:290px;">
<datepicker ng-model="dateobj.date" ng-change="changeDayDate()" min-date="minDate" max-date="dateMaxPicker" show-weeks="true" class="well well-sm"></datepicker>
</div>
- <div class = "timepick" ng-controller="radioTimeCtrl">
+ <div class = "timepick" ng-controller="RadioTimeCtrl">
<div>
<div class="btn-group">
<label class="btn btn-primary" ng-model="radioModel" ng-change="changeFonc()" btn-radio="'Left'">Début de période </label>
@@ -68,7 +68,7 @@
<alert type="danger" >Choisir une période :</alert>
- <div class = "timepick" ng-controller="radioTimeCtrl">
+ <div class = "timepick" ng-controller="RadioTimeCtrl">
<br/>
1
0
28 May '14
Author: echatellier
Date: 2014-05-28 10:05:18 +0200 (Wed, 28 May 2014)
New Revision: 2991
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2991
Log:
Fix bootstrap css
Modified:
branches/ng-jtimer/src/main/webapp/partials/tasks.html
Modified: branches/ng-jtimer/src/main/webapp/partials/tasks.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-05-28 08:02:30 UTC (rev 2990)
+++ branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-05-28 08:05:18 UTC (rev 2991)
@@ -27,7 +27,7 @@
<!-- Websocket information -->
<div id="alerts">
<div class="alert alert-warning" ng-if="!webSocketClientOnline">
- <span class="icon-warning-sign"></span> Impossible de contacter le client local pour la gestion de l'inactivité.
+ <span class="glyphicon glyphicon-warning-sign"></span> Impossible de contacter le client local pour la gestion de l'inactivité.
<a href="#" target="_blank">Télécharger le client local</a>.
</div>
</div>
1
0
r2990 - branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities
by echatellier@users.chorem.org 28 May '14
by echatellier@users.chorem.org 28 May '14
28 May '14
Author: echatellier
Date: 2014-05-28 10:02:30 +0200 (Wed, 28 May 2014)
New Revision: 2990
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2990
Log:
Fix invalid javadoc
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java
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-05-27 08:21:57 UTC (rev 2989)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2014-05-28 08:02:30 UTC (rev 2990)
@@ -130,8 +130,9 @@
}
/**
- * Get task uuid
- * @return the task uuid
+ * Set task uuid
+ *
+ * @param taskuuid task uuid
*/
public void setTaskId(String taskuuid) {
taskId = taskuuid;
1
0
r2989 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/storage java/org/chorem/jtimer/web webapp/js
by obruce@users.chorem.org 27 May '14
by obruce@users.chorem.org 27 May '14
27 May '14
Author: obruce
Date: 2014-05-27 10:21:57 +0200 (Tue, 27 May 2014)
New Revision: 2989
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2989
Log:
storage: correction suppression
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java
branches/ng-jtimer/src/main/webapp/js/controllers.js
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-05-26 16:19:25 UTC (rev 2988)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-27 08:21:57 UTC (rev 2989)
@@ -533,12 +533,12 @@
* Methode qui va modifier l'attribut removed d'un timertime a l'aide de son identifiant
* @param timeId l'identifiant du temps
*/
- public void removeTimeWithId(String timeId) {
+ public void removeTimeWithId(String timeId,long time) {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("UPDATE " +
- TABLE_TIME + " SET removed = 1" +
+ TABLE_TIME + " SET removed = 1, modificationDate =" +time +
" WHERE uuid = ?");
statement.setString(1, timeId);
@@ -554,12 +554,13 @@
/**
* 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
*/
- public void removeTaskWithId(String taskId) {
+ public void removeTaskWithId(String taskId, long time) {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("UPDATE " +
- TABLE_TASK + " SET removed = 1" +
+ TABLE_TASK + " SET removed = 1, modificationDate =" +time +
" WHERE taskId = '"+taskId +"'");
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java 2014-05-26 16:19:25 UTC (rev 2988)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java 2014-05-27 08:21:57 UTC (rev 2989)
@@ -10,7 +10,9 @@
import org.restlet.representation.StringRepresentation;
import org.restlet.resource.*;
+import java.util.Date;
+
public class TaskResource extends ServerResource {
private static final Log log = LogFactory.getLog(TaskResource.class);
@@ -49,7 +51,7 @@
@Delete
public void deleteTask() {
String taskId = (String)getRequest().getAttributes().get("taskId");
- storage.removeTaskWithId(taskId);
+ storage.removeTaskWithId(taskId, new Date().getTime());
}
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-05-26 16:19:25 UTC (rev 2988)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java 2014-05-27 08:21:57 UTC (rev 2989)
@@ -101,7 +101,7 @@
@Delete
public void deleteTime() {
String timeId = (String)getRequest().getAttributes().get("taskId");
- storage.removeTimeWithId(timeId);
+ storage.removeTimeWithId(timeId, new Date().getTime());
}
/**
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-26 16:19:25 UTC (rev 2988)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-27 08:21:57 UTC (rev 2989)
@@ -15,7 +15,7 @@
//interval de conec
var interval = 20000; //TODO: obruce 05-05-14 decider d'un intervalle interessant
// periode de delais = 3 periode +1msec
- var delayAccess = 3 * interval +1;
+ var delayAccess = 2 * interval +1;
// {TreeNode} l'arbre regenere automatiquement lorsque les donnees changent
$scope.tree;
@@ -181,6 +181,7 @@
angular.forEach(response, function (item) {
+ //La tache existe
if(item.taskId in $scope.data.tasks){
console.log("Tache existe");
@@ -195,15 +196,12 @@
tmp.task.name = item.name;
}
-
save();
-
-
}else if(!item.isremoved){
console.log("Nouvelle tache");
- //console.log(item);
+ console.log(item);
var newTask = new Task( item.name, item.taskId, item.parent);
1
0
r2988 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/entities java/org/chorem/jtimer/storage java/org/chorem/jtimer/web webapp/js
by obruce@users.chorem.org 26 May '14
by obruce@users.chorem.org 26 May '14
26 May '14
Author: obruce
Date: 2014-05-26 18:19:25 +0200 (Mon, 26 May 2014)
New Revision: 2988
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2988
Log:
storage changement pour la suppression
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTime.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java
branches/ng-jtimer/src/main/webapp/js/controllers.js
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-05-26 09:26:00 UTC (rev 2987)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2014-05-26 16:19:25 UTC (rev 2988)
@@ -67,12 +67,16 @@
/** Total time. */
protected long totalTime;
+ /** if task is removed */
+ protected boolean isremoved;
+
/**
* Constructor.
*/
public TimerTask() {
// wrong value to detect bug
number = -1;
+ this.isremoved = false;
}
/**
@@ -87,6 +91,7 @@
this.taskId = UUID.randomUUID().toString();
this.parent = "";
this.modificationDate = new Date();
+ this.isremoved = false;
}
/**
@@ -101,6 +106,7 @@
this.taskId = UUID.randomUUID().toString();
this.parent = "";
this.modificationDate = new Date(datetime);
+ this.isremoved = false;
}
@@ -224,4 +230,8 @@
public void setTotalTime(long totalTime) {
this.totalTime = totalTime;
}
+
+ public boolean getRemoved() {return isremoved;}
+
+ public void setRemoved(boolean removed) {this.isremoved = removed;}
}
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTime.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTime.java 2014-05-26 09:26:00 UTC (rev 2987)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTime.java 2014-05-26 16:19:25 UTC (rev 2988)
@@ -17,7 +17,7 @@
/** Task identifier it refers to */
protected String taskId;
- /** Task identifier*/
+ /** Time identifier*/
protected String timeId;
/** Creation Date*/
@@ -29,8 +29,12 @@
/** Time Elapsed in the period */
protected long time;
+ /** */
+ protected boolean isremoved;
+
public TimerTime() {
+ isremoved = false;
}
/**
@@ -45,6 +49,7 @@
this.time = time;
this.creationDate = creationDate;
this.modificationDate = creationDate;
+ this.isremoved=false;
}
@@ -98,4 +103,12 @@
", time=" + time +
'}';
}
+
+ public void setRemoved(boolean removed) {
+ this.isremoved = removed;
+ }
+
+ public boolean getRemoved() {
+ return isremoved;
+ }
}
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-05-26 09:26:00 UTC (rev 2987)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-26 16:19:25 UTC (rev 2988)
@@ -137,7 +137,7 @@
/**
* Create tables
- * @param conn
+ * @param conn la connection
*/
protected void createSchema(Connection conn) {
Statement statement = null;
@@ -153,6 +153,7 @@
" modificationDate LONG, " +
" hidden BOOLEAN," +
" note TEXT," +
+ "removed BOOLEAN," +
" PRIMARY KEY (id, taskId))");
statement.executeUpdate("CREATE TABLE " + TABLE_TIME +
"(taskid LONG NOT NULL," +
@@ -160,6 +161,7 @@
" uuid varchar(255) unique," +
" duration LONG," +
" modificationDate LONG," +
+ "removed BOOLEAN," +
" PRIMARY KEY (taskid, date, uuid)," +
" FOREIGN KEY (taskid)" +
" REFERENCES " + TABLE_TASK +"(id)" +
@@ -184,7 +186,8 @@
int result = 0;
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement("SELECT count(*) FROM " + TABLE_TASK);
+ statement = connection.prepareStatement("SELECT count(*) FROM " + TABLE_TASK
+ + " WHERE removed = 0");
ResultSet rs = statement.executeQuery();
if (rs.next()) {
result = rs.getInt(1);
@@ -198,17 +201,18 @@
}
/**
- * Query that returns every tasks
+ * Query that returns not removed tasks
* @return tasks arraylist of tasks
*/
public ArrayList<TimerTask> getTasks(Long date) {
- ArrayList<TimerTask> tasks = new ArrayList<TimerTask>();
+ 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.id = TI.taskid AND TA.modificationDate >" +date +
+ " WHERE TA.id = TI.taskid" +
+ " AND TA.modificationDate >" +date +
" GROUP BY TA.id");
ResultSet rs = statement.executeQuery();
while (rs.next()) {
@@ -217,6 +221,7 @@
task.setTaskId(rs.getString("taskId"));
task.setName(rs.getString("name"));
task.setParent(rs.getString("parent"));
+ task.setRemoved(rs.getBoolean("removed"));
task.setTodayTime(0);
task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
task.setTotalTime(rs.getLong("totalduration"));
@@ -225,7 +230,8 @@
// not timed tasks
statement2 = connection.prepareStatement("SELECT * FROM " + TABLE_TASK +
- " WHERE (id not in (SELECT taskid FROM " + TABLE_TIME + ")) AND "+ TABLE_TASK +".modificationDate >" +date );
+ " WHERE (id not in (SELECT taskid FROM " + TABLE_TIME + "))" +
+ " AND "+ TABLE_TASK +".modificationDate >" +date);
rs = statement2.executeQuery();
while (rs.next()) {
TimerTask task = new TimerTask();
@@ -234,6 +240,7 @@
task.setTaskId(rs.getString("taskId"));
task.setParent(rs.getString("parent"));
task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
+ task.setRemoved(rs.getBoolean("removed"));
task.setTodayTime(0);
task.setTotalTime(0);
tasks.add(task);
@@ -248,21 +255,21 @@
}
-
/* Insert, Update, Delete */
public void addTask(TimerTask task) {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("INSERT INTO " +
- TABLE_TASK + "(name, parent, taskId, hidden, note, modificationDate)" +
- " VALUES (?, ?, ?, ?, ?,?)", Statement.RETURN_GENERATED_KEYS);
+ TABLE_TASK + "(name, parent, taskId, hidden, note, modificationDate, removed)" +
+ " VALUES (?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
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.setBoolean(7,task.getRemoved());
statement.executeUpdate();
// get generated id
@@ -281,7 +288,7 @@
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("UPDATE " +
- TABLE_TASK + " SET name=?, parent=?, hidden=?, note=?, modificationDate=?" +
+ TABLE_TASK + " SET name=?, parent=?, hidden=?, note=?, modificationDate=?, removed=?" +
" WHERE taskId = ?");
statement.setString(1, task.getName()); //name
statement.setString(2, task.getParent()); //parent
@@ -289,6 +296,7 @@
statement.setString(4, null /*project.getNote()*/);//note
statement.setLong(5, task.getModificationDate().getTime()); //modificationDate
statement.setString(6, task.getTaskId()); //taskId
+ statement.setBoolean(7,task.getRemoved());
statement.executeUpdate();
} catch (SQLException ex) {
@@ -302,12 +310,13 @@
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("UPDATE " +
- TABLE_TIME + " SET date=?, duration=?, modificationDate=?" +
+ TABLE_TIME + " SET date=?, duration=?, modificationDate=?, removed = ?" +
" WHERE uuid = ?");
statement.setLong(1, t.getCreationDate().getTime());
statement.setLong(2, t.getTime());
statement.setLong(3, t.getModificationDate().getTime()); //modificationDate
statement.setString(4, t.getTimeId() );
+ statement.setBoolean(5, t.getRemoved());
statement.executeUpdate();
} catch (SQLException ex) {
throw new StorageException("Can't modify time", ex);
@@ -318,8 +327,8 @@
/**
* Returns task number with ID
- * @param id
- * @return
+ * @param id identifiant de la tache
+ * @return le long representant la tache dans la base
*/
public long getTaskNumber(String id) {
PreparedStatement statement = null;
@@ -342,23 +351,24 @@
/**
* Ajoute une periode pour une tache
- * @param task
- * @param date
- * @param uuid
- * @param duration
+ * @param task la tache qui va recevoir un temps
+ * @param date la date de creation
+ * @param uuid l'identifiant du temps
+ * @param duration le duree de la periode
*/
public void addTaskTime(TimerTask task, Date date, String uuid, long duration) {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("INSERT INTO " + TABLE_TIME +
- "(taskid, date, uuid, duration, modificationDate)" +
- " VALUES(?, ?, ?, ?,?)");
+ "(taskid, date, uuid, duration, modificationDate, removed)" +
+ " VALUES(?, ?, ?, ?, ?, ?)");
statement.setLong(1, task.getNumber());
statement.setLong(2, date.getTime());
statement.setString(3, uuid);
statement.setLong(4, duration);
statement.setLong(5, new Date().getTime());
+ statement.setBoolean(6, false);
statement.executeUpdate();
} catch (SQLException ex) {
throw new StorageException("Can't add task time", ex);
@@ -369,24 +379,22 @@
/**
* Ajoute une periode pour une tache
- * @param time
- * @param number
+ * @param time le timertime a ajouter
+ * @param number le numero identidfiant la tache dans la base
*/
public void addTaskTime(TimerTime time, long number) {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("INSERT INTO " + TABLE_TIME +
- "(taskid, date, uuid, duration, modificationDate)" +
- " VALUES(?, ?, ?, ?, ?)");
+ "(taskid, date, uuid, duration, modificationDate, removed)" +
+ " VALUES(?, ?, ?, ?, ?, ?)");
statement.setLong(1, number);
statement.setLong(2, time.getCreationDate().getTime());
statement.setString(3, time.getTimeId());
statement.setLong(4, time.getTime());
- if(log.isDebugEnabled()){
- log.info(time.getModificationDate().getTime());
- }
statement.setLong(5, time.getModificationDate().getTime());
+ statement.setBoolean(6, time.getRemoved());
statement.executeUpdate();
} catch (SQLException ex) {
throw new StorageException("Can't add task time", ex);
@@ -422,13 +430,13 @@
while (rs.next()) {
-
TimerTime time = new TimerTime();
time.setTaskId(rs.getString("mytask"));
time.setTimeId(rs.getString("uuid"));
time.setTime(rs.getLong("duration"));
time.setCreationDate(new java.util.Date(rs.getLong("date")));
time.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
+ time.setRemoved(rs.getBoolean("removed"));
times.add(time);
@@ -455,6 +463,7 @@
statement = connection.prepareStatement("SELECT TI.* FROM " +
TABLE_TASK + " TA, "+ TABLE_TIME + " TI" +
" WHERE TA.id = TI.taskid AND TA.taskId = '" +taskid +"' " +
+ " AND TA.removed = 0" +
" AND TI.modificationDate >" +date);
ResultSet rs = statement.executeQuery();
while (rs.next()) {
@@ -464,6 +473,7 @@
time.setTime(rs.getLong("duration"));
time.setCreationDate(new java.util.Date(rs.getLong("date")));
time.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
+ time.setRemoved(rs.getBoolean("removed"));
times.add(time);
}
@@ -480,7 +490,7 @@
/**
* Methode qui va supprimer un timertime a l'aide de son identifiant
- * @param timeId
+ * @param timeId l'identifiant du temps
*/
public void deleteTimeWithId(String timeId) {
@@ -500,7 +510,7 @@
/**
* Methode qui va supprimer un timertime a l'aide de son identifiant
- * @param taskId
+ * @param taskId l'identifiant de la tache
*/
public void deleteTaskWithId(String taskId) {
PreparedStatement statement = null;
@@ -517,18 +527,49 @@
}
- public void deleteTask(TimerTask task) {
+
+ /** Suppression virtuelle */
+ /**
+ * Methode qui va modifier l'attribut removed d'un timertime a l'aide de son identifiant
+ * @param timeId l'identifiant du temps
+ */
+ public void removeTimeWithId(String timeId) {
+
PreparedStatement statement = null;
try {
- statement = connection.prepareStatement("DELETE FROM " +
- TABLE_TASK + " WHERE id = ?");
- statement.setLong(1, task.getNumber());
+ statement = connection.prepareStatement("UPDATE " +
+ TABLE_TIME + " SET removed = 1" +
+ " WHERE uuid = ?");
+
+ statement.setString(1, timeId);
statement.executeUpdate();
} catch (SQLException ex) {
+ throw new StorageException("Can't delete time", ex);
+ } finally {
+ closeStatement(statement);
+ }
+
+ }
+
+ /**
+ * Methode qui va va modifier l'attribut removed d'un timertask a l'aide de son identifiant
+ * @param taskId l'identifiant de la tache
+ */
+ public void removeTaskWithId(String taskId) {
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement("UPDATE " +
+ TABLE_TASK + " SET removed = 1" +
+ " WHERE taskId = '"+taskId +"'");
+
+
+ statement.executeUpdate();
+ } catch (SQLException ex) {
throw new StorageException("Can't delete project", ex);
} finally {
closeStatement(statement);
}
+
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java 2014-05-26 09:26:00 UTC (rev 2987)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java 2014-05-26 16:19:25 UTC (rev 2988)
@@ -37,6 +37,7 @@
String taskId = (String)getRequest().getAttributes().get("taskId");
Gson gson = new Gson();
String json = gson.toJson(Long.valueOf(taskId).longValue());
+
return new StringRepresentation( json , MediaType.APPLICATION_JSON);
}
@@ -47,9 +48,8 @@
*/
@Delete
public void deleteTask() {
-
String taskId = (String)getRequest().getAttributes().get("taskId");
- storage.deleteTaskWithId(taskId);
+ storage.removeTaskWithId(taskId);
}
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-05-26 09:26:00 UTC (rev 2987)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java 2014-05-26 16:19:25 UTC (rev 2988)
@@ -5,6 +5,7 @@
import java.util.ArrayList;
import java.util.Date;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,12 +55,11 @@
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) {
@@ -83,10 +83,12 @@
} catch (Exception e) {
date = (long) 0;
}
-
+ ArrayList<TimerTask> timerTasks;
Gson gson = builder.create();
- ArrayList<TimerTask> timerTasks = storage.getTasks(date);
+
+ timerTasks = storage.getTasks(date);
+
//On ordonne les donnees, tache fille placee en début
int tabSize = timerTasks.size();
@@ -98,10 +100,8 @@
i--;
tabSize--;
}
-
}
-
String json = gson.toJson(timerTasks);
return new StringRepresentation(json, MediaType.APPLICATION_JSON);
}
@@ -115,11 +115,14 @@
Gson gson = builder.create();
String repr1 = representation.getText();
+ if (log.isInfoEnabled()) {
+ log.info("La task suivante est cree : " + repr1);
+ }
TimerTask t = gson.fromJson(repr1, TimerTask.class);
if (log.isInfoEnabled()) {
log.info("La task suivante est cree : " + t.toString());
}
-
+ t.setRemoved(false);
storage.addTask(t);
}
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-05-26 09:26:00 UTC (rev 2987)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java 2014-05-26 16:19:25 UTC (rev 2988)
@@ -55,6 +55,7 @@
}
});
+
builder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
@Override
public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) {
@@ -100,7 +101,7 @@
@Delete
public void deleteTime() {
String timeId = (String)getRequest().getAttributes().get("taskId");
- storage.deleteTimeWithId(timeId);
+ storage.removeTimeWithId(timeId);
}
/**
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-05-26 09:26:00 UTC (rev 2987)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java 2014-05-26 16:19:25 UTC (rev 2988)
@@ -49,6 +49,7 @@
}
});
+
builder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
@Override
public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) {
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-26 09:26:00 UTC (rev 2987)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-26 16:19:25 UTC (rev 2988)
@@ -14,8 +14,8 @@
//interval de conec
var interval = 20000; //TODO: obruce 05-05-14 decider d'un intervalle interessant
- // {Timestamp} periode de delais = 3 periode
- var delayAccess = 30000;
+ // periode de delais = 3 periode +1msec
+ var delayAccess = 3 * interval +1;
// {TreeNode} l'arbre regenere automatiquement lorsque les donnees changent
$scope.tree;
@@ -129,8 +129,7 @@
angular.forEach(response, function (item) {
- //On verife si l'element n'est pas en cours de suppression
- if(!(item.taskId in $scope.data.tasks)){
+ if((!(item.taskId in $scope.data.tasks)) && item.isremoved == false){
console.log( "Un element non present " + item.name + item.modificationDate);
var newTask = new Task( item.name, item.taskId, item.parent);
@@ -181,22 +180,31 @@
serverTaskAccess.query({date : ($scope.taskAccess-delayAccess)}, function (response) {
angular.forEach(response, function (item) {
- console.log("Changement d'une tâche");
- console.log(item);
+
if(item.taskId in $scope.data.tasks){
+ console.log("Tache existe");
+ //console.log(item);
+
//On cherche le node et on le met à jour
- $scope.tree.getNode(item.taskId).task.name = item.name;
+ var tmp = $scope.tree.getNode(item.taskId);
- save();
+ if(item.isremoved){
+ $scope.removeTask(tmp);
+ }else{
+ tmp.task.name = item.name;
+ }
- //On change la date de dernier acces
- $scope.taskAccess = Date.now();
- $scope.todo.lastTaskAccess= $scope.taskAccess;
+
save();
- }else{
+
+ }else if(!item.isremoved){
+
+ console.log("Nouvelle tache");
+ //console.log(item);
+
var newTask = new Task( item.name, item.taskId, item.parent);
if(item.parent == "" ){
@@ -215,7 +223,7 @@
//On ajoute le node à l'arbre
if ($scope.tree) {
- // $scope.tree.getNode(item.taskId).addChild($scope.createTreeNode(newTask));
+ $scope.tree.getNode(item.parent).addChild($scope.createTreeNode(newTask));
}
//Les temps sont recuperes du serveur
@@ -224,8 +232,14 @@
save();
}
}
+
});
});
+
+ //On change la date de dernier acces
+ $scope.taskAccess = Date.now();
+ $scope.todo.lastTaskAccess= $scope.taskAccess;
+ save();
}
/**
@@ -234,7 +248,6 @@
*/
var updateTimesFromServer = function(){
-
serverTimeAccess.query({date : $scope.timeAccess-delayAccess}, function (response) {
angular.forEach(response, function (item) {
@@ -850,7 +863,7 @@
if ( $scope.online) {
pushTodoListToServ();
- updateTasksFromServ();
+ initTasksFromServ();
}
}
1
0
r2987 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/storage java/org/chorem/jtimer/web webapp/js webapp/partials
by obruce@users.chorem.org 26 May '14
by obruce@users.chorem.org 26 May '14
26 May '14
Author: obruce
Date: 2014-05-26 11:26:00 +0200 (Mon, 26 May 2014)
New Revision: 2987
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2987
Log:
controller: correction update
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/java/org/chorem/jtimer/web/TimeResource.java
branches/ng-jtimer/src/main/webapp/js/controllers.js
branches/ng-jtimer/src/main/webapp/partials/tasks.html
branches/ng-jtimer/src/main/webapp/partials/timeModal.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-05-22 08:10:28 UTC (rev 2986)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-26 09:26:00 UTC (rev 2987)
@@ -483,6 +483,7 @@
* @param timeId
*/
public void deleteTimeWithId(String timeId) {
+
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("DELETE FROM " +
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-05-22 08:10:28 UTC (rev 2986)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java 2014-05-26 09:26:00 UTC (rev 2987)
@@ -4,8 +4,6 @@
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Date;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@@ -37,7 +35,6 @@
private static final Log log = LogFactory.getLog(TasksResource.class);
protected Storage storage;
- private final static Logger LOGGER = Logger.getLogger(TasksResource.class.getName());
private GsonBuilder builder;
/**
@@ -119,7 +116,9 @@
Gson gson = builder.create();
String repr1 = representation.getText();
TimerTask t = gson.fromJson(repr1, TimerTask.class);
- LOGGER.log(Level.INFO, "repr1");
+ if (log.isInfoEnabled()) {
+ log.info("La task suivante est cree : " + t.toString());
+ }
storage.addTask(t);
}
@@ -135,6 +134,10 @@
String repr1 = representation.getText();
TimerTask t = gson.fromJson(repr1, TimerTask.class);
+ if (log.isInfoEnabled()) {
+ log.info("La task suivante est en cours de maj : " + t.toString());
+ }
+
storage.modifyTask(t);
}
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-05-22 08:10:28 UTC (rev 2986)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java 2014-05-26 09:26:00 UTC (rev 2987)
@@ -73,7 +73,7 @@
* @return la representation de la liste
*/
@Get("json")
- public Representation getTask() {
+ public Representation getTime() {
Long date = (long) 0;
try{
@@ -98,7 +98,7 @@
*
*/
@Delete
- public void deleteTask() {
+ public void deleteTime() {
String timeId = (String)getRequest().getAttributes().get("taskId");
storage.deleteTimeWithId(timeId);
}
@@ -108,7 +108,7 @@
* suite d'une requête de type POST
*/
@Post("json")
- public void createTask(Representation representation) throws IOException {
+ public void createTime(Representation representation) throws IOException {
String timeId = (String)getRequest().getAttributes().get("taskId");
long number = storage.getTaskNumber(timeId);
@@ -119,10 +119,7 @@
TimerTime t = gson.fromJson(repr1, TimerTime.class);
if (log.isInfoEnabled()) {
- log.info(repr1);
- log.info(t);
- log.info(t.getModificationDate().getTime());
- log.info(number);
+ log.info("La periode suivante est cree : " + t.toString());
}
storage.addTaskTime(t, number);
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-22 08:10:28 UTC (rev 2986)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-26 09:26:00 UTC (rev 2987)
@@ -8,10 +8,15 @@
//{tdListData} toutes les donnees non envoyees
$scope.todo = $localStorage.getTodo("todo");
- // {Date} last update to server
+ // {Timestamp} last update to server
$scope.taskAccess = $scope.todo.lastTaskAccess;
$scope.timeAccess = $scope.todo.lastTimeAccess;
+ //interval de conec
+ var interval = 20000; //TODO: obruce 05-05-14 decider d'un intervalle interessant
+ // {Timestamp} periode de delais = 3 periode
+ var delayAccess = 30000;
+
// {TreeNode} l'arbre regenere automatiquement lorsque les donnees changent
$scope.tree;
// {Array of Function} les listeners qui surveille l'ajout de nouveau temps, et qui les ajoutes dans l'arbre
@@ -148,14 +153,19 @@
save();
}
+ save();
}
});
console.log("Je suis dans le get tasks");
//On change la date de dernier acces
- $scope.taskAccess = new Date().getTime();
+ $scope.taskAccess = Date.now();
$scope.todo.lastTaskAccess= $scope.taskAccess;
+
+ $scope.timeAccess = Date.now();
+ $scope.todo.lastTimeAccess= $scope.timeAccess;
+
save();
});
};
@@ -168,24 +178,22 @@
*/
var updateTasksFromServ = function(){
- serverTaskAccess.query({date : $scope.taskAccess}, function (response) {
+ serverTaskAccess.query({date : ($scope.taskAccess-delayAccess)}, function (response) {
- console.log("Chercher modif du serveur des taches");
-
angular.forEach(response, function (item) {
+ console.log("Changement d'une tâche");
console.log(item);
-
if(item.taskId in $scope.data.tasks){
- //On cherche le node et on le met à jour
- $scope.tree.getNode(item.taskId).task.name = item.name;
+ //On cherche le node et on le met à jour
+ $scope.tree.getNode(item.taskId).task.name = item.name;
- save();
+ save();
- //On change la date de dernier acces
- $scope.taskAccess = Date.now();
- $scope.todo.lastTaskAccess= $scope.taskAccess;
- save();
+ //On change la date de dernier acces
+ $scope.taskAccess = Date.now();
+ $scope.todo.lastTaskAccess= $scope.taskAccess;
+ save();
}else{
@@ -207,7 +215,7 @@
//On ajoute le node à l'arbre
if ($scope.tree) {
- $scope.tree.getNode(item.taskId).addChild($scope.createTreeNode(newTask));
+ // $scope.tree.getNode(item.taskId).addChild($scope.createTreeNode(newTask));
}
//Les temps sont recuperes du serveur
@@ -225,15 +233,20 @@
*
*/
var updateTimesFromServer = function(){
- console.log("Chercher modif temps du serveur");
- serverTimeAccess.query({date : $scope.timeAccess}, function (response) {
+ serverTimeAccess.query({date : $scope.timeAccess-delayAccess}, function (response) {
+
angular.forEach(response, function (item) {
+ //le temps n'existe pas
+ console.log("Changement d'une periode");
+ console.log(item);
- if(!(existInObject($scope.data.times,item.timeId,task.taskId)) ){
+ var editedTime = getObjectInArrayWithId($scope.data.times[item.taskId],item.timeId);
- console.log(item);
+ if(editedTime == undefined){
+
+ console.log("le temps n'existe pas");
if(!$scope.data.times[item.taskId]){$scope.data.times[item.taskId] = []}
taskTime = new TaskTime($scope.data.tasks[item.taskId], item.timeId, item.creationDate, item.time);
@@ -242,6 +255,7 @@
save();
}else{
+ console.log("Temps existe donc remplacé");
//Le temps existe
var editedTime = getObjectInArrayWithId($scope.data.times[item.taskId],item.timeId);
editedTime.time = item.time;
@@ -287,27 +301,26 @@
$scope.data.times[task.taskId].push(taskTime);
save();
}
-
-
});
-
//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
+ */
var existInObject = function(object, item, pos){
return (object[pos]) && (item in object[pos]);
};
- var pushChangesToServ= function(){
+ /**
+ * Methode qui pousse la todolist vers le serveur pour ssauvegarde les changements
+ * Sauve les changements dans le localStorage
+ */
+ var pushTodoListToServ= function(){
//On supprime de la base les taches sotckees pour suppression
angular.forEach($scope.todo.stockedDeletedTasks, function(task){
@@ -323,6 +336,9 @@
//On ajoute au serveur les taches stockees pour l'ajout
angular.forEach($scope.todo.stockedNewTasks, function(task){
+ //On change la date au dernier acces
+ task['modificationDate']=$scope.taskAccess;
+
serverTaskAccess.create(angular.toJson(task),
function(){
console.log("persist task success" + task);
@@ -335,7 +351,7 @@
//On ajoute au serveur les taches stockees pour l'ajout
angular.forEach($scope.todo.stockedEditedTasks, function(task){
//On change la date au dernier acces
- task.modificationDate = $scope.serverTaskAccess;
+ task["modificationDate"]=$scope.taskAccess;
serverTaskAccess.update(angular.toJson(task),
function(){
@@ -351,7 +367,7 @@
angular.forEach($scope.todo.stockedNewTimes, function(times,task){
angular.forEach(times, function(time){
//On change la date au dernier acces
- time.modificationDate = $scope.serverTaskAccess;
+ time["modificationDate"]=$scope.timeAccess;
serverTimeAccess.create({taskId: task} , angular.toJson(time),
function(){
@@ -368,6 +384,9 @@
//On update les temps sur le serveur
angular.forEach($scope.todo.stockedEditedTimes, function(times,task){
angular.forEach(times, function(time){
+
+ time["modificationDate"]=$scope.timeAccess;
+
serverTimeAccess.update({taskId: task}, angular.toJson(time),
function(){
console.log("update time success" + task);
@@ -382,9 +401,9 @@
//On supprime de la base les taches sotckees pour suppression
angular.forEach($scope.todo.stockedDeletedTimes, function(times,task){
angular.forEach(times, function(time){
- serverTimeAccess.delete({taskId: task}, angular.toJson(time),
+ serverTimeAccess.delete({taskId: time},
function(){
- console.log("update time success" + task);
+ console.log("delete time success" + task);
$scope.todo.stockedDeletedTimes[task].shift();
},
function(){
@@ -393,7 +412,6 @@
});
});
-
save();
}
@@ -424,14 +442,13 @@
*/
var timer = function() {
$interval(function() {
- //A changer
- //initControllerWithServ();
- pushChangesToServ();
+
+ pushTodoListToServ();
updateTasksFromServ();
updateTimesFromServer();
- //updateTimesFromServer();
- }, 30000); //TODO: obruce 05-05-14 for now 30s but for real put at least 2h: 200000000
+
+ }, interval);
};
timer();
@@ -661,7 +678,7 @@
$scope.saveTask = function(node) {
node.edit = null;
- //node.task.modificationDate = $scope.taskAccess;
+
$scope.todo.stockedEditedTasks.push(node.task);
save();
};
@@ -817,7 +834,7 @@
$scope.todo.stockedDeletedTimes[id].push($scope.data.times[id][item.index].timeId);
$scope.data.times[id].splice(item.index,1);
-
+ console.log( $scope.data.times[id]);
save();
}
@@ -832,7 +849,7 @@
//Si en ligne on envoie les donnees
if ( $scope.online) {
- pushChangesToServ();
+ pushTodoListToServ();
updateTasksFromServ();
}
@@ -848,6 +865,11 @@
}
+
+
+
+
+
/**
* Controller de pour la modal d'inactivite.
*
Modified: branches/ng-jtimer/src/main/webapp/partials/tasks.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-05-22 08:10:28 UTC (rev 2986)
+++ branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-05-26 09:26:00 UTC (rev 2987)
@@ -5,7 +5,9 @@
<form ng-submit="addTask()">
<input class='search-query form-group form-group form-control input-sm' ng-model="name" placeholder="New Task">
</form>
+
</span>
+
<!--Header partie droite -->
<span class="right">
<a class="glyphicon glyphicon-plus-sign" ng-click="showMenu = !showMenu">
@@ -21,12 +23,16 @@
<i class="glyphicon glyphicon-cloud" ng-class="{online: online, offline: !online}"></i>
</span>
</div>
+
+<!-- Websocket information -->
<div id="alerts">
<div class="alert alert-warning" ng-if="!webSocketClientOnline">
<span class="icon-warning-sign"></span> Impossible de contacter le client local pour la gestion de l'inactivité.
<a href="#" target="_blank">Télécharger le client local</a>.
</div>
</div>
+
+<!-- Footer -->
<div id="footer">
<span class="left">{{currentDate()}}</span>
<span class="center"><i class="fa fa-html5"></i> <a href="#">WebTimer</a></span>
@@ -34,6 +40,8 @@
<span class="right">Dernière mise à jour: {{getLastMajDate()}}</span>
</div>
+
+<!-- Div interne-->
<div>
<div class='table'>
<div class='tr'>
@@ -83,8 +91,6 @@
<i class="glyphicon glyphicon-pencil" ></i>
</a>
-
-
</span>
</div>
Modified: branches/ng-jtimer/src/main/webapp/partials/timeModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/timeModal.html 2014-05-22 08:10:28 UTC (rev 2986)
+++ branches/ng-jtimer/src/main/webapp/partials/timeModal.html 2014-05-26 09:26:00 UTC (rev 2987)
@@ -42,7 +42,7 @@
<datepicker ng-model="dateobj.date" ng-change="changeDayDate()" min-date="minDate" max-date="dateMaxPicker" show-weeks="true" class="well well-sm"></datepicker>
</div>
- <div ng-controller="radioTimeCtrl">
+ <div class = "timepick" ng-controller="radioTimeCtrl">
<div>
<div class="btn-group">
<label class="btn btn-primary" ng-model="radioModel" ng-change="changeFonc()" btn-radio="'Left'">Début de période </label>
1
0
Author: obruce
Date: 2014-05-22 10:10:28 +0200 (Thu, 22 May 2014)
New Revision: 2986
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2986
Log:
controller: changement synchro
Modified:
branches/ng-jtimer/src/main/webapp/js/controllers.js
branches/ng-jtimer/src/main/webapp/js/entities.js
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-21 16:52:22 UTC (rev 2985)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-22 08:10:28 UTC (rev 2986)
@@ -116,6 +116,7 @@
/**
* Récupère les nouveaux elements du serveur et les ajoute a l'arbre pour l'affichage
+ *
*/
var initTasksFromServ = function(){
@@ -139,7 +140,6 @@
}
}else{
- //TODO obruce ajout avec parent deja present
//Un noeud avec un parent est ajoute à l'arbre de son parent
$scope.data.tasks[newTask.taskId] = newTask;
save();
@@ -160,11 +160,13 @@
});
};
+
+
/**
* Methode qui va chercher les mise à jour sur les taches
*
*/
- var updateTaskFromServ = function(){
+ var updateTasksFromServ = function(){
serverTaskAccess.query({date : $scope.taskAccess}, function (response) {
@@ -172,34 +174,82 @@
angular.forEach(response, function (item) {
console.log(item);
+
+ if(item.taskId in $scope.data.tasks){
+
//On cherche le node et on le met à jour
$scope.tree.getNode(item.taskId).task.name = item.name;
save();
//On change la date de dernier acces
- $scope.taskAccess = new Date().getTime();
+ $scope.taskAccess = Date.now();
$scope.todo.lastTaskAccess= $scope.taskAccess;
save();
+
+ }else{
+
+ var newTask = new Task( item.name, item.taskId, item.parent);
+
+ if(item.parent == "" ){
+
+ //Un noeud sans parent est ajouter à l'arbre du scope
+ $scope.data.tasks[newTask.taskId] = newTask;
+ save();
+ if ($scope.tree) {
+ $scope.tree.addChild($scope.createTreeNode(newTask));
+ }
+
+ }else{
+ //Un noeud avec un parent est ajoute à l'arbre de son parent
+ $scope.data.tasks[newTask.taskId] = newTask;
+ save();
+
+ //On ajoute le node à l'arbre
+ if ($scope.tree) {
+ $scope.tree.getNode(item.taskId).addChild($scope.createTreeNode(newTask));
+ }
+
+ //Les temps sont recuperes du serveur
+ getTimesFromServerWithTask(newTask);
+
+ save();
+ }
+ }
});
-
});
}
+ /**
+ * Fait la mise à jour des temps
+ *
+ */
var updateTimesFromServer = function(){
console.log("Chercher modif temps du serveur");
serverTimeAccess.query({date : $scope.timeAccess}, function (response) {
angular.forEach(response, function (item) {
- console.log(item);
- if(!$scope.data.times[item.taskId]){$scope.data.times[item.taskId] = []}
- taskTime = new TaskTime($scope.data.tasks[item.taskId], item.timeId, item.creationDate, item.time);
- $scope.data.times[item.taskId].push(taskTime);
+ if(!(existInObject($scope.data.times,item.timeId,task.taskId)) ){
- save();
+ console.log(item);
+ if(!$scope.data.times[item.taskId]){$scope.data.times[item.taskId] = []}
+ taskTime = new TaskTime($scope.data.tasks[item.taskId], item.timeId, item.creationDate, item.time);
+ $scope.data.times[item.taskId].push(taskTime);
+
+ save();
+
+ }else{
+ //Le temps existe
+ var editedTime = getObjectInArrayWithId($scope.data.times[item.taskId],item.timeId);
+ editedTime.time = item.time;
+ editedTime.creationDate = item.creationDate;
+
+ save();
+ }
+
//On change la date de dernier acces
$scope.timeAccess = new Date().getTime();
$scope.todo.lastTimeAccess= $scope.timeAccess;
@@ -209,6 +259,16 @@
}
+ //Recuperer un element dans un array avec son id
+ var getObjectInArrayWithId= function(array, id){
+ var res;
+ angular.forEach(array, function(time){
+ if(time.timeId == id){
+ res = time;
+ }
+ });
+ return res;
+ }
/**
* Methode qui recupere les temps pour une tache
@@ -262,6 +322,7 @@
});
//On ajoute au serveur les taches stockees pour l'ajout
angular.forEach($scope.todo.stockedNewTasks, function(task){
+
serverTaskAccess.create(angular.toJson(task),
function(){
console.log("persist task success" + task);
@@ -273,6 +334,9 @@
});
//On ajoute au serveur les taches stockees pour l'ajout
angular.forEach($scope.todo.stockedEditedTasks, function(task){
+ //On change la date au dernier acces
+ task.modificationDate = $scope.serverTaskAccess;
+
serverTaskAccess.update(angular.toJson(task),
function(){
console.log("update task success" + task);
@@ -286,6 +350,9 @@
//On ajoute les nouveaux temps au serveur
angular.forEach($scope.todo.stockedNewTimes, function(times,task){
angular.forEach(times, function(time){
+ //On change la date au dernier acces
+ time.modificationDate = $scope.serverTaskAccess;
+
serverTimeAccess.create({taskId: task} , angular.toJson(time),
function(){
console.log("persist time success" + task);
@@ -295,7 +362,7 @@
function(){
console.log("fail");
});
- });
+ });
});
//On update les temps sur le serveur
@@ -360,7 +427,8 @@
//A changer
//initControllerWithServ();
pushChangesToServ();
- updateTaskFromServ();
+ updateTasksFromServ();
+ updateTimesFromServer();
//updateTimesFromServer();
}, 30000); //TODO: obruce 05-05-14 for now 30s but for real put at least 2h: 200000000
@@ -368,19 +436,6 @@
timer();
/**
- *Méthode qui lance les actions à faires sur le serveur
- */
- var initControllerWithServ = function(){
- //Si en ligne on envoie les donnees
- if ( $scope.online) {
-
- pushChangesToServ();
- initTasksFromServ();
- }
-
- }
-
- /**
* Ajoute une tache root
*/
$scope.addTask = function() {
@@ -606,7 +661,7 @@
$scope.saveTask = function(node) {
node.edit = null;
- node.task.modificationDate = $scope.taskAccess;
+ //node.task.modificationDate = $scope.taskAccess;
$scope.todo.stockedEditedTasks.push(node.task);
save();
};
@@ -770,6 +825,19 @@
});
}
+ /**
+ *Méthode qui lance les actions à faires sur le serveur
+ */
+ var initControllerWithServ = function(){
+ //Si en ligne on envoie les donnees
+ if ( $scope.online) {
+
+ pushChangesToServ();
+ updateTasksFromServ();
+ }
+
+ }
+
//force the first server connection
initControllerWithServ();
// force the first tree creation
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-05-21 16:52:22 UTC (rev 2985)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-05-22 08:10:28 UTC (rev 2986)
@@ -461,7 +461,7 @@
this.creationDate = date;
}
- this.modificationDate = this.creationDate;
+ this.modificationDate = Date.now();
if(time == undefined){
this.time = 0;
1
0
r2985 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/entities java/org/chorem/jtimer/storage java/org/chorem/jtimer/web webapp/js
by obruce@users.chorem.org 21 May '14
by obruce@users.chorem.org 21 May '14
21 May '14
Author: obruce
Date: 2014-05-21 18:52:22 +0200 (Wed, 21 May 2014)
New Revision: 2985
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2985
Log:
controller: changement synchro serveur -> ui (pas fini)
entities: getNode
Rest getalltimes, ajout timesresource
Added:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTime.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java
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
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTime.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTime.java 2014-05-21 14:42:45 UTC (rev 2984)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTime.java 2014-05-21 16:52:22 UTC (rev 2985)
@@ -93,7 +93,8 @@
return "TimerTime{" +
", taskId='" + taskId + '\'' +
", timeId='" + timeId + '\'' +
- ", modificationDate=" + creationDate +
+ ", creationDate=" + creationDate +
+ ", modificationDate=" + modificationDate +
", time=" + time +
'}';
}
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-05-21 14:42:45 UTC (rev 2984)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-21 16:52:22 UTC (rev 2985)
@@ -5,7 +5,12 @@
import org.chorem.jtimer.entities.TimerTask;
import org.chorem.jtimer.entities.TimerTime;
-import java.sql.*;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -63,6 +68,7 @@
//TODO obruce 15-05-14 path a definir
String url = "/tmp/jtimer/jtimer";
//String url = "/home/olivia/Bureau/jtimer/jtimer";
+
if (log.isInfoEnabled()) {
log.info("Opening connection to database : " + url);
}
@@ -371,13 +377,16 @@
try {
statement = connection.prepareStatement("INSERT INTO " + TABLE_TIME +
"(taskid, date, uuid, duration, modificationDate)" +
- " VALUES(?, ?, ?, ?)");
+ " VALUES(?, ?, ?, ?, ?)");
statement.setLong(1, number);
statement.setLong(2, time.getCreationDate().getTime());
statement.setString(3, time.getTimeId());
statement.setLong(4, time.getTime());
- statement.setLong(4, time.getModificationDate().getTime());
+ if(log.isDebugEnabled()){
+ log.info(time.getModificationDate().getTime());
+ }
+ statement.setLong(5, time.getModificationDate().getTime());
statement.executeUpdate();
} catch (SQLException ex) {
throw new StorageException("Can't add task time", ex);
@@ -394,20 +403,59 @@
}
+ /**
+ * Query that returns every task's times
+ * @return times hashMap(key: taskId, value: times)
+ */
+ public ArrayList<TimerTime> getTimes(Long date) {
+ ArrayList<TimerTime> times = new ArrayList<>();
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement("SELECT TA.taskId AS mytask, TI.* FROM " +
+ TABLE_TASK + " TA, "+ TABLE_TIME + " TI" +
+ " WHERE TA.id = TI.taskid" +
+ " AND TI.modificationDate >" +date);
+
+ ResultSet rs = statement.executeQuery();
+
+ while (rs.next()) {
+
+
+ TimerTime time = new TimerTime();
+ time.setTaskId(rs.getString("mytask"));
+ time.setTimeId(rs.getString("uuid"));
+ time.setTime(rs.getLong("duration"));
+ time.setCreationDate(new java.util.Date(rs.getLong("date")));
+ time.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
+
+ times.add(time);
+
+ }
+
+ } catch (SQLException ex) {
+ throw new StorageException("Can't get time", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ return times;
+ }
+
+
/**
- * Query that returns every tasks
+ * Query that returns every tasks for a specified task
* @return tasks arraylist of tasks
*/
- public List<TimerTime> getTimes(String taskid) {
+ public List<TimerTime> getTimes(String taskid, Long date) {
List<TimerTime> times = new ArrayList<>();
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("SELECT TI.* FROM " +
TABLE_TASK + " TA, "+ TABLE_TIME + " TI" +
- " WHERE TA.id = TI.taskid AND TA.taskId = '" +taskid +"' ");
+ " WHERE TA.id = TI.taskid AND TA.taskId = '" +taskid +"' " +
+ " AND TI.modificationDate >" +date);
ResultSet rs = statement.executeQuery();
while (rs.next()) {
TimerTime time = new TimerTime();
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java 2014-05-21 14:42:45 UTC (rev 2984)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java 2014-05-21 16:52:22 UTC (rev 2985)
@@ -1,14 +1,18 @@
package org.chorem.jtimer.web;
-import javax.servlet.*;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -34,10 +38,6 @@
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
- //Avant l'execution de la requete
- if (log.isDebugEnabled()) {
- log.debug("Passage dans le filter");
- }
if(servletRequest instanceof HttpServletRequest ) {
@@ -50,7 +50,7 @@
while (lesElem.hasMoreElements()) {
names += ", " + lesElem.nextElement();
}
- log.warn(names);
+ log.warn("request Headers :" + names);
httpServletResponse.addHeader(HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, "*");
httpServletResponse.addHeader(HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
@@ -67,10 +67,6 @@
}
-
- if (log.isWarnEnabled()) {
- log.warn("Fin filter");
- }
}
@Override
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-05-21 14:42:45 UTC (rev 2984)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java 2014-05-21 16:52:22 UTC (rev 2985)
@@ -25,9 +25,11 @@
Router router = new Router(context);
// Defines only one route
- router.attach("/tasks", TasksResource.class);
- router.attach("/tasks/{taskId}", TaskResource.class);
- router.attach("/tasks/{taskId}/time", TimeResource.class);
+ router.attach("/tasks/task", TasksResource.class);
+ router.attach("/tasks/task/{taskId}", TaskResource.class);
+ //router.attach("/tasks/{taskId}/time", TimeResource.class);
+ router.attach("/tasks/time/{taskId}", TimeResource.class);
+ router.attach("/tasks/time", TimesResource.class);
return router;
}
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-05-21 14:42:45 UTC (rev 2984)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java 2014-05-21 16:52:22 UTC (rev 2985)
@@ -79,12 +79,12 @@
*/
@Get("json")
public Representation getTasks() {
- Long date = Long.valueOf(0);
+ Long date = (long) 0;
try {
date = Long.valueOf(getQuery().getValues("date"));
} catch (Exception e) {
- date = Long.valueOf(0);
+ date = (long) 0;
}
Gson gson = builder.create();
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-05-21 14:42:45 UTC (rev 2984)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java 2014-05-21 16:52:22 UTC (rev 2985)
@@ -1,7 +1,14 @@
package org.chorem.jtimer.web;
-import com.google.gson.*;
-
+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;
@@ -9,7 +16,13 @@
import org.restlet.data.MediaType;
import org.restlet.representation.Representation;
import org.restlet.representation.StringRepresentation;
-import org.restlet.resource.*;
+import org.restlet.resource.Delete;
+import org.restlet.resource.Get;
+import org.restlet.resource.Options;
+import org.restlet.resource.Post;
+import org.restlet.resource.Put;
+import org.restlet.resource.ResourceException;
+import org.restlet.resource.ServerResource;
import java.io.IOException;
import java.lang.reflect.Type;
@@ -61,8 +74,17 @@
*/
@Get("json")
public Representation getTask() {
+
+ 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<TimerTime> timerTimes = storage.getTimes(taskId);
+ List<TimerTime> timerTimes = storage.getTimes(taskId, date);
Gson gson = builder.create();
String json = gson.toJson(timerTimes);
@@ -87,6 +109,7 @@
*/
@Post("json")
public void createTask(Representation representation) throws IOException {
+
String timeId = (String)getRequest().getAttributes().get("taskId");
long number = storage.getTaskNumber(timeId);
@@ -95,7 +118,14 @@
TimerTime t = gson.fromJson(repr1, TimerTime.class);
- storage.addTaskTime(t,number);
+ if (log.isInfoEnabled()) {
+ log.info(repr1);
+ log.info(t);
+ log.info(t.getModificationDate().getTime());
+ log.info(number);
+ }
+
+ storage.addTaskTime(t, number);
}
/**
@@ -114,9 +144,7 @@
@Options
public void timeOptions() {
- if (log.isInfoEnabled()) {
- log.info("org.chorem.jtimer.web.TimeResource.timeOptions");
- }
+
}
}
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java 2014-05-21 16:52:22 UTC (rev 2985)
@@ -0,0 +1,91 @@
+package org.chorem.jtimer.web;
+
+import com.google.gson.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.jtimer.entities.TimerTask;
+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 org.restlet.resource.ServerResource;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+
+/**
+ * Created by olivia on 21/05/14.
+ */
+public class TimesResource extends ServerResource {
+
+ private static final Log log = LogFactory.getLog(TaskResource.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());
+ }
+ });
+
+ }
+
+ /**
+ * Methode qui retourne la representation de la liste de toutes les temps
+ * Suite a une requete de type GET
+ *
+ * @return
+ */
+ @Get("json")
+ public Representation getTimes() {
+
+ Long date = (long) 0;
+
+ try {
+ date = Long.valueOf(getQuery().getValues("date"));
+ } catch (Exception e) {
+ date = (long) 0;
+ }
+
+ Gson gson = builder.create();
+ ArrayList<TimerTime> timerTasks = storage.getTimes(date);
+
+ String json = gson.toJson(timerTasks);
+
+ if (log.isInfoEnabled()) {
+ log.info(json);
+ }
+
+ return new StringRepresentation(json, MediaType.APPLICATION_JSON);
+ }
+
+
+}
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-21 14:42:45 UTC (rev 2984)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-21 16:52:22 UTC (rev 2985)
@@ -9,7 +9,8 @@
$scope.todo = $localStorage.getTodo("todo");
// {Date} last update to server
- $scope.access = $scope.todo.lastAccess;
+ $scope.taskAccess = $scope.todo.lastTaskAccess;
+ $scope.timeAccess = $scope.todo.lastTimeAccess;
// {TreeNode} l'arbre regenere automatiquement lorsque les donnees changent
$scope.tree;
@@ -64,7 +65,7 @@
* @returns moment
*/
$scope.getLastMajDate = function(){
- return moment($scope.access).format("YYYY-MM-DD H:mm:ss");
+ return moment($scope.taskAccess).format("YYYY-MM-DD H:mm:ss");
};
/**
@@ -116,13 +117,9 @@
/**
* Récupère les nouveaux elements du serveur et les ajoute a l'arbre pour l'affichage
*/
- var getTasksFromServ = function(){
+ var initTasksFromServ = function(){
- serverTaskAccess.query({date : $scope.access},function (response) {
- //On change la date de dernier acces
- $scope.access = new Date().getTime();
- $scope.todo.lastAccess= $scope.access;
- save();
+ serverTaskAccess.query({}, function (response) {
angular.forEach(response, function (item) {
@@ -147,30 +144,81 @@
$scope.data.tasks[newTask.taskId] = newTask;
save();
//Les temps sont recuperes du serveur
- getTimesFromServer(newTask);
+ getTimesFromServerWithTask(newTask);
save();
}
- }else{
- console.log( "Un element deja present " + item.name + item.modificationDate);
- var newTask = new Task( item.name, item.taskId, item.parent);
- $scope.data.tasks[newTask.taskId] = newTask;
- save();
-
}
});
console.log("Je suis dans le get tasks");
-
+ //On change la date de dernier acces
+ $scope.taskAccess = new Date().getTime();
+ $scope.todo.lastTaskAccess= $scope.taskAccess;
+ save();
});
};
- var getTimesFromServer = function(task){
+ /**
+ * Methode qui va chercher les mise à jour sur les taches
+ *
+ */
+ var updateTaskFromServ = function(){
+ serverTaskAccess.query({date : $scope.taskAccess}, function (response) {
+
+ console.log("Chercher modif du serveur des taches");
+
+ angular.forEach(response, function (item) {
+ console.log(item);
+ //On cherche le node et on le met à jour
+ $scope.tree.getNode(item.taskId).task.name = item.name;
+
+ save();
+
+ //On change la date de dernier acces
+ $scope.taskAccess = new Date().getTime();
+ $scope.todo.lastTaskAccess= $scope.taskAccess;
+ save();
+ });
+
+ });
+ }
+
+ var updateTimesFromServer = function(){
+ console.log("Chercher modif temps du serveur");
+
+ serverTimeAccess.query({date : $scope.timeAccess}, function (response) {
+
+ angular.forEach(response, function (item) {
+ console.log(item);
+ if(!$scope.data.times[item.taskId]){$scope.data.times[item.taskId] = []}
+
+ taskTime = new TaskTime($scope.data.tasks[item.taskId], item.timeId, item.creationDate, item.time);
+ $scope.data.times[item.taskId].push(taskTime);
+
+ save();
+
+ //On change la date de dernier acces
+ $scope.timeAccess = new Date().getTime();
+ $scope.todo.lastTimeAccess= $scope.timeAccess;
+ save();
+ });
+ });
+
+ }
+
+
+ /**
+ * Methode qui recupere les temps pour une tache
+ */
+ var getTimesFromServerWithTask = function(task){
+
if(!$scope.data.times[task.taskId]){$scope.data.times[task.taskId] = []}
- serverTimeAccess.query({taskId : task.taskId}, function (response) {
+ serverTimeAccess.query({taskId : task.taskId, date : $scope.timeAccess}, function (response) {
+
angular.forEach(response, function (item) {
if(!(existInObject($scope.data.times,item.timeId,task.taskId)) && !(existInObject($scope.todo.stockedDeletedTimes, item.timeId, task.taskId))){
@@ -179,9 +227,20 @@
$scope.data.times[task.taskId].push(taskTime);
save();
}
+
+
});
+
+ //On change la date de dernier acces
+ $scope.timeAccess = new Date().getTime();
+ $scope.todo.lastTimeAccess= $scope.timeAccess;
+ save();
+
+
});
+
+
}
var existInObject = function(object, item, pos){
@@ -298,7 +357,12 @@
*/
var timer = function() {
$interval(function() {
- actionToServ();
+ //A changer
+ //initControllerWithServ();
+ pushChangesToServ();
+ updateTaskFromServ();
+
+ //updateTimesFromServer();
}, 30000); //TODO: obruce 05-05-14 for now 30s but for real put at least 2h: 200000000
};
timer();
@@ -306,12 +370,12 @@
/**
*Méthode qui lance les actions à faires sur le serveur
*/
- var actionToServ = function(){
+ var initControllerWithServ = function(){
//Si en ligne on envoie les donnees
if ( $scope.online) {
pushChangesToServ();
- getTasksFromServ();
+ initTasksFromServ();
}
}
@@ -325,14 +389,14 @@
//On synchronise la tache creer
serverTaskAccess.create(angular.toJson(newTask),
- function(){
- console.log("persist task success" + newTask);
- $scope.todo.stockedNewTasks.shift();
+ function(){
+ console.log("persist task success" + newTask);
+ $scope.todo.stockedNewTasks.shift();
},
- function(){
- console.log("fail");
- //On ajoute à la file de synchro
- $scope.todo.stockedNewTasks.push(newTask);
+ function(){
+ console.log("fail");
+ //On ajoute à la file de synchro
+ $scope.todo.stockedNewTasks.push(newTask);
});
$scope.name = "";
@@ -542,7 +606,7 @@
$scope.saveTask = function(node) {
node.edit = null;
- node.task.setModificationDate();
+ node.task.modificationDate = $scope.taskAccess;
$scope.todo.stockedEditedTasks.push(node.task);
save();
};
@@ -707,11 +771,10 @@
}
//force the first server connection
- actionToServ();
+ initControllerWithServ();
// force the first tree creation
$scope.createTree();
-
// connect to webscocket server (go client)
wtWebsocket.connect();
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-05-21 14:42:45 UTC (rev 2984)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-05-21 16:52:22 UTC (rev 2985)
@@ -60,7 +60,9 @@
* @returns {tdListData}
*/
var tdListData = function(){
- this.lastAccess = 0;
+ //Les timestamp de dernier acces
+ this.lastTimeAccess = 0;
+ this.lastTaskAccess = 0;
// {Array of TaskID} la file de tache attendant la synchronisation avec le serveur
this.stockedDeletedTasks = [];
// {Array of Task} file de tache attendant la synchronisation avec le serveur
@@ -95,7 +97,8 @@
}
if (json) {
- this.lastAccess = json.lastAccess;
+ this.lastTaskAccess = json.lastTaskAccess;
+ this.lastTimeAccess = json.lastTimeAccess;
angular.forEach(json.stockedDeletedTasks, function (t) {
this.stockedDeletedTasks.push(t);
@@ -241,6 +244,24 @@
};
/**
+ * Methode qui fait un parcours reccursif de l'arbre et recupere l'element voulu
+ */
+TreeNode.prototype.getNode = function(taskid,task){
+
+ angular.forEach(this.children, function(elem){
+
+ if(taskid == elem.task.taskId){
+ task = elem;
+ }else{
+ task = elem.getNode(taskid, task);
+ }
+ });
+
+ return task;
+}
+
+
+/**
* Ce retire de l'arbre
* @returns {undefined}
*/
@@ -385,16 +406,7 @@
this.syncOptions = {};
};
-
/**
- * Change la date de derniere modification
- * @returns {undefined}
- */
-Task.prototype.setModificationDate = function() {
- this.modificationDate = Date.now();
-};
-
-/**
* Marque la tache comme supprimee
* @returns {undefined}
*/
@@ -447,9 +459,10 @@
this.creationDate = Date.now();
}else{
this.creationDate = date;
-
}
+ this.modificationDate = this.creationDate;
+
if(time == undefined){
this.time = 0;
}else{
Modified: branches/ng-jtimer/src/main/webapp/js/service.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/service.js 2014-05-21 14:42:45 UTC (rev 2984)
+++ branches/ng-jtimer/src/main/webapp/js/service.js 2014-05-21 16:52:22 UTC (rev 2985)
@@ -1,7 +1,7 @@
angular.module("serverAccessService", ["ngResource"])
.factory("serverTaskAccess", function ( $resource) {
// Encapsule l'acces au server
- return $resource("http://localhost:8080/rest/tasks/:taskId",{},
+ return $resource("/rest/tasks/task/:taskId",{},
{
query : {method:'GET', isArray:true},
get : {method: 'GET',isArray: false},
@@ -18,7 +18,7 @@
angular.module("serverTimeService", ["ngResource"])
.factory("serverTimeAccess", function ( $resource) {
// Encapsule l'acces au server
- return $resource("http://localhost:8080/rest/tasks/:taskId/time",{},
+ return $resource("/rest/tasks/time/:taskId",{},
{
query : {method:'GET', isArray:true},
get : {method: 'GET', isArray: false},
1
0
Author: athimel
Date: 2014-05-21 16:42:45 +0200 (Wed, 21 May 2014)
New Revision: 2984
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2984
Log:
Clean pom.xml
Modified:
branches/ng-jtimer/pom.xml
Modified: branches/ng-jtimer/pom.xml
===================================================================
--- branches/ng-jtimer/pom.xml 2014-05-21 14:08:23 UTC (rev 2983)
+++ branches/ng-jtimer/pom.xml 2014-05-21 14:42:45 UTC (rev 2984)
@@ -6,12 +6,12 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>5.0.6</version>
+ <version>5.0.7</version>
</parent>
<groupId>org.chorem</groupId>
<artifactId>jtimer</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>jTimer</name>
@@ -31,6 +31,10 @@
<platform>chorem.org</platform>
<license.licenseName>gpl_v3</license.licenseName>
<javaVersion>1.7</javaVersion>
+ <restletVersion>2.2.1</restletVersion>
+ <gsonVersion>2.2.4</gsonVersion>
+ <h2Version>1.4.178</h2Version>
+ <jettyVersion>9.1.5.v20140505</jettyVersion>
</properties>
<build>
@@ -108,7 +112,7 @@
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
- <version>9.1.4.v20140401</version>
+ <version>${jettyVersion}</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
@@ -161,42 +165,42 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
- <version>1.4.177</version>
+ <version>${h2Version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
- <version>2.2.4</version>
+ <version>${gsonVersion}</version>
</dependency>
<dependency>
<groupId>org.restlet.jee</groupId>
<artifactId>org.restlet</artifactId>
- <version>2.2.0</version>
+ <version>${restletVersion}</version>
</dependency>
<dependency>
<groupId>org.restlet.jee</groupId>
<artifactId>org.restlet.ext.servlet</artifactId>
- <version>2.2.0</version>
+ <version>${restletVersion}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-runner</artifactId>
- <version>9.1.4.v20140401</version>
+ <version>${jettyVersion}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
- <id>maven-restlet</id>
- <name>Public online Restlet repository</name>
- <url>http://maven.restlet.org</url>
+ <id>jtimer-group</id>
+ <url>http://maven.nuiton.org/nexus/content/groups/jtimer</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
- <id>nuiton</id>
- <url>http://nexus.nuiton.org/nexus/content/groups/public</url>
+ <id>jtimer-group</id>
+ <url>http://maven.nuiton.org/nexus/content/groups/jtimer</url>
</pluginRepository>
</pluginRepositories>
+
</project>
1
0
Author: obruce
Date: 2014-05-21 16:08:23 +0200 (Wed, 21 May 2014)
New Revision: 2983
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2983
Log:
pom : org.nuiton version
Modified:
branches/ng-jtimer/pom.xml
Modified: branches/ng-jtimer/pom.xml
===================================================================
--- branches/ng-jtimer/pom.xml 2014-05-21 09:57:31 UTC (rev 2982)
+++ branches/ng-jtimer/pom.xml 2014-05-21 14:08:23 UTC (rev 2983)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>5.0.6-SNAPSHOT</version>
+ <version>5.0.6</version>
</parent>
<groupId>org.chorem</groupId>
1
0