compatible.add(docusedby[i]);
}
}
- List<Publication> relist = current.getRelations(UsedByRelation.class);
- for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
- Publication using = i.next();
+ for (Publication using : current.getRelations(UsedByRelation.class)) {
if (!compatible.contains(using.getIndex())) {
outdate(using);
}
// Republish the previous version if any to avoid it becoming an orphan
Document prevVersion = torem.value().getPreviousVersion();
if (prevVersion != null) {
+ prevVersion.setHistory(prevVersion.getHistory() - 1);
add(aStep, new Publication(prevVersion, aStep.getOwner()));
getProjectElementDAO().merge(aStep.getOwner());
}
return false;
}
- List<Publication> using = _operand.getRelations(UsedByRelation.class);
+ List<Relation> using = _operand.value().getRelations(
+ UsedByRelation.class);
return using.isEmpty();
}
// ==============================================================================================================================
// Getters and setters
// ==============================================================================================================================
-
+
public DocumentType getDefaultDocumentType() {
return _deftype;
}
this._state = ProgressState.valueOf(state);
}
- // ==============================================================================================================================
+ // =========================================================================
// Protected services
- // ==============================================================================================================================
-
+ // =========================================================================
+
protected 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);
public void setUses(final String list) {
this._docuses = list;
}
-
+
public String getWriteAccess() {
Boolean res = (_mystudy != null);
if (res) {
}
return res.toString();
}
+
+ /**
+ * Refresh the study representation according to the current database content.
+ */
+ public void refreshStudy() {
+ // Update of the open study
+ String selection = _mystudy.getSelection();
+ _mystudy = open(getStudyService().selectStudy(_mystudy.getIndex())); // Updates the study
+ _mystudy.setSelection(selection); // Rebuilds the presentation
+ }
}
\ No newline at end of file
* Operations enumeration.
*/
private enum Execute {
+ /**
+ * Possible document operations.
+ */
renameDocument, accept, promote, demote, review, invalidate, approve, disapprove
};
- // ==============================================================================================================================
+ // =========================================================================
// Action methods
- // ==============================================================================================================================
+ // =========================================================================
/**
* Open a study.
getPublicationService().approve(doc,
Calendar.getInstance().getTime());
_openStudy.update(doc);
- _openStudy.getMenu().refreshSelectedItem(); // Updates the menu icon, in case of other documents in approved state
+ // Update the menu icon, in case of other documents in approved state
+ _openStudy.getMenu().refreshSelectedItem();
}
res = SUCCESS;
} catch (RuntimeException saverror) {
Step step = _openStudy.getSelectedStep();
Publication edited = step.getDocument(Long.valueOf(_index));
Date modifTime = Calendar.getInstance().getTime();
-
+
// Replace the document source file
getPublicationService().replace(edited, upfile, modifTime);
-
+
_openStudy.update(edited);
res = SUCCESS;
} catch (Exception error) {
setMenu();
_openStudy = getOpenStudy();
Step step = _openStudy.getSelectedStep();
- Publication doctag = step.getDocument(Long.valueOf(_index));
- Long prevVersion = 0L;
- if (doctag.value().getPreviousVersion() != null) {
- prevVersion = doctag.value().getPreviousVersion().getIndex();
- }
if (getStepService().removeDocument(step, Long.valueOf(_index))) { // Updates the data structure
- _openStudy.remove(doctag); // Updates the presentation
- // The previous version must be republished if any
- if (prevVersion > 0) {
- _openStudy.add(step.getDocument(prevVersion));
+ // Re-opening (refreshing) the currently open study
+ if (_selection == null) { // Opening a study just newed
+ _selection = _openStudy.getSelection(); // Default selection
}
+ _openStudy = open(getStudyService().selectStudy(
+ _openStudy.getIndex())); // Closes the previously open study
+ _openStudy.setSelection(_selection);
}
return SUCCESS;
}
- // ==============================================================================================================================
+ // =========================================================================
// Getters and setters
- // ==============================================================================================================================
+ // =========================================================================
/**
* Set the document title.
_mystudy.add(addoc); // Updates the presentation
} else {
// Re-opening (refreshing) the currently open study
- String selection = _mystudy.getSelection();
- _mystudy = open(getStudyService().selectStudy(
- _mystudy.getIndex())); // Updates the study
- _mystudy.setSelection(selection);
+ refreshStudy();
}
res = SUCCESS;
} catch (FileNotFoundException error) {
setupDefaultUses(_deftype);
}
// Add additional documents used by the current version
- for (Relation usesRel: doc.getRelations(UsesRelation.class)) {
+ for (Relation usesRel : doc.getRelations(UsesRelation.class)) {
Document used = (Document) usesRel.getTo();
if (!_defuses.contains(used)) {
_defuses.add(used);
_usedby.addAll(tag.getRelations(UsedByRelation.class));
// Initialize applicable states list
- if(tag.value().getProgressState() == ProgressState.EXTERN) {
+ if (tag.value().getProgressState() == ProgressState.EXTERN) {
_documentStates.add(ProgressState.EXTERN);
} else {
- _documentStates.add(ProgressState.inWORK);
- if (_deftype != null) {
- // Check if the validation cycle of the document type can has a review state
- ValidationCycle cycle = getStudyService().getValidationCycleOf(
- _mystudy.getMystudy(), _deftype);
- if ((cycle != null) && cycle.enables(ValidationStep.REVIEW)) {
- _documentStates.add(ProgressState.inDRAFT);
+ _documentStates.add(ProgressState.inWORK);
+ if (_deftype != null) {
+ // Check if the validation cycle of the document type can has a review state
+ ValidationCycle cycle = getStudyService()
+ .getValidationCycleOf(_mystudy.getMystudy(),
+ _deftype);
+ if ((cycle != null) && cycle.enables(ValidationStep.REVIEW)) {
+ _documentStates.add(ProgressState.inDRAFT);
+ }
}
}
- }
} else {
if (!(Constants.NONE.equals(getToolProperty()))) {
initializationFullScreenContext(Constants.STUDY_MENU,
_state, aDate, listDocuses, _docusedby);
// Update of the open study
- _mystudy.setSelection(_mystudy.getSelection()); // Rebuilds the presentation
- // TODO: Look is an optimization is possible (for example by updating the presentation of versioned document)
+ refreshStudy();
res = SUCCESS;
} catch (FileNotFoundException error) {