Salome HOME
Fix for some problems with definition uses.
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / VersionDocumentAction.java
index 90733644a26a13fa2c333d2f464ab4891df951f6..1eeaabe06b8dfeabc5f4be792f2d9b03391f5ce6 100644 (file)
@@ -21,6 +21,8 @@ import org.splat.dal.bo.som.ValidationStep;
 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;
@@ -65,6 +67,7 @@ public class VersionDocumentAction extends BaseUploadDocumentAction {
                File upfile = commonInitialize(Constants.TRUE);
 
                _mystudy = getOpenStudy();
+               //updating relations of docs
                _mystudy.updateCurrentStep();
                _defuses = new ArrayList<Document>();
                
@@ -95,10 +98,12 @@ public class VersionDocumentAction extends BaseUploadDocumentAction {
                        
                        // 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)
-                       for(Iterator<Document> document = _defuses.iterator(); document.hasNext(); ) {
-                               Publication pub = tag.getOwner().getPublication(document.next());
-                               if(pub != null && pub.getRelations(UsesRelation.class).contains(tag)) {
-                                       document.remove();
+                       List<Document> toDeleteFromDefuses = new ArrayList<Document>();
+                       getPublicationService().findSequenceUses(toDeleteFromDefuses, tag,
+                                       _defuses);
+                       for (Document document : toDeleteFromDefuses) {
+                               if (_defuses.contains(document)) {
+                                       _defuses.remove(document);
                                }
                        }