ItEr56S12CUAsignacionRecursosLimitantesItEr55S16: Add QueuePosition

* Keep LimitingResourceQueueElement in LimitingResourceQueue sorted
This commit is contained in:
Diego Pino Garcia 2010-04-27 17:16:18 +02:00 committed by Javier Moran Rua
parent 592ca70a1f
commit a06aea5656
5 changed files with 115 additions and 5 deletions

View file

@ -20,8 +20,12 @@
package org.navalplanner.business.planner.entities;
import static org.navalplanner.business.i18n.I18nHelper._;
import java.util.Date;
import org.apache.commons.lang.Validate;
import org.joda.time.LocalDate;
import org.navalplanner.business.common.BaseEntity;
import org.navalplanner.business.resources.entities.LimitingResourceQueue;
@ -38,7 +42,11 @@ public class LimitingResourceQueueElement extends BaseEntity {
private Date earlierStartDateBecauseOfGantt;
public Date getEarlierStartDateBecauseOfGantt() {
private QueuePosition startQueuePosition;
private QueuePosition endQueuePosition;
public Date getEarlierStartDateBecauseOfGantt() {
return earlierStartDateBecauseOfGantt;
}
@ -47,7 +55,7 @@ public class LimitingResourceQueueElement extends BaseEntity {
this.earlierStartDateBecauseOfGantt = earlierStartDateBecauseOfGantt;
}
public static LimitingResourceQueueElement create() {
public static LimitingResourceQueueElement create() {
return create(new LimitingResourceQueueElement());
}
@ -71,4 +79,36 @@ public static LimitingResourceQueueElement create() {
this.limitingResourceQueue = limitingResourceQueue;
}
public LocalDate getStartDate() {
return startQueuePosition.getDate();
}
public void setStartDate(LocalDate date) {
startQueuePosition.setDate(date);
}
public int getStartHour() {
return startQueuePosition.getHour();
}
public void setStartHour(int hour) {
startQueuePosition.setHour(hour);
}
public LocalDate getEndDate() {
return endQueuePosition.getDate();
}
public void setEndDate(LocalDate date) {
endQueuePosition.setDate(date);
}
public int getEndHour() {
return endQueuePosition.getHour();
}
public void setEndHour(int hour) {
endQueuePosition.setHour(hour);
}
}

View file

@ -0,0 +1,56 @@
/*
* This file is part of NavalPlan
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* 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.navalplanner.business.planner.entities;
import static org.navalplanner.business.i18n.I18nHelper._;
import org.apache.commons.lang.Validate;
import org.joda.time.LocalDate;
/**
*
* @author Diego Pino Garcia <dpino@igalia.com>
*
*/
public class QueuePosition {
private LocalDate date;
private int hour = 0;
public LocalDate getDate() {
return date;
}
public void setDate(LocalDate date) {
this.date = date;
}
public int getHour() {
return hour;
}
public void setHour(int hour) {
Validate.isTrue(hour >= 0 && hour <= 23, _("Hour should be a value between 0 and 23"));
this.hour = hour;
}
}

View file

@ -21,9 +21,11 @@
package org.navalplanner.business.resources.entities;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import org.apache.commons.lang.math.NumberUtils;
import org.navalplanner.business.common.BaseEntity;
import org.navalplanner.business.planner.entities.LimitingResourceQueueElement;
@ -37,7 +39,7 @@ public class LimitingResourceQueue extends BaseEntity {
private Resource resource;
private Set<LimitingResourceQueueElement> limitingResourceQueueElements =
new HashSet<LimitingResourceQueueElement>();
new TreeSet<LimitingResourceQueueElement>();
public static LimitingResourceQueue create() {
return create(new LimitingResourceQueue());

View file

@ -60,6 +60,7 @@
</class>
<!-- LimitingResourceQueueElement -->
<class name="LimitingResourceQueueElement" table="limiting_resource_queue_element">
<id name="id" type="long" access="property">
<generator class="hilo">
@ -74,6 +75,16 @@
<property name="earlierStartDateBecauseOfGantt" column="EARLIER_START_DATE_BECAUSE_OF_GANTT" />
<component name="startQueuePosition" class="org.navalplanner.business.planner.entities.QueuePosition">
<property name="date" column="START_DATE" />
<property name="hour" column="START_HOUR" />
</component>
<component name="endQueuePosition" class="org.navalplanner.business.planner.entities.QueuePosition">
<property name="date" column="END_DATE" />
<property name="hour" column="END_HOUR" />
</component>
</class>
<!-- DayAssignment -->

View file

@ -78,7 +78,8 @@
<many-to-one name="resource" column="RESOURCE_ID" not-null="false" unique="true" />
<set name="limitingResourceQueueElements" cascade="all-delete-orphan" inverse="true" >
<set name="limitingResourceQueueElements" cascade="all-delete-orphan" inverse="true"
order-by="START_DATE, START_HOUR">
<key column="LIMITING_RESOURCE_QUEUE_ID" not-null="true" />
<one-to-many class="org.navalplanner.business.planner.entities.LimitingResourceQueueElement" />
</set>