return this;
}
+ /**
+ * Get the date.
+ * @return the date
+ */
+ public Date getDate() {
+ return date;
+ }
+
public Properties setDescription(String summary)
throws InvalidPropertyException {
if (summary.length() == 0)
this.name = name;
return this;
}
+
+ public String getName() {
+ return this.name;
+ }
public Properties setOwner(ProjectElement owner) {
this.owner = owner;
return this;
}
+ public ProjectElement getOwner() {
+ return this.owner;
+ }
// Required only for passing search arguments
public Properties setReference(String did)
throws InvalidPropertyException {
state = ProgressState.inWORK; // Promoted when saving this document
version = new Revision().toString();
}
- Study owner = null;
- if (dprop.owner instanceof Study)
- owner = (Study) dprop.owner;
- else
- owner = ((Scenario) dprop.owner).getOwnerStudy();
-
- ProjectSettingsService.Step step = ProjectSettingsServiceImpl
- .getStep(this.step);
- SimpleDateFormat tostring = new SimpleDateFormat("yyyy");
- String year = tostring.format(owner.getDate());
if (name == null) { // Newed document
this.name = "%n"; // Named later at publication
this.history = -1; // Marks the document as undefined for future assignment
}
- String filename = generateEncodedName(owner);
- String path;
-
- path = owner.getReference();
- did = new StringBuffer(path).append(".%").append(suformat).toString(); // Document reference
- path = new StringBuffer(year).append("/").append(path).append("/")
- .append(step.getPath()) // File path relative to the repository vault
- .append(filename).append(".").append(myfile.getFormat()) // File name and extension
- .toString();
- myfile.changePath(path);
}
// ==============================================================================================================================
// --------------------------------------
return lasdate;
}
+
+ public void setLastModificationDate(Date aDate) {
+ lasdate = aDate;
+ }
public String getFormat() {
// --------------------------
else
return name;
}
+
+ /**
+ * Set document title.
+ * @param aTitle document title to set
+ */
+ public void setTitle(String aTitle) {
+ this.name = aTitle;
+ }
public DocumentType getType() {
// ------------------------------
/**
* Returns the version number of this document. The version number, when exists, is either of the internal form (m.n.s) usable for
- * building a Revision object, or any string in case of external document (document with EXTERN state).<br/>
- * <br/>
- * Note: document slots have a version number equal to "0.0.0".
+ * building a Revision object, or any string in case of external document (document with EXTERN state).<br/> <br/> Note: document slots
+ * have a version number equal to "0.0.0".
*
* @return the version number of this document, or null if this is EXTERN.
* @see #isUndefined()
ProjectSettingsService.Step step) {
// --------------------------------------------------------------------------
Integer number = step.getNumber();
- String query = new StringBuffer("from DocumentType")
- .append(" where step like '%-").append(number).append("-%'")
- .toString();
+ String query = new StringBuffer("from DocumentType").append(
+ " where step like '%-").append(number).append("-%'").toString();
List<DocumentType> types = Database.getSession().createQuery(query)
.list();
return false;
DecimalFormat tostring = new DecimalFormat(suformat);
- did = did.replace("%" + suformat,
- tostring.format(scope.getLastLocalIndex()));
+ did = did.replace("%" + suformat, tostring.format(scope
+ .getLastLocalIndex()));
return true;
}
Database.getSession().update(this);
}
- /**
- * Defines this document.
- *
- * @param dprop
- * the properties of the document
- *
- * @see Step#createDocument(Properties)
- * @see #isUndefined()
- */
- public void initialize(Properties dprop) throws MissedPropertyException,
- InvalidPropertyException, NotApplicableException {
- // --------------------------------------------
- if (!this.isUndefined())
- throw new NotApplicableException(
- "Cannot initialize an existing Document");
- if (dprop.name == null)
- throw new MissedPropertyException("name");
- if (dprop.name.length() == 0)
- throw new InvalidPropertyException("name");
- if (dprop.owner == null)
- throw new MissedPropertyException("owner");
- // if (dprop.owner instanceof Study && !ProjectSettings.getStep(step).appliesTo(Study.class)) {
- // throw new InvalidPropertyException("step");
- // }
- name = dprop.name;
- myfile.changePath(myfile.getRelativePath().replace("%n",
- getEncodedRootName((Study) dprop.owner)));
- if (history == -1)
- history = 0;
- if (dprop.date == null) {
- Calendar current = Calendar.getInstance();
- lasdate = current.getTime(); // Today
- } else {
- lasdate = dprop.date;
- }
- Database.getSession().update(this);
- }
-
public boolean promote(Timestamp stamp) {
// -------------------------------------------
ProgressState newstate = null;
// TODO: Promote documents using this one
// }
- // ==============================================================================================================================
- // Private services
- // ==============================================================================================================================
-
- private String generateEncodedName(Study scope) {
- // ------------------------------------------------
- StringBuffer encoding = new StringBuffer();
- FileNaming scheme = getProjectSettingsService().getFileNamingScheme();
- DecimalFormat tostring = new DecimalFormat(suformat);
-
- int number = getStudyService().generateLocalIndex(scope);
-
- if (scheme == FileNaming.encoded) {
- encoding.append(scope.getReference()).append(".")
- .append(tostring.format(number));
- } else { // title and (temporarily) asis
- encoding.append(name).append(".").append(tostring.format(number));
- }
- return encoding.toString();
- }
-
- private String getEncodedRootName(Study scope) {
- // -----------------------------------------------
- FileNaming scheme = getProjectSettingsService().getFileNamingScheme();
-
- if (scheme == FileNaming.encoded)
- return scope.getReference();
- else
- return name;
- }
-
/**
* @return
*/
public void setStudyService(StudyService studyService) {
_studyService = studyService;
}
+
+ /**
+ * Get the step.
+ * @return the step
+ */
+ public int getStep() {
+ return step;
+ }
+
+ /**
+ * Set the step.
+ * @param step the step to set
+ */
+ public void setStep(int step) {
+ this.step = step;
+ }
+
+ /**
+ * Get the did.
+ * @return the did
+ */
+ public String getDid() {
+ return did;
+ }
+
+ /**
+ * Set the did.
+ * @param did the did to set
+ */
+ public void setDid(String did) {
+ this.did = did;
+ }
+
+ /**
+ * Get the myfile.
+ * @return the myfile
+ */
+ public File getFile() {
+ return myfile;
+ }
+
+ /**
+ * Set the myfile.
+ * @param myfile the myfile to set
+ */
+ public void setFile(File myfile) {
+ this.myfile = myfile;
+ }
+
+ /**
+ * Get the history.
+ * @return the history
+ */
+ public int getHistory() {
+ return history;
+ }
+
+ /**
+ * Set the history.
+ * @param history the history to set
+ */
+ public void setHistory(int history) {
+ this.history = history;
+ }
}
\ No newline at end of file
// Protected service
// ==============================================================================================================================
- protected void changePath (String path) {
+ public void changePath (String path) {
// ---------------------------------------
this.path = path;
this.myfile = null;
* @version $Revision$
*****************************************************************************/
-package org.splat.service;
+package org.splat.service;
+
+import org.splat.dal.bo.som.Document;
+import org.splat.dal.bo.som.Publication;
+import org.splat.dal.bo.som.Document.Properties;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.NotApplicableException;
+import org.splat.som.Step;
/**
* @author RKV
- *
+ *
*/
public interface DocumentService {
+ /**
+ * Defines this document.
+ *
+ * @param dprop
+ * the properties of the document
+ *
+ * @see Step#createDocument(Properties)
+ * @see #isUndefined()
+ */
+ public void initialize(Document aDoc, Properties dprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ NotApplicableException;
+
+ public void generateDocumentId(Document aDoc, Properties dprop);
}
package org.splat.service;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+
+import org.splat.dal.bo.som.Document;
+import org.splat.dal.bo.som.Scenario;
+import org.splat.dal.bo.som.Study;
+import org.splat.dal.bo.som.Document.Properties;
+import org.splat.dal.dao.som.Database;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.NotApplicableException;
+import org.splat.service.technical.ProjectSettingsService;
+import org.splat.service.technical.ProjectSettingsServiceImpl;
+import org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming;
+import org.splat.som.Step;
+
/**
* @author RKV
*
*/
public class DocumentServiceImpl implements DocumentService {
+ private StudyService _studyService;
+ private ProjectSettingsService _projectSettingsService;
+
+ public void generateDocumentId(Document aDoc, Properties dprop) {
+ Study owner = null;
+ if (dprop.getOwner() instanceof Study)
+ owner = (Study) dprop.getOwner();
+ else
+ owner = ((Scenario) dprop.getOwner()).getOwnerStudy();
+
+ SimpleDateFormat tostring = new SimpleDateFormat("yyyy");
+ String year = tostring.format(owner.getDate());
+ String filename = generateEncodedName(aDoc, owner);
+ String path = owner.getReference();
+ ProjectSettingsService.Step step = ProjectSettingsServiceImpl
+ .getStep(aDoc.getStep());
+ aDoc.setDid( new StringBuffer(path).append(".%").append(aDoc.suformat).toString()); // Document reference
+ path = new StringBuffer(year).append("/").append(path).append("/")
+ .append(step.getPath()) // File path relative to the repository vault
+ .append(filename).append(".").append(aDoc.getFile().getFormat()) // File name and extension
+ .toString();
+ aDoc.getFile().changePath(path);
+ }
+
+ private String generateEncodedName(Document aDoc, Study scope) {
+ // ------------------------------------------------
+ StringBuffer encoding = new StringBuffer();
+ FileNaming scheme = getProjectSettings().getFileNamingScheme();
+ DecimalFormat tostring = new DecimalFormat(aDoc.suformat);
+
+ int number = getStudyService().generateLocalIndex(scope);
+
+ if (scheme == FileNaming.encoded) {
+ encoding.append(scope.getReference()).append(".").append(
+ tostring.format(number));
+ } else { // title and (temporarily) asis
+ encoding.append(aDoc.getTitle()).append(".").append(tostring.format(number));
+ }
+ return encoding.toString();
+ }
+
+ private String getEncodedRootName(Document aDoc, Study scope) {
+ // -----------------------------------------------
+ FileNaming scheme = getProjectSettings().getFileNamingScheme();
+
+ if (scheme == FileNaming.encoded)
+ return scope.getReference();
+ else
+ return aDoc.getTitle();
+ }
+
+ /**
+ * Defines this document.
+ *
+ * @param dprop
+ * the properties of the document
+ *
+ * @see Step#createDocument(Properties)
+ * @see #isUndefined()
+ */
+ public void initialize(Document aDoc, Properties dprop) throws MissedPropertyException,
+ InvalidPropertyException, NotApplicableException {
+ // --------------------------------------------
+ if (!aDoc.isUndefined())
+ throw new NotApplicableException(
+ "Cannot initialize an existing Document");
+ if (dprop.getName() == null)
+ throw new MissedPropertyException("name");
+ if (dprop.getName().length() == 0)
+ throw new InvalidPropertyException("name");
+ if (dprop.getOwner() == null)
+ throw new MissedPropertyException("owner");
+ // if (dprop.owner instanceof Study && !ProjectSettings.getStep(step).appliesTo(Study.class)) {
+ // throw new InvalidPropertyException("step");
+ // }
+ aDoc.setTitle(dprop.getName());
+ aDoc.getFile().changePath(aDoc.getFile().getRelativePath().replace("%n",
+ getEncodedRootName(aDoc, (Study) dprop.getOwner())));
+ if (aDoc.getHistory() == -1)
+ aDoc.setHistory( 0 );
+ if (dprop.getDate() == null) {
+ Calendar current = Calendar.getInstance();
+ aDoc.setLastModificationDate(current.getTime()); // Today
+ } else {
+ aDoc.setLastModificationDate(dprop.getDate());
+ }
+ Database.getSession().update(aDoc);
+ }
+
+ /**
+ * Get the studyService.
+ * @return the studyService
+ */
+ public StudyService getStudyService() {
+ return _studyService;
+ }
+
+ /**
+ * Set the studyService.
+ * @param studyService the studyService to set
+ */
+ public void setStudyService(StudyService studyService) {
+ _studyService = studyService;
+ }
+
+ /**
+ * Get project settings.
+ *
+ * @return Project settings service
+ */
+ private ProjectSettingsService getProjectSettings() {
+ return _projectSettingsService;
+ }
+
+ /**
+ * Set project settings service.
+ *
+ * @param projectSettingsService
+ * project settings service
+ */
+ public void setProjectSettings(ProjectSettingsService projectSettingsService) {
+ _projectSettingsService = projectSettingsService;
+ }
+
}
*/
public boolean isStudyResult (DocumentType aType) {
// -------------------------------
- List<ProjectSettingsService.Step> step = getProjectSettingsService().getAllSteps();
+ List<ProjectSettingsService.Step> step = getProjectSettings().getAllSteps();
ProjectSettingsService.Step lastep = step.get( step.size()-1 );
return (aType.isResultOf(lastep));
}
/**
* @return
*/
- public ProjectSettingsService getProjectSettingsService() {
+ public ProjectSettingsService getProjectSettings() {
return _projectSettingsService;
}
- public void setProjectSettingsService(
+ public void setProjectSettings(
ProjectSettingsService projectSettingsService) {
_projectSettingsService = projectSettingsService;
}
throw new FileNotFoundException();
if (state == ProgressState.inWORK || state == ProgressState.EXTERN) {
- Database.getSession().save(this); // Must be done before updating the study in order to fix this final (rid-based) hascode
+ Database.getSession().save(aPublication); // Must be done before updating the study in order to fix this final (rid-based) hascode
aPublication.value().updateAs(state);
} else {
DocumentType mytype = aPublication.value().getType();
aScenario.setUser(user);
aScenario.setLastModificationDate(Calendar.getInstance().getTime());
- Database.getSession().update(this);
+ Database.getSession().update(aScenario);
return true;
}
package org.splat.service;
+import java.io.IOException;
+
+import org.splat.dal.bo.som.Document;
+import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MismatchException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
+import org.splat.kernel.NotApplicableException;
import org.splat.som.Step;
/**
*/
public interface StepService {
+ public Publication createDocument(Step aStep, Document.Properties dprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ MultiplyDefinedException, IOException;
+
+ public Publication assignDocument(Step aStep, Document.Properties dprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ NotApplicableException;
+
+ public Publication versionDocument(Step aStep, Publication base,
+ Document.Properties dprop) throws MissedPropertyException,
+ InvalidPropertyException, MultiplyDefinedException, IOException,
+ MismatchException;
+
public SimulationContext addSimulationContext(Step aStep,
SimulationContext.Properties dprop) throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException,
package org.splat.service;
+import java.io.File;
+import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import org.hibernate.Session;
+import org.splat.dal.bo.kernel.Relation;
+import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.KnowledgeElement;
+import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.Scenario;
import org.splat.dal.bo.som.SimulationContext;
+import org.splat.dal.bo.som.Study;
+import org.splat.dal.bo.som.UsedByRelation;
+import org.splat.dal.bo.som.UsesRelation;
+import org.splat.dal.bo.som.VersionsRelation;
import org.splat.dal.dao.som.Database;
import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MismatchException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
+import org.splat.kernel.NotApplicableException;
import org.splat.service.technical.IndexService;
import org.splat.service.technical.IndexServiceImpl;
+import org.splat.som.Revision;
import org.splat.som.Step;
/**
public class StepServiceImpl implements StepService {
private IndexService _indexService;
+ private DocumentService _documentService;
public SimulationContext addSimulationContext(Step aStep,
SimulationContext.Properties dprop) throws MissedPropertyException,
return true;
}
+ public Publication createDocument (Step aStep, Document.Properties dprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException, IOException {
+ // -------------------------------------------------------------
+ Document newdoc = new Document(dprop.setOwner(aStep.getOwner()).setStep(aStep.getStep()));
+ getDocumentService().generateDocumentId(newdoc, dprop);
+
+// Creation of the save directory
+ File wdir = newdoc.getSaveDirectory();
+ if (!wdir.exists()) if (!wdir.mkdirs()) throw new IOException("Cannot create the repository vault directory");
+
+// Identification and save
+ newdoc.buildReferenceFrom(aStep.getOwnerStudy());
+ Database.getSession().save(newdoc);
+
+ return new Publication(newdoc, aStep.getOwner());
+ }
+
+ public Publication assignDocument (Step aStep, Document.Properties dprop) throws MissedPropertyException, InvalidPropertyException, NotApplicableException {
+ // -------------------------------------------------------------
+ String refid = dprop.getReference();
+ if (refid == null) return null;
+
+ Document slot = Database.selectDocument(refid, new Revision().toString());
+ if ( slot == null ) return null;
+ if (!slot.isUndefined()) return null; // Should not happen
+
+ getDocumentService().initialize(slot, dprop.setOwner(aStep.getOwnerStudy()));
+ return new Publication(slot, aStep.getOwner());
+ }
+
+ public Publication versionDocument (Step aStep, Publication base) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException, IOException, MismatchException {
+ // -----------------------------------------------------
+ return versionDocument(aStep, base, new Document.Properties());
+ }
+
+ public Publication versionDocument (Step aStep, Publication base, String reason) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException, IOException, MismatchException {
+ // --------------------------------------------------------------------
+ return versionDocument(aStep, base, new Document.Properties().setDescription(reason));
+ }
+
+ public Publication versionDocument (Step aStep, Publication base, Document.Properties dprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException, IOException, MismatchException {
+ // --------------------------------------------------------------------------------
+ Document previous = base.value();
+
+ dprop.setDocument(previous); // Initializes the Step property
+ if (dprop.getStep().getNumber() != aStep.getNumber()) throw new MismatchException();
+
+ if (dprop.getAuthor() == null) dprop.setAuthor(previous.getAuthor());
+ String summary = dprop.getDescription();
+
+// Creation of the document
+ Document newdoc = new Document(dprop.setOwner(aStep.getOwner()).setStep(aStep.getStep()));
+ getDocumentService().generateDocumentId(newdoc, dprop);
+ newdoc.buildReferenceFrom(aStep.getOwner(), previous);
+ Database.getSession().save(newdoc);
+
+// Versioning
+ if (summary == null) newdoc.addRelation( new VersionsRelation(newdoc, previous) );
+ else newdoc.addRelation( new VersionsRelation(newdoc, previous, summary) );
+
+// Update of usedby relations, if exist
+ List<Relation> relist = previous.getRelations(UsedByRelation.class);
+ Study scope = aStep.getOwnerStudy();
+ for (Iterator<Relation> i=relist.iterator(); i.hasNext();) {
+ UsedByRelation relation = (UsedByRelation)i.next();
+ Document relatedoc = relation.getTo();
+ if (scope.shares(relatedoc)) relatedoc.addRelation( new UsesRelation(relatedoc, newdoc) );
+ else relation.moveTo(newdoc);
+ }
+ return new Publication(newdoc, aStep.getOwner());
+ }
+
/**
* @return
*/
public void setIndexService(IndexService indexService) {
_indexService = indexService;
}
+
+ /**
+ * Get the documentService.
+ * @return the documentService
+ */
+ public DocumentService getDocumentService() {
+ return _documentService;
+ }
+
+ /**
+ * Set the documentService.
+ * @param documentService the documentService to set
+ */
+ public void setDocumentService(DocumentService documentService) {
+ _documentService = documentService;
+ }
}
return added;
}
- /**
- * @return
- */
- public StepService getStepService() {
- return _stepService;
- }
-
- public void setStepService(StepService stepService) {
- _stepService = stepService;
- }
-
public SimulationContext addProjectContext(Study aStudy,
SimulationContext context) {
// ----------------------------------------------------------------------
ProjectElementService projectElementService) {
_projectElementService = projectElementService;
}
+
+ /**
+ * Get the stepService.
+ * @return the stepService
+ */
+ public StepService getStepService() {
+ return _stepService;
+ }
+
+ /**
+ * Set the stepService.
+ * @param stepService the stepService to set
+ */
+ public void setStepService(StepService stepService) {
+ _stepService = stepService;
+ }
}
import org.splat.dal.bo.som.UsedByRelation;
import org.splat.dal.bo.som.UsesRelation;
import org.splat.dal.bo.som.VersionsRelation;
+import org.splat.dal.bo.som.Document.Properties;
import org.splat.dal.dao.som.Database;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MismatchException;
// Public member functions
// ==============================================================================================================================
- public Publication createDocument (Document.Properties dprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException, IOException {
-// -------------------------------------------------------------
- Document newdoc = new Document(dprop.setOwner(owner).setStep(step));
-
-// Creation of the save directory
- File wdir = newdoc.getSaveDirectory();
- if (!wdir.exists()) if (!wdir.mkdirs()) throw new IOException("Cannot create the repository vault directory");
-
-// Identification and save
- newdoc.buildReferenceFrom(getOwnerStudy());
- Database.getSession().save(newdoc);
-
- return new Publication(newdoc, owner);
- }
-
- public Publication assignDocument (Document.Properties dprop) throws MissedPropertyException, InvalidPropertyException, NotApplicableException {
-// -------------------------------------------------------------
- String refid = dprop.getReference();
- if (refid == null) return null;
-
- Document slot = Database.selectDocument(refid, new Revision().toString());
- if ( slot == null ) return null;
- if (!slot.isUndefined()) return null; // Should not happen
-
- slot.initialize(dprop.setOwner(getOwnerStudy()));
- return new Publication(slot, owner);
- }
-
- public Publication versionDocument (Publication base) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException, IOException, MismatchException {
-// -----------------------------------------------------
- return versionDocument(base, new Document.Properties());
- }
-
- public Publication versionDocument (Publication base, String reason) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException, IOException, MismatchException {
-// --------------------------------------------------------------------
- return versionDocument(base, new Document.Properties().setDescription(reason));
- }
-
- public Publication versionDocument (Publication base, Document.Properties dprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException, IOException, MismatchException {
-// --------------------------------------------------------------------------------
- Document previous = base.value();
-
- dprop.setDocument(previous); // Initializes the Step property
- if (dprop.getStep().getNumber() != this.step.getNumber()) throw new MismatchException();
-
- if (dprop.getAuthor() == null) dprop.setAuthor(previous.getAuthor());
- String summary = dprop.getDescription();
-
-// Creation of the document
- Document newdoc = new Document(dprop.setOwner(owner).setStep(step));
- newdoc.buildReferenceFrom(getOwner(), previous);
- Database.getSession().save(newdoc);
-
-// Versioning
- if (summary == null) newdoc.addRelation( new VersionsRelation(newdoc, previous) );
- else newdoc.addRelation( new VersionsRelation(newdoc, previous, summary) );
-
-// Update of usedby relations, if exist
- List<Relation> relist = previous.getRelations(UsedByRelation.class);
- Study scope = getOwnerStudy();
- for (Iterator<Relation> i=relist.iterator(); i.hasNext();) {
- UsedByRelation relation = (UsedByRelation)i.next();
- Document relatedoc = relation.getTo();
- if (scope.shares(relatedoc)) relatedoc.addRelation( new UsesRelation(relatedoc, newdoc) );
- else relation.moveTo(newdoc);
- }
- return new Publication(newdoc, owner);
- }
-
public User getActor () {
// -----------------------
return actor;
<bean id="documentTypeService"
class="org.splat.service.DocumentTypeServiceImpl">
- <property name="projectSettingsService"
- ref="projectSettings" />
+ <property name="projectSettings" ref="projectSettings" />
+ </bean>
+
+ <bean id="documentService"
+ class="org.splat.service.DocumentServiceImpl">
+ <property name="projectSettings" ref="projectSettings" />
+ <property name="studyService" ref="studyService" />
</bean>
<bean id="knowledgeElementService"
<bean id="stepService" class="org.splat.service.StepServiceImpl">
<property name="indexService" ref="indexService" />
+ <property name="documentService" ref="documentService" />
</bean>
<bean id="studyService"
connex.flush();
Document.Properties dprop = new Document.Properties();
- Publication credoc = step.createDocument(dprop.setName(docname)
+ 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 (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();
package org.splat.simer;
+
/**
*
* @author Daniel Brunier-Coulin
import org.splat.dal.bo.som.VersionsRelation;
import org.splat.wapp.PopupMenu;
-
public class DocumentFacade implements HistoryFacade {
- private OpenObject owner;
- private Publication me;
- private Document my; // Published document
- private ProgressState state; // Document state
- private String version; // My document version in customized format
- private State display; // Presentation state
- private String surl; // URL of the source file
- private String format; // Extension of the source file
- private String icon; // Corresponding icon
- private String sharing; // Icon qualifying sharing between scenarios of a same study
- private String updated; // Icon qualifying versioning from the previous study version
- private String size;
- private String date;
- private String description;
- private List<DocumentFacade> uses;
- private List<FileFacade> exports;
- private List<HistoryFacade> history;
- private PopupMenu popup;
+ private OpenObject owner;
+ private Publication me;
+ private Document my; // Published document
+ private ProgressState state; // Document state
+ private String version; // My document version in customized format
+ private State display; // Presentation state
+ private String surl; // URL of the source file
+ private String format; // Extension of the source file
+ private String icon; // Corresponding icon
+ private String sharing; // Icon qualifying sharing between scenarios of a same study
+ private String updated; // Icon qualifying versioning from the previous study version
+ private String size;
+ private String date;
+ private String description;
+ private List<DocumentFacade> uses;
+ private List<FileFacade> exports;
+ private List<HistoryFacade> history;
+ private PopupMenu popup;
private ProjectSettingsService _projectSettingsService;
private PublicationService _publicationService;
-
- private enum State { closed, open, deepopen }
-
-// ==============================================================================================================================
-// Constructors
-// ==============================================================================================================================
-
- public DocumentFacade (OpenObject opened, Publication represented) {
-// ------------------------------------------------------------------
- owner = opened;
- me = represented;
- my = me.value();
- state = my.getProgressState();
- display = State.closed;
- description = null;
- uses = null;
- exports = null;
- history = null;
- popup = null;
-
- this.refresh(); // Initializes the presentation of my document
- }
-/**
- * Constructs the facade of a document presented in the history folder.
- *
- * @param represented the represented history document
- */
- private DocumentFacade (OpenObject opened, Document represented) {
-// ----------------------------------------------------------------
- owner = opened;
- me = null; // Marks the history context
- my = represented;
- state = my.getProgressState(); // In reality, HISTORY
- display = State.open; // Because the given document is a history document
- description = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale()).getString("history.creation") + " " + my.getAuthor().toString();
- uses = null;
- exports = null;
- history = null;
- popup = null;
-
- this.refresh(); // Initializes the presentation of my document
- }
-
-// ==============================================================================================================================
-// Public member functions
-// ==============================================================================================================================
-
- public void develop () {
-// -------------------
- if (display != State.open) { // Opening the document
- if (uses == null) {
- List<Publication> relist = me.getRelations(UsesRelation.class);
-
- uses = new ArrayList<DocumentFacade>(relist.size());
- for (Iterator<Publication> i=relist.iterator(); i.hasNext();) {
- Publication used = i.next();
- Integer index = used.getIndex();
- DocumentFacade facade = OpenObject.docpres.get(index);
- if (facade == null) {
- facade = new DocumentFacade(owner, used);
- OpenObject.docpres.put(index, facade);
- }
- uses.add(facade);
- }
- }
- if (exports == null) {
- List<Relation> relation = my.getRelations(ConvertsRelation.class);
-
- exports = new ArrayList<FileFacade>(relation.size());
- for (Iterator<Relation> i=relation.iterator(); i.hasNext();) {
- ConvertsRelation export = (ConvertsRelation)i.next();
- exports.add( new FileFacade(export) );
- }
- }
- if (history == null) {
- if (my.getPreviousVersion() != null || state == ProgressState.inCHECK || state == ProgressState.APPROVED) history = new ArrayList<HistoryFacade>();
- }
- display = State.open;
- } else { // Opening the history of document, if exist
- if (history.isEmpty()) collectHistory(my);
- display = State.deepopen;
- }
- }
-
- public void reduce () {
-// ---------------------
- if (display == State.deepopen) display = State.open;
- }
-
- public void reduceAll () {
-// ------------------------
- display = State.closed;
- }
-
-// ==============================================================================================================================
-// Getters
-// ==============================================================================================================================
-
- public List<FileFacade> getAttachments () {
-// ------------------------------------------
- return exports;
- }
- public String getDate () {
-// ------------------------
- return date;
- }
- public String getDescription () {
-// -------------------------------
- return description;
- }
- public String getEditIcon () {
-// ----------------------------
- return "icon.ed" + state + ".png";
- }
- public String getFileIcon () {
-// ----------------------------
- return icon;
- }
- public List<HistoryFacade> getHistory () {
-// ----------------------------------------
- return history;
- }
- public String getIndex () {
-// -------------------------
- return String.valueOf(my.getIndex());
- }
- public PopupMenu getPopup () { // Contextualizes the pop-up
-// ----------------------------
- popup.setContext("document", new DocumentRights(owner.getUser(), me));
- return popup; // callers must "use" the returned pop-up before getting another pop-up
- }
- public String getPresentationState () {
-// -------------------------------------
- return display.toString();
- }
- public String getProgressState () {
-// ---------------------------------
- return state.toString();
- }
- public String getSharingIcon () {
-// -------------------------------
- return sharing;
- }
- public String getSize () {
-// ------------------------
- return size;
- }
- public String getStateIcon () {
-// -----------------------------
- return "icon." + state + ".png";
- }
- public String getTitle () {
-// -------------------------
- return my.getTitle();
- }
- public String getURL () {
-// -----------------------
- return surl;
- }
- public List<DocumentFacade> getUses () {
-// ---------------------------------------
- return uses;
- }
- public String getVersion () {
-// ---------------------------
- return version;
- }
- public String getVersioningIcon () {
-// ----------------------------------
- return updated;
- }
- public boolean isFacadeOf (Publication represented) {
-// ---------------------------------------------------
- return me.equals(represented);
- }
-// ==============================================================================================================================
-// Protected services
-// ==============================================================================================================================
-
- protected void refresh () {
-// -------------------------
- ResourceBundle custom = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
- DecimalFormat sizstring = new DecimalFormat(custom.getString("size.format")); // Locale size display format
- SimpleDateFormat datstring = new SimpleDateFormat(custom.getString("date.format")); // Locale date display format
- Revision.Format verstring = new Revision.Format(getProjectSettings().getRevisionPattern());
- String path = my.getSourceFile().getRelativePath();
- String[] mapping = ApplicationSettings.getViewersMapping();
-
- for (int i=0; i<mapping.length; i++) {
- org.splat.dal.bo.som.File export = my.getAttachedFile(mapping[i]);
- if (export == null) continue;
- path = export.getRelativePath();
- break;
- }
- surl = ApplicationSettings.getRepositoryURL() + path;
- surl = surl.replaceAll("'", "\\\\'");
- format = my.getFormat();
- if (format.equals("xml")) format = XMLDocument.getActualFormat(my.getSourceFile().asFile());
-
-// Document state (overridable by the publication - see below)
- state = my.getProgressState();
- version = my.getVersion(); // May be null
-
-// Icons definition
- icon = "icon." + format + ".png";
- sharing = "image.hold.gif";
- updated = "image.hold.gif";
- File image = new File(ApplicationSettings.getApplicationSkinPath() + icon);
- if (!image.exists()) icon = "icon.any.png";
-
- if (me != null) {
- if (me.getOwnerStudy().shares(my)) {
- sharing = "image.share.png";
- updated = "icon.hold.png";
- }
- if (me.isOutdated()) state = ProgressState.inWORK; // Overrides the document state
-
- } else { // Facade in the history folder
- if (!my.isVersioned()) { // History of the last version
- if (state != ProgressState.inWORK) icon = "icon.inWORK.png";
- else icon = "icon." + state.toString() + ".png";
- } else
- if ( my.isPublished()) {
- sharing = "image.share.png"; // Not correct if published in a previous version of the study
- updated = "icon.hold.png";
- }
- }
-// Document description
- VersionsRelation versions = (VersionsRelation)my.getFirstRelation(VersionsRelation.class);
- if (versions != null) {
- description = versions.getDescription();
- }
-// File details
- if (state != ProgressState.EXTERN) version = verstring.format(version);
- size = sizstring.format(my.getSourceFile().asFile().length()/1000);
- date = datstring.format(my.getLastModificationDate());
-
-// Refresh of the history in case of promotion
- if (display == State.deepopen) {
- history.clear();
- collectHistory(my);
- }
-// Popup menus
- if (me == null) return; // No pop-up (yet) in the history folder
- if (state == ProgressState.EXTERN) popup = ApplicationSettings.getPopupMenu("extern");
- else if (state == ProgressState.inWORK) popup = ApplicationSettings.getPopupMenu("editable");
- else if (state == ProgressState.inDRAFT) popup = ApplicationSettings.getPopupMenu("reviewable");
- else if (state == ProgressState.APPROVED) popup = ApplicationSettings.getPopupMenu("approved");
- else { //(state == ProgressState.inCHECK)
- DocumentType mytype = me.value().getType(); // Only result documents need to be approved
- Step mystep = getPublicationService().getInvolvedStep(me);
- if (mytype.isResultOf(mystep.getStep())) popup = ApplicationSettings.getPopupMenu("approvable");
- else popup = ApplicationSettings.getPopupMenu("notresult");
- }
- }
-
- protected void setVersioned () {
-// ------------------------------
- updated = "image.modified.png";
- }
-
-// ==============================================================================================================================
-// Private services
-// ==============================================================================================================================
-
- private void collectHistory (Document given) {
-// --------------------------------------------
- VersionsRelation versions = (VersionsRelation)given.getFirstRelation(VersionsRelation.class);
- Timestamp[] stamp = given.getStamps(); // Stamps in ascending order of date
-
- for (int i=stamp.length-1; i>-1; i--) history.add( new StampFacade(stamp[i]) );
- history.add( new DocumentFacade(owner, given) );
- if (versions != null) collectHistory(versions.getTo());
- }
-
- /**
- * Get project settings.
+
+ private enum State {
+ closed, open, deepopen
+ }
+
+ // ==============================================================================================================================
+ // Constructors
+ // ==============================================================================================================================
+
+ public DocumentFacade(OpenObject opened, Publication represented,
+ ProjectSettingsService projectSettings,
+ PublicationService publicationService) {
+ // ------------------------------------------------------------------
+ setProjectSettings(projectSettings);
+ setPublicationService(publicationService);
+ owner = opened;
+ me = represented;
+ my = me.value();
+ state = my.getProgressState();
+ display = State.closed;
+ description = null;
+ uses = null;
+ exports = null;
+ history = null;
+ popup = null;
+
+ this.refresh(); // Initializes the presentation of my document
+ }
+
+ /**
+ * Constructs the facade of a document presented in the history folder.
+ *
+ * @param represented
+ * the represented history document
+ */
+ private DocumentFacade(OpenObject opened, Document represented,
+ ProjectSettingsService projectSettings,
+ PublicationService publicationService) {
+ // ----------------------------------------------------------------
+ setProjectSettings(projectSettings);
+ setPublicationService(publicationService);
+ owner = opened;
+ me = null; // Marks the history context
+ my = represented;
+ state = my.getProgressState(); // In reality, HISTORY
+ display = State.open; // Because the given document is a history document
+ description = ResourceBundle.getBundle("som",
+ ApplicationSettings.getCurrentLocale()).getString(
+ "history.creation")
+ + " " + my.getAuthor().toString();
+ uses = null;
+ exports = null;
+ history = null;
+ popup = null;
+
+ this.refresh(); // Initializes the presentation of my document
+ }
+
+ // ==============================================================================================================================
+ // Public member functions
+ // ==============================================================================================================================
+
+ public void develop() {
+ // -------------------
+ if (display != State.open) { // Opening the document
+ if (uses == null) {
+ List<Publication> relist = me.getRelations(UsesRelation.class);
+
+ uses = new ArrayList<DocumentFacade>(relist.size());
+ for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
+ Publication used = i.next();
+ Integer index = used.getIndex();
+ DocumentFacade facade = OpenObject.docpres.get(index);
+ if (facade == null) {
+ facade = new DocumentFacade(owner, used, getProjectSettings(), getPublicationService());
+ OpenObject.docpres.put(index, facade);
+ }
+ uses.add(facade);
+ }
+ }
+ if (exports == null) {
+ List<Relation> relation = my
+ .getRelations(ConvertsRelation.class);
+
+ exports = new ArrayList<FileFacade>(relation.size());
+ for (Iterator<Relation> i = relation.iterator(); i.hasNext();) {
+ ConvertsRelation export = (ConvertsRelation) i.next();
+ exports.add(new FileFacade(export));
+ }
+ }
+ if (history == null) {
+ if (my.getPreviousVersion() != null
+ || state == ProgressState.inCHECK
+ || state == ProgressState.APPROVED)
+ history = new ArrayList<HistoryFacade>();
+ }
+ display = State.open;
+ } else { // Opening the history of document, if exist
+ if (history.isEmpty())
+ collectHistory(my);
+ display = State.deepopen;
+ }
+ }
+
+ public void reduce() {
+ // ---------------------
+ if (display == State.deepopen)
+ display = State.open;
+ }
+
+ public void reduceAll() {
+ // ------------------------
+ display = State.closed;
+ }
+
+ // ==============================================================================================================================
+ // Getters
+ // ==============================================================================================================================
+
+ public List<FileFacade> getAttachments() {
+ // ------------------------------------------
+ return exports;
+ }
+
+ public String getDate() {
+ // ------------------------
+ return date;
+ }
+
+ public String getDescription() {
+ // -------------------------------
+ return description;
+ }
+
+ public String getEditIcon() {
+ // ----------------------------
+ return "icon.ed" + state + ".png";
+ }
+
+ public String getFileIcon() {
+ // ----------------------------
+ return icon;
+ }
+
+ public List<HistoryFacade> getHistory() {
+ // ----------------------------------------
+ return history;
+ }
+
+ public String getIndex() {
+ // -------------------------
+ return String.valueOf(my.getIndex());
+ }
+
+ public PopupMenu getPopup() { // Contextualizes the pop-up
+ // ----------------------------
+ popup.setContext("document", new DocumentRights(owner.getUser(), me));
+ return popup; // callers must "use" the returned pop-up before getting another pop-up
+ }
+
+ public String getPresentationState() {
+ // -------------------------------------
+ return display.toString();
+ }
+
+ public String getProgressState() {
+ // ---------------------------------
+ return state.toString();
+ }
+
+ public String getSharingIcon() {
+ // -------------------------------
+ return sharing;
+ }
+
+ public String getSize() {
+ // ------------------------
+ return size;
+ }
+
+ public String getStateIcon() {
+ // -----------------------------
+ return "icon." + state + ".png";
+ }
+
+ public String getTitle() {
+ // -------------------------
+ return my.getTitle();
+ }
+
+ public String getURL() {
+ // -----------------------
+ return surl;
+ }
+
+ public List<DocumentFacade> getUses() {
+ // ---------------------------------------
+ return uses;
+ }
+
+ public String getVersion() {
+ // ---------------------------
+ return version;
+ }
+
+ public String getVersioningIcon() {
+ // ----------------------------------
+ return updated;
+ }
+
+ public boolean isFacadeOf(Publication represented) {
+ // ---------------------------------------------------
+ return me.equals(represented);
+ }
+
+ // ==============================================================================================================================
+ // Protected services
+ // ==============================================================================================================================
+
+ protected void refresh() {
+ // -------------------------
+ ResourceBundle custom = ResourceBundle.getBundle("som",
+ ApplicationSettings.getCurrentLocale());
+ DecimalFormat sizstring = new DecimalFormat(custom
+ .getString("size.format")); // Locale size display format
+ SimpleDateFormat datstring = new SimpleDateFormat(custom
+ .getString("date.format")); // Locale date display format
+ Revision.Format verstring = new Revision.Format(getProjectSettings()
+ .getRevisionPattern());
+ String path = my.getSourceFile().getRelativePath();
+ String[] mapping = ApplicationSettings.getViewersMapping();
+
+ for (int i = 0; i < mapping.length; i++) {
+ org.splat.dal.bo.som.File export = my.getAttachedFile(mapping[i]);
+ if (export == null)
+ continue;
+ path = export.getRelativePath();
+ break;
+ }
+ surl = ApplicationSettings.getRepositoryURL() + path;
+ surl = surl.replaceAll("'", "\\\\'");
+ format = my.getFormat();
+ if (format.equals("xml"))
+ format = XMLDocument.getActualFormat(my.getSourceFile().asFile());
+
+ // Document state (overridable by the publication - see below)
+ state = my.getProgressState();
+ version = my.getVersion(); // May be null
+
+ // Icons definition
+ icon = "icon." + format + ".png";
+ sharing = "image.hold.gif";
+ updated = "image.hold.gif";
+ File image = new File(ApplicationSettings.getApplicationSkinPath()
+ + icon);
+ if (!image.exists())
+ icon = "icon.any.png";
+
+ if (me != null) {
+ if (me.getOwnerStudy().shares(my)) {
+ sharing = "image.share.png";
+ updated = "icon.hold.png";
+ }
+ if (me.isOutdated())
+ state = ProgressState.inWORK; // Overrides the document state
+
+ } else { // Facade in the history folder
+ if (!my.isVersioned()) { // History of the last version
+ if (state != ProgressState.inWORK)
+ icon = "icon.inWORK.png";
+ else
+ icon = "icon." + state.toString() + ".png";
+ } else if (my.isPublished()) {
+ sharing = "image.share.png"; // Not correct if published in a previous version of the study
+ updated = "icon.hold.png";
+ }
+ }
+ // Document description
+ VersionsRelation versions = (VersionsRelation) my
+ .getFirstRelation(VersionsRelation.class);
+ if (versions != null) {
+ description = versions.getDescription();
+ }
+ // File details
+ if (state != ProgressState.EXTERN)
+ version = verstring.format(version);
+ size = sizstring.format(my.getSourceFile().asFile().length() / 1000);
+ date = datstring.format(my.getLastModificationDate());
+
+ // Refresh of the history in case of promotion
+ if (display == State.deepopen) {
+ history.clear();
+ collectHistory(my);
+ }
+ // Popup menus
+ if (me == null)
+ return; // No pop-up (yet) in the history folder
+ if (state == ProgressState.EXTERN)
+ popup = ApplicationSettings.getPopupMenu("extern");
+ else if (state == ProgressState.inWORK)
+ popup = ApplicationSettings.getPopupMenu("editable");
+ else if (state == ProgressState.inDRAFT)
+ popup = ApplicationSettings.getPopupMenu("reviewable");
+ else if (state == ProgressState.APPROVED)
+ popup = ApplicationSettings.getPopupMenu("approved");
+ else { // (state == ProgressState.inCHECK)
+ DocumentType mytype = me.value().getType(); // Only result documents need to be approved
+ Step mystep = getPublicationService().getInvolvedStep(me);
+ if (mytype.isResultOf(mystep.getStep()))
+ popup = ApplicationSettings.getPopupMenu("approvable");
+ else
+ popup = ApplicationSettings.getPopupMenu("notresult");
+ }
+ }
+
+ protected void setVersioned() {
+ // ------------------------------
+ updated = "image.modified.png";
+ }
+
+ // ==============================================================================================================================
+ // Private services
+ // ==============================================================================================================================
+
+ private void collectHistory(Document given) {
+ // --------------------------------------------
+ VersionsRelation versions = (VersionsRelation) given
+ .getFirstRelation(VersionsRelation.class);
+ Timestamp[] stamp = given.getStamps(); // Stamps in ascending order of date
+
+ for (int i = stamp.length - 1; i > -1; i--)
+ history.add(new StampFacade(stamp[i]));
+ history.add(new DocumentFacade(owner, given, getProjectSettings(), getPublicationService()));
+ if (versions != null)
+ collectHistory(versions.getTo());
+ }
+
+ /**
+ * Get project settings.
+ *
* @return Project settings service
*/
private ProjectSettingsService getProjectSettings() {
/**
* Set project settings service.
- * @param projectSettingsService project settings service
+ *
+ * @param projectSettingsService
+ * project settings service
*/
- public void setProjectSettings(
- ProjectSettingsService projectSettingsService) {
+ public void setProjectSettings(ProjectSettingsService projectSettingsService) {
_projectSettingsService = projectSettingsService;
}
+
/**
* Get the publicationService.
*
import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.ProgressState;
import org.splat.service.PublicationService;
+import org.splat.service.StepService;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.DocumentType;
private String date = ""; // Date extracted from the imported file, if exist
private ProjectSettingsService _projectSettingsService;
private PublicationService _publicationService;
+ private StepService _stepService;
private static final long serialVersionUID = 2587822564883588556L;
if (docref.length() == 0) { // Importation of a foreign document
// TODO: Extract property of supported documents (DOCX, ODT...)
- addoc = step.createDocument(dprop.setName(docname)
+ addoc = getStepService().createDocument(step, dprop.setName(docname)
.setType(type).setFormat(table[table.length - 1])
.setAuthor(user));
updir = addoc.getSourceFile().asFile();
locale.getString("date.format"));
dprop.setDate(get.parse(date));
}
- addoc = step.assignDocument(dprop.setReference(docref).setName(
+ addoc = getStepService().assignDocument(step, dprop.setReference(docref).setName(
docname));
updir = addoc.getSourceFile().asFile();
if (logger.isInfoEnabled())
public void setPublicationService(PublicationService publicationService) {
_publicationService = publicationService;
}
+
+ /**
+ * Get the stepService.
+ * @return the stepService
+ */
+ public StepService getStepService() {
+ return _stepService;
+ }
+
+ /**
+ * Set the stepService.
+ * @param stepService the stepService to set
+ */
+ public void setStepService(StepService stepService) {
+ _stepService = stepService;
+ }
}
\ No newline at end of file
private KnowledgeElement myknelm;
private String credate;
private ProjectElementService _projectElementService;
- private ProjectSettingsService _projectSettingsService;
public class Menu extends SimpleMenu {
// ------------------------------------
_projectElementService = projectElementService;
}
- /**
- * Get project settings.
- * @return Project settings service
- */
- private ProjectSettingsService getProjectSettings() {
- return _projectSettingsService;
- }
-
- /**
- * Set project settings service.
- * @param projectSettingsService project settings service
- */
- public void setProjectSettings(
- ProjectSettingsService projectSettingsService) {
- _projectSettingsService = projectSettingsService;
- }
}
\ No newline at end of file
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.KnowledgeElementType;
import org.splat.dal.bo.som.ProgressState;
+import org.splat.service.PublicationService;
import org.splat.service.dto.Proxy;
+import org.splat.service.technical.ProjectSettingsService;
import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.Scenario;
import org.splat.som.Step;
protected Menu menu = null; // Left pane menu of this object
protected PopupMenu popup = null; // Pop-up menu of this object, if the user has write access
+ private ProjectSettingsService _projectSettingsService;
+ private PublicationService _publicationService;
protected static HashMap<Integer, DocumentFacade> docpres = null;
protected static HashMap<Integer, KnowledgeElementFacade> knowpres = null;
Integer index = present.getIndex();
DocumentFacade facade = docpres.get(index);
if (facade == null) {
- facade = new DocumentFacade(this, present);
+ facade = new DocumentFacade(this, present, getProjectSettings(), getPublicationService());
docpres.put(index, facade);
}
contents.add(facade);
contents = null;
}
}
+
+ /**
+ * Get project settings.
+ * @return Project settings service
+ */
+ public ProjectSettingsService getProjectSettings() {
+ return _projectSettingsService;
+ }
+
+ /**
+ * Get the publicationService.
+ *
+ * @return the publicationService
+ */
+ public PublicationService getPublicationService() {
+ return _publicationService;
+ }
+
+ /**
+ * Set project settings service.
+ * @param projectSettingsService project settings service
+ */
+ public void setProjectSettings(
+ ProjectSettingsService projectSettingsService) {
+ _projectSettingsService = projectSettingsService;
+ }
+
+ /**
+ * Set the publicationService.
+ *
+ * @param publicationService
+ * the publicationService to set
+ */
+ public void setPublicationService(PublicationService publicationService) {
+ _publicationService = publicationService;
+ }
}
\ No newline at end of file
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.ProgressState;
import org.splat.service.ProjectElementService;
+import org.splat.service.PublicationService;
import org.splat.service.ScenarioService;
+import org.splat.service.StepService;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.dal.bo.som.Publication;
import org.splat.som.Revision;
private String credate;
private String lasdate;
private Publication selecdoc;
- private ProjectSettingsService _projectSettingsService;
private ProjectElementService _projectElementService;
private ScenarioService _scenarioService;
-
- protected final static Logger logger = org.splat.simer.Action.logger;
+ private StepService _stepService;
+ protected final static Logger logger = org.splat.simer.Action.logger;
// ==============================================================================================================================
// Constructor
Step step = getSelectedStep(); // Should we check if the given document type is compatible ?
DocumentType type = Document.selectType(typename);
Document.Properties dprop = new Document.Properties();
- Document medoc = step.createDocument(dprop.setType(type).setFormat("xml").setAuthor(author)).value();
+ Document medoc = getStepService().createDocument(step, dprop.setType(type).setFormat("xml").setAuthor(author)).value();
transax.commit();
// Instantiation of the template into the user download directory
protected void add (Publication doc) {
// ------------------------------------
- DocumentFacade facade = new DocumentFacade(this, doc);
+ DocumentFacade facade = new DocumentFacade(this, doc, getProjectSettings(), getPublicationService());
boolean first = (contents.size() == 0);
docpres.put(doc.getIndex(), facade);
}
/**
- * Get project settings.
- * @return Project settings service
- */
- private ProjectSettingsService getProjectSettings() {
- return _projectSettingsService;
- }
-
- /**
- * Set project settings service.
- * @param projectSettingsService project settings service
- */
- public void setProjectSettings(
- ProjectSettingsService projectSettingsService) {
- _projectSettingsService = projectSettingsService;
- }
- /**
* Get the projectElementService.
*
* @return the projectElementService
public void setScenarioService(ScenarioService scenarioService) {
_scenarioService = scenarioService;
}
+
+ /**
+ * Get the stepService.
+ * @return the stepService
+ */
+ public StepService getStepService() {
+ return _stepService;
+ }
+
+ /**
+ * Set the stepService.
+ * @param stepService the stepService to set
+ */
+ public void setStepService(StepService stepService) {
+ _stepService = stepService;
+ }
}
\ No newline at end of file
import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.ProgressState;
import org.splat.service.PublicationService;
+import org.splat.service.StepService;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.dal.bo.som.Publication;
import org.splat.som.Revision;
private String date = ""; // Date extracted from the imported file, if exist
private ProjectSettingsService _projectSettingsService;
private PublicationService _publicationService;
+ private StepService _stepService;
private static final long serialVersionUID = -5702264003232132168L;
Publication next;
if (docver.length() == 0) { // Importation of a foreign document
- next = step.versionDocument(current, dprop.setAuthor(user)
+ next = getStepService().versionDocument(step, current, dprop.setAuthor(user)
.setDescription(summary));
updir = next.getSourceFile().asFile();
if (logger.isInfoEnabled())
locale.getString("date.format"));
dprop.setDate(get.parse(date));
}
- next = step.versionDocument(current, dprop.setAuthor(user)
+ next = getStepService().versionDocument(step, current, dprop.setAuthor(user)
.setDescription(summary));
updir = next.getSourceFile().asFile();
if (logger.isInfoEnabled())
public void setPublicationService(PublicationService publicationService) {
_publicationService = publicationService;
}
+
+ /**
+ * Get the stepService.
+ * @return the stepService
+ */
+ public StepService getStepService() {
+ return _stepService;
+ }
+
+ /**
+ * Set the stepService.
+ * @param stepService the stepService to set
+ */
+ public void setStepService(StepService stepService) {
+ _stepService = stepService;
+ }
}
\ No newline at end of file
tocheck = new Vector<SimulationContextFacade>(context.size());
for (Iterator<SimulationContext> i=context.iterator(); i.hasNext(); ) {
- tocheck.add( new SimulationContextFacade(i.next()) );
+ tocheck.add( new SimulationContextFacade(i.next(), getProjectSettings().getAllSteps()) );
}
selection = 0;
edition = null;
edition = next;
selected.add(edition);
}
- tocheck.add( new SimulationContextFacade(next) );
+ tocheck.add( new SimulationContextFacade(next, getProjectSettings().getAllSteps()) );
}
KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
List<Proxy> kelm = getSearchService().selectKnowledgeElementsWhere(kprop.setSimulationContexts(selected).setState(ProgressState.inWORK));
private String name;
private int at;
private ProgressState state;
- private ProjectSettingsService _projectSettingsService;
// ==============================================================================================================================
// Constructor
// ==============================================================================================================================
- public SimulationContextFacade (SimulationContext represented) {
+ public SimulationContextFacade (SimulationContext represented, List<ProjectSettingsService.Step> steps) {
// --------------------------------------------------------------
- List<ProjectSettingsService.Step> steps = getProjectSettings().getAllSteps();
SimulationContextType mytype;
my = represented;
// -------------------------
return my.getValue();
}
- /**
- * Get project settings.
- * @return Project settings service
- */
- private ProjectSettingsService getProjectSettings() {
- return _projectSettingsService;
- }
-
- /**
- * Set project settings service.
- * @param projectSettingsService project settings service
- */
- public void setProjectSettings(
- ProjectSettingsService projectSettingsService) {
- _projectSettingsService = projectSettingsService;
- }
}
\ No newline at end of file
<property name="projectElementService"
ref="projectElementService" />
<property name="projectSettings" ref="projectSettings" />
+ <property name="publicationService" ref="publicationService" />
<property name="scenarioService" ref="scenarioService" />
+ <property name="stepService" ref="stepService" />
</bean>
<bean id="openKnowledge" class="org.splat.simer.OpenKnowledge"
<bean id="importDocumentAction"
class="org.splat.simer.ImportDocumentAction" scope="prototype">
+ <property name="stepService" ref="stepService" />
<property name="projectSettings" ref="projectSettings" />
<property name="publicationService" ref="publicationService" />
</bean>
class="org.splat.simer.VersionDocumentAction" scope="prototype">
<property name="projectSettings" ref="projectSettings" />
<property name="publicationService" ref="publicationService" />
+ <property name="stepService" ref="stepService" />
</bean>
<bean id="editDocumentAction"