Salome HOME
Fixed removing of a document from scenario. Deleted related documents and their relat...
authorrkv <rkv@opencascade.com>
Tue, 25 Dec 2012 13:03:16 +0000 (13:03 +0000)
committerrkv <rkv@opencascade.com>
Tue, 25 Dec 2012 13:03:16 +0000 (13:03 +0000)
Workspace/Siman-Common/src/conf/log-messages.properties
Workspace/Siman-Common/src/conf/log-messages_en.properties
Workspace/Siman-Common/src/org/splat/common/properties/MessageKeyEnum.java
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Entity.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/Scenario.hbm.xml
Workspace/Siman-Common/src/org/splat/exception/DocumentIsUsedException.java [new file with mode: 0644]
Workspace/Siman-Common/src/org/splat/service/StepService.java
Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java
Workspace/Siman-Common/src/test/splat/service/TestStepService.java
Workspace/Siman/src/org/splat/simer/EditDocumentAction.java

index 8669c7ba3cfab79fd3efc136540ea867a8d369a6..343ff9a43a1c4f562523ff4fd371d4a151c596ef 100644 (file)
@@ -16,3 +16,4 @@ USR-000001=User {0} is not found in the database
 KNT-000001=Knowledge element type "{0}" already exists
 SCT-000001=Simulation context type "{0}" already exists
 DCT-000001=Document type "{0}" already exists
+DCT-000002=Can not delete the document "{0}" because it is used by other documents.
index 8669c7ba3cfab79fd3efc136540ea867a8d369a6..343ff9a43a1c4f562523ff4fd371d4a151c596ef 100644 (file)
@@ -16,3 +16,4 @@ USR-000001=User {0} is not found in the database
 KNT-000001=Knowledge element type "{0}" already exists
 SCT-000001=Simulation context type "{0}" already exists
 DCT-000001=Document type "{0}" already exists
+DCT-000002=Can not delete the document "{0}" because it is used by other documents.
index ce03ca850e0edeeed0704e13531f2616eee9cbfb..62aa2494327deeb89baa1e33cda5472df2ea9a21 100644 (file)
@@ -84,7 +84,11 @@ public enum MessageKeyEnum {
        /**
         * Document type "{0}" already exists.
         */
-       DCT_000001("DCT-000001");
+       DCT_000001("DCT-000001"),
+       /**
+        * Can not delete the document "{0}" because it is used by other documents.
+        */
+       DCT_000002("DCT-000002");
        
        /**
        * Value.
index bb8f0d490aa404f411fe80570f3323fb49996034..060f84db6674dd26c99064d109984fc5114dbee2 100644 (file)
@@ -167,9 +167,11 @@ public abstract class Entity extends Any {
                                break;
                        }
                }
-               this.getAllRelations().remove(res);
-               if (res.isBidirectional()) {
-                       ((Entity)res.getTo()).getAllRelations().remove(res.getReverse());
+               if (res != null) {
+                       this.getAllRelations().remove(res);
+                       if (res.isBidirectional()) {
+                               ((Entity)res.getTo()).getAllRelations().remove(res.getReverse());
+                       }
                }
                return res;
        }
index fb54359403f9a222ee8025a06beee411ca19ef9d..efad6f296c50f2e7698c1744c64e897a7fe64206 100644 (file)
@@ -11,7 +11,7 @@
   <union-subclass name="org.splat.dal.bo.som.Scenario" extends="org.splat.dal.bo.som.ProjectElement" table="scenario" lazy="false">
   
       <!-- Study owner                 -->    
-      <many-to-one name="owner" column="owner" cascade="merge" insert="false" update="false" access="field" not-null="true" />
+      <many-to-one name="owner" column="owner" insert="false" update="false" access="field" not-null="true" />
   
       <!-- int   sid                   -->
       <property    name="sid"   column="sid"   access="field" not-null="true" />    
diff --git a/Workspace/Siman-Common/src/org/splat/exception/DocumentIsUsedException.java b/Workspace/Siman-Common/src/org/splat/exception/DocumentIsUsedException.java
new file mode 100644 (file)
index 0000000..95fc57b
--- /dev/null
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * Company         OPEN CASCADE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   25.12.2012
+ * @author         $Author$
+ * @version        $Revision$
+ * @copyright      OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.exception;
+
+import org.splat.common.properties.MessageKeyEnum;
+
+/**
+ * This exception is thrown when trying to delete a document used by other documents.
+ * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+public class DocumentIsUsedException extends BusinessException {
+
+       /**
+        * Serial version ID.
+        */
+       private static final long serialVersionUID = 8835396863040438781L;
+
+       /**
+        * Error message key.
+        */
+       private static final MessageKeyEnum MESSAGE_KEY = MessageKeyEnum.DCT_000002;
+
+       /**
+        * The document title.
+        */
+       private transient final String _documentTitle;
+       /**
+        * Constructor with document title as a parameter.
+        * 
+        * @param documentTitle
+        *            the document title
+        */
+       public DocumentIsUsedException(final String documentTitle) {
+               super(MESSAGE_KEY.toString(), documentTitle);
+               _documentTitle = documentTitle;
+       }
+       /**
+        * Get the document title.
+        * @return the document title
+        */
+       public String getDocumentTitle() {
+               return _documentTitle;
+       }
+}
index 95c1ccfd8f2ad8d80b0ecbe30b5c9aa997bc30ef..a4071b12dda117775b3674fea6d429dcf7287783 100644 (file)
@@ -16,6 +16,7 @@ import org.splat.dal.bo.som.Document;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.Publication;
 import org.splat.dal.bo.som.SimulationContext;
+import org.splat.exception.DocumentIsUsedException;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MismatchException;
 import org.splat.kernel.MissedPropertyException;
@@ -168,8 +169,11 @@ public interface StepService {
         * @param docId
         *            the document id
         * @return true if removing of the document succeeded
+        * @throws DocumentIsUsedException
+        *             if the document is used by other documents
         */
-       boolean removeDocument(Step aStep, long docId);
+       boolean removeDocument(Step aStep, long docId)
+                       throws DocumentIsUsedException;
 
        /**
         * Get document types which are applicable for the given study step (activity).
index 5d29e806638917f71b20592802fba1d49b9262b4..0faf6d8d702592abe6f306bbc49429394b74fed2 100644 (file)
@@ -34,6 +34,7 @@ import org.splat.dal.dao.som.ProjectElementDAO;
 import org.splat.dal.dao.som.PublicationDAO;
 import org.splat.dal.dao.som.SimulationContextDAO;
 import org.splat.dal.dao.som.VersionsRelationDAO;
+import org.splat.exception.DocumentIsUsedException;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MismatchException;
 import org.splat.kernel.MissedPropertyException;
@@ -479,13 +480,18 @@ public class StepServiceImpl implements StepService {
         * @param docId
         *            the document id
         * @return true if removing of the document succeeded
+        * @throws DocumentIsUsedException
+        *             if the document is used by other documents
         */
        @Transactional
-       public boolean removeDocument(final Step aStep, final long docId) {
+       public boolean removeDocument(final Step aStep, final long docId)
+                       throws DocumentIsUsedException {
                Publication torem = aStep.getDocument(docId);
                boolean res = (torem != null);
                if (res) {
-                       torem = getPublicationDAO().merge(torem);
+                       if (!torem.value().getRelations(UsedByRelation.class).isEmpty()) {
+                               throw new DocumentIsUsedException(torem.value().getTitle());
+                       }
                        remove(aStep, torem);
                        Document value = torem.value();
                        if (!value.isPublished() && !value.isVersioned()) { // The referenced document is no more used
@@ -509,11 +515,12 @@ public class StepServiceImpl implements StepService {
                                                                + doc.getTitle() + " to " + value.getTitle());
                                        }
                                        doc.removeRelation(UsedByRelation.class, value);
+                                       getDocumentDAO().merge(doc);
                                }
+                               value = getPublicationDAO().merge(torem).value();
                                // Synchronize deleted objects with the database to avoid hibernate exception
-                               // related with null value of not-nullable property because back reference from Document to Publication is not mapped:
                                // org.hibernate.PropertyValueException: not-null property references a null or transient value:
-                               // org.splat.dal.bo.som.Publication.mydoc
+                               // org.splat.dal.bo.som.UsedByRelation.refer
                                getDocumentDAO().flush(); // To show to the database that files from ConvertsRelation(s) are deleted already
                                getDocumentDAO().delete(value); // The corresponding physical file is not removed from the vault
                                // Delete document's files
index dd9b728c38187497fe9b7c90aae25a16f77ef96e..dc3d615f7fdf2d8b090083d9206100b6a2b1111a 100644 (file)
@@ -11,6 +11,7 @@ package test.splat.service;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.sql.SQLException;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -28,22 +29,17 @@ import org.splat.dal.bo.som.UsesRelation;
 import org.splat.dal.bo.som.Document.Properties;
 import org.splat.dal.dao.som.Database;
 import org.splat.dal.dao.som.ScenarioDAO;
+import org.splat.exception.BusinessException;
+import org.splat.exception.DocumentIsUsedException;
 import org.splat.kernel.InvalidPropertyException;
-import org.splat.kernel.MismatchException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.MultiplyDefinedException;
-import org.splat.kernel.NotApplicableException;
 import org.splat.log.AppLogger;
 import org.splat.service.DocumentTypeService;
-import org.splat.service.KnowledgeElementTypeService;
-import org.splat.service.ProjectElementService;
 import org.splat.service.PublicationService;
-import org.splat.service.ScenarioService;
-import org.splat.service.SimulationContextService;
 import org.splat.service.StepService;
 import org.splat.service.StudyService;
 import org.splat.service.technical.ProjectSettingsService;
-import org.splat.service.technical.RepositoryService;
 import org.splat.service.technical.ProjectSettingsService.Step;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -74,27 +70,6 @@ public class TestStepService extends BaseTest {
        @Qualifier("studyService")
        private transient StudyService _studyService;
 
-       /**
-        * The ScenarioService. Later injected by Spring.
-        */
-       @Autowired
-       @Qualifier("scenarioService")
-       private transient ScenarioService _scenarioService;
-
-       /**
-        * The ProjectElementService. Later injected by Spring.
-        */
-       @Autowired
-       @Qualifier("projectElementService")
-       private transient ProjectElementService _projectElementService;
-
-       /**
-        * The RepositoryService. Later injected by Spring.
-        */
-       @Autowired
-       @Qualifier("repositoryService")
-       private transient RepositoryService _repositoryService;
-
        /**
         * The Scenario DAO. Later injected by Spring.
         */
@@ -116,13 +91,6 @@ public class TestStepService extends BaseTest {
        @Qualifier("stepService")
        private transient StepService _stepService;
 
-       /**
-        * The SimulationContextService. Later injected by Spring.
-        */
-       @Autowired
-       @Qualifier("simulationContextService")
-       private transient SimulationContextService _simulationContextService;
-
        /**
         * The ProjectSettingsService. Later injected by Spring.
         */
@@ -138,33 +106,13 @@ public class TestStepService extends BaseTest {
        private transient DocumentTypeService _documentTypeService;
 
        /**
-        * The KnowledgeElementTypeService. Later injected by Spring.
-        */
-       @Autowired
-       @Qualifier("knowledgeElementTypeService")
-       private transient KnowledgeElementTypeService _knowledgeElementTypeService;
-
-       /**
-        * Test check-in scenario operation to be performed after SALOME session.<BR>
+        * Test removeDocument method.<BR>
         * <B>Description :</B> <BR>
-        * <i>Create a scenario and try to check-in it with some simulated SALOME results data.<BR>
-        * After check-in verify following points:
-        * <ul>
-        * <li>scenario is no more marked as checked out</li>
-        * <li>new document versions are created for checked in documents</li>
-        * <li>presentation of the previous version is removed</li>
-        * <li>uses relations are copied correctly</li>
-        * <li>files are moved correctly</li>
-        * <li>formats of files are new if they are according to the document's type on the study step</li>
-        * <li>new documents are created for new data</li>
-        * <li>new documents have correctly generated names</li>
-        * <li>uses relations are created correctly</li>
-        * <li>files are moved correctly</li>
-        * </ul>
+        * <i>Create a scenario and try to remove documents from it.<BR>
         * </i><BR>
         * <B>Action : </B><BR>
-        * <i>1. call the method for an existing scenario id.</i><BR>
-        * <i>2. call the method for a not existing scenario id.</i><BR>
+        * <i>1. call the method for all documents used by other document(s).</i><BR>
+        * <i>2. call the method for all documents starting from the last activity.</i><BR>
         * <B>Test data : </B><BR>
         * <i>no input parameters</i><BR>
         * <i>no input parameters</i><BR>
@@ -172,33 +120,23 @@ public class TestStepService extends BaseTest {
         * <B>Outcome results:</B><BR>
         * <i>
         * <ul>
-        * <li>New version of existing documents must be created and new documents must be imported for documents with zero id. Correct
-        * relations must be created.<BR>
+        * <li>Exception DocumentIsUsedException is expected<BR>
         * </li>
-        * <li>Exception is thrown<BR>
+        * <li>All documents and their files and relations must be removed<BR>
         * </li>
         * </ul>
         * </i>
         * 
-        * @throws InvalidPropertyException
-        *             if an invalid property is used when creating objects
-        * @throws MultiplyDefinedException
-        *             when trying to create an object with already existing id
-        * @throws MissedPropertyException
-        *             if a mandatory property is not defined for an object to be created
+        * @throws BusinessException
+        *             if scenario creation or checkin is failed
         * @throws IOException
         *             if scenario creation is failed
         * @throws SQLException
         *             if scenario creation is failed
-        * @throws NotApplicableException
-        *             if checkin failed
-        * @throws MismatchException
-        *             if checkin failed
         */
        @Test
-       public void testRemoveDocument() throws InvalidPropertyException,
-                       MissedPropertyException, MultiplyDefinedException, IOException,
-                       SQLException, MismatchException, NotApplicableException {
+       public void testRemoveDocument() throws BusinessException, IOException,
+                       SQLException {
                LOG.debug(">>>>> BEGIN testRemoveDocument()");
                startNestedTransaction();
 
@@ -212,20 +150,121 @@ public class TestStepService extends BaseTest {
                _scenarioDAO.flush();
                Scenario aScen = _scenarioDAO.get(scenarioId);
 
+               ht.evict(aScen);
+               ht.evict(aScen.getOwnerStudy());
+
                Assert.assertTrue(ht.find("from UsesRelation").size() > 0,
                                "Uses relations were not created in the database.");
 
                Assert.assertTrue(ht.find("from UsedByRelation").size() > 0,
                                "UsedBy relations were not created in the database.");
 
-               // ////////////////////////////////////////////////////////
-               // Call removeDocument method for each document of the
-               // study/scenario starting from the last document.
-
                ProjectElement projElem;
-               boolean ok;
+               boolean ok = false;
                long docId;
                Step step;
+               int nbDoc = ht.find("from Document").size();
+               int nbRemovedDoc = 0;
+               List<Long> removedDocs = new ArrayList<Long>();
+
+               // ////////////////////////////////////////////////////////
+               // Call removeDocument method for each document
+               // used by other document(s).
+               // Exception DocumentIsUsedException is expected
+               for (int i = 1; i <= _projectSettings.getAllSteps().size(); i++) {
+                       LOG.debug("Remove used documents from the step " + i);
+                       step = _projectSettings.getStep(i);
+                       if (step.appliesTo(Study.class)) {
+                               projElem = _studyService.selectStudy(aScen.getOwnerStudy()
+                                               .getIndex());
+                       } else {
+                               projElem = aScen;
+                       }
+
+                       org.splat.som.Step aScStep = new org.splat.som.Step(step, projElem);
+
+                       if (aScStep.getDocuments().size() > 0) {
+                               docId = aScStep.getDocuments().get(0).value().getIndex();
+                               ht.flush();
+                               List<UsesRelation> uses = ht
+                                               .find("from UsesRelation where owner=" + docId);
+                               List<UsedByRelation> usedBy = ht
+                                               .find("from UsedByRelation where owner=" + docId);
+                               if (!usedBy.isEmpty()) {
+                                       int usesRefer = ht.find(
+                                                       "from UsesRelation where refer=" + docId).size();
+                                       int usedByRefer = ht.find(
+                                                       "from UsedByRelation where refer=" + docId).size();
+                                       int convertsNb = ht.find(
+                                                       "from ConvertsRelation where owner=" + docId)
+                                                       .size();
+                                       LOG.debug("Remove used document "
+                                                       + aScStep.getDocument(docId).value().getTitle());
+                                       LOG.debug("From db: It uses following " + uses.size()
+                                                       + " documents: ");
+                                       for (UsesRelation rel : uses) {
+                                               LOG.debug(rel.getTo().getTitle());
+                                       }
+                                       LOG
+                                                       .debug("From step: It uses following "
+                                                                       + aScStep.getDocument(docId).value()
+                                                                                       .getRelations(UsesRelation.class)
+                                                                                       .size() + " documents: ");
+                                       for (Publication rel : aScStep.getDocument(docId)
+                                                       .getRelations(UsesRelation.class)) {
+                                               LOG.debug(rel.value().getTitle());
+                                       }
+                                       LOG.debug("From db: It is used by following "
+                                                       + usedBy.size() + " documents: ");
+                                       for (UsedByRelation rel : usedBy) {
+                                               LOG.debug(rel.getTo().getTitle());
+                                       }
+                                       LOG.debug("From step: It is used by following "
+                                                       + aScStep.getDocument(docId).value().getRelations(
+                                                                       UsedByRelation.class).size()
+                                                       + " documents: ");
+                                       for (Publication rel : aScStep.getDocument(docId)
+                                                       .getRelations(UsedByRelation.class)) {
+                                               LOG.debug(rel.value().getTitle());
+                                       }
+                                       try {
+                                               ok = _stepService.removeDocument(aScStep, docId);
+                                               Assert.fail("DocumentIsUsedException must be thrown.");
+                                       } catch (DocumentIsUsedException e) {
+                                               LOG.debug("Expected exception is thrown: "
+                                                               + e.getLocalizedMessage());
+                                       }
+                                       _scenarioDAO.flush();
+                                       ht.flush();
+                                       Assert
+                                                       .assertEquals(ht.find(
+                                                                       "from UsesRelation where owner=" + docId)
+                                                                       .size(), uses.size(),
+                                                                       "UsesRelation(s) must not be changed.");
+                                       Assert.assertEquals(ht.find(
+                                                       "from UsedByRelation where owner=" + docId).size(),
+                                                       usedBy.size(),
+                                                       "UsedByRelation(s) must not be changed.");
+                                       Assert.assertEquals(ht.find(
+                                                       "from UsesRelation where refer=" + docId).size(),
+                                                       usesRefer,
+                                                       "Referencing UsesRelation(s) must not be changed.");
+                                       Assert
+                                                       .assertEquals(ht.find(
+                                                                       "from UsedByRelation where refer=" + docId)
+                                                                       .size(), usedByRefer,
+                                                                       "Referencing UsedByRelation(s) must not be changed.");
+                                       Assert.assertEquals(ht.find(
+                                                       "from ConvertsRelation where owner=" + docId)
+                                                       .size(), convertsNb,
+                                                       "ConvertsRelation(s) must not be changed.");
+                               }
+                       }
+               }
+
+               // ////////////////////////////////////////////////////////
+               // Call removeDocument method for each document
+               // starting from the last activity.
                for (int i = _projectSettings.getAllSteps().size(); i > 0; i--) {
                        LOG.debug("Remove documents from the step " + i);
                        step = _projectSettings.getStep(i);
@@ -240,7 +279,7 @@ public class TestStepService extends BaseTest {
 
                        if (aScStep.getDocuments().size() > 0) {
                                docId = aScStep.getDocuments().get(0).value().getIndex();
-                               LOG.debug("Remove document "
+                               LOG.debug("Remove document#" + docId + " "
                                                + aScStep.getDocument(docId).value().getTitle());
                                ht.flush();
                                List<UsesRelation> uses = ht
@@ -271,11 +310,32 @@ public class TestStepService extends BaseTest {
                                                UsedByRelation.class)) {
                                        LOG.debug(rel.value().getTitle());
                                }
+                               Assert.assertEquals(ht.find("from Document where rid=" + docId)
+                                               .size(), 1, "Nothing to delete.");
+
                                ok = _stepService.removeDocument(aScStep, docId);
 
+                               nbRemovedDoc++;
+                               removedDocs.add(docId);
+
                                Assert.assertTrue(ok, "Removing was failed.");
                                _scenarioDAO.flush();
                                ht.flush();
+
+                               for (Long id : removedDocs) {
+                                       String title = "";
+                                       if (ht.get(Document.class, id) != null) {
+                                               title = ht.get(Document.class, id).getTitle();
+                                       }
+                                       Assert.assertEquals(ht
+                                                       .find("from Document where rid=" + id).size(), 0,
+                                                       "Document#" + id + "(" + title
+                                                                       + ") was not removed from the database.");
+                               }
+
+                               Assert.assertEquals(ht.find("from Document").size(), nbDoc
+                                               - nbRemovedDoc,
+                                               "Documents were not removed from the database.");
                                Assert.assertEquals(ht.find(
                                                "from UsesRelation where owner=" + docId).size(), 0,
                                                "UsesRelation(s) were not removed from the database.");
@@ -284,25 +344,33 @@ public class TestStepService extends BaseTest {
                                                                "from UsedByRelation where owner=" + docId)
                                                                .size(), 0,
                                                                "UsedByRelation(s) were not removed from the database.");
-                               Assert.assertEquals(ht.find(
-                                               "from UsesRelation where refer=" + docId).size(), 0,
-                                               "Referencing UsesRelation(s) were not removed from the database.");
+                               Assert
+                                               .assertEquals(ht.find(
+                                                               "from UsesRelation where refer=" + docId)
+                                                               .size(), 0,
+                                                               "Referencing UsesRelation(s) were not removed from the database.");
                                Assert
                                                .assertEquals(ht.find(
                                                                "from UsedByRelation where refer=" + docId)
                                                                .size(), 0,
                                                                "Referencing UsedByRelation(s) were not removed from the database.");
                                Assert
-                               .assertEquals(ht.find(
-                                               "from ConvertsRelation where owner=" + docId)
-                                               .size(), 0,
-                                               "ConvertsRelation(s) were not removed from the database.");
+                                               .assertEquals(ht.find(
+                                                               "from ConvertsRelation where owner=" + docId)
+                                                               .size(), 0,
+                                                               "ConvertsRelation(s) were not removed from the database.");
                        }
                }
 
-               Assert.assertEquals(ht.find("from Document").size(), 0,
-                               "Documents were not removed from the database.");
+               Assert
+                               .assertEquals(ht.find("from Document").size(), nbDoc
+                                               - nbRemovedDoc,
+                                               "Documents were not removed from the database.");
 
+               Assert
+               .assertEquals(ht.find("from File").size(), 0,
+                               "Files were not removed from the database.");
+               
                Assert.assertEquals(ht.find(
                                "from Publication where owner=" + aScen.getIndex()).size(), 0,
                                "Publications were not removed from the database.");
index c4260d8d71ebb82ad5b2acb5deb96d2208b8760d..795572d80f3447fa2df9efa89e44c779a804abf7 100644 (file)
@@ -6,6 +6,7 @@ import java.util.Calendar;
 import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.ConvertsRelation;
 import org.splat.dal.bo.som.Publication;
+import org.splat.exception.DocumentIsUsedException;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.service.PublicationService;
 import org.splat.service.StepService;
@@ -137,7 +138,17 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                }
        }
 
-       public String doDeleteDocument() {
+       /**
+        * Remove the selected document from the current activity.
+        * 
+        * @return SUCCESS
+        * @throws DocumentIsUsedException
+        *             if the document is used by other document(s)
+        * @throws NumberFormatException
+        *             if the document id can not be transformed to number
+        */
+       public String doDeleteDocument() throws DocumentIsUsedException,
+                       NumberFormatException {
 
                setMenu();
                _openStudy = getOpenStudy();