@Test public void should_transform_receivedDate_to_valid_date_format_when_sip_is_ingest() throws Exception { final InputStream resourceAsStream = getClass().getResourceAsStream( "/ArchiveUnitDateWithBadFormatInElasticSearch/archive_unit_with_bad_receivedDate.xml"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); ArchiveUnitType archiveUnitType = (ArchiveUnitType) unmarshaller.unmarshal(resourceAsStream); ArchiveUnitRoot archiveUnitRoot = archiveUnitMapper.map(archiveUnitType, "", "", "operationId", "INGEST"); ArchiveUnitInternalModel archiveUnit = archiveUnitRoot.getArchiveUnit(); final DescriptiveMetadataModel descriptiveMetadataModel = archiveUnit.getDescriptiveMetadataModel(); assertThat(descriptiveMetadataModel.getReceivedDate()) .isEqualTo("2016-11-15T00:00:00+03:00"); }
public ArchiveUnitRoot map(ArchiveUnitType archiveUnitType, String id, String groupId, String operationId, String unitType) throws ProcessingMalformedDataException, ProcessingObjectReferenceException { ArchiveUnitRoot archiveUnitRoot = new ArchiveUnitRoot(); ArchiveUnitInternalModel archiveUnit = archiveUnitRoot.getArchiveUnit(); archiveUnit.setId(id); archiveUnit.setOg(groupId); archiveUnit.setOpi(operationId); archiveUnit.setOps(Collections.singletonList(operationId)); archiveUnit.setUnitType(unitType); IdentifierType archiveUnitProfile = archiveUnitType.getArchiveUnitProfile(); if (archiveUnitProfile != null) { archiveUnit.setArchiveUnitProfile(archiveUnitProfile.getValue()); } DescriptiveMetadataContentType metadataContentType = archiveUnitType.getContent(); if (metadataContentType != null) { DescriptiveMetadataModel metadataModel = descriptiveMetadataMapper.map(metadataContentType); archiveUnit.setDescriptiveMetadataModel(metadataModel); } else { archiveUnit.setDescriptiveMetadataModel(new DescriptiveMetadataModel()); } mapAndValidateDataObjectReference(archiveUnitType); ManagementType management = archiveUnitType.getManagement(); fillManagement(management, archiveUnit.getManagement()); if (archiveUnitType.getContent() != null && archiveUnitType.getContent().getHistory() != null) { fillHistory(archiveUnitType.getContent().getHistory(), archiveUnit.getHistory()); } if (management != null && management.getLogBook() != null) { List<LogbookEvent> logbookExternal = management.getLogBook() .getEvent() .stream() .map(this::toLogbookEvent) .collect(Collectors.toList()); archiveUnitRoot.setLogbookLifeCycleExternal(logbookExternal); } archiveUnit.setSedaVersion(VitamConstants.SEDA_CURRENT_VERSION); String vitamImplVersion = this.getClass().getPackage().getImplementationVersion(); if (vitamImplVersion != null) { archiveUnit.setImplementationVersion(vitamImplVersion); } else { archiveUnit.setImplementationVersion(""); } return archiveUnitRoot; }
ArchiveUnitMapper { public ArchiveUnitRoot map(ArchiveUnitType archiveUnitType, String id, String groupId, String operationId, String unitType) throws ProcessingMalformedDataException, ProcessingObjectReferenceException { ArchiveUnitRoot archiveUnitRoot = new ArchiveUnitRoot(); ArchiveUnitInternalModel archiveUnit = archiveUnitRoot.getArchiveUnit(); archiveUnit.setId(id); archiveUnit.setOg(groupId); archiveUnit.setOpi(operationId); archiveUnit.setOps(Collections.singletonList(operationId)); archiveUnit.setUnitType(unitType); IdentifierType archiveUnitProfile = archiveUnitType.getArchiveUnitProfile(); if (archiveUnitProfile != null) { archiveUnit.setArchiveUnitProfile(archiveUnitProfile.getValue()); } DescriptiveMetadataContentType metadataContentType = archiveUnitType.getContent(); if (metadataContentType != null) { DescriptiveMetadataModel metadataModel = descriptiveMetadataMapper.map(metadataContentType); archiveUnit.setDescriptiveMetadataModel(metadataModel); } else { archiveUnit.setDescriptiveMetadataModel(new DescriptiveMetadataModel()); } mapAndValidateDataObjectReference(archiveUnitType); ManagementType management = archiveUnitType.getManagement(); fillManagement(management, archiveUnit.getManagement()); if (archiveUnitType.getContent() != null && archiveUnitType.getContent().getHistory() != null) { fillHistory(archiveUnitType.getContent().getHistory(), archiveUnit.getHistory()); } if (management != null && management.getLogBook() != null) { List<LogbookEvent> logbookExternal = management.getLogBook() .getEvent() .stream() .map(this::toLogbookEvent) .collect(Collectors.toList()); archiveUnitRoot.setLogbookLifeCycleExternal(logbookExternal); } archiveUnit.setSedaVersion(VitamConstants.SEDA_CURRENT_VERSION); String vitamImplVersion = this.getClass().getPackage().getImplementationVersion(); if (vitamImplVersion != null) { archiveUnit.setImplementationVersion(vitamImplVersion); } else { archiveUnit.setImplementationVersion(""); } return archiveUnitRoot; } }
ArchiveUnitMapper { public ArchiveUnitRoot map(ArchiveUnitType archiveUnitType, String id, String groupId, String operationId, String unitType) throws ProcessingMalformedDataException, ProcessingObjectReferenceException { ArchiveUnitRoot archiveUnitRoot = new ArchiveUnitRoot(); ArchiveUnitInternalModel archiveUnit = archiveUnitRoot.getArchiveUnit(); archiveUnit.setId(id); archiveUnit.setOg(groupId); archiveUnit.setOpi(operationId); archiveUnit.setOps(Collections.singletonList(operationId)); archiveUnit.setUnitType(unitType); IdentifierType archiveUnitProfile = archiveUnitType.getArchiveUnitProfile(); if (archiveUnitProfile != null) { archiveUnit.setArchiveUnitProfile(archiveUnitProfile.getValue()); } DescriptiveMetadataContentType metadataContentType = archiveUnitType.getContent(); if (metadataContentType != null) { DescriptiveMetadataModel metadataModel = descriptiveMetadataMapper.map(metadataContentType); archiveUnit.setDescriptiveMetadataModel(metadataModel); } else { archiveUnit.setDescriptiveMetadataModel(new DescriptiveMetadataModel()); } mapAndValidateDataObjectReference(archiveUnitType); ManagementType management = archiveUnitType.getManagement(); fillManagement(management, archiveUnit.getManagement()); if (archiveUnitType.getContent() != null && archiveUnitType.getContent().getHistory() != null) { fillHistory(archiveUnitType.getContent().getHistory(), archiveUnit.getHistory()); } if (management != null && management.getLogBook() != null) { List<LogbookEvent> logbookExternal = management.getLogBook() .getEvent() .stream() .map(this::toLogbookEvent) .collect(Collectors.toList()); archiveUnitRoot.setLogbookLifeCycleExternal(logbookExternal); } archiveUnit.setSedaVersion(VitamConstants.SEDA_CURRENT_VERSION); String vitamImplVersion = this.getClass().getPackage().getImplementationVersion(); if (vitamImplVersion != null) { archiveUnit.setImplementationVersion(vitamImplVersion); } else { archiveUnit.setImplementationVersion(""); } return archiveUnitRoot; } ArchiveUnitMapper(DescriptiveMetadataMapper descriptiveMetadataMapper,
        RuleMapper ruleMapper); }
ArchiveUnitMapper { public ArchiveUnitRoot map(ArchiveUnitType archiveUnitType, String id, String groupId, String operationId, String unitType) throws ProcessingMalformedDataException, ProcessingObjectReferenceException { ArchiveUnitRoot archiveUnitRoot = new ArchiveUnitRoot(); ArchiveUnitInternalModel archiveUnit = archiveUnitRoot.getArchiveUnit(); archiveUnit.setId(id); archiveUnit.setOg(groupId); archiveUnit.setOpi(operationId); archiveUnit.setOps(Collections.singletonList(operationId)); archiveUnit.setUnitType(unitType); IdentifierType archiveUnitProfile = archiveUnitType.getArchiveUnitProfile(); if (archiveUnitProfile != null) { archiveUnit.setArchiveUnitProfile(archiveUnitProfile.getValue()); } DescriptiveMetadataContentType metadataContentType = archiveUnitType.getContent(); if (metadataContentType != null) { DescriptiveMetadataModel metadataModel = descriptiveMetadataMapper.map(metadataContentType); archiveUnit.setDescriptiveMetadataModel(metadataModel); } else { archiveUnit.setDescriptiveMetadataModel(new DescriptiveMetadataModel()); } mapAndValidateDataObjectReference(archiveUnitType); ManagementType management = archiveUnitType.getManagement(); fillManagement(management, archiveUnit.getManagement()); if (archiveUnitType.getContent() != null && archiveUnitType.getContent().getHistory() != null) { fillHistory(archiveUnitType.getContent().getHistory(), archiveUnit.getHistory()); } if (management != null && management.getLogBook() != null) { List<LogbookEvent> logbookExternal = management.getLogBook() .getEvent() .stream() .map(this::toLogbookEvent) .collect(Collectors.toList()); archiveUnitRoot.setLogbookLifeCycleExternal(logbookExternal); } archiveUnit.setSedaVersion(VitamConstants.SEDA_CURRENT_VERSION); String vitamImplVersion = this.getClass().getPackage().getImplementationVersion(); if (vitamImplVersion != null) { archiveUnit.setImplementationVersion(vitamImplVersion); } else { archiveUnit.setImplementationVersion(""); } return archiveUnitRoot; } ArchiveUnitMapper(DescriptiveMetadataMapper descriptiveMetadataMapper,
        RuleMapper ruleMapper); ArchiveUnitRoot map(ArchiveUnitType archiveUnitType, String id, String groupId, String operationId,
        String unitType); DataObjectReference mapAndValidateDataObjectReference(ArchiveUnitType archiveUnitType); }
ArchiveUnitMapper { public ArchiveUnitRoot map(ArchiveUnitType archiveUnitType, String id, String groupId, String operationId, String unitType) throws ProcessingMalformedDataException, ProcessingObjectReferenceException { ArchiveUnitRoot archiveUnitRoot = new ArchiveUnitRoot(); ArchiveUnitInternalModel archiveUnit = archiveUnitRoot.getArchiveUnit(); archiveUnit.setId(id); archiveUnit.setOg(groupId); archiveUnit.setOpi(operationId); archiveUnit.setOps(Collections.singletonList(operationId)); archiveUnit.setUnitType(unitType); IdentifierType archiveUnitProfile = archiveUnitType.getArchiveUnitProfile(); if (archiveUnitProfile != null) { archiveUnit.setArchiveUnitProfile(archiveUnitProfile.getValue()); } DescriptiveMetadataContentType metadataContentType = archiveUnitType.getContent(); if (metadataContentType != null) { DescriptiveMetadataModel metadataModel = descriptiveMetadataMapper.map(metadataContentType); archiveUnit.setDescriptiveMetadataModel(metadataModel); } else { archiveUnit.setDescriptiveMetadataModel(new DescriptiveMetadataModel()); } mapAndValidateDataObjectReference(archiveUnitType); ManagementType management = archiveUnitType.getManagement(); fillManagement(management, archiveUnit.getManagement()); if (archiveUnitType.getContent() != null && archiveUnitType.getContent().getHistory() != null) { fillHistory(archiveUnitType.getContent().getHistory(), archiveUnit.getHistory()); } if (management != null && management.getLogBook() != null) { List<LogbookEvent> logbookExternal = management.getLogBook() .getEvent() .stream() .map(this::toLogbookEvent) .collect(Collectors.toList()); archiveUnitRoot.setLogbookLifeCycleExternal(logbookExternal); } archiveUnit.setSedaVersion(VitamConstants.SEDA_CURRENT_VERSION); String vitamImplVersion = this.getClass().getPackage().getImplementationVersion(); if (vitamImplVersion != null) { archiveUnit.setImplementationVersion(vitamImplVersion); } else { archiveUnit.setImplementationVersion(""); } return archiveUnitRoot; } ArchiveUnitMapper(DescriptiveMetadataMapper descriptiveMetadataMapper,
        RuleMapper ruleMapper); ArchiveUnitRoot map(ArchiveUnitType archiveUnitType, String id, String groupId, String operationId,
        String unitType); DataObjectReference mapAndValidateDataObjectReference(ArchiveUnitType archiveUnitType);  }