New web service returning the assigned tasks of a user
It uses MyTasksAreaModel, as the main UI for bound users. The service is only accessible for bound users. FEA: ItEr77S14BoundUsersWebServices
This commit is contained in:
parent
98eeed0801
commit
5ebffa666b
10 changed files with 339 additions and 23 deletions
|
|
@ -42,6 +42,7 @@ import org.hibernate.validator.Valid;
|
|||
import org.joda.time.LocalDate;
|
||||
import org.libreplan.business.advance.bootstrap.PredefinedAdvancedTypes;
|
||||
import org.libreplan.business.advance.entities.AdvanceAssignment;
|
||||
import org.libreplan.business.advance.entities.AdvanceMeasurement;
|
||||
import org.libreplan.business.advance.entities.AdvanceType;
|
||||
import org.libreplan.business.advance.entities.DirectAdvanceAssignment;
|
||||
import org.libreplan.business.advance.entities.IndirectAdvanceAssignment;
|
||||
|
|
@ -70,6 +71,7 @@ import org.libreplan.business.scenarios.entities.Scenario;
|
|||
import org.libreplan.business.templates.entities.OrderElementTemplate;
|
||||
import org.libreplan.business.trees.ITreeNode;
|
||||
import org.libreplan.business.util.deepcopy.DeepCopy;
|
||||
import org.libreplan.business.workingday.EffortDuration;
|
||||
import org.libreplan.business.workingday.IntraDayDate;
|
||||
import org.libreplan.business.workreports.daos.IWorkReportLineDAO;
|
||||
import org.libreplan.business.workreports.entities.WorkReportLine;
|
||||
|
|
@ -1588,4 +1590,19 @@ public abstract class OrderElement extends IntegrationEntity implements
|
|||
parent = null;
|
||||
}
|
||||
|
||||
public AdvanceMeasurement getLastAdvanceMeasurement() {
|
||||
DirectAdvanceAssignment advanceAssignment = getReportGlobalAdvanceAssignment();
|
||||
if (advanceAssignment == null) {
|
||||
return null;
|
||||
}
|
||||
return advanceAssignment.getLastAdvanceMeasurement();
|
||||
}
|
||||
|
||||
public String getEffortAsString() {
|
||||
SumChargedEffort sumChargedEffort = getSumChargedEffort();
|
||||
EffortDuration effort = sumChargedEffort != null ? sumChargedEffort
|
||||
.getTotalChargedEffort() : EffortDuration.zero();
|
||||
return effort.toFormattedString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,9 @@ import javax.annotation.Resource;
|
|||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.libreplan.business.advance.entities.AdvanceMeasurement;
|
||||
import org.libreplan.business.advance.entities.DirectAdvanceAssignment;
|
||||
import org.libreplan.business.common.entities.PersonalTimesheetsPeriodicityEnum;
|
||||
import org.libreplan.business.orders.entities.OrderElement;
|
||||
import org.libreplan.business.orders.entities.SumChargedEffort;
|
||||
import org.libreplan.business.planner.entities.Task;
|
||||
import org.libreplan.business.workingday.EffortDuration;
|
||||
import org.libreplan.web.common.Util;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
|
|
@ -75,21 +72,15 @@ public class MyTasksAreaController extends GenericForwardComposer {
|
|||
|
||||
Util.appendLabel(row, getProgress(orderElement));
|
||||
|
||||
Util.appendLabel(row, getEffort(orderElement));
|
||||
Util.appendLabel(row, _("{0} h", orderElement.getEffortAsString()));
|
||||
|
||||
appendTimeTrackingButton(row, task);
|
||||
}
|
||||
|
||||
private String getEffort(OrderElement orderElement) {
|
||||
SumChargedEffort sumChargedEffort = orderElement.getSumChargedEffort();
|
||||
EffortDuration effort = sumChargedEffort != null ? sumChargedEffort
|
||||
.getTotalChargedEffort() : EffortDuration.zero();
|
||||
return _("{0} h", effort.toFormattedString());
|
||||
}
|
||||
|
||||
private String getProgress(OrderElement orderElement) {
|
||||
|
||||
AdvanceMeasurement lastAdvanceMeasurement = getLastAdvanceMeasurement(orderElement);
|
||||
AdvanceMeasurement lastAdvanceMeasurement = orderElement
|
||||
.getLastAdvanceMeasurement();
|
||||
if (lastAdvanceMeasurement != null) {
|
||||
return MessageFormat.format("[{0} %] ({1})",
|
||||
lastAdvanceMeasurement.getValue(),
|
||||
|
|
@ -98,17 +89,6 @@ public class MyTasksAreaController extends GenericForwardComposer {
|
|||
return "";
|
||||
}
|
||||
|
||||
private AdvanceMeasurement getLastAdvanceMeasurement(
|
||||
OrderElement orderElement) {
|
||||
DirectAdvanceAssignment advanceAssignment = orderElement
|
||||
.getReportGlobalAdvanceAssignment();
|
||||
if (advanceAssignment == null) {
|
||||
return null;
|
||||
}
|
||||
return advanceAssignment
|
||||
.getLastAdvanceMeasurement();
|
||||
}
|
||||
|
||||
private void appendTimeTrackingButton(Row row, final Task task) {
|
||||
EventListener trackTimeButtonListener = new EventListener() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* This file is part of LibrePlan
|
||||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.libreplan.ws.boundusers.api;
|
||||
|
||||
/**
|
||||
* Service for managing operations related with bound users.
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
public interface IBoundUserService {
|
||||
|
||||
TaskListDTO getTasks();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* This file is part of LibrePlan
|
||||
*
|
||||
* Copyright (C) 2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.libreplan.ws.boundusers.api;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
|
||||
import org.libreplan.business.planner.entities.Task;
|
||||
|
||||
/**
|
||||
* DTO for a {@link Task} entity.
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
@XmlRootElement(name = "task")
|
||||
public class TaskDTO {
|
||||
|
||||
@XmlAttribute
|
||||
public String name;
|
||||
|
||||
@XmlAttribute
|
||||
public String code;
|
||||
|
||||
@XmlAttribute(name = "project-name")
|
||||
public String projectName;
|
||||
|
||||
@XmlAttribute(name = "start-date")
|
||||
public XMLGregorianCalendar startDate;
|
||||
|
||||
@XmlAttribute(name = "end-date")
|
||||
public XMLGregorianCalendar endDate;
|
||||
|
||||
@XmlAttribute(name = "progress-value")
|
||||
public BigDecimal progressValue;
|
||||
|
||||
@XmlAttribute(name = "progress-date")
|
||||
public XMLGregorianCalendar progressDate;
|
||||
|
||||
@XmlAttribute
|
||||
public String effort;
|
||||
|
||||
public TaskDTO() {}
|
||||
|
||||
public TaskDTO(String name, String code, String projectName,
|
||||
XMLGregorianCalendar startDate, XMLGregorianCalendar endDate,
|
||||
BigDecimal progressValue, XMLGregorianCalendar progressDate,
|
||||
String effort) {
|
||||
this.name = name;
|
||||
this.code = code;
|
||||
this.projectName = projectName;
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
this.progressValue = progressValue;
|
||||
this.progressDate = progressDate;
|
||||
this.effort = effort;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* This file is part of LibrePlan
|
||||
*
|
||||
* Copyright (C) 2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.libreplan.ws.boundusers.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.libreplan.business.planner.entities.Task;
|
||||
|
||||
/**
|
||||
* DTO for a list of {@link Task} entities.
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
@XmlRootElement(name = "task-list")
|
||||
public class TaskListDTO {
|
||||
|
||||
@XmlElement(name = "task")
|
||||
public List<TaskDTO> tasks = new ArrayList<TaskDTO>();
|
||||
|
||||
public TaskListDTO() {}
|
||||
|
||||
public TaskListDTO(List<TaskDTO> tasks) {
|
||||
this.tasks = tasks;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* This file is part of LibrePlan
|
||||
*
|
||||
* Copyright (C) 2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Specification of namespace for REST-based services.
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
@javax.xml.bind.annotation.XmlSchema(elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED, namespace = WSCommonGlobalNames.REST_NAMESPACE)
|
||||
package org.libreplan.ws.boundusers.api;
|
||||
|
||||
import org.libreplan.ws.common.api.WSCommonGlobalNames;
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* This file is part of LibrePlan
|
||||
*
|
||||
* Copyright (C) 2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.libreplan.ws.boundusers.impl;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
|
||||
import org.libreplan.web.users.dashboard.IMyTasksAreaModel;
|
||||
import org.libreplan.ws.boundusers.api.IBoundUserService;
|
||||
import org.libreplan.ws.boundusers.api.TaskListDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* REST-based implementation of {@link IBoundUserService};
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
@Path("/bounduser/")
|
||||
@Produces("application/xml")
|
||||
@Service("boundUserServiceREST")
|
||||
public class BoundUserServiceREST implements IBoundUserService {
|
||||
|
||||
@Autowired
|
||||
private IMyTasksAreaModel myTasksAreaModel;
|
||||
|
||||
@Override
|
||||
@GET
|
||||
@Path("/mytasks/")
|
||||
public TaskListDTO getTasks() {
|
||||
return TaskConverter.toDTO(myTasksAreaModel.getTasks());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* This file is part of LibrePlan
|
||||
*
|
||||
* Copyright (C) 2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.libreplan.ws.boundusers.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.libreplan.business.advance.entities.AdvanceMeasurement;
|
||||
import org.libreplan.business.orders.entities.OrderElement;
|
||||
import org.libreplan.business.planner.entities.Task;
|
||||
import org.libreplan.ws.boundusers.api.TaskDTO;
|
||||
import org.libreplan.ws.boundusers.api.TaskListDTO;
|
||||
import org.libreplan.ws.common.impl.DateConverter;
|
||||
|
||||
/**
|
||||
* Converter from/to {@link Task} related entities to/from DTOs.
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
public final class TaskConverter {
|
||||
|
||||
private TaskConverter() {
|
||||
}
|
||||
|
||||
public final static TaskDTO toDTO(Task task) {
|
||||
OrderElement orderElement = task.getOrderElement();
|
||||
|
||||
AdvanceMeasurement lastAdvanceMeasurement = orderElement
|
||||
.getLastAdvanceMeasurement();
|
||||
BigDecimal progressValue = null;
|
||||
LocalDate progressDate = null;
|
||||
if (lastAdvanceMeasurement != null) {
|
||||
progressValue = lastAdvanceMeasurement.getValue();
|
||||
progressDate = lastAdvanceMeasurement.getDate();
|
||||
}
|
||||
|
||||
return new TaskDTO(task.getName(), orderElement.getCode(), orderElement
|
||||
.getOrder().getName(),
|
||||
DateConverter.toXMLGregorianCalendar(task.getStartDate()),
|
||||
DateConverter.toXMLGregorianCalendar(task.getEndDate()),
|
||||
progressValue,
|
||||
DateConverter.toXMLGregorianCalendar(progressDate),
|
||||
orderElement.getEffortAsString());
|
||||
}
|
||||
|
||||
public final static TaskListDTO toDTO(Collection<Task> tasks) {
|
||||
List<TaskDTO> dtos = new ArrayList<TaskDTO>();
|
||||
for (Task each : tasks) {
|
||||
dtos.add(toDTO(each));
|
||||
}
|
||||
return new TaskListDTO(dtos);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -73,6 +73,7 @@
|
|||
<ref bean="materialServiceREST"/>
|
||||
<ref bean="unitTypeServiceREST"/>
|
||||
<ref bean="expenseSheetServiceREST"/>
|
||||
<ref bean="boundUserServiceREST"/>
|
||||
</jaxrs:serviceBeans>
|
||||
<jaxrs:providers>
|
||||
<ref bean="runtimeExceptionMapper" />
|
||||
|
|
|
|||
|
|
@ -13,6 +13,12 @@
|
|||
entry-point-ref="customAuthenticationEntryPoint">
|
||||
|
||||
<!-- Web services -->
|
||||
<intercept-url pattern="/ws/rest/bounduser/**"
|
||||
access="ROLE_BOUND_USER"
|
||||
method="GET" />
|
||||
<intercept-url pattern="/ws/rest/bounduser/**"
|
||||
access="ROLE_BOUND_USER"
|
||||
method="POST" />
|
||||
<intercept-url pattern="/ws/rest/subcontracting/**"
|
||||
access="ROLE_WS_SUBCONTRACTING"
|
||||
method="GET" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue