]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
- Set up-to date functionality is implemented;
authormka <mka@opencascade.com>
Mon, 1 Jul 2013 13:51:59 +0000 (13:51 +0000)
committermka <mka@opencascade.com>
Mon, 1 Jul 2013 13:51:59 +0000 (13:51 +0000)
- Uses presentation during version operation functionality is implemented;
- Add new simulation context functionality is improved;
- Author can approve the study;
- Reader cannot rename the scenario;

18 files changed:
Workspace/Siman-Common/src/org/splat/dal/bo/som/SimulationContext.java
Workspace/Siman-Common/src/org/splat/service/PublicationService.java
Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/ServiceLocator.java
Workspace/Siman-Common/src/org/splat/service/ServiceLocatorImpl.java
Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java
Workspace/Siman-Common/src/org/splat/som/DocumentRights.java
Workspace/Siman-Common/src/org/splat/som/StudyRights.java
Workspace/Siman-Common/src/spring/businessServiceContext.xml
Workspace/Siman/WebContent/jsp/editContents.jsp
Workspace/Siman/WebContent/jsp/readContents.jsp
Workspace/Siman/WebContent/study/editScenarioProperties.jsp
Workspace/Siman/src/org/splat/simer/ApplicationSettings.java
Workspace/Siman/src/org/splat/simer/DocumentFacade.java
Workspace/Siman/src/org/splat/simer/EditDocumentAction.java
Workspace/Siman/src/org/splat/simer/EditSimulationContextAction.java
Workspace/Siman/src/org/splat/simer/OpenStudy.java
Workspace/Siman/src/org/splat/simer/VersionDocumentAction.java

index ab900bd0660bf2b122c4f95e7fc4d5bdeb682fc6..88698b9c686ab2840cbfb4328379ac90f0e02afb 100644 (file)
@@ -88,8 +88,7 @@ public class SimulationContext extends Persistent implements Serializable {
       {
         if (type == null)  throw new MissedPropertyException("type");
         if (step == null)  throw new MissedPropertyException("step");
-        if (value == null) throw new MissedPropertyException("value");        
-        if (!type.isAttachedTo(step)) throw new InvalidPropertyException("step");
+        if (value == null) throw new MissedPropertyException("value");
       }
     }
 //  Database fetch constructor
index bc5ccc3d1e229b0ca9053f3ec8bf62092d77e4b9..62bca2ee9e52fab4404cdb2a0837d900e16f72a8 100644 (file)
@@ -339,4 +339,13 @@ public interface PublicationService {
         */
        DocToCompareDTO getDocToCompareDTO(long publicationId)
                        throws InvalidParameterException;
+       
+       /**
+        * Check if this publication is outdated and other publications used by it are up-to-date.
+        * 
+        * @param aPublication
+        *            the publication
+        * @return true if succeeded
+        */
+       boolean canBeActualized(Publication aPublication);
 }
index 60ca0a7c8c8890a24ef9a57c0a547a2ae6e0f5d9..e0bc6e6c55ed6c94c0aba667fc7c9c51d56b11bf 100644 (file)
@@ -30,6 +30,7 @@ import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.ProgressState;
 import org.splat.dal.bo.som.ProjectElement;
 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.SimulationContextType;
 import org.splat.dal.bo.som.Study;
@@ -670,9 +671,12 @@ public class PublicationServiceImpl implements PublicationService {
         */
        @Transactional(readOnly=true)
        public Document getLastVersion(final Document doc, final ProjectElement owner) {
-               Document theLastVersion = _documentService.selectDocument(doc.getIndex());      //get document attached to hibernate session
+               Document document = _documentService.selectDocument(doc.getIndex());    //get document attached to hibernate session
                ProjectElement trueOwner = _projectElementDAO.merge(owner);
-               if(trueOwner.getPublication(theLastVersion) == null) {  //start recursive search
+               Document theLastVersion = null;
+               if(trueOwner.getPublication(document) != null) {
+                       theLastVersion = document;
+               } else {        //start recursive search
                        List<VersionsRelation> relations = _versionsRelationDAO
                                        .getFilteredList(Restrictions.eq("refer", theLastVersion));
                        //there may be several next versions if document is shared between scenarios,
@@ -684,21 +688,18 @@ public class PublicationServiceImpl implements PublicationService {
                                }
                        }
                }
-               if(theLastVersion != null && trueOwner.getPublication(theLastVersion) == null) {
-                       theLastVersion = null;
+               if(theLastVersion == null && owner instanceof Scenario) {
+                       theLastVersion = getLastVersion(doc, ((Scenario)owner).getOwnerStudy());
                }
                return theLastVersion;
        }
 
-       /**
-        * Check if this publication is outdated and other publications used by it are up-to-date.
-        * 
-        * @param aPublication
-        *            the publication
-        * @return true if succeeded
+       /** 
+        * {@inheritDoc}
+        * @see org.splat.service.PublicationService#canBeActualized(org.splat.dal.bo.som.Publication)
         */
        @Transactional(readOnly=true)
-       private boolean canBeActualized(final Publication aPublication) {
+       public boolean canBeActualized(final Publication aPublication) {
                boolean res = aPublication.isOutdated();
                for(Publication used : aPublication.getRelations(UsesRelation.class)) {
                        if(used.isOutdated()) {
@@ -719,26 +720,27 @@ public class PublicationServiceImpl implements PublicationService {
         */
        @Transactional
        public boolean actualize(final Publication aPublication) {
-               boolean res = aPublication.isOutdated() && canBeActualized(aPublication);
+               Publication mergedPublication = getPublicationDAO().merge(aPublication);
+               boolean res = aPublication.isOutdated();
                if (res) {
                        //Replace dependencies to old versions of documents with dependencies to the latest versions.
-                       for(Relation rel : aPublication.value().getRelations(UsesRelation.class)) {
+                       for(Relation rel : mergedPublication.value().getRelations(UsesRelation.class)) {
                                Document used = (Document)rel.getTo();
-                               if(aPublication.getOwnerStudy().getPublication(used) == null) {
-                                       aPublication.value().removeRelation(UsesRelation.class, used);
+                               if(mergedPublication.getOwnerStudy().getPublication(used) == null) {
+                                       mergedPublication.value().removeRelation(UsesRelation.class, used);
                                        //There is always a last version
-                                       Document theLastVersion = getLastVersion(used, aPublication.getOwner());
-                                       aPublication.addDependency(theLastVersion);
+                                       Document theLastVersion = getLastVersion(used, mergedPublication.getOwner());
+                                       mergedPublication.addDependency(theLastVersion);
                                }
                        }
                        
-                       aPublication.setIsnew('Y');
-                       getPublicationDAO().update(aPublication);
-                       
-                       //recursively actualize all documents that don't use any more outdated documents.
-                       for(Publication using : aPublication.getRelations(UsedByRelation.class)) {
-                               actualize(using);
-                       }
+                       mergedPublication.setIsnew('Y');
+                       getPublicationDAO().update(mergedPublication);
+               
+//                     //recursively actualize all documents that don't use any more outdated documents.
+//                     for(Publication using : aPublication.getRelations(UsedByRelation.class)) {
+//                             actualize(using);       //by the way, the recursive call won't be transactional as it is not called via spring proxy
+//                     }
                }
                return res;
        }
index b4f0ae150d65e7feaf85d4a65d2722514d96e869..482733ac8b5c065ae433360b3b7c3364ed7896f5 100644 (file)
@@ -46,4 +46,18 @@ public interface ServiceLocator {
         *            the userService to set
         */
        void setUserService(UserService userService);
+
+       /**
+        * Get the publicationService.
+        * 
+        * @return the publicationService
+        */
+       PublicationService getPublicationService();
+       /**
+        * Set the publicationService.
+        * 
+        * @param publicationService
+        *            the publicationService to set
+        */
+       void setPublicationService(PublicationService publicationService);
 }
index 966d8824fde831166831bdd5278848010453b053..5a0965f2447bf78543ee6079ef873539d3377286 100644 (file)
@@ -45,6 +45,10 @@ public final class ServiceLocatorImpl implements ServiceLocator {
         * Injected user service.
         */
        private UserService _userService;
+       /**
+        * Injected publication service.
+        */
+       private PublicationService _publicationService;
 
        /**
         * Get the studyService.
@@ -77,4 +81,20 @@ public final class ServiceLocatorImpl implements ServiceLocator {
        public void setUserService(final UserService userService) {
                _userService = userService;
        }
+
+       /**
+        * Get the publicationService.
+        * @return the publicationService
+        */
+       public PublicationService getPublicationService() {
+               return _publicationService;
+       }
+
+       /**
+        * Set the publicationService.
+        * @param publicationService the publicationService to set
+        */
+       public void setPublicationService(final PublicationService publicationService) {
+               _publicationService = publicationService;
+       }
 }
index 29d53c0468181c367d2c03809dbddf55f6166595..db9ec2c65c3ba5022bdae2a0ce5967d15c58fe4a 100644 (file)
@@ -131,6 +131,7 @@ public class StepServiceImpl implements StepService {
         * @see org.splat.service.StepService#addSimulationContext(org.splat.som.Step, org.splat.dal.bo.som.SimulationContext.Properties)
         */
        @Override
+       @Transactional
        public SimulationContext addSimulationContext(final Step aStep,
                        final SimulationContext.Properties dprop)
                        throws MissedPropertyException, InvalidPropertyException,
index b757a49cd5b7682b75de2afb1839645b49b6f05f..9e9d7242092e5d7c87b5ebeb29374b75eee4ff0a 100644 (file)
@@ -99,7 +99,8 @@ public class DocumentRights {
         * @see Publication#accept()
         */
        public boolean canAccept() {
-               return _isauthor && _operand.isOutdated();
+               return _isauthor && ServiceLocatorImpl.getInstance()
+                               .getPublicationService().canBeActualized(_operand);
        }
 
        /**
@@ -113,7 +114,8 @@ public class DocumentRights {
        public boolean canApprove() {
                User approver = _cycle.getActor(ValidationStep.APPROVAL); // May be null if not approvable
                boolean res = (_user.equals(approver))
-                               && (_operand.getProgressState() == ProgressState.inCHECK);
+                               && (_operand.getProgressState() == ProgressState.inCHECK)
+                               && !_operand.isOutdated();
                if (res) {
                        List<Relation> use = _operand.value().getRelations(
                                        UsesRelation.class);
@@ -230,6 +232,9 @@ public class DocumentRights {
                User manager = _operand.getOwnerStudy().getAuthor();
                User publisher = _cycle.getActor(ValidationStep.PROMOTION); // Null if the default users are involved
 
+               if(_operand.isOutdated()) {
+                       return false;
+               }
                if (_operand.getProgressState() != ProgressState.inWORK) {
                        if (_operand.getProgressState() == ProgressState.inDRAFT) {
                                return canReview();
@@ -355,7 +360,7 @@ public class DocumentRights {
        public boolean canReview() {
                User reviewer = _cycle.getActor(ValidationStep.REVIEW); // May be null if not reviewable
 
-               if (!_user.equals(reviewer)) {
+               if (!_user.equals(reviewer) || _operand.isOutdated()) {
                        return false;
                }
                if (_operand.getProgressState() != ProgressState.inDRAFT) {
index 2eeff0ef1ed66a88f1c7476d461a9ed039b64648..62c0a1e1bb7e90e226892a9993f87b24b1eb64db 100644 (file)
@@ -198,7 +198,7 @@ public class StudyRights {
         */
        public boolean canApprove() {
                User approver = _cycle.getActor(ValidationStep.APPROVAL); // May be null if not approvable
-               return (_user.equals(approver))
+               return (_user.equals(approver) || _isauthor)
                                && getStudyService().canBeApproved(_operand);
        }
 
@@ -284,6 +284,15 @@ public class StudyRights {
 
                return res;
        }
+       
+       /**
+        * Checks if the user has right to rename a scenario of the study.
+        * 
+        * @return true if user in an author, contributor or a validation cycle member of the study.
+        */
+       public boolean canRenameScenario() {
+               return _isauthor || getStudyService().hasActor(_operand, _user);
+       }
 
        // ==============================================================================================================================
        // Getter
index 37a4c9ebe1df3e44402c2f5994e234b08d1bb14b..7f911caf3e2cd82660b91501086801563da63b05 100644 (file)
@@ -16,6 +16,7 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
                factory-method="getInstance">
                <property name="studyService" ref="studyService" />
                <property name="userService" ref="userService" />
+               <property name="publicationService" ref="publicationService" />
        </bean>
 
        <bean id="userService" class="org.splat.service.UserServiceImpl">
index 91797a1f82d6539ce5bf7a98689a66c24832cadf..c32ca889feee6fcdd791dd8f33f09faccdeca020 100644 (file)
             <img src="<s:url value="/skin/%{stateIcon}"/>" width=14 height=14 border="none" title=""/>
           </s:else>
         </td>
-        <td><img src="<s:url value="/skin/%{fileIcon}"/>" border="none" title=""/></td>
+        <td>
+          <s:a href="%{URL}" target="_blank" cssClass="link"> 
+            <img src="<s:url value="/skin/%{fileIcon}"/>" border="none" title=""/>  </s:a>
+        </td>
         <td>
           <s:if test="%{curAction == 'renameDocument'}">
             <s:if test="%{#selectedDocIndex == #docindex}">
index c8c4d4769e4c8be58310ab16f2d0d61f8651cd61..29cca49671d78f2f931d34fe92b00e8045630012 100644 (file)
           </s:else>
         </td>
         <td><img src="<s:url value="/skin/%{stateIcon}"/>" width=14 height=14 border="none" title=""/></td>
-        <td><img src="<s:url value="/skin/%{fileIcon}"/>" border="none" title=""/></td>
+        <td>
+          <s:a href="%{URL}" target="_blank" cssClass="link"> 
+            <img src="<s:url value="/skin/%{fileIcon}"/>" border="none" title=""/> </s:a>
+        </td>
         <td>
           <s:a href="%{URL}" target="_blank" cssClass="link"><s:property value="title"/></s:a>
         </td>
index 9fc64c4fdd0b76cfdab24c770ad93528265b86f4..4d4a2e93d9abef40677131aa6d0ddbef13ca3ecc 100644 (file)
@@ -52,7 +52,7 @@
         </s:if>
 
 <!-- Scenario ckecked-in (editable)
-  -->   <s:else>
+  --> <s:elseif test="%{openStudy.StudyRights.canRenameScenario()}">
         <s:form name="property" action="valid-rename" method="post" validate="true" cssClass="text">
             <tr>
               <td><s:text name="field.scenariotitle"/>:&nbsp;<span class="error">*</span></td>
               </td>
             </tr>
         </s:form>
-        </s:else>
+      </s:elseif><s:else>
+        <table>
+          <tr height="28">
+            <td valign="middle"><s:text name="field.scenariotitle"/>:&nbsp;</td>
+            <td>
+              <s:text name="%{selectedScenarioTitle}"/>
+            </td>
+          </tr>
+        </table>
+      </s:else>
 
         </div>
       </div>
index 8b0e90565f10c11a4685ca7867cd657e7cc4a3a0..001e781aaab2419f7090343a9c9c61e74e56a637 100644 (file)
@@ -156,6 +156,10 @@ public class ApplicationSettings {
         * Demote icon file name.
         */
        private static final String IMG_DEMOTE = "image.demote.png";
+       /**
+        * Accept icon file name.
+        */
+       private static final String IMG_ACCEPT = "image.accept.png";
        
        /**
         * Attach menu item name.
@@ -197,6 +201,10 @@ public class ApplicationSettings {
         * Rename menu item name.
         */
        private static final String MNU_RENAME = "rename";
+       /**
+        * Set up-to-date menu item name.
+        */
+       private static final String MNU_ACTUALIZE = "accept";
 
        /**
         * Attach menu item name.
@@ -258,6 +266,10 @@ public class ApplicationSettings {
         * Remove as reference menu item label key.
         */
        private static final String MNU_NAME_REMOVE_AS_REFERENCE = "menu.removeasreference";
+       /**
+        * Set up-to-date menu item label key.
+        */
+       private static final String MNU_NAME_ACTUALIZE = "menu.actualize";
        // /**
        // * Not yet implemented action name.
        // */
@@ -282,6 +294,10 @@ public class ApplicationSettings {
         * Promote the study action name.
         */
        private static final String ACT_PROMOTE_STUDY = "edit-study?action=promote";
+       /**
+        * Set up-to-date action name.
+        */
+       private static final String ACT_ACTUALIZE = "setDocument?action=accept";
        
        /**
         * Siman application server name.
@@ -826,10 +842,9 @@ public class ApplicationSettings {
                 */
                private EditableDocumentPopup() {
                        super();
-                       /*
-                        * addItem("accept", new PopupItem("menu.accept").icon( "image.accept.png").action("setDocument?action=accept")
-                        * .confirmation("message.accept.document"));
-                        */
+                       addItem(MNU_ACTUALIZE, new PopupItem(MNU_NAME_ACTUALIZE)
+                                       .icon(IMG_ACCEPT).action(ACT_ACTUALIZE)
+                                       .confirmation("message.actualize.document"));
                        addItem(MNU_PROMOTE, new PopupItem(MNU_NAME_PROMOTE).icon(
                                        IMG_PROMOTE).action("setDocument?action=promote")
                                        .confirmation("message.promote.document"));
@@ -863,6 +878,9 @@ public class ApplicationSettings {
                 */
                private ReviewableDocumentPopup() {
                        super();
+                       addItem(MNU_ACTUALIZE, new PopupItem(MNU_NAME_ACTUALIZE)
+                                       .icon(IMG_ACCEPT).action(ACT_ACTUALIZE)
+                                       .confirmation("message.actualize.document"));
                        addItem(MNU_DEMOTE, new PopupItem(MNU_NAME_DEMOTE).icon(
                                        IMG_DEMOTE).action("setDocument?action=demote")
                                        .confirmation("message.demote.document"));
@@ -891,6 +909,9 @@ public class ApplicationSettings {
                 */
                private NotResultDocumentPopup() {
                        super();
+                       addItem(MNU_ACTUALIZE, new PopupItem(MNU_NAME_ACTUALIZE)
+                                       .icon(IMG_ACCEPT).action(ACT_ACTUALIZE)
+                                       .confirmation("message.actualize.document"));
                        addItem(MNU_DEMOTE, new PopupItem(MNU_NAME_DEMOTE).icon(
                                        IMG_DEMOTE).action("setDocument?action=demote")
                                        .confirmation("message.demote.document"));
@@ -919,6 +940,10 @@ public class ApplicationSettings {
                 */
                private ApprovableDocumentPopup() {
                        super();
+                       addItem(MNU_ACTUALIZE, new PopupItem(MNU_NAME_ACTUALIZE)
+                                       .icon(IMG_ACCEPT).action(ACT_ACTUALIZE)
+                                       .confirmation("message.actualize.document"));
+                       
                        /*addItem("undo", new PopupItem(MNU_NAME_DEMOTE).icon(
                                        "image.invalidate.png").action(
                                        "setDocument?action=invalidate").confirmation(
@@ -941,6 +966,9 @@ public class ApplicationSettings {
                 */
                private ApprovedPopup() {
                        super();
+                       addItem(MNU_ACTUALIZE, new PopupItem(MNU_NAME_ACTUALIZE)
+                                       .icon(IMG_ACCEPT).action(ACT_ACTUALIZE)
+                                       .confirmation("message.actualize.document"));
                        addItem(MNU_ATTACH, new PopupItem(MNU_NAME_ATTACH).icon(IMG_ATTACH)
                                        .action(ACT_ATTACH));
                        addSeparator();
index 9b19f6f4ba156cfd86f037a4d4a5c5ad63e03d12..accc56b79e994100c74df290d1a9a453e3d7acbf 100644 (file)
@@ -225,19 +225,26 @@ public class DocumentFacade implements HistoryFacade {
                        _display = State.deepopen;
                } else { // Opening the document
                        if (_uses == null) {
-                               List<Relation> used = _me.value().getRelations(UsesRelation.class);
-                               
-                               _uses = new ArrayList<DocumentFacade>();
-                               for(Relation relation : used) {
-                                       Document doc = (Document)relation.getTo();
-                                       Publication pub = _me.getOwner().getPublication(
-                                                       _publicationService.getLastVersion(doc, _me.getOwner()));
-                                       DocumentFacade facade = _owner._docpres.get(pub.getIndex());
-                                       if (facade == null && pub != null) {
-                                               facade = new DocumentFacade(_owner, pub,
+                               List<Relation> relist = _me.value().getRelations(UsesRelation.class);
+
+                               _uses = new ArrayList<DocumentFacade>(relist.size());
+                               for (Relation relation : relist) {
+                                       Document used = ((UsesRelation)relation).getTo();
+                                       
+                                       DocumentFacade facade = null;
+                                       
+                                       Publication publication = _me.getOwner().getPublication(used);
+                                       if(publication == null) {
+                                               publication = _me.getOwnerStudy().getPublication(used);
+                                       }
+                                       if(publication != null) {
+                                               facade = _owner._docpres.get(publication.getIndex());
+                                       }
+                                       
+                                       if (facade == null) {
+                                               facade = new DocumentFacade(_owner, used,
                                                                getProjectSettings(), getPublicationService(),
                                                                getApplicationSettings());
-                                               _owner._docpres.put(pub.getIndex(), facade);
                                        }
                                        _uses.add(facade);
                                }
index ab8b2fb04ae396775f7079bbf81b388fb99b0c89..a9048035e93d956b609b39c380435af4877a3b55 100644 (file)
@@ -95,7 +95,7 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                                setAction(null);
                        } else if (todo == Execute.accept) {
                                getPublicationService().actualize(doc);
-                               _openStudy.update(doc);
+                               doOpen();       //so pop-up menus of documents depending on this one will be updated
                        } else if (todo == Execute.promote) {
                                getPublicationService().promote(doc,
                                                Calendar.getInstance().getTime());
index f1a074041311a808b3b2cd0df51d8000eb6cb430..b38efc265c3ce14d5209290523aed07198be94dc 100644 (file)
@@ -1,6 +1,8 @@
 package org.splat.simer;
 
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Iterator;
 import java.util.List;
 
 import org.splat.dal.bo.som.ProjectElement;
@@ -132,6 +134,7 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
 
                        if (_newtype.length() == 0 || _value.length() == 0) {
                                res = INPUT;
+                               setAction("newContext");
                        } else {
 
                                Step step = _openStudy.getSelectedStep();
index 46d1085395bc5639bc5711ea4e8bcf2a947ba506..cad212ae8a2be79810024c0f06957ca00138ae8c 100644 (file)
@@ -646,7 +646,12 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
        protected void update(final Publication doc) {
                DocumentFacade facade = _docpres.get(doc.getIndex());
                if (facade != null) {
-                       facade.refresh();
+                       _contents.remove(facade);
+                       facade = new DocumentFacade(this, doc,
+                                       getProjectSettings(), getPublicationService(),
+                                       getApplicationSettings());
+                       _docpres.put(doc.getIndex(), facade);
+                       _contents.add(facade);
                }
        }
 
index b4ec29adfe25e4226b3e38287c1a5ce3c5869117..f533f66334f4293a8ca9fce0d07d7f23dc5ef026 100644 (file)
@@ -5,6 +5,7 @@ import java.io.FileNotFoundException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.Iterator;
 import java.util.List;
 import java.util.ResourceBundle;
 
@@ -81,14 +82,25 @@ public class VersionDocumentAction extends BaseUploadDocumentAction {
                        // Add additional documents used by the current version
                        for (Relation usesRel : doc.getRelations(UsesRelation.class)) {
                                Document used = (Document) usesRel.getTo();
-                               if (!_defuses.contains(getPublicationService().getLastVersion(used, tag.getOwner()))) {
-                                       _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)
+                       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();
+                               }
+                       }
+                       
                        // Setup dependencies
                        _usedby.addAll(tag.getRelations(UsedByRelation.class));