started to add paralell schedule events
This commit is contained in:
parent
3b25bed168
commit
3a7314ed61
src/main/java/se/su/dsv/scipro
@ -155,9 +155,15 @@ public abstract class Event extends LazyDeletableDomainObject
|
|||||||
@Override
|
@Override
|
||||||
public int compareTo(Event other) {
|
public int compareTo(Event other) {
|
||||||
int dcomp = dueDate.compareTo(other.dueDate);
|
int dcomp = dueDate.compareTo(other.dueDate);
|
||||||
if(dcomp == 0)
|
if(dcomp == 0){
|
||||||
|
/*if(id == null){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if (other.id == null){
|
||||||
|
return 1;
|
||||||
|
}*/
|
||||||
return id.compareTo(other.id);
|
return id.compareTo(other.id);
|
||||||
else
|
}else
|
||||||
return dcomp;
|
return dcomp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,11 +78,16 @@ 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 = datePointer;
|
||||||
ProjectEvent event = e.createEventFromTemplate();
|
ProjectEvent event = e.createEventFromTemplate();
|
||||||
event.setParticipants(project.getProjectParticipants());
|
event.setParticipants(project.getProjectParticipants());
|
||||||
|
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)
|
if(duration < 1.0)
|
||||||
duration = 1.0;
|
duration = 1.0;
|
||||||
@ -93,7 +104,14 @@ public class ScheduleGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.setDueDate(datePointer.toDate());
|
event.setDueDate(datePointer.toDate());
|
||||||
|
event.setCreator(SciProSession.get().getUser());
|
||||||
|
event.setProjectSchedule(projectSchedule);
|
||||||
|
event = projectEventDao.save(event);
|
||||||
events.add(event);
|
events.add(event);
|
||||||
|
|
||||||
|
|
||||||
|
datePointer = tempPointer;
|
||||||
|
System.out.println(event);
|
||||||
}
|
}
|
||||||
return new ScheduleGeneratorResult(template, events, totalDuration, templateEstimatedDays, startDate.toDate(), endDate.toDate());
|
return new ScheduleGeneratorResult(template, events, totalDuration, templateEstimatedDays, startDate.toDate(), endDate.toDate());
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,8 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,10 +91,13 @@ public class TemplateGenerator { //based on ScheduleGenerator
|
|||||||
pet.setNumberInOrder(counter);
|
pet.setNumberInOrder(counter);
|
||||||
pet.setRequireHandIn(pe.isRequireHandIn());
|
pet.setRequireHandIn(pe.isRequireHandIn());
|
||||||
pet.setScheduleTemplate(template);
|
pet.setScheduleTemplate(template);
|
||||||
måste få in daysOffset i projectEventTemplate
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,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