import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
+import java.util.Iterator;
import java.util.List;
import java.util.ResourceBundle;
import org.splat.kernel.InvalidPropertyException;
import org.splat.manox.Reader;
import org.splat.manox.Toolbox;
+import org.splat.service.PublicationService;
+import org.splat.service.StudyService;
import org.splat.som.Revision;
import org.splat.som.Step;
import org.splat.wapp.Constants;
File upfile = commonInitialize(Constants.TRUE);
_mystudy = getOpenStudy();
+ //updating relations of docs
+ _mystudy.updateCurrentStep();
_defuses = new ArrayList<Document>();
-
+
Publication tag = _mystudy.getSelectedStep().getDocument(
Integer.valueOf(_index));
Document doc = tag.value();
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);
+ Document lastVersion = getPublicationService().getLastVersion(used, tag.getOwner());
+ if (lastVersion != null && !_defuses.contains(lastVersion)) {
+ _defuses.add(lastVersion);
}
}
// Avoid recursive using of the document
if (_defuses.contains(doc)) {
_defuses.remove(doc);
}
+
+ // Avoid using of documents dependent on the current version of the document being versioned
+ // (This case is possible only if both documents belong to the step of the same Project Element)
+ List<Document> toDeleteFromDefuses = new ArrayList<Document>();
+ getPublicationService().findSequenceUses(toDeleteFromDefuses, tag,
+ _defuses);
+ for (Document document : toDeleteFromDefuses) {
+ if (_defuses.contains(document)) {
+ _defuses.remove(document);
+ }
+ }
+
// Setup dependencies
_usedby.addAll(tag.getRelations(UsedByRelation.class));
// Initialize applicable states list
- _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);
+ 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);
+ }
}
}
-
} 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) {