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;
public class SaveDocumentAction extends Action {
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = -3364960833373200115L;
+
+ /**
+ * Current open study.
+ */
private OpenStudy mystudy = null;
private int doctype = 0;
private String filename = null;
private ProgressState state = null;
private List<Document> defuses = null;
private String summary = null; // Summary of changes in the new version
+ /**
+ * Injected scenario service.
+ */
private ScenarioService _scenarioService;
+ /**
+ * Injected publication service.
+ */
private PublicationService _publicationService;
+ /**
+ * Injected step service.
+ */
private StepService _stepService;
-
- private static final long serialVersionUID = -3364960833373200115L;
+ /**
+ * Injected document type service.
+ */
+ private DocumentTypeService _documentTypeService;
+ /**
+ * Injected repository service.
+ */
+ private RepositoryService _repositoryService;
+ /**
+ * Injected simulation context service.
+ */
+ private SimulationContextService _simulationContextService;
// ==============================================================================================================================
// Action methods
public String doSave() {
// -----------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
try {
// Getting user inputs
mystudy = getOpenStudy();
User user = getConnectedUser();
Step step = mystudy.getSelectedStep();
- DocumentType type = Document.selectType(doctype);
+ DocumentType type = getDocumentTypeService().selectType(doctype);
// File updir = Database.getDownloadDirectory(user);
// File upfile = new File(updir.getPath() + "/" + filename);
- String upath = Database.getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file between users
+ String upath = getRepositoryService().getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file
+ // between users
File upfile = new File(upath + filename);
String[] table = filename.split("\\x2E");
String format = table[table.length - 1];
connex.flush();
Document.Properties dprop = new Document.Properties();
- Publication credoc = step.createDocument(dprop.setName(docname)
- .setType(type).setFormat(format).setAuthor(user));
+ Publication credoc = getStepService().createDocument(
+ step,
+ dprop.setName(docname).setType(type).setFormat(format)
+ .setAuthor(user));
// Writing the uploaded file into the created document
File target = credoc.getSourceFile().asFile();
if (target.exists())
// 1. Conversion of the document to internal format, if required
// TODO: The following code is temporary, waiting for the support of converters
if (format.equals("part")) {
- ConvertsRelation export = credoc.attach("brep");
+ ConvertsRelation export = getPublicationService().attach(
+ credoc, "brep");
target = export.getTo().asFile();
if (target.exists())
// 2. Addition of simulation contexts
if (type.equals("model")) { // Set the characteristics of the mesh
SimulationContext.Properties cprop = new SimulationContext.Properties();
- SimulationContextType ctype = SimulationContext
+ SimulationContextType ctype = getSimulationContextService()
.selectType("model");
- SimulationContext context = Database.selectSimulationContext(
- ctype, "Éléments finis");
+ SimulationContext context = getSimulationContextService()
+ .selectSimulationContext(ctype, "Éléments finis");
if (context == null) {
getStepService().addSimulationContext(step,
cprop.setType(ctype).setValue("Éléments finis"));
} else {
getStepService().addSimulationContext(step, context);
}
- ctype = SimulationContext.selectType("element");
- context = Database.selectSimulationContext(ctype, "Surfacique");
+ ctype = getSimulationContextService().selectType("element");
+ context = getSimulationContextService()
+ .selectSimulationContext(ctype, "Surfacique");
if (context == null) {
getStepService().addSimulationContext(step,
cprop.setType(ctype).setValue("Surfacique"));
} else {
getStepService().addSimulationContext(step, context);
}
- ctype = SimulationContext.selectType("shape");
- context = Database.selectSimulationContext(ctype, "Triangles");
+ ctype = getSimulationContextService().selectType("shape");
+ context = getSimulationContextService()
+ .selectSimulationContext(ctype, "Triangles");
if (context == null) {
getStepService().addSimulationContext(step,
cprop.setType(ctype).setValue("Triangles"));
public String doVersion() {
// --------------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
try {
// Getting user inputs
Step step = mystudy.getSelectedStep();
// File updir = Database.getDownloadDirectory(user);
// File upfile = new File(updir.getPath() + "/" + filename);
- String upath = Database.getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file between users
+ String upath = getRepositoryService().getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file
+ // between users
File upfile = new File(upath + filename);
String[] table = filename.split("\\x2E");
String format = table[table.length - 1];
if (summary.length() > 0)
dprop.setDescription(summary);
- Publication next = step.versionDocument(current, dprop);
+ Publication next = getStepService().versionDocument(step, current,
+ dprop);
// Writing the uploaded file into the created document
File target = next.getSourceFile().asFile();
// 1. Conversion of the document to internal format, if required
// TODO: The following code is temporary, waiting for the support of converters
if (format.equals("part")) {
- ConvertsRelation export = next.attach("brep");
+ ConvertsRelation export = getPublicationService().attach(next,
+ "brep");
String fname = table[0];
for (int i = 1; i < table.length - 1; i++)
// ==============================================================================================================================
private void setupDefaultUses(DocumentType type) {
- // -------------------------------------------------
Set<DocumentType> uses = type.getDefaultUses();
for (Iterator<DocumentType> i = uses.iterator(); i.hasNext();) {
defuses.addAll(usedoc);
}
}
+
+ /**
+ * Get the repositoryService.
+ *
+ * @return the repositoryService
+ */
+ public RepositoryService getRepositoryService() {
+ return _repositoryService;
+ }
+
+ /**
+ * Set the repositoryService.
+ *
+ * @param repositoryService
+ * the repositoryService to set
+ */
+ public void setRepositoryService(RepositoryService repositoryService) {
+ _repositoryService = repositoryService;
+ }
+
+ /**
+ * Get the simulationContextService.
+ *
+ * @return the simulationContextService
+ */
+ public SimulationContextService getSimulationContextService() {
+ return _simulationContextService;
+ }
+
+ /**
+ * Set the simulationContextService.
+ *
+ * @param simulationContextService
+ * the simulationContextService to set
+ */
+ public void setSimulationContextService(
+ SimulationContextService simulationContextService) {
+ _simulationContextService = simulationContextService;
+ }
+
+ /**
+ * Get the documentTypeService.
+ *
+ * @return the documentTypeService
+ */
+ public DocumentTypeService getDocumentTypeService() {
+ return _documentTypeService;
+ }
+
+ /**
+ * Set the documentTypeService.
+ *
+ * @param documentTypeService
+ * the documentTypeService to set
+ */
+ public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+ _documentTypeService = documentTypeService;
+ }
}
\ No newline at end of file