class 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;
    }

    public  ArchiveUnitMapper(DescriptiveMetadataMapper descriptiveMetadataMapper,
        RuleMapper ruleMapper);

}