[Bug #744] Fixes HibernateException when retrieving 'progressType' from Configuration
This commit is contained in:
parent
d631b20b3d
commit
2b28b757f8
6 changed files with 44 additions and 44 deletions
|
|
@ -786,6 +786,10 @@ public class Planner extends HtmlMacroComponent {
|
|||
return isShowingResources;
|
||||
}
|
||||
|
||||
public boolean isShowingAdvances() {
|
||||
return isShowingAdvances;
|
||||
}
|
||||
|
||||
public boolean isExpandAll() {
|
||||
return isExpandAll;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -553,12 +553,17 @@ public class TaskComponent extends Div implements AfterCompose {
|
|||
}
|
||||
|
||||
public void updateCompletion(String progressType) {
|
||||
int startPixels = this.task.getBeginDate().toPixels(getMapper());
|
||||
if (task.isShowingAdvances()) {
|
||||
int startPixels = this.task.getBeginDate().toPixels(getMapper());
|
||||
|
||||
String widthAdvancePercentage = pixelsFromStartUntil(startPixels,
|
||||
this.task.getAdvanceEndDate(progressType)) + "px";
|
||||
response(null, new AuInvoke(this, "resizeCompletion2Advance",
|
||||
widthAdvancePercentage));
|
||||
String widthAdvancePercentage = pixelsFromStartUntil(startPixels,
|
||||
this.task.getAdvanceEndDate(progressType)) + "px";
|
||||
response(null, new AuInvoke(this, "resizeCompletion2Advance",
|
||||
widthAdvancePercentage));
|
||||
} else {
|
||||
response(null,
|
||||
new AuInvoke(this, "resizeCompletion2Advance", "0px"));
|
||||
}
|
||||
}
|
||||
|
||||
private int pixelsFromStartUntil(int startPixels, GanttDate until) {
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ import java.util.Set;
|
|||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.AssertTrue;
|
||||
import org.navalplanner.business.common.Registry;
|
||||
import org.navalplanner.business.common.daos.IConfigurationDAO;
|
||||
import org.navalplanner.business.common.entities.ProgressType;
|
||||
import org.navalplanner.business.orders.entities.TaskSource;
|
||||
import org.navalplanner.business.scenarios.entities.Scenario;
|
||||
|
|
@ -50,8 +48,6 @@ public class TaskGroup extends TaskElement {
|
|||
return create(taskGroup, taskSource);
|
||||
}
|
||||
|
||||
private IConfigurationDAO configurationDAO;
|
||||
|
||||
private List<TaskElement> taskElements = new ArrayList<TaskElement>();
|
||||
|
||||
private PlanningData planningData;
|
||||
|
|
@ -245,32 +241,6 @@ public class TaskGroup extends TaskElement {
|
|||
planningData.update(criticalPath);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For root tasks, retrieves the advance percentage from configured progress type,
|
||||
* this is necessary as in the company view the advance progress shown in each task,
|
||||
* if not progress type selected, is the one set in the configuration
|
||||
*/
|
||||
@Override
|
||||
public BigDecimal getAdvancePercentage() {
|
||||
if (isTaskRoot(this)) {
|
||||
final ProgressType progressType = getProgressTypeFromConfiguration();
|
||||
return getAdvancePercentage(progressType);
|
||||
}
|
||||
return super.getAdvancePercentage();
|
||||
}
|
||||
|
||||
private ProgressType getProgressTypeFromConfiguration() {
|
||||
return getConfigurationDAO().getConfiguration().getProgressType();
|
||||
}
|
||||
|
||||
private IConfigurationDAO getConfigurationDAO() {
|
||||
if (configurationDAO == null) {
|
||||
configurationDAO = Registry.getConfigurationDAO();
|
||||
}
|
||||
return configurationDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a root task, retrieves the progress selected by the progressType
|
||||
* If there's not progressType, return taskElement.advancePercentage
|
||||
|
|
@ -292,8 +262,4 @@ public class TaskGroup extends TaskElement {
|
|||
return taskGroup.getParent() == null;
|
||||
}
|
||||
|
||||
public BigDecimal getRawAdvancePercentage() {
|
||||
return super.getAdvancePercentage();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -53,6 +53,8 @@ import org.joda.time.Seconds;
|
|||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.common.IAdHocTransactionService;
|
||||
import org.navalplanner.business.common.IOnTransaction;
|
||||
import org.navalplanner.business.common.Registry;
|
||||
import org.navalplanner.business.common.daos.IConfigurationDAO;
|
||||
import org.navalplanner.business.common.entities.ProgressType;
|
||||
import org.navalplanner.business.labels.entities.Label;
|
||||
import org.navalplanner.business.orders.daos.IOrderElementDAO;
|
||||
|
|
@ -155,6 +157,9 @@ public class TaskElementAdapter implements ITaskElementAdapter {
|
|||
@Autowired
|
||||
private IResourceAllocationDAO resourceAllocationDAO;
|
||||
|
||||
@Autowired
|
||||
private IConfigurationDAO configurationDAO;
|
||||
|
||||
private Scenario scenario;
|
||||
|
||||
|
||||
|
|
@ -468,13 +473,34 @@ public class TaskElementAdapter implements ITaskElementAdapter {
|
|||
@Override
|
||||
public GanttDate getAdvanceEndDate() {
|
||||
BigDecimal advancePercentage = BigDecimal.ZERO;
|
||||
|
||||
if (taskElement.getOrderElement() != null) {
|
||||
advancePercentage = taskElement
|
||||
.getAdvancePercentage();
|
||||
if (isTaskRoot(taskElement)) {
|
||||
ProgressType progressType = getProgressTypeFromConfiguration();
|
||||
advancePercentage = taskElement.getAdvancePercentage(progressType);
|
||||
|
||||
} else {
|
||||
advancePercentage = taskElement.getAdvancePercentage();
|
||||
}
|
||||
}
|
||||
return getAdvanceEndDate(advancePercentage);
|
||||
}
|
||||
|
||||
private boolean isTaskRoot(TaskElement taskElement) {
|
||||
return taskElement instanceof TaskGroup && taskElement.getParent() == null;
|
||||
}
|
||||
|
||||
private ProgressType getProgressTypeFromConfiguration() {
|
||||
return transactionService
|
||||
.runOnReadOnlyTransaction(new IOnTransaction<ProgressType>() {
|
||||
@Override
|
||||
public ProgressType execute() {
|
||||
return configurationDAO.getConfiguration()
|
||||
.getProgressType();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private GanttDate getAdvanceEndDate(BigDecimal advancePercentage) {
|
||||
Integer hours = Integer.valueOf(0);
|
||||
if (taskElement.getOrderElement() != null) {
|
||||
|
|
|
|||
|
|
@ -158,8 +158,7 @@ public class CompanyPlanningController implements Composer {
|
|||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
ProgressType progressType = getSelectedProgressType();
|
||||
planner.updateCompletion(progressType.toString());
|
||||
planner.updateCompletion(getSelectedProgressType().toString());
|
||||
}
|
||||
|
||||
private ProgressType getSelectedProgressType() {
|
||||
|
|
|
|||
|
|
@ -1585,7 +1585,7 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
public void update() {
|
||||
TaskGroup rootTask = planningState.getRootTask();
|
||||
|
||||
setAdvancePercentage(rootTask.getRawAdvancePercentage());
|
||||
setAdvancePercentage(rootTask.getAdvancePercentage());
|
||||
setCriticalPathByDuration(rootTask.getCriticalPathProgressByDuration());
|
||||
setCriticalPathByNumHours(rootTask.getCriticalPathProgressByNumHours());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue