Merge branch 'activityplan' of ssh://git.dsv.su.se/git/scipro/personal/fn into activityplan
* 'activityplan' of ssh://git.dsv.su.se/git/scipro/personal/fn: a new version of saving schedules as templates that supports simultaneus events started to add paralell schedule events added daysOffset to projecteventtemplate
This commit is contained in:
commit
19a3962a0c
src/main/java/se/su/dsv/scipro
@ -154,11 +154,7 @@ public abstract class Event extends LazyDeletableDomainObject
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Event other) {
|
public int compareTo(Event other) {
|
||||||
int dcomp = dueDate.compareTo(other.dueDate);
|
return (int) (dueDate.getTime() - other.dueDate.getTime());
|
||||||
if(dcomp == 0)
|
|
||||||
return id.compareTo(other.id);
|
|
||||||
else
|
|
||||||
return dcomp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Panel getDisplayPanel(String id){
|
public Panel getDisplayPanel(String id){
|
||||||
|
@ -38,6 +38,9 @@ public class ProjectEventTemplate extends DomainObject implements Comparable<Pro
|
|||||||
@Column(nullable=false)
|
@Column(nullable=false)
|
||||||
private long estimatedTimeConsumption = 0;
|
private long estimatedTimeConsumption = 0;
|
||||||
|
|
||||||
|
@Column(nullable=false)
|
||||||
|
private int daysOffset;
|
||||||
|
|
||||||
@Column(nullable=false)
|
@Column(nullable=false)
|
||||||
private boolean requireHandIn = false;
|
private boolean requireHandIn = false;
|
||||||
|
|
||||||
@ -46,6 +49,10 @@ public class ProjectEventTemplate extends DomainObject implements Comparable<Pro
|
|||||||
|
|
||||||
public ProjectEventTemplate(){}
|
public ProjectEventTemplate(){}
|
||||||
|
|
||||||
|
public ProjectEventTemplate(int daysOffset){
|
||||||
|
this.daysOffset = daysOffset;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -53,6 +60,14 @@ public class ProjectEventTemplate extends DomainObject implements Comparable<Pro
|
|||||||
public void setId(Long id) {
|
public void setId(Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setdaysOffset(int daysOffset){
|
||||||
|
this.daysOffset = daysOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDaysOffset(){
|
||||||
|
return daysOffset;
|
||||||
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
|
@ -11,7 +11,10 @@ import org.joda.time.DateMidnight;
|
|||||||
import org.joda.time.DateTimeConstants;
|
import org.joda.time.DateTimeConstants;
|
||||||
import org.joda.time.Days;
|
import org.joda.time.Days;
|
||||||
|
|
||||||
|
import se.su.dsv.scipro.SciProSession;
|
||||||
|
import se.su.dsv.scipro.data.dao.interfaces.EventDao;
|
||||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||||
|
import se.su.dsv.scipro.data.dao.interfaces.ProjectEventDao;
|
||||||
import se.su.dsv.scipro.data.dao.interfaces.ScheduleTemplateDao;
|
import se.su.dsv.scipro.data.dao.interfaces.ScheduleTemplateDao;
|
||||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||||
import se.su.dsv.scipro.data.dataobjects.ProjectEvent;
|
import se.su.dsv.scipro.data.dataobjects.ProjectEvent;
|
||||||
@ -27,6 +30,9 @@ public class ScheduleGenerator {
|
|||||||
@SpringBean
|
@SpringBean
|
||||||
private ProjectDao projectDao;
|
private ProjectDao projectDao;
|
||||||
|
|
||||||
|
@SpringBean
|
||||||
|
private ProjectEventDao projectEventDao;
|
||||||
|
|
||||||
private Project project;
|
private Project project;
|
||||||
private ScheduleTemplate template;
|
private ScheduleTemplate template;
|
||||||
private List<ProjectEventTemplate> eventTemplates;
|
private List<ProjectEventTemplate> eventTemplates;
|
||||||
@ -72,14 +78,17 @@ public class ScheduleGenerator {
|
|||||||
|
|
||||||
List<ProjectEvent> events = new ArrayList<ProjectEvent>();
|
List<ProjectEvent> events = new ArrayList<ProjectEvent>();
|
||||||
DateMidnight datePointer = new DateMidnight(startDate);
|
DateMidnight datePointer = new DateMidnight(startDate);
|
||||||
|
DateMidnight tempPointer;
|
||||||
|
|
||||||
int totalDuration = 0;
|
int totalDuration = 0;
|
||||||
for(ProjectEventTemplate e : eventTemplates){
|
for(ProjectEventTemplate e : eventTemplates){
|
||||||
|
tempPointer = new DateMidnight(datePointer);
|
||||||
ProjectEvent event = e.createEventFromTemplate();
|
ProjectEvent event = e.createEventFromTemplate();
|
||||||
event.setParticipants(project.getProjectParticipants());
|
event.setParticipants(project.getProjectParticipants());//might have to remove this
|
||||||
|
if(e.getEstimatedTimeConsumption() <= 1){
|
||||||
|
datePointer = new DateMidnight(startDate).plusDays(e.getDaysOffset());
|
||||||
|
}
|
||||||
double duration = (double) e.getEstimatedTimeConsumption() * ratio;
|
double duration = (double) e.getEstimatedTimeConsumption() * ratio;
|
||||||
if(duration < 1.0)
|
|
||||||
duration = 1.0;
|
|
||||||
|
|
||||||
datePointer = datePointer.plusDays((int) duration);
|
datePointer = datePointer.plusDays((int) duration);
|
||||||
totalDuration += (int)duration;
|
totalDuration += (int)duration;
|
||||||
@ -94,6 +103,9 @@ public class ScheduleGenerator {
|
|||||||
}
|
}
|
||||||
event.setDueDate(datePointer.toDate());
|
event.setDueDate(datePointer.toDate());
|
||||||
events.add(event);
|
events.add(event);
|
||||||
|
if(e.getEstimatedTimeConsumption() <= 1){
|
||||||
|
datePointer = tempPointer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new ScheduleGeneratorResult(template, events, totalDuration, templateEstimatedDays, startDate.toDate(), endDate.toDate());
|
return new ScheduleGeneratorResult(template, events, totalDuration, templateEstimatedDays, startDate.toDate(), endDate.toDate());
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ public class TemplateGenerator { //based on ScheduleGenerator
|
|||||||
|
|
||||||
private int templateEstimatedDays = 0;
|
private int templateEstimatedDays = 0;
|
||||||
private int durationInDays = 0;
|
private int durationInDays = 0;
|
||||||
|
private int daysOffset;
|
||||||
|
|
||||||
private DateMidnight startDate;
|
private DateMidnight startDate;
|
||||||
|
|
||||||
@ -56,12 +57,9 @@ public class TemplateGenerator { //based on ScheduleGenerator
|
|||||||
if(schedule.getStartDate() != null){
|
if(schedule.getStartDate() != null){
|
||||||
this.startDate = new DateMidnight(schedule.getStartDate());
|
this.startDate = new DateMidnight(schedule.getStartDate());
|
||||||
}else{
|
}else{
|
||||||
this.startDate = new DateMidnight(projectEvents.first().getDueDate());
|
int days = (new DateMidnight(projectEvents.first().getDueDate()).getDayOfYear() - new DateMidnight(schedule.getStartDate()).getDayOfYear());
|
||||||
|
this.startDate = new DateMidnight(projectEvents.first().getDueDate()).minusDays(days);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScheduleTemplate generate(){
|
public ScheduleTemplate generate(){
|
||||||
@ -94,9 +92,12 @@ public class TemplateGenerator { //based on ScheduleGenerator
|
|||||||
pet.setRequireHandIn(pe.isRequireHandIn());
|
pet.setRequireHandIn(pe.isRequireHandIn());
|
||||||
pet.setScheduleTemplate(template);
|
pet.setScheduleTemplate(template);
|
||||||
|
|
||||||
|
int daysOffset = (new DateMidnight(pe.getDueDate()).getDayOfYear() - startDate.getDayOfYear());
|
||||||
|
|
||||||
|
pet.setdaysOffset(daysOffset);
|
||||||
|
|
||||||
datePointer = datePointer.plusDays(durationInDays);
|
datePointer = datePointer.plusDays(durationInDays);
|
||||||
templateEstimatedDays += durationInDays;
|
setTemplateEstimatedDays(getTemplateEstimatedDays() + durationInDays);
|
||||||
projectEventTemplate.add(pet);
|
projectEventTemplate.add(pet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,5 +159,21 @@ public class TemplateGenerator { //based on ScheduleGenerator
|
|||||||
this.startDate = new DateMidnight(startDate);
|
this.startDate = new DateMidnight(startDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTemplateEstimatedDays() {
|
||||||
|
return templateEstimatedDays;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemplateEstimatedDays(int templateEstimatedDays) {
|
||||||
|
this.templateEstimatedDays = templateEstimatedDays;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDaysOffset() {
|
||||||
|
return daysOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDaysOffset(int daysOffset) {
|
||||||
|
this.daysOffset = daysOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user