package org.splat.simer;
+import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.splat.kernel.InvalidPropertyException;
-import org.splat.kernel.MissedPropertyException;
-import org.splat.kernel.MultiplyDefinedException;
+import org.splat.exception.BusinessException;
import org.splat.service.SearchService;
import org.splat.service.dto.Proxy;
import org.splat.service.dto.ScenarioDTO;
* The selected source study id.
*/
private long _fromStudyId = 0;
+ /**
+ * The selected source scenario id.
+ */
+ private long _fromScenarioId = 0;
+
+ /**
+ * The selected source study id.
+ */
+ private int _finalStep = 0;
/**
* Injected search service.
*/
/**
* {@inheritDoc}
*
+ * @throws IOException
+ *
* @see org.splat.simer.NewStudyAction#doCreate()
*/
@Override
- public String doCreate() throws InvalidPropertyException,
- MissedPropertyException, MultiplyDefinedException {
+ public String doCreate() throws BusinessException, IOException {
String res = super.doCreate();
if (SUCCESS.equals(res)) {
// Copy content from the selected study
+ getScenarioService().copyStudyContent(_fromStudyId,
+ _fromScenarioId, _finalStep, getOpenStudy().getIndex());
+ } else {
+ doInitialize();
}
return res;
}
public String doInitialize() {
// Initialize contexts list, study title and menus.
super.doInitialize();
-
+
// Initialize source studies list, scenarios list and steps list
-
+
// Get visible studies
StudySearchFilterDTO filter = new StudySearchFilterDTO();
if (getConnectedUser() != null) {
filter.setConnectedUserId(getConnectedUser().getIndex());
}
List<Proxy> studies = getSearchService().selectStudiesWhere(filter);
-
+
// Fill the studies list
- for (Proxy study: studies) {
+ _studies.put(0L, "");
+ for (Proxy study : studies) {
_studies.put(study.getIndex(), study.getTitle());
}
-
+
// Fill lists of scenarios and steps according to the selected study
if (_fromStudyId > 0 && _studies.containsKey(_fromStudyId)) {
// Get scenarios from the selected study
- List<ScenarioDTO> scens = getScenarioService().getStudyScenarios(_fromStudyId);
- for (ScenarioDTO scen: scens) {
+ List<ScenarioDTO> scens = getScenarioService().getStudyScenarios(
+ _fromStudyId);
+ for (ScenarioDTO scen : scens) {
_scenarios.put(scen.getIndex(), scen.getTitle());
}
// Fill steps
- for (ProjectSettingsService.Step step: getStepsConfigService().getSteps()) {
- _steps.put(step.getNumber(), getText("folder.step." + step.getNumber()));
+ for (ProjectSettingsService.Step step : getStepsConfigService()
+ .getSteps()) {
+ _steps.put(step.getNumber(),
+ getText("folder.step." + step.getNumber()));
}
}
final StepsConfigService stepsConfigService) {
_stepsConfigService = stepsConfigService;
}
+
+ /**
+ * Get the fromScenarioId.
+ *
+ * @return the fromScenarioId
+ */
+ public long getFromScenarioId() {
+ return _fromScenarioId;
+ }
+
+ /**
+ * Set the fromScenarioId.
+ *
+ * @param fromScenarioId
+ * the fromScenarioId to set
+ */
+ public void setFromScenarioId(final long fromScenarioId) {
+ _fromScenarioId = fromScenarioId;
+ }
+
+ /**
+ * Get the finalStep.
+ *
+ * @return the finalStep
+ */
+ public int getFinalStep() {
+ return _finalStep;
+ }
+
+ /**
+ * Set the finalStep.
+ *
+ * @param finalStep
+ * the finalStep to set
+ */
+ public void setFinalStep(final int finalStep) {
+ _finalStep = finalStep;
+ }
}