Skip to content

Latest commit

 

History

History

plume-file-metadata-database

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Plume File Metadata Database

A Plume File module to store file metadata into database, with a strong reference to a database object through a foreign key.

The metadata-database module implements the FileMetadataService of the core module.

Setup

  1. Install Maven dependency:
<dependency>
  <groupId>com.coreoz</groupId>
  <artifactId>plume-file-metadata-database</artifactId>
</dependency>
  1. In the ApplicationModule class, install the following Guice module:
install(new GuiceFileMetadataDatabaseModule());
  1. Create the plm_file table by applying the correct creation script

  2. Create a foreign key between the plm_file table and your project table :

CREATE TABLE `PLM_USER_FILE`
(
    `user_id`          bigint(20)   NOT NULL,
    `file_unique_name` VARCHAR(255) NOT NULL,
    FOREIGN KEY (file_unique_name) REFERENCES PLM_FILE (unique_name)
)
    DEFAULT CHARSET = utf8;

Each table that references the PLM_FILE table must have a FileTypeDatabase enum entry.

  1. Create a FileTypeDatabase enum

A FileTypeDatabase is an implementation of the FileType interface needed in the core. The FileTypeDatabase will reference the QueryDsl EntityPath database column that references to the file metadata table.

For example, if my plm_file table is referenced by my project table column plm_user_file.file_unique_name, my project file type will look like this :

public enum MyProjectFileType implements FileTypeDatabase {
    ENUM(QUserFile.userFile, QUserFile.userFile.fileUniqueName)
    ;

    private final EntityPath<?> fileEntity;
    private final StringPath joinColumn;

    ShowcaseFileType(EntityPath<?> fileEntity, StringPath joinColumn) {
        this.fileEntity = fileEntity;
        this.joinColumn = joinColumn;
    }

    @Override
    public EntityPath<?> getFileEntity() {
        return fileEntity;
    }

    @Override
    public StringPath getJoinColumn() {
        return joinColumn;
    }
}
  1. Create an implementation of FileTypeProvider

The FileTypeProvider will be used to get the FileTypeDatabase types directly injected in the classes.

public class MyProjectFileTypesProvider implements FileTypesProvider {
    @Override
    public Collection<FileTypeDatabase> fileTypesAvailable() {
        return List.of(MyProjectFileType.values());
    }
}

Don't forget to bind the implementation to the interface in your ApplicationModule :

bind(FileTypesProvider.class).to(MyProjectFileTypesProvider.class);