Skip to content

3.1.5 SUBMOD.001.005 : Delete AML File

NamidM edited this page May 20, 2021 · 19 revisions

Contents

Changelog

Version Date Author Comment
0.1 17.01.2021 Namid Marxen und Nils-Christopher Wiesenauer created
1.0 14.05.2021 Namid Marxen und Nils-Christopher Wiesenauer finished

1. Scope

The Module Documentations (MODs) describes the architecture, the interfaces and the main features of the module. It also describes the module/component test including the results. It can also serve as a programming or integration manual for the module. If there are some risks related to the module itself, they shall be noted and commented within this document.

2. Definitions

AML: Automation Markup Language

CRUD: Create Read Update Delete

GUI: Graphical User Interface

JSend: A specification that lays down some rules for how JSON responses from web servers should be formatted

SAS: System Architecture Specification

SRS: System Requirements Specification

3 Module requirements

This submodule contains the endpoint for deleting stored AML files.

This REST API is the most important module because it contains the logic for converting the AML file to JSON. It also includes the authorization to the database. When a file is uploaded to the server it is converted from an AML format to a JSON format so that it can be saved in the MongoDB database. The content of the files are saved as a string and then converted into one JSON object, so that each file has their own database entry, with the JSON object as the content.

3.1 User view

The user has the ability to delete files stored in the database. He can click a button in the list of files to delete a file.

3.2 Requirements

The submodule contains the requirement LF80 which describes that the user can delete files. With this feature the user can click on a button to delete a file which sends a DELETE request to the REST API. The REST API then sends a delete request to the MongoDB database.

3.3 Module Context

The submodule to delete AML files gives the user the ability to delete saved files. The user sends a DELETE request from the GUI and the REST API sends a request to the database to delete a specific file.

Component REST API Submodule 5

4. Analysis

This feature is important, because the user has to have the ability to delete files.

5. Design

We included all /file routes into our server.js where the FILE schema is imported to have every endpoint together and clear.

5.1 Risks

When the user cannot delete AML files anymore, the files cannot be removed from the database.

6. Implementation

Link to sourcecode: server.js

6.1 Delete document by _id from database

The needed /file/:id DELETE endpoint is defined below. Here we are using the created FILE model to delete a file document by _id from MongoDB by using FILE.deleteFile(_id, callback).

const FILE = require('./models/file');
...
app.delete('/file/:id', (req, res) => {
  FILE.deleteFile(req.params.id, (err, file) => {
    >> 6.2 Response
  });
});
...

6.2 Response

After saying we want to delete a document with the provided _id we have different callback. If an error ocurred, we are sending a JSend with status 'error' and a defined message back. If everything was correct and the file was deleted, and we are sending a JSend with status 'success' back.

...
if (!err && file) {
  res.status(200).send({ status: 'success', data: file });
} else {
  res.status(200).send({ status: 'error', message: 'Unable to delete file' });
}
...

7. Module Test

Module Test Documentation

8. Summary

The endpoint/submodule to delete an AML file is neccessary to provide the user with the ability to delete a specific file. It is triggered by a request from the GUI when clicked on the delete button of a specific file. The request is processed by the REST API and another request is sent to the database.

The implementation of the module is descriped with SwaggerUI.

9. Appendix

9.1 References

  1. SRS (System Requirements Specification)
  2. SAS (System Architecuture Specification)
  3. Systemtestplan

9.2 Sourcecode

The source code of this module can be found here: aml-database-management-api

9.3 Module Test Cases

Testcase <TC.REST.003.F> (DELETE call)

Testcase ID: TC.REST.003.F
Testcase Name: DELETE call
Requirement ID(s): LF110, LF100, LF30
Description: The test case verifies that the REST API DELETE call works as documented in the SRS

Test Steps:

Step Action Expected Result
1 Use the GUI to upload two files Two files are uploaded and visible in the table in the home page
2 Open Postman and send the following GET request: localhost:3000/file. Remember the _id attribute of one of the files One of the _id attributes is remembered.
3 Send the following DELETE request: localhost:3000/file/{mongoDBID}, where {mongoDBID} is the _id attribute of the first file that has been received in step 2. You receive "status": "success" as well as the a response in the format below, along with HTTP-Code 200.
2 Send the following GET request: localhost:3000/file Verify only the not deleted file is not returned anymore, along with HTTP-Code 200.
{
    "status": "success",
    "data": {
        "n": 1,
        "ok": 1,
        "deletedCount": 1
    }
}
Clone this wiki locally