A Document Management System (DMS) is a system that allows you to store files and keep track of the versions of those files. Ontimize Boot provides a DMS system that allows to store the files that are associated to the different records of a database table.
Previous concepts
Document (or workspace): It is superentity into which several files can be grouped.
File: The file is the generic representation of a file. A file groups several versions of itself.
Version: Is the relationship to a physical file.
Category (or folder): Is a way of grouping files within the document.
Prerequisites
You can follow this tutorial using your own application, although for this example we will use an application created using the archetype that can be found on this page and with a REST service.
There are 2 options to follow this tutorial, clone the repository with the initial state and follow the tutorial step by step, or download the final example and see which files are new and which have been updated.
To simplify the code being written, three dots (…) may appear in some parts of the code. This indicates that there may be previous code before and after those dots.
Steps
Database
DMS Tables
With the database started, we create the new tables that will store the DMS information.
Once the tables have been created, we add the foreign keys
Link DMS table with entity table
In this example we want each new candidate added to the application to have its own space to store documents, so we will modify the CANDIDATES table to contain a column that stores the primary key of the document (or workspace) that will be associated with it.
Server
Add DMS dependencies
model/pom.xml
ws/pom.xml
ontimize-examples
projectwiki-api
src
main
java
com
ontimize
projectwiki
api
core
service
ICandidateService.java
IUserService.java
pom.xml
projectwiki-boot
src
main
java
com
ontimize
projectwiki
ServerApplication.java
resources
application.yml
pom.xml
projectwiki-model
src
main
db
templateDB.properties
templateDB.txt
java
com
ontimize
projectwiki
model
core
dao
CandidateDao.java
UserDao.java
UserRoleDao.java
service
CandidateService.java
UserService.java
resources
dao
CandidateDao.xml
placeholders.properties
RoleDao.xml
RoleServerPermissionDao.xml
ServerPermissionDao.xml
UserDao.xml
UserRoleDao.xml
pom.xml
projectwiki-ws
src
main
java
com
ontimize
projectwiki
ws
core
rest
CandidateRestController.java
MainRestController.java
TestRestController.java
UserRestController.java
pom.xml
.gitignore
pom.xml
README.md
Add DMS DAO and modify Candidate DAO
A specific DAO will be created for each table in the DMS system, and each of them will implement a different interface. In turn, the candidate DAO will be modified to reflect the new column it contains.
DMSCategoryDao.xml
DMSDocumentDao.xml
DMSDocumentFileDao.xml
DMSDocumentFileVersionDao.xml
DMSDocumentPropertyDao.xml
DMSRelatedDocumentDao.xml
ontimize-examples
projectwiki-api
src
main
java
com
ontimize
projectwiki
api
core
service
ICandidateService.java
IUserService.java
pom.xml
projectwiki-boot
src
main
java
com
ontimize
projectwiki
ServerApplication.java
resources
application.yml
pom.xml
projectwiki-model
src
main
db
templateDB.properties
templateDB.txt
java
com
ontimize
projectwiki
model
core
dao
CandidateDao.java
UserDao.java
UserRoleDao.java
service
CandidateService.java
UserService.java
resources
dao
CandidateDao.xml
DMSCategoryDao.xml
DMSDocumentDao.xml
DMSDocumentFileDao.xml
DMSDocumentFileVersionDao.xml
DMSDocumentPropertyDao.xml
DMSRelatedDocumentDao.xml
placeholders.properties
RoleDao.xml
RoleServerPermissionDao.xml
ServerPermissionDao.xml
UserDao.xml
UserRoleDao.xml
pom.xml
projectwiki-ws
src
main
java
com
ontimize
projectwiki
ws
core
rest
CandidateRestController.java
MainRestController.java
TestRestController.java
UserRestController.java
pom.xml
.gitignore
pom.xml
README.md
CandidateDao.java
DMSCategoryDao.java
DMSDocumentDao.java
DMSDocumentFileDao.java
DMSDocumentFileVersionDao.java
DMSDocumentPropertyDao.java
DMSRelatedDocumentDao.java
ontimize-examples
projectwiki-api
src
main
java
com
ontimize
projectwiki
api
core
service
ICandidateService.java
IUserService.java
pom.xml
projectwiki-boot
src
main
java
com
ontimize
projectwiki
ServerApplication.java
resources
application.yml
pom.xml
projectwiki-model
src
main
db
templateDB.properties
templateDB.txt
java
com
ontimize
projectwiki
model
core
dao
CandidateDao.java
DMSCategoryDao.java
DMSDocumentDao.java
DMSDocumentFileDao.java
DMSDocumentFileVersionDao.java
DMSDocumentPropertyDao.java
DMSRelatedDocumentDao.java
UserDao.java
UserRoleDao.java
service
CandidateService.java
UserService.java
resources
dao
CandidateDao.xml
DMSCategoryDao.xml
DMSDocumentDao.xml
DMSDocumentFileDao.xml
DMSDocumentFileVersionDao.xml
DMSDocumentPropertyDao.xml
DMSRelatedDocumentDao.xml
placeholders.properties
RoleDao.xml
RoleServerPermissionDao.xml
ServerPermissionDao.xml
UserDao.xml
UserRoleDao.xml
pom.xml
projectwiki-ws
src
main
java
com
ontimize
projectwiki
ws
core
rest
CandidateRestController.java
MainRestController.java
TestRestController.java
UserRestController.java
pom.xml
.gitignore
pom.xml
README.md
Modify CandidateService insert method
The method of inserting new candidates will be modified so that, when inserting them, they will have a workspace to maintain the files to be uploaded associated with the inserted candidate.
CandidateService.java
ontimize-examples
projectwiki-api
src
main
java
com
ontimize
projectwiki
api
core
service
ICandidateService.java
IUserService.java
pom.xml
projectwiki-boot
src
main
java
com
ontimize
projectwiki
ServerApplication.java
resources
application.yml
pom.xml
projectwiki-model
src
main
db
templateDB.properties
templateDB.txt
java
com
ontimize
projectwiki
model
core
dao
CandidateDao.java
DMSCategoryDao.java
DMSDocumentDao.java
DMSDocumentFileDao.java
DMSDocumentFileVersionDao.java
DMSDocumentPropertyDao.java
DMSRelatedDocumentDao.java
UserDao.java
UserRoleDao.java
service
CandidateService.java
UserService.java
resources
dao
CandidateDao.xml
DMSCategoryDao.xml
DMSDocumentDao.xml
DMSDocumentFileDao.xml
DMSDocumentFileVersionDao.xml
DMSDocumentPropertyDao.xml
DMSRelatedDocumentDao.xml
placeholders.properties
RoleDao.xml
RoleServerPermissionDao.xml
ServerPermissionDao.xml
UserDao.xml
UserRoleDao.xml
pom.xml
projectwiki-ws
src
main
java
com
ontimize
projectwiki
ws
core
rest
CandidateRestController.java
MainRestController.java
TestRestController.java
UserRestController.java
pom.xml
.gitignore
pom.xml
README.md
Add File Manager Rest Controller
DMSNameConverter.java
FileManagerRestController.java
ontimize-examples
projectwiki-api
src
main
java
com
ontimize
projectwiki
api
core
service
ICandidateService.java
IUserService.java
pom.xml
projectwiki-boot
src
main
java
com
ontimize
projectwiki
ServerApplication.java
resources
application.yml
pom.xml
projectwiki-model
src
main
db
templateDB.properties
templateDB.txt
java
com
ontimize
projectwiki
model
core
dao
CandidateDao.java
DMSCategoryDao.java
DMSDocumentDao.java
DMSDocumentFileDao.java
DMSDocumentFileVersionDao.java
DMSDocumentPropertyDao.java
DMSRelatedDocumentDao.java
UserDao.java
UserRoleDao.java
service
CandidateService.java
UserService.java
resources
dao
CandidateDao.xml
DMSCategoryDao.xml
DMSDocumentDao.xml
DMSDocumentFileDao.xml
DMSDocumentFileVersionDao.xml
DMSDocumentPropertyDao.xml
DMSRelatedDocumentDao.xml
placeholders.properties
RoleDao.xml
RoleServerPermissionDao.xml
ServerPermissionDao.xml
UserDao.xml
UserRoleDao.xml
pom.xml
projectwiki-ws
src
main
java
com
ontimize
projectwiki
ws
core
rest
CandidateRestController.java
DMSNameConverter.java
FileManagerRestController.java
MainRestController.java
TestRestController.java
UserRestController.java
pom.xml
.gitignore
pom.xml
README.md
Modify application.yml
The application.yml file will be modified to indicate the path where the dms files will be stored and the engine it will use. In this link you have information about the configuration of the DMS system in the application.yml file.
The path specified in the basePath variable must exist before the server is started.
application.yml
ontimize-examples
projectwiki-api
src
main
java
com
ontimize
projectwiki
api
core
service
ICandidateService.java
IUserService.java
pom.xml
projectwiki-boot
src
main
java
com
ontimize
projectwiki
ServerApplication.java
resources
application.yml
pom.xml
projectwiki-model
src
main
db
templateDB.properties
templateDB.txt
java
com
ontimize
projectwiki
model
core
dao
CandidateDao.java
DMSCategoryDao.java
DMSDocumentDao.java
DMSDocumentFileDao.java
DMSDocumentFileVersionDao.java
DMSDocumentPropertyDao.java
DMSRelatedDocumentDao.java
UserDao.java
UserRoleDao.java
service
CandidateService.java
UserService.java
resources
dao
CandidateDao.xml
DMSCategoryDao.xml
DMSDocumentDao.xml
DMSDocumentFileDao.xml
DMSDocumentFileVersionDao.xml
DMSDocumentPropertyDao.xml
DMSRelatedDocumentDao.xml
placeholders.properties
RoleDao.xml
RoleServerPermissionDao.xml
ServerPermissionDao.xml
UserDao.xml
UserRoleDao.xml
pom.xml
projectwiki-ws
src
main
java
com
ontimize
projectwiki
ws
core
rest
CandidateRestController.java
DMSNameConverter.java
FileManagerRestController.java
MainRestController.java
TestRestController.java
UserRestController.java
pom.xml
.gitignore
pom.xml
README.md
Add permissions
It is necessary to add the permissions required for the role associated with the user to be able to execute REST requests, which are secured. For the example, we will add all the methods and give access to the demo user role.