ItEr29S12CUVisualizacionModelosPlanificacionItEr28S15: Fixed validation exceptions raised by save milestone operation

This commit is contained in:
Lorenzo Tilve 2009-10-09 10:44:03 +02:00 committed by Javier Moran Rua
parent efde2ddefc
commit 90afb1c903
12 changed files with 67 additions and 22 deletions

View file

@ -238,7 +238,7 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
add(position, list);
}
IDomainAndBeansMapper<T> getMapper() {
public IDomainAndBeansMapper<T> getMapper() {
return mapper;
}

View file

@ -20,6 +20,7 @@
package org.zkoss.ganttz.extensions;
import org.zkoss.ganttz.adapters.IDomainAndBeansMapper;
import org.zkoss.ganttz.adapters.PlannerConfiguration;
import org.zkoss.ganttz.data.Position;
import org.zkoss.ganttz.timetracker.TimeTracker;
@ -77,6 +78,11 @@ public class ContextRelativeToOtherComponent<T> implements IContext<T> {
@Override
public TimeTracker getTimeTracker() {
return context.getTimeTracker();
}
@Override
public IDomainAndBeansMapper<T> getMapper() {
return context.getMapper();
};
}

View file

@ -20,6 +20,7 @@
package org.zkoss.ganttz.extensions;
import org.zkoss.ganttz.adapters.IDomainAndBeansMapper;
import org.zkoss.ganttz.adapters.PlannerConfiguration;
import org.zkoss.ganttz.data.Position;
import org.zkoss.ganttz.data.Task;
@ -84,4 +85,9 @@ public class ContextWithPlannerTask<T> implements IContextWithPlannerTask<T> {
return context.getTimeTracker();
}
@Override
public IDomainAndBeansMapper<T> getMapper() {
return context.getMapper();
}
}

View file

@ -23,6 +23,7 @@ package org.zkoss.ganttz.extensions;
import org.zkoss.ganttz.Planner;
import org.zkoss.ganttz.TaskComponent;
import org.zkoss.ganttz.adapters.IAdapterToTaskFundamentalProperties;
import org.zkoss.ganttz.adapters.IDomainAndBeansMapper;
import org.zkoss.ganttz.adapters.IStructureNavigator;
import org.zkoss.ganttz.adapters.PlannerConfiguration;
import org.zkoss.ganttz.data.Position;
@ -96,4 +97,6 @@ public interface IContext<T> {
*/
TimeTracker getTimeTracker();
IDomainAndBeansMapper<T> getMapper();
}

View file

@ -0,0 +1,24 @@
/*
* This file is part of ###PROJECT_NAME###
*
* 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/>.
*/
// making believe to zk that milestone.js exists, so it doesn't throw error.
// zkMilestone code is in tasklist.js
//This way there can be a schedule showing only tasks or taskcontainers.

View file

@ -28,7 +28,6 @@ import java.util.List;
import java.util.Set;
import org.apache.commons.lang.Validate;
import org.hibernate.validator.NotNull;
import org.navalplanner.business.calendars.entities.BaseCalendar;
import org.navalplanner.business.common.BaseEntity;
import org.navalplanner.business.orders.entities.OrderElement;
@ -51,7 +50,6 @@ public abstract class TaskElement extends BaseEntity {
protected Integer shareOfHours;
@NotNull
private OrderElement orderElement;
private Set<Dependency> dependenciesWithThisOrigin = new HashSet<Dependency>();

View file

@ -27,12 +27,10 @@ import java.util.List;
import java.util.Set;
import org.apache.commons.lang.Validate;
import org.hibernate.validator.NotNull;
import org.joda.time.DateTime;
import org.joda.time.Days;
import org.navalplanner.business.common.IValidable;
import org.navalplanner.business.common.exceptions.ValidationException;
import org.navalplanner.business.orders.entities.HoursGroup;
import org.navalplanner.business.orders.entities.OrderElement;
/**
@ -46,9 +44,6 @@ public class TaskMilestone extends TaskElement implements IValidable {
return milestone;
}
@NotNull
private HoursGroup hoursGroup;
private CalculatedValue calculatedValue = CalculatedValue.END_DATE;
private Set<ResourceAllocation<?>> resourceAllocations = new HashSet<ResourceAllocation<?>>();

View file

@ -15,7 +15,7 @@
<property name="startDate" type="timestamp" />
<property name="endDate" type="timestamp" />
<many-to-one name="orderElement" cascade="none" column="ORDER_ELEMENT_ID"/>
<many-to-one name="orderElement" cascade="none" column="ORDER_ELEMENT_ID" not-null="false" />
<many-to-one name="parent" class="TaskGroup" cascade="none" column="parent"/>

View file

@ -29,6 +29,7 @@ import static org.junit.Assert.assertTrue;
import static org.navalplanner.business.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_FILE;
import static org.navalplanner.business.test.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_TEST_FILE;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@ -36,6 +37,8 @@ import javax.annotation.Resource;
import org.hibernate.SessionFactory;
import org.junit.Before;
import org.hibernate.validator.ClassValidator;
import org.hibernate.validator.InvalidValue;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.navalplanner.business.IDataBootstrap;
@ -161,16 +164,22 @@ public class TaskElementDAOTest {
@Test
public void canSaveMilestone() {
TaskMilestone milestone = createValidTaskMilestone();
ClassValidator<TaskMilestone> validator = new ClassValidator<TaskMilestone>(
TaskMilestone.class);
InvalidValue[] invalidValues = validator.getInvalidValues(milestone);
if (invalidValues.length > 0) {
throw new RuntimeException(Arrays.toString(invalidValues));
}
taskElementDAO.save(milestone);
// flushAndEvict(milestone);
// TaskElement fromDB;
// try {
// fromDB = taskElementDAO.find(milestone.getId());
// } catch (InstanceNotFoundException e) {
// throw new RuntimeException(e);
// }
// assertThat(fromDB.getId(), equalTo(milestone.getId()));
// assertThat(fromDB, is(TaskMilestone.class));
flushAndEvict(milestone);
TaskElement fromDB;
try {
fromDB = taskElementDAO.find(milestone.getId());
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}
assertThat(fromDB.getId(), equalTo(milestone.getId()));
assertThat(fromDB, is(TaskMilestone.class));
}
@Test

View file

@ -49,7 +49,8 @@ public class AddMilestoneCommand implements IAddMilestoneCommand {
TaskElement task) {
TaskMilestone milestone = new TaskMilestone();
milestone.setName("new milestone");
context.add(milestone);
context.add(context.getMapper().findPositionFor(task), milestone);
planningState.added(milestone);
}
@Override

View file

@ -90,7 +90,10 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
@Override
public boolean isMilestone(TaskElement object) {
return object instanceof TaskMilestone;
if (object != null) {
return object instanceof TaskMilestone;
}
return false;
}
}

View file

@ -212,8 +212,8 @@ min-width:200px;
width: 15px;
float: right;
position:relative;
left: 8px;
top: -3px;
left: 7px;
top: -13px;
}
.row .closed {