Adds functionality to imports milestones
FEA: ItEr77S05BasicProjectImport
This commit is contained in:
parent
d3361ac0c9
commit
892fdfd5cf
5 changed files with 151 additions and 4 deletions
|
|
@ -92,6 +92,8 @@ public class MPXJProjectFileConversor {
|
|||
|
||||
importData.tasks = getImportTasks(file.getChildTasks());
|
||||
|
||||
importData.milestones = getImportMilestones(file.getChildTasks());
|
||||
|
||||
return importData;
|
||||
|
||||
}
|
||||
|
|
@ -140,6 +142,9 @@ public class MPXJProjectFileConversor {
|
|||
|
||||
importData.tasks = getImportTasks(task.getChildTasks());
|
||||
|
||||
importData.milestones = getImportMilestones(task
|
||||
.getChildTasks());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -148,6 +153,53 @@ public class MPXJProjectFileConversor {
|
|||
return importData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a List of MPXJ Tasks into a List of {@link MilestoneDTO}.
|
||||
*
|
||||
* @param childTasks
|
||||
* List of MPXJ Tasks to extract data from.
|
||||
* @return List<MilestoneDTO> List of MilestoneDTO with the data that we want to
|
||||
* import.
|
||||
*/
|
||||
private static List<MilestoneDTO> getImportMilestones(List<Task> childTasks) {
|
||||
|
||||
List<MilestoneDTO> milestones = new ArrayList<MilestoneDTO>();
|
||||
|
||||
for (Task task : childTasks) {
|
||||
|
||||
if (task.getMilestone()) {
|
||||
|
||||
MilestoneDTO milestone = getMilestoneData(task);
|
||||
|
||||
milestones.add(milestone);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return milestones;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a MPXJ Task into a {@link MilestoneDTO}.
|
||||
*
|
||||
* @param task
|
||||
* MPXJ Task to extract data from.
|
||||
* @return MilestoneDTO MilestoneDTO with the data that we want to import.
|
||||
*/
|
||||
private static MilestoneDTO getMilestoneData(Task task) {
|
||||
|
||||
MilestoneDTO milestone = new MilestoneDTO();
|
||||
|
||||
milestone.name = task.getName();
|
||||
|
||||
milestone.startDate = task.getStart();
|
||||
|
||||
return milestone;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Private method
|
||||
*
|
||||
|
|
@ -182,12 +234,18 @@ public class MPXJProjectFileConversor {
|
|||
|
||||
for (Task task : tasks) {
|
||||
|
||||
OrderElementDTO importTask = getTaskData(task);
|
||||
if (!task.getMilestone()) {
|
||||
|
||||
importTask.children = getImportTasks(task.getChildTasks());
|
||||
OrderElementDTO importTask = getTaskData(task);
|
||||
|
||||
importTasks.add(importTask);
|
||||
importTask.children = getImportTasks(task.getChildTasks());
|
||||
|
||||
importTask.milestones = getImportMilestones(task
|
||||
.getChildTasks());
|
||||
|
||||
importTasks.add(importTask);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return importTasks;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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.importers;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Class that represents no persistent milestones. <br />
|
||||
*
|
||||
* @author Alba Carro Pérez <alba.carro@gmail.com>
|
||||
*/
|
||||
public class MilestoneDTO {
|
||||
|
||||
/**
|
||||
* Name of the milestone
|
||||
*/
|
||||
public String name;
|
||||
|
||||
/**
|
||||
* Start date of the milestone
|
||||
*/
|
||||
public Date startDate;
|
||||
|
||||
}
|
||||
|
|
@ -58,4 +58,9 @@ public class OrderDTO {
|
|||
*/
|
||||
public List<OrderElementDTO> tasks;
|
||||
|
||||
/**
|
||||
* List of {@link MilestoneDTO} of the project that is going to be imported.
|
||||
*/
|
||||
public List<MilestoneDTO> milestones;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,4 +69,9 @@ public class OrderElementDTO {
|
|||
*/
|
||||
public int totalHours;
|
||||
|
||||
/**
|
||||
* Milestones of this task.
|
||||
*/
|
||||
public List<MilestoneDTO> milestones;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import org.libreplan.business.planner.daos.ITaskElementDAO;
|
|||
import org.libreplan.business.planner.daos.ITaskSourceDAO;
|
||||
import org.libreplan.business.planner.entities.TaskElement;
|
||||
import org.libreplan.business.planner.entities.TaskGroup;
|
||||
import org.libreplan.business.planner.entities.TaskMilestone;
|
||||
import org.libreplan.business.scenarios.IScenarioManager;
|
||||
import org.libreplan.business.scenarios.entities.OrderVersion;
|
||||
import org.libreplan.business.scenarios.entities.Scenario;
|
||||
|
|
@ -284,6 +285,12 @@ public class OrderImporterMPXJ implements IOrderImporter {
|
|||
|
||||
}
|
||||
|
||||
for (MilestoneDTO milestone : project.milestones) {
|
||||
|
||||
taskElements.add(createTaskMilestone(milestone));
|
||||
|
||||
}
|
||||
|
||||
for (TaskElement taskElement : taskElements) {
|
||||
taskGroup.addTaskElement(taskElement);
|
||||
}
|
||||
|
|
@ -292,6 +299,26 @@ public class OrderImporterMPXJ implements IOrderImporter {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Private method.
|
||||
*
|
||||
* It makes a {@link TaskMilestone} from a {@link MilsetoneDTO}
|
||||
*
|
||||
* @param milestone
|
||||
* MilestoneDTO to extract data from.
|
||||
*
|
||||
* @return TaskElement TaskElement that represent the data.
|
||||
*/
|
||||
@Transactional
|
||||
private TaskElement createTaskMilestone(MilestoneDTO milestone) {
|
||||
|
||||
TaskElement taskMilestone = TaskMilestone.create(milestone.startDate);
|
||||
|
||||
taskMilestone.setName(milestone.name);
|
||||
|
||||
return taskMilestone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Private method.
|
||||
*
|
||||
|
|
@ -335,6 +362,12 @@ public class OrderImporterMPXJ implements IOrderImporter {
|
|||
|
||||
}
|
||||
|
||||
for (MilestoneDTO milestone : task.milestones) {
|
||||
|
||||
taskElements.add(createTaskMilestone(milestone));
|
||||
|
||||
}
|
||||
|
||||
for (TaskElement childTaskElement : taskElements) {
|
||||
((TaskGroup) taskElement).addTaskElement(childTaskElement);
|
||||
}
|
||||
|
|
@ -367,7 +400,13 @@ public class OrderImporterMPXJ implements IOrderImporter {
|
|||
taskSources.add(taskGroup.getTaskSource());
|
||||
|
||||
for (TaskElement taskElement : taskGroup.getAllChildren()) {
|
||||
taskSources.add(taskElement.getTaskSource());
|
||||
|
||||
if (!taskElement.isMilestone()) {
|
||||
|
||||
taskSources.add(taskElement.getTaskSource());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
orderDAO.save(order);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue