Commit 9c49108f authored by marceteau's avatar marceteau
Browse files

repositionnement de l'AU contenant Archive.xml + correctif mapping

parent 3230637b
......@@ -365,31 +365,31 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
private DataObjectPackageType mapArchiveBlock(fr.gouv.culture.archivesdefrance.seda.v2.OrganizationType submissionAgency, ArchiveType currentArchive) throws IngestRejectException {
ObjectFactory objectFactory = new ObjectFactory();
DataObjectPackageType dataObjectPackage = objectFactory.createDataObjectPackageType();
// Contrat d'archive
ArchivesIDType archiveId = currentArchive.getArchivalAgreement();
IdentifierType archivalAgreement = objectFactory.createIdentifierType();
archivalAgreement.setValue(archiveId.getValue());
archivalAgreement.setValue(properties.getProperty("ArchivalAgreement"));
manifest.setArchivalAgreement(archivalAgreement);
// Profil d'archivage
// ArchivesIDType archiveProfileId = currentArchive.getArchivalProfile();
// ArchivesIDType archiveProfileId = currentArchive.getArchivalProfile();
ManagementMetadataType managementMetadata = objectFactory.createManagementMetadataType();
// IdentifierType archivalProfile = objectFactory.createIdentifierType();
// archivalProfile.setValue(archiveProfileId.getValue());
// managementMetadata.setArchivalProfile(archivalProfile);
// IdentifierType archivalProfile = objectFactory.createIdentifierType();
// archivalProfile.setValue(archiveProfileId.getValue());
// managementMetadata.setArchivalProfile(archivalProfile);
fr.gouv.culture.archivesdefrance.seda.v2.AppraisalRuleType appraisalRule = mapAppraisalRules(currentArchive.getAppraisalRule());
managementMetadata.setAppraisalRule(appraisalRule);
AccessRuleType accessRestrictionRule = mapAccessRule(currentArchive.getAccessRestrictionRule());
// String seda2Value = ACCESS_RULE.valueOf(accessRule.ge).value;
// String seda2Value = ACCESS_RULE.valueOf(accessRule.ge).value;
managementMetadata.setAccessRule(accessRestrictionRule);
IdentifierType originatingAgencyIdentifier = objectFactory.createIdentifierType();
originatingAgencyIdentifier.setValue(properties.getProperty(ORIGINATING_AGENCY_IDENTIFIER));
......@@ -398,14 +398,14 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
IdentifierType identifier = objectFactory.createIdentifierType();
identifier.setValue(properties.getProperty(SUBMISSION_AGENCY_IDENTIFIER));
managementMetadata.setSubmissionAgencyIdentifier(identifier);
dataObjectPackage.setManagementMetadata(managementMetadata);
addArchiveTransferXml(archiveTransferSEDA10, this.archiveType);
binaryDataObjectWithTypeList = new ArrayList<BinaryDataObjectTypeWithType>();
List<DataObjectGroupType> objectGroups = mapDataObjectGroup(currentArchive.getArchiveObject(), currentArchive);
dataObjectPackage.getDataObjectGroupOrBinaryDataObjectOrPhysicalDataObject().addAll(objectGroups);
// Création des ArchiveUnit dans le bloc DescriptiveMetada
......@@ -414,30 +414,30 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
DescriptiveMetadataType descriptiveMetadata = objectFactory.createDescriptiveMetadataType();
List<ArchiveUnitType> archiveUnits = mapDataObjectMetadataToArchiveUnit(binaryDataObjectWithTypeList, currentArchive);
// Unité d'archive principale où sont mappées les informations
// du bloc <archive> du SEDA 1.0
ArchiveUnitType rootArchiveUnit = objectFactory.createArchiveUnitType();
archiveUnitCounter++;
rootArchiveUnit.setId("ID" + archiveUnitCounter);
rootArchiveUnit.getArchiveUnitOrArchiveUnitReferenceAbstractOrDataObjectReference().addAll(archiveUnits);
/**
* Balise <Content> de l'unité d'archive racine
*/
DescriptiveMetadataContentType content = objectFactory.createDescriptiveMetadataContentType();
// Balise <Description>
ContentDescriptionType contentDescription = currentArchive.getContentDescription();
TextType descriptionSEDA10 = contentDescription.getDescription();
fr.gouv.culture.archivesdefrance.seda.v2.TextType description = objectFactory.createTextType();
description.setValue(descriptionSEDA10.getValue());
content.getDescription().add(description);
// Balise <DescriptionLevel>
LevelType descriptionLevel = mapDescriptionLevel(contentDescription);
content.setDescriptionLevel(descriptionLevel);
fr.gouv.culture.archivesdefrance.seda.v2.TextType documentTypeText = objectFactory.createTextType();
if(properties.getProperty(DOCUMENT_TYPE) != null) {
documentTypeText.setValue(properties.getProperty(DOCUMENT_TYPE));
......@@ -445,8 +445,17 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
}
if(properties.getProperty(KEYWORD_CONTENT) != null &&properties.getProperty(KEYWORD_CONTENT).equalsIgnoreCase("true")) {
for(KeywordType keyword : currentArchive.getContentDescription().getKeyword()) {
content.getTag().add(keyword.getKeywordContent().getValue());
String tag;
if(keyword.getKeywordContent().getRole().trim().equalsIgnoreCase("")) {
tag = keyword.getKeywordContent().getValue();
} else {
tag = keyword.getKeywordContent().getRole() + " : " + keyword.getKeywordContent().getValue();
}
content.getTag().add(tag);
}
}
......@@ -461,14 +470,14 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
} else {
filePlan = currentArchive.getContentDescription().getFilePlanPosition().get(0).getValue();
}
addGhostArchiveUnit(objectFactory, descriptiveMetadata, rootArchiveUnit, filePlan);
}
// Identifiant du service versant d'origine - peut être null
ArchivesIDType origAgencyId = currentArchive.getOriginatingAgencyArchiveIdentifier();
if (origAgencyId != null)
content.getOriginatingAgencyArchiveUnitIdentifier().add(origAgencyId.getValue());
......@@ -478,32 +487,32 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
ArchivesIDType transferringAgencyId = currentArchive.getTransferringAgencyArchiveIdentifier();
content.getTransferringAgencyArchiveUnitIdentifier().add(transferringAgencyId.getValue());
}
if(properties.getProperty(IDENTIFIANT_DOC_PRODUCTEUR).equalsIgnoreCase("OriginatingAgencyArchiveUnitIdentifier")) {
ArchivesIDType transferringAgencyId = currentArchive.getOriginatingAgencyArchiveIdentifier();
content.getTransferringAgencyArchiveUnitIdentifier().add(transferringAgencyId.getValue());
} else if(properties.getProperty(IDENTIFIANT_DOC_PRODUCTEUR).equalsIgnoreCase("OriginatingSystemId")) {
// ArchivesIDType transferringAgencyId = currentArchive.getOriginatingAgencyArchiveIdentifier();
// content.getTransferringAgencyArchiveUnitIdentifier().add(transferringAgencyId.getValue());
// ArchivesIDType transferringAgencyId = currentArchive.getOriginatingAgencyArchiveIdentifier();
// content.getTransferringAgencyArchiveUnitIdentifier().add(transferringAgencyId.getValue());
}
// Nom de l'archive <name> vers <Title>
TextType name = currentArchive.getName();
name.getValue();
fr.gouv.culture.archivesdefrance.seda.v2.TextType title = objectFactory.createTextType();
title.setValue(name.getValue());
content.getTitle().add(title);
mapLanguage(content, contentDescription);
// DescriptionLanguage
List<CodeLanguageType> descriptionLanguageList = currentArchive.getDescriptionLanguage();
if (descriptionLanguageList.size() > 1)
logger.warn("Plusieurs DescriptionLanguage - une seule sera conservé dans le bordereau SEDA 2.1");
if (!descriptionLanguageList.isEmpty())
content.setDescriptionLanguage(descriptionLanguageList.get(0).getValue().toString());
// OriginatingAgency
if (originatingAgencyBool != null && "true".equalsIgnoreCase(originatingAgencyBool.trim()) ) {
......@@ -523,14 +532,14 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
content.setOriginatingAgency(originatingAgency);
}
}
// Le service versant soumettant <SubmissionAgency>
// On reprends la <TransferringAgency> du paquet dans son ensemble
// content.setSubmissionAgency(submissionAgency);
// content.setSubmissionAgency(submissionAgency);
content.setStartDate(currentArchive.getContentDescription().getOldestDate().toString());
content.setEndDate(currentArchive.getContentDescription().getLatestDate().toString());
// Event
if(this.getArchiveType().equalsIgnoreCase("Archive.xml")) {
EventType event = objectFactory.createEventType();
......@@ -540,17 +549,17 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
event.setEventDateTime(dateArchivagePAC);
content.getEvent().add(event);
}
rootArchiveUnit.setContent(content);
// Historique de la conservation
fr.gouv.culture.archivesdefrance.seda.v2.CustodialHistoryType custodialHistory = mapCustodialHistory(currentArchive);
content.setCustodialHistory(custodialHistory);
descriptiveMetadata.getArchiveUnit().add(rootArchiveUnit);
dataObjectPackage.setDescriptiveMetadata(descriptiveMetadata);
return dataObjectPackage;
}
......@@ -776,10 +785,19 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
*/
List<ArchiveUnitType> listArchiveUnits = new ArrayList<ArchiveUnitType>();
// L'AU de l'archivetransfer.xml ou de l'archive.xml est placée en dernier
ArchiveUnitType archiveUnitArchiveXML = null;
if (! archive.getArchiveObject().isEmpty()) {
for (ArchiveObjectType archiveObject : archive.getArchiveObject()) {
ArchiveUnitType archiveUnit = buildArchiveUnit(archiveObject);
listArchiveUnits.add(archiveUnit);
if(archiveUnit.getContent().getTitle().get(0).getValue().equalsIgnoreCase("Certificat d'archivage")
|| archiveUnit.getContent().getTitle().get(0).getValue().equalsIgnoreCase("Bordereau de versement")) {
archiveUnitArchiveXML = archiveUnit;
} else {
listArchiveUnits.add(archiveUnit);
}
}
}
//Cas particulier où le document n'est pas dans un ArchiveObject
......@@ -789,6 +807,11 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
listArchiveUnits.add(archiveUnit);
}
}
if(archiveUnitArchiveXML != null) {
listArchiveUnits.add(archiveUnitArchiveXML);
}
return listArchiveUnits;
}
......@@ -913,17 +936,15 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
*/
private ArchiveUnitType buildArchiveUnit(DocumentType document) {
ObjectFactory objectFactory = new ObjectFactory();
ArchiveUnitType archiveUnit = objectFactory.createArchiveUnitType();
archiveUnitCounter++;
archiveUnit.setId("ID" + archiveUnitCounter);
DescriptiveMetadataContentType content = objectFactory.createDescriptiveMetadataContentType();
content.setDescriptionLevel(LevelType.fromValue("Item"));
fr.gouv.culture.archivesdefrance.seda.v2.TextType title = objectFactory.createTextType();
title.setValue(document.getDescription().getValue());
title.setLang(document.getDescription().getLanguageID());
......@@ -932,11 +953,16 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
fr.gouv.culture.archivesdefrance.seda.v2.TextType type = objectFactory.createTextType();
type.setValue(document.getType().get(0).getValue().value());
content.setType(type);
if(document.getLanguage() != null) {
content.getLanguage().add(document.getLanguage().get(0).getValue().toString());
}
archiveUnit.setContent(content);
DataObjectRefType objectRef = buildDataReferenceObject(document.getId());
archiveUnit.getArchiveUnitOrArchiveUnitReferenceAbstractOrDataObjectReference().add(objectRef);
// Récupération du type
// On prends le type du premier <Document>
// L'identifiant du <Document> corresponds à l'index du binaryDataObject dans la liste construite
......@@ -950,9 +976,9 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
typeValue.setValue(valueCodeType);
content.setType(typeValue);
}
return archiveUnit;
}
/**
......@@ -1002,15 +1028,15 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
}
mapLanguage(content, contentDescription);
if(contentDescription.getLatestDate() != null) {
content.setEndDate(contentDescription.getLatestDate().toString());
}
if(contentDescription.getOldestDate() != null) {
content.setStartDate(contentDescription.getOldestDate().toString());
}
if(!contentDescription.getKeyword().isEmpty()) {
for(KeywordType keyword : contentDescription.getKeyword()) {
String tag;
......@@ -1054,9 +1080,11 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
private List<DataObjectGroupType> mapDataObjectGroup(List<ArchiveObjectType> archiveObjects, ArchiveType currentArchive) throws IngestRejectException {
ObjectFactory objectFactory = new ObjectFactory();
List<DataObjectGroupType> dataObjectGroupList = new ArrayList<DataObjectGroupType>();
DataObjectGroupType dataObjectGroupArchiveXml = null;
for (ArchiveObjectType archiveObject : archiveObjects) {
if (!archiveObject.getDocument().isEmpty()) {
for (DocumentType document : archiveObject.getDocument()) {
......@@ -1069,15 +1097,20 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
BinaryDataObjectTypeWithType binaryDataObject = mapBinaryDataObject(document);
dataObjectGroup.getBinaryDataObjectOrPhysicalDataObject().add(binaryDataObject);
binaryDataObjectWithTypeList.add(binaryDataObject);
dataObjectGroupList.add(dataObjectGroup);
dataObjectGroup.setId("OID" + binaryObjectCounter);
if(document.getAttachment().getFilename().equalsIgnoreCase("Content/Archive.xml")
|| document.getAttachment().getFilename().equalsIgnoreCase("Content/ArchiveTransfer.xml")) {
dataObjectGroupArchiveXml = dataObjectGroup;
} else {
dataObjectGroupList.add(dataObjectGroup);
}
}
}
if (!archiveObject.getArchiveObject().isEmpty()) {
dataObjectGroupList.addAll(mapDataObjectGroup(archiveObject.getArchiveObject(), currentArchive));
}
}
//Cas particulier où les document sont à la racine de la balise Archive
if(!currentArchive.getDocument().isEmpty()) {
for(DocumentType document : currentArchive.getDocument()) {
......@@ -1085,11 +1118,16 @@ public class Seda1ToSeda21Converter extends AbstractArchiveConverter {
BinaryDataObjectTypeWithType binaryDataObject = mapBinaryDataObject(document);
dataObjectGroup.getBinaryDataObjectOrPhysicalDataObject().add(binaryDataObject);
binaryDataObjectWithTypeList.add(binaryDataObject);
dataObjectGroupList.add(dataObjectGroup);
dataObjectGroup.setId("OID" + binaryObjectCounter);
dataObjectGroupList.add(dataObjectGroup);
}
}
//Le fichier Archive.xml ou ArchiveTransfer.xml est en dernière position
if(dataObjectGroupArchiveXml != null) {
dataObjectGroupList.add(dataObjectGroupArchiveXml);
}
return dataObjectGroupList;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment