ItEr42S24CUTimeLineMateriais : Deletes the query through the DAO and uses the methods of navigation to retrieve the task element.
This commit is contained in:
parent
48e2f89c51
commit
71d329f1e3
5 changed files with 24 additions and 44 deletions
|
|
@ -233,7 +233,7 @@ public abstract class OrderElement extends BaseEntity implements
|
|||
return getSchedulingState().isSomewhatScheduled();
|
||||
}
|
||||
|
||||
private boolean isSchedulingPoint() {
|
||||
public boolean isSchedulingPoint() {
|
||||
return getSchedulingState().getType() == Type.SCHEDULING_POINT;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,21 +20,11 @@
|
|||
package org.navalplanner.business.planner.daos;
|
||||
|
||||
import org.navalplanner.business.common.daos.IGenericDAO;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
import org.navalplanner.business.orders.entities.TaskSource;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
|
||||
/**
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*
|
||||
*/
|
||||
public interface ITaskSourceDAO extends IGenericDAO<TaskSource, Long> {
|
||||
|
||||
/**
|
||||
* Returns the unique {@link taskElement} assigned to the current
|
||||
* {@link OrderElement}
|
||||
* @param
|
||||
* @return {@link TaskElement}
|
||||
*/
|
||||
TaskElement findUniqueByOrderElement(OrderElement orderElement);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,8 @@
|
|||
*/
|
||||
package org.navalplanner.business.planner.daos;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Query;
|
||||
import org.navalplanner.business.common.daos.GenericDAOHibernate;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
import org.navalplanner.business.orders.entities.TaskSource;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
|
@ -38,23 +34,4 @@ import org.springframework.stereotype.Repository;
|
|||
public class TaskSourceDAO extends GenericDAOHibernate<TaskSource, Long>
|
||||
implements ITaskSourceDAO {
|
||||
|
||||
public TaskElement findUniqueByOrderElement(OrderElement orderElement) {
|
||||
String strQuery = "SELECT task " + "FROM TaskSource taskSource "
|
||||
+ "LEFT OUTER JOIN taskSource.task task "
|
||||
+ "LEFT OUTER JOIN taskSource.orderElement orderElement "
|
||||
+ "WHERE task IN (SELECT task FROM Task task) ";
|
||||
|
||||
if (orderElement != null) {
|
||||
strQuery += "AND orderElement = :orderElement ";
|
||||
}
|
||||
try {
|
||||
Query query = getSession().createQuery(strQuery);
|
||||
query.setParameter("orderElement", orderElement);
|
||||
query.setMaxResults(1);
|
||||
return (TaskElement) query.uniqueResult();
|
||||
} catch (HibernateException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -309,13 +309,25 @@
|
|||
<reportElement x="505" y="1" width="1" height="72"/>
|
||||
</line>
|
||||
<line>
|
||||
<reportElement x="580" y="1" width="1" height="72"/>
|
||||
<reportElement x="580" y="0" width="1" height="73">
|
||||
<printWhenExpression><![CDATA[$P{status} == null]]></printWhenExpression>
|
||||
</reportElement>
|
||||
</line>
|
||||
<line>
|
||||
<reportElement x="0" y="0" width="581" height="1"/>
|
||||
<reportElement x="0" y="0" width="506" height="1"/>
|
||||
</line>
|
||||
<line>
|
||||
<reportElement x="0" y="73" width="581" height="1"/>
|
||||
<reportElement x="0" y="73" width="506" height="1"/>
|
||||
</line>
|
||||
<line>
|
||||
<reportElement x="506" y="0" width="74" height="1">
|
||||
<printWhenExpression><![CDATA[$P{status} == null]]></printWhenExpression>
|
||||
</reportElement>
|
||||
</line>
|
||||
<line>
|
||||
<reportElement x="506" y="73" width="75" height="1">
|
||||
<printWhenExpression><![CDATA[$P{status} == null]]></printWhenExpression>
|
||||
</reportElement>
|
||||
</line>
|
||||
</band>
|
||||
</detail>
|
||||
|
|
|
|||
|
|
@ -203,12 +203,11 @@ public class TimeLineRequiredMaterialModel implements
|
|||
OrderElement current = material.getOrderElement();
|
||||
OrderElement result = current;
|
||||
while (current != null) {
|
||||
TaskElement task = taskSourceDAO.findUniqueByOrderElement(current);
|
||||
if (task != null) {
|
||||
return task;
|
||||
if (current.isSchedulingPoint()) {
|
||||
return current.getAssociatedTaskElement();
|
||||
}
|
||||
result = current;
|
||||
current = orderElementDAO.findParent(current);
|
||||
current = current.getParent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -218,9 +217,11 @@ public class TimeLineRequiredMaterialModel implements
|
|||
Date lessDate = null;
|
||||
TaskElement resultTask = null;
|
||||
for (OrderElement child : current.getAllChildren()) {
|
||||
TaskElement task = taskSourceDAO.findUniqueByOrderElement(child);
|
||||
if (task != null) {
|
||||
if ((lessDate == null) || (lessDate.after(task.getStartDate()))) {
|
||||
if (child.isSchedulingPoint()) {
|
||||
TaskElement task = child.getAssociatedTaskElement();
|
||||
if ((task != null)
|
||||
&& ((lessDate == null) || (lessDate.after(task
|
||||
.getStartDate())))) {
|
||||
lessDate = task.getStartDate();
|
||||
resultTask = task;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue