ItEr60S17CambiosPantallaVistaEmpresa: Created entity SumChargedHours, with one-to-one relation with OrderElement
This commit is contained in:
parent
97222ebb43
commit
8d363fd10b
4 changed files with 116 additions and 0 deletions
|
|
@ -107,6 +107,8 @@ public abstract class OrderElement extends IntegrationEntity implements
|
|||
|
||||
private Boolean dirtyLastAdvanceMeasurementForSpreading = true;
|
||||
|
||||
private SumChargedHours sumChargedHours = SumChargedHours.create();
|
||||
|
||||
public OrderElementTemplate getTemplate() {
|
||||
return template;
|
||||
}
|
||||
|
|
@ -1263,4 +1265,12 @@ public abstract class OrderElement extends IntegrationEntity implements
|
|||
dirtyLastAdvanceMeasurementForSpreading = true;
|
||||
}
|
||||
|
||||
public void setSumChargedHours(SumChargedHours sumChargedHours) {
|
||||
this.sumChargedHours = sumChargedHours;
|
||||
}
|
||||
|
||||
public SumChargedHours getSumChargedHours() {
|
||||
return sumChargedHours;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* This file is part of NavalPlan
|
||||
*
|
||||
* Copyright (C) 2009-2010 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.orders.entities;
|
||||
|
||||
import org.navalplanner.business.common.BaseEntity;
|
||||
|
||||
/**
|
||||
* It represents the hours charged to an {@link OrderElement}, avoiding the
|
||||
* need to iterate among the work report lines to get this information. <br />
|
||||
* @author Jacobo Aragunde Pérez <jaragunde@igalia.com>
|
||||
*/
|
||||
public class SumChargedHours extends BaseEntity {
|
||||
|
||||
private Integer directChargedHours = new Integer(0);
|
||||
|
||||
private Integer indirectChargedHours = new Integer(0);
|
||||
|
||||
protected SumChargedHours() {}
|
||||
|
||||
public static SumChargedHours create() {
|
||||
return create(new SumChargedHours());
|
||||
}
|
||||
|
||||
public void setDirectChargedHours(Integer directChargedHours) {
|
||||
this.directChargedHours = directChargedHours;
|
||||
}
|
||||
|
||||
public void addDirectChargedHours(Integer directChargedHours) {
|
||||
this.directChargedHours += directChargedHours;
|
||||
}
|
||||
|
||||
public Integer getDirectChargedHours() {
|
||||
return directChargedHours;
|
||||
}
|
||||
|
||||
public void setIndirectChargedHours(Integer indirectChargedHours) {
|
||||
this.indirectChargedHours = indirectChargedHours;
|
||||
}
|
||||
|
||||
public void addIndirectChargedHours(Integer indirectChargedHours) {
|
||||
this.indirectChargedHours += indirectChargedHours;
|
||||
}
|
||||
|
||||
public Integer getIndirectChargedHours() {
|
||||
return indirectChargedHours;
|
||||
}
|
||||
|
||||
public Integer getTotalChargedHours() {
|
||||
return directChargedHours + indirectChargedHours;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -74,6 +74,13 @@
|
|||
column="SCHEDULING_STATE_FOR_VERSION_ID" />
|
||||
</map>
|
||||
|
||||
<many-to-one name="sumChargedHours"
|
||||
class="SumChargedHours"
|
||||
column="SUM_CHARGED_HOURS_ID"
|
||||
cascade="save-update, delete"
|
||||
unique="true"
|
||||
lazy="false" />
|
||||
|
||||
<joined-subclass name="OrderLineGroup">
|
||||
<key column="ORDERELEMENTID"></key>
|
||||
|
||||
|
|
@ -219,4 +226,16 @@
|
|||
</set>
|
||||
</class>
|
||||
|
||||
<class name="SumChargedHours">
|
||||
<id name="id" access="property" type="long">
|
||||
<generator class="hilo" >
|
||||
<param name="max_lo">100</param>
|
||||
</generator>
|
||||
</id>
|
||||
<version name="version" access="property" type="long" />
|
||||
|
||||
<property name="directChargedHours" access="field" />
|
||||
<property name="indirectChargedHours" access="field" />
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ package org.navalplanner.business.test.orders.daos;
|
|||
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
|
@ -414,4 +415,20 @@ public class OrderElementDAOTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSumChargedHoursRelation() throws InstanceNotFoundException {
|
||||
OrderLine orderLine = createValidOrderLine();
|
||||
|
||||
orderLine.getSumChargedHours().setDirectChargedHours(8);
|
||||
orderLine.getSumChargedHours().setIndirectChargedHours(10);
|
||||
|
||||
orderElementDAO.save(orderLine);
|
||||
|
||||
OrderElement orderLineCopy = orderElementDAO.find(orderLine.getId());
|
||||
|
||||
assertEquals(orderLine.getSumChargedHours().getId(),
|
||||
orderLineCopy.getSumChargedHours().getId());
|
||||
|
||||
assertTrue(orderLineCopy.getSumChargedHours().getTotalChargedHours().equals(18));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue