import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.splat.kernel.Do;
import org.splat.dal.bo.kernel.User;
-import org.splat.service.DocumentTypeService;
-import org.splat.service.PublicationService;
-import org.splat.service.ScenarioService;
-import org.splat.service.SimulationContextService;
-import org.splat.service.StepService;
-import org.splat.service.technical.RepositoryService;
-import org.splat.simer.Action;
-import org.splat.simer.OpenStudy;
import org.splat.dal.bo.som.ConvertsRelation;
-import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.ProgressState;
import org.splat.dal.bo.som.Scenario;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.dal.dao.som.Database;
+import org.splat.kernel.Do;
+import org.splat.service.DocumentTypeService;
+import org.splat.service.PublicationService;
+import org.splat.service.ScenarioService;
+import org.splat.service.SimulationContextService;
+import org.splat.service.StepService;
+import org.splat.service.technical.RepositoryService;
+import org.splat.simer.Action;
+import org.splat.simer.OpenStudy;
import org.splat.som.Step;
public class SaveDocumentAction extends Action {
.setAuthor(user));
// Writing the uploaded file into the created document
File target = credoc.getSourceFile().asFile();
- if (target.exists())
+ if (target.exists()) {
target.delete();
+ }
Do.copy(upfile, target); // Instead of rename for keeping the "uploaded" file for further use
// upfile.renameTo(target);
credoc, "brep");
target = export.getTo().asFile();
- if (target.exists())
+ if (target.exists()) {
target.delete();
+ }
Do.copy(upfile, target); // Instead of rename for keeping the "uploaded" file for further use
}
// 2. Addition of simulation contexts
* @param publicationService
* the publicationService to set
*/
- public void setPublicationService(PublicationService publicationService) {
+ public void setPublicationService(final PublicationService publicationService) {
_publicationService = publicationService;
}
* @param scenarioService
* the scenarioService to set
*/
- public void setScenarioService(ScenarioService scenarioService) {
+ public void setScenarioService(final ScenarioService scenarioService) {
_scenarioService = scenarioService;
}
* @param stepService
* the stepService to set
*/
- public void setStepService(StepService stepService) {
+ public void setStepService(final StepService stepService) {
_stepService = stepService;
}
Publication current = mystudy.getSelectedDocument();
Document.Properties dprop = new Document.Properties();
dprop.setAuthor(user);
- if (summary.length() > 0)
+ if (summary.length() > 0) {
dprop.setDescription(summary);
+ }
Publication next = getStepService().versionDocument(step, current,
dprop);
// Writing the uploaded file into the created document
File target = next.getSourceFile().asFile();
- if (target.exists())
+ if (target.exists()) {
target.delete();
+ }
Do.copy(upfile, target); // Instead of rename for keeping the "uploaded" file for further use
// upfile.renameTo(target);
"brep");
String fname = table[0];
- for (int i = 1; i < table.length - 1; i++)
+ for (int i = 1; i < table.length - 1; i++) {
fname = fname + table[i];
+ }
upfile = new File(upath + fname + ".brep");
upfile.renameTo(export.getTo().asFile());
}
return summary;
}
- public void setDescription(String summary) {
+ public void setDescription(final String summary) {
// -------------------------------------------
this.summary = summary;
}
- public void setDocumentName(String name) {
+ public void setDocumentName(final String name) {
// -----------------------------------------
this.docname = name;
}
- public void setDocumentState(String state) {
+ public void setDocumentState(final String state) {
// -------------------------------------------
this.state = ProgressState.valueOf(state);
}
- public void setDocumentType(String value) {
+ public void setDocumentType(final String value) {
// ------------------------------------------
this.doctype = Integer.valueOf(value);
}
- public void setFileName(String name) {
+ public void setFileName(final String name) {
// -------------------------------------
this.filename = name;
}
// Private service
// ==============================================================================================================================
- private void setupDefaultUses(DocumentType type) {
+ private void setupDefaultUses(final DocumentType type) {
Set<DocumentType> uses = type.getDefaultUses();
for (Iterator<DocumentType> i = uses.iterator(); i.hasNext();) {
DocumentType usetype = i.next();
List<Document> usedoc = mystudy.collectInvolvedDocuments(usetype);
- if (usedoc.isEmpty())
+ if (usedoc.isEmpty()) {
setupDefaultUses(usetype);
- else
+ } else {
defuses.addAll(usedoc);
+ }
}
}
* @param repositoryService
* the repositoryService to set
*/
- public void setRepositoryService(RepositoryService repositoryService) {
+ public void setRepositoryService(final RepositoryService repositoryService) {
_repositoryService = repositoryService;
}
* the simulationContextService to set
*/
public void setSimulationContextService(
- SimulationContextService simulationContextService) {
+ final SimulationContextService simulationContextService) {
_simulationContextService = simulationContextService;
}
* @param documentTypeService
* the documentTypeService to set
*/
- public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+ public void setDocumentTypeService(final DocumentTypeService documentTypeService) {
_documentTypeService = documentTypeService;
}
}
\ No newline at end of file