/**
* logger for the service.
*/
- public final static AppLogger logger = AppLogger
+ public final static AppLogger LOG = AppLogger
.getLogger(SimulationContextServiceImpl.class);
+
+ /**
+ * Step property name.
+ */
+ public final static String STEP_PROP = "step";
+
/**
* Injected simulation context DAO.
*/
/**
* Injected project settings service.
*/
- private ProjectSettingsService _projectSettingsService;
+ private ProjectSettingsService _projectSettings;
/**
* Get simulation contexts which are currently in the given state.
result = clist.get(0); // Supposed being the most used one if many exist
}
} catch (InvalidPropertyException error) {
- logger.info("Attempt to select a simulation context \""
+ LOG.info("Attempt to select a simulation context \""
+ celt.getName() + "\" with an invalid value.");
}
return result;
public List<SimulationContextType> selectAllTypes() {
// Useless to order by names as the result mixes localized
// and non localized types
- return getSimulationContextTypeDAO().getAll(Order.asc("step"));
+ return getSimulationContextTypeDAO().getAll(Order.asc(STEP_PROP));
}
/**
// .append("'");
// }
// query = query.append(" order by step asc");
- Criterion aCondition = Restrictions.eq("step", step[0].getNumber());
+ Criterion aCondition = Restrictions.eq(STEP_PROP, step[0].getNumber());
for (int i = 1; i < step.length; i++) { // Useless to order as the result mixes localized and non localized types
- aCondition = Restrictions.or(aCondition, Restrictions.eq("step",
+ aCondition = Restrictions.or(aCondition, Restrictions.eq(STEP_PROP,
step[i].getNumber()));
}
return getSimulationContextTypeDAO().getFilteredList(aCondition,
- Order.asc("step"));
+ Order.asc(STEP_PROP));
}
/**
// }
// query = query.append(order);
Criterion aCondition = null;
- Order anOrder = Order.asc("step");
+ Order anOrder = Order.asc(STEP_PROP);
if (step != null) {
- aCondition = Restrictions.eq("step", step.getNumber());
+ aCondition = Restrictions.eq(STEP_PROP, step.getNumber());
anOrder = Order.desc("state"); // APPROVED (upper case A) is grater than inCHECK (lower case i)
}
if (state != null) {
aCondition = Restrictions.and(aCondition, Restrictions.eq("state",
state));
if (step != null) {
- if (state != ProgressState.APPROVED) {
- anOrder = Order.asc("name");
- } else {
+ if (state == ProgressState.APPROVED) {
anOrder = null; // Approved types are localized
+ } else {
+ anOrder = Order.asc("name");
}
}
}
* @return true if approval succeeded
*/
public boolean approve(final SimulationContext simCtx) {
- if (simCtx.getProgressState() != ProgressState.inCHECK) {
- return false;
- }
- simCtx.setProgressState(ProgressState.APPROVED); // The type name is supposed being localized
- if (simCtx.isSaved()) {
- getSimulationContextDAO().update(simCtx);
+ boolean res = (simCtx.getProgressState() == ProgressState.inCHECK);
+ if (res) {
+ simCtx.setProgressState(ProgressState.APPROVED); // The type name is supposed being localized
+ if (simCtx.isSaved()) {
+ getSimulationContextDAO().update(simCtx);
+ }
}
- return true;
+ return res;
}
/**
* @return Project settings service
*/
private ProjectSettingsService getProjectSettings() {
- return _projectSettingsService;
+ return _projectSettings;
}
/**
* project settings service
*/
public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
- _projectSettingsService = projectSettingsService;
+ _projectSettings = projectSettingsService;
}
}