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