リファクタリング

This commit is contained in:
r-ca 2024-01-08 12:29:24 +09:00
parent a42ef8f4fc
commit a78cac8178
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -31,6 +31,7 @@ public class DocumentProcessorImpl implements DocumentProcessor{
private static final String DEFAULT_SAVE_DIR = "raw"; private static final String DEFAULT_SAVE_DIR = "raw";
private DocumentDetail documentDetail; private DocumentDetail documentDetail;
private XmlMetaModel xmlMetaModel; private XmlMetaModel xmlMetaModel;
private Path documentRootPath;
// Injection // Injection
private FileManagerFactory fileManagerFactory; private FileManagerFactory fileManagerFactory;
@ -50,13 +51,12 @@ public class DocumentProcessorImpl implements DocumentProcessor{
@Override @Override
public void init() { public void init() {
logger.debug("init", "called"); logger.debug("init", "called");
Path path = documentDetail.getPath().getFullPath(); // Init Variables
logger.debug("init", "path: " + path.toString()); this.documentRootPath = documentDetail.getPath().getFullPath();
FileManager fileManager = fileManagerFactory.create(path); //Initialize FileManager FileManager fileManager = fileManagerFactory.create(this.documentRootPath); //Initialize FileManager
fileManager.changeDir(path); fileManager.autoCreateDir(this.documentRootPath);
fileManager.autoCreateToCurrentDir();
// rawディレクトリInit // rawディレクトリInit
fileManager.autoCreateDir(DEFAULT_SAVE_DIR); fileManager.autoCreateDir(DEFAULT_SAVE_DIR);
@ -92,11 +92,10 @@ public class DocumentProcessorImpl implements DocumentProcessor{
@Override @Override
public void addNewPageToLast(Bitmap bitmap) { public void addNewPageToLast(Bitmap bitmap) {
logger.debug("addNewPageToLast", "called"); logger.debug("addNewPageToLast", "called");
Path path = documentDetail.getPath().getFullPath();
String fileName = String.format(UUID.randomUUID().toString() + ".png"); // TODO-rca: 対応表をもたせる String fileName = String.format(UUID.randomUUID().toString() + ".png"); // TODO-rca: 対応表をもたせる
logger.debug("addNewPageToLast", "fileName: " + fileName); logger.debug("addNewPageToLast", "fileName: " + fileName);
FileManager fileManager = fileManagerFactory.create(path); FileManager fileManager = fileManagerFactory.create(this.documentRootPath);
if(fileManager.getList().contains(path.resolve(DEFAULT_SAVE_DIR))) { if(fileManager.getList().contains(this.documentRootPath.resolve(DEFAULT_SAVE_DIR))) {
logger.debug("addNewPageToLast", "raw dir found"); logger.debug("addNewPageToLast", "raw dir found");
fileManager.changeDir(DEFAULT_SAVE_DIR); fileManager.changeDir(DEFAULT_SAVE_DIR);
} else { } else {