Source:
public void convertProcess(int index) throws DAOException, IOException, ConfigurationException { final long begin = System.nanoTime(); Integer processId = processesTransfer.get(index).getId(); Process process = processService.getById(processId); String processTitle = process.getTitle(); logger.info("Starting to convert process (ID {})...", processTitle, processId); URI metadataFilePath = fileService.getMetadataFilePath(process); URI anchorFilePath = insertBeforeXml(metadataFilePath, APPENDIX_ANCOR); URI yearFilePath = insertBeforeXml(metadataFilePath, APPENDIX_YEAR); dataEditorService.readData(anchorFilePath); dataEditorService.readData(yearFilePath); dataEditorService.readData(metadataFilePath); Workpiece workpiece = metsService.loadWorkpiece(metadataFilePath); IncludedStructuralElement newspaperIncludedStructuralElement = workpiece.getRootElement(); if (Objects.isNull(title)) { initializeMigrator(process, newspaperIncludedStructuralElement.getType()); } IncludedStructuralElement yearIncludedStructuralElement = cutOffTopLevel(newspaperIncludedStructuralElement); final String year = createLinkStructureAndCopyDates(process, yearFilePath, yearIncludedStructuralElement); workpiece.setRootElement(cutOffTopLevel(yearIncludedStructuralElement)); metsService.saveWorkpiece(workpiece, metadataFilePath); for (Metadata metadata : metsService.loadWorkpiece(anchorFilePath).getRootElement().getMetadata()) { if (!overallMetadata.contains(metadata)) { logger.debug("Adding metadata to newspaper {}: {}", title, metadata); overallMetadata.add(metadata); } } yearsChildren.computeIfAbsent(year, each -> new ArrayList<>()).add(processId); ServiceManager.getFileService().renameFile(anchorFilePath, "meta_anchor.migrated"); ServiceManager.getFileService().renameFile(yearFilePath, "meta_year.migrated"); logger.info("Process (ID {}) successfully converted.", processTitle, processId); if (logger.isTraceEnabled()) { logger.trace("Converting took ms.", processTitle, TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - begin)); } }

Target:
public void convertProcess(int index) throws DAOException, IOException, ConfigurationException { final long begin = System.nanoTime(); Integer processId = transferredProcess.get(index).getId(); Process process = processService.getById(processId); String processTitle = process.getTitle(); logger.info("Starting to convert process (ID {})...", processTitle, processId); URI metadataFilePath = fileService.getMetadataFilePath(process); URI anchorFilePath = fileService.createAnchorFile(metadataFilePath); URI yearFilePath = fileService.createYearFile(metadataFilePath); dataEditorService.readData(anchorFilePath); dataEditorService.readData(yearFilePath); dataEditorService.readData(metadataFilePath); Workpiece workpiece = metsService.loadWorkpiece(metadataFilePath); IncludedStructuralElement newspaperIncludedStructuralElement = workpiece.getRootElement(); if (Objects.isNull(title)) { initializeMigrator(process, newspaperIncludedStructuralElement.getType()); } IncludedStructuralElement yearIncludedStructuralElement = cutOffTopLevel(newspaperIncludedStructuralElement); final String year = createLinkStructureAndCopyDates(process, yearFilePath, yearIncludedStructuralElement); workpiece.setRootElement(cutOffTopLevel(yearIncludedStructuralElement)); metsService.saveWorkpiece(workpiece, metadataFilePath); for (Metadata metadata : metsService.loadWorkpiece(anchorFilePath).getRootElement().getMetadata()) { if (!overallMetadata.contains(metadata)) { logger.debug("Adding metadata to newspaper {}: {}", title, metadata); overallMetadata.add(metadata); } } yearsChildren.computeIfAbsent(year, each -> new ArrayList<>()).add(processId); ServiceManager.getFileService().renameFile(anchorFilePath, "meta_anchor.migrated"); ServiceManager.getFileService().renameFile(yearFilePath, "meta_year.migrated"); logger.info("Process (ID {}) successfully converted.", processTitle, processId); if (logger.isTraceEnabled()) { logger.trace("Converting took ms.", processTitle, TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - begin)); } }