@RunWithCustomExecutor @Test public void testPrepareObjectGroupDistribution() throws Exception { givenInitialReportData(); givenUnits("IngestCleanup/Preparation/units.json"); givenObjectGroups("IngestCleanup/Preparation/objectGroups.json"); givenExistingAccessionRegisterDetails(); ItemStatus itemStatus = instance.execute(params, handlerIO); assertThat(itemStatus.getGlobalStatus()).isEqualTo(StatusCode.OK); assertJsonlReportsEqualUnordered( handlerIO.getFileFromWorkspace(IngestCleanupPreparationPlugin.OBJECT_GROUPS_TO_DELETE_JSONL), PropertiesUtils.getResourceFile("IngestCleanup/Preparation/expectedObjectGroupDistributionFile.jsonl"), 0); }
@Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { String ingestOperationId = param.getParameterValue(WorkerParameterName.ingestOperationIdToCleanup); PurgeAccessionRegisterModel accessionRegisterModel = new PurgeAccessionRegisterModel(); accessionRegisterModel.setOpi(ingestOperationId); CleanupReportManager cleanupReportManager = loadCleanupReportManager(handler); prepareUnits(handler, ingestOperationId, accessionRegisterModel, cleanupReportManager); prepareObjectGroups(handler, ingestOperationId, accessionRegisterModel, cleanupReportManager); prepareAccessingRegister(handler, ingestOperationId, accessionRegisterModel); cleanupReportManager.persistReportDataToWorkspace(handler); LOGGER.info("Ingest cleanup preparation succeeded"); return buildItemStatus(INGEST_CLEANUP_PREPARATION, StatusCode.OK); } catch (ProcessingStatusException e) { LOGGER.error(String.format("Ingest cleanup preparation failed with status [%s]", e.getStatusCode()), e); return buildItemStatus(INGEST_CLEANUP_PREPARATION, e.getStatusCode(), e.getEventDetails()); } }
IngestCleanupPreparationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { String ingestOperationId = param.getParameterValue(WorkerParameterName.ingestOperationIdToCleanup); PurgeAccessionRegisterModel accessionRegisterModel = new PurgeAccessionRegisterModel(); accessionRegisterModel.setOpi(ingestOperationId); CleanupReportManager cleanupReportManager = loadCleanupReportManager(handler); prepareUnits(handler, ingestOperationId, accessionRegisterModel, cleanupReportManager); prepareObjectGroups(handler, ingestOperationId, accessionRegisterModel, cleanupReportManager); prepareAccessingRegister(handler, ingestOperationId, accessionRegisterModel); cleanupReportManager.persistReportDataToWorkspace(handler); LOGGER.info("Ingest cleanup preparation succeeded"); return buildItemStatus(INGEST_CLEANUP_PREPARATION, StatusCode.OK); } catch (ProcessingStatusException e) { LOGGER.error(String.format("Ingest cleanup preparation failed with status [%s]", e.getStatusCode()), e); return buildItemStatus(INGEST_CLEANUP_PREPARATION, e.getStatusCode(), e.getEventDetails()); } } }
IngestCleanupPreparationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { String ingestOperationId = param.getParameterValue(WorkerParameterName.ingestOperationIdToCleanup); PurgeAccessionRegisterModel accessionRegisterModel = new PurgeAccessionRegisterModel(); accessionRegisterModel.setOpi(ingestOperationId); CleanupReportManager cleanupReportManager = loadCleanupReportManager(handler); prepareUnits(handler, ingestOperationId, accessionRegisterModel, cleanupReportManager); prepareObjectGroups(handler, ingestOperationId, accessionRegisterModel, cleanupReportManager); prepareAccessingRegister(handler, ingestOperationId, accessionRegisterModel); cleanupReportManager.persistReportDataToWorkspace(handler); LOGGER.info("Ingest cleanup preparation succeeded"); return buildItemStatus(INGEST_CLEANUP_PREPARATION, StatusCode.OK); } catch (ProcessingStatusException e) { LOGGER.error(String.format("Ingest cleanup preparation failed with status [%s]", e.getStatusCode()), e); return buildItemStatus(INGEST_CLEANUP_PREPARATION, e.getStatusCode(), e.getEventDetails()); } } IngestCleanupPreparationPlugin(); @VisibleForTesting  IngestCleanupPreparationPlugin(MetaDataClientFactory metaDataClientFactory,
        AdminManagementClientFactory adminManagementClientFactory); }
IngestCleanupPreparationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { String ingestOperationId = param.getParameterValue(WorkerParameterName.ingestOperationIdToCleanup); PurgeAccessionRegisterModel accessionRegisterModel = new PurgeAccessionRegisterModel(); accessionRegisterModel.setOpi(ingestOperationId); CleanupReportManager cleanupReportManager = loadCleanupReportManager(handler); prepareUnits(handler, ingestOperationId, accessionRegisterModel, cleanupReportManager); prepareObjectGroups(handler, ingestOperationId, accessionRegisterModel, cleanupReportManager); prepareAccessingRegister(handler, ingestOperationId, accessionRegisterModel); cleanupReportManager.persistReportDataToWorkspace(handler); LOGGER.info("Ingest cleanup preparation succeeded"); return buildItemStatus(INGEST_CLEANUP_PREPARATION, StatusCode.OK); } catch (ProcessingStatusException e) { LOGGER.error(String.format("Ingest cleanup preparation failed with status [%s]", e.getStatusCode()), e); return buildItemStatus(INGEST_CLEANUP_PREPARATION, e.getStatusCode(), e.getEventDetails()); } } IngestCleanupPreparationPlugin(); @VisibleForTesting  IngestCleanupPreparationPlugin(MetaDataClientFactory metaDataClientFactory,
        AdminManagementClientFactory adminManagementClientFactory); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); }
IngestCleanupPreparationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { String ingestOperationId = param.getParameterValue(WorkerParameterName.ingestOperationIdToCleanup); PurgeAccessionRegisterModel accessionRegisterModel = new PurgeAccessionRegisterModel(); accessionRegisterModel.setOpi(ingestOperationId); CleanupReportManager cleanupReportManager = loadCleanupReportManager(handler); prepareUnits(handler, ingestOperationId, accessionRegisterModel, cleanupReportManager); prepareObjectGroups(handler, ingestOperationId, accessionRegisterModel, cleanupReportManager); prepareAccessingRegister(handler, ingestOperationId, accessionRegisterModel); cleanupReportManager.persistReportDataToWorkspace(handler); LOGGER.info("Ingest cleanup preparation succeeded"); return buildItemStatus(INGEST_CLEANUP_PREPARATION, StatusCode.OK); } catch (ProcessingStatusException e) { LOGGER.error(String.format("Ingest cleanup preparation failed with status [%s]", e.getStatusCode()), e); return buildItemStatus(INGEST_CLEANUP_PREPARATION, e.getStatusCode(), e.getEventDetails()); } } IngestCleanupPreparationPlugin(); @VisibleForTesting  IngestCleanupPreparationPlugin(MetaDataClientFactory metaDataClientFactory,
        AdminManagementClientFactory adminManagementClientFactory); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); static final String UNITS_TO_DELETE_JSONL; static final String OBJECT_GROUPS_TO_DELETE_JSONL; static final String ACCESSION_REGISTERS_JSONL; }