@Test public void should_map_element_to_hashMap() throws Exception { Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); ArchiveUnitType archiveUnitType = (ArchiveUnitType) unmarshaller.unmarshal(getClass().getResourceAsStream( "/element_unit_with_custodial_history.xml")); ArchiveUnitRoot archiveUnitRoot = archiveUnitMapper.map(archiveUnitType, "", "", "operationId", "INGEST"); ArchiveUnitInternalModel archiveUnit = archiveUnitRoot.getArchiveUnit(); DescriptiveMetadataModel descriptiveMetadataModel = archiveUnit.getDescriptiveMetadataModel(); assertNotNull(descriptiveMetadataModel); CustodialHistoryModel custodialHistoryModel = descriptiveMetadataModel.getCustodialHistory(); assertNotNull(custodialHistoryModel); List<String> custodialHistoryItem = custodialHistoryModel.getCustodialHistoryItem(); assertNotNull(custodialHistoryItem); assertTrue(custodialHistoryItem.size() == 2); DataObjectReference custodialHistoryFile = custodialHistoryModel.getCustodialHistoryFile(); assertNotNull(custodialHistoryFile); assertTrue(custodialHistoryFile.getDataObjectGroupReferenceId().equals("ID0007")); }
public CustodialHistoryModel map(CustodialHistoryType custodialHistory) { if (custodialHistory == null) { return null; } CustodialHistoryModel custodialHistoryModel = new CustodialHistoryModel(); List<String> collect = custodialHistory.getCustodialHistoryItem().stream() .map(TextType::getValue).collect( Collectors.toList()); custodialHistoryModel.getCustodialHistoryItem().addAll(collect); DataObjectRefType dataObjectRefType = custodialHistory.getCustodialHistoryFile(); if (dataObjectRefType != null) { DataObjectReference custodialHistoryFile = new DataObjectReference(); if(dataObjectRefType.getDataObjectGroupReferenceId() != null){ custodialHistoryFile.setDataObjectGroupReferenceId(dataObjectRefType.getDataObjectGroupReferenceId()); } if(dataObjectRefType.getDataObjectReferenceId() != null){ custodialHistoryFile.setDataObjectReferenceId(dataObjectRefType.getDataObjectReferenceId()); } custodialHistoryModel.setCustodialHistoryFile(custodialHistoryFile); } return custodialHistoryModel; }
CustodialHistoryMapper { public CustodialHistoryModel map(CustodialHistoryType custodialHistory) { if (custodialHistory == null) { return null; } CustodialHistoryModel custodialHistoryModel = new CustodialHistoryModel(); List<String> collect = custodialHistory.getCustodialHistoryItem().stream() .map(TextType::getValue).collect( Collectors.toList()); custodialHistoryModel.getCustodialHistoryItem().addAll(collect); DataObjectRefType dataObjectRefType = custodialHistory.getCustodialHistoryFile(); if (dataObjectRefType != null) { DataObjectReference custodialHistoryFile = new DataObjectReference(); if(dataObjectRefType.getDataObjectGroupReferenceId() != null){ custodialHistoryFile.setDataObjectGroupReferenceId(dataObjectRefType.getDataObjectGroupReferenceId()); } if(dataObjectRefType.getDataObjectReferenceId() != null){ custodialHistoryFile.setDataObjectReferenceId(dataObjectRefType.getDataObjectReferenceId()); } custodialHistoryModel.setCustodialHistoryFile(custodialHistoryFile); } return custodialHistoryModel; } }
CustodialHistoryMapper { public CustodialHistoryModel map(CustodialHistoryType custodialHistory) { if (custodialHistory == null) { return null; } CustodialHistoryModel custodialHistoryModel = new CustodialHistoryModel(); List<String> collect = custodialHistory.getCustodialHistoryItem().stream() .map(TextType::getValue).collect( Collectors.toList()); custodialHistoryModel.getCustodialHistoryItem().addAll(collect); DataObjectRefType dataObjectRefType = custodialHistory.getCustodialHistoryFile(); if (dataObjectRefType != null) { DataObjectReference custodialHistoryFile = new DataObjectReference(); if(dataObjectRefType.getDataObjectGroupReferenceId() != null){ custodialHistoryFile.setDataObjectGroupReferenceId(dataObjectRefType.getDataObjectGroupReferenceId()); } if(dataObjectRefType.getDataObjectReferenceId() != null){ custodialHistoryFile.setDataObjectReferenceId(dataObjectRefType.getDataObjectReferenceId()); } custodialHistoryModel.setCustodialHistoryFile(custodialHistoryFile); } return custodialHistoryModel; }  }
CustodialHistoryMapper { public CustodialHistoryModel map(CustodialHistoryType custodialHistory) { if (custodialHistory == null) { return null; } CustodialHistoryModel custodialHistoryModel = new CustodialHistoryModel(); List<String> collect = custodialHistory.getCustodialHistoryItem().stream() .map(TextType::getValue).collect( Collectors.toList()); custodialHistoryModel.getCustodialHistoryItem().addAll(collect); DataObjectRefType dataObjectRefType = custodialHistory.getCustodialHistoryFile(); if (dataObjectRefType != null) { DataObjectReference custodialHistoryFile = new DataObjectReference(); if(dataObjectRefType.getDataObjectGroupReferenceId() != null){ custodialHistoryFile.setDataObjectGroupReferenceId(dataObjectRefType.getDataObjectGroupReferenceId()); } if(dataObjectRefType.getDataObjectReferenceId() != null){ custodialHistoryFile.setDataObjectReferenceId(dataObjectRefType.getDataObjectReferenceId()); } custodialHistoryModel.setCustodialHistoryFile(custodialHistoryFile); } return custodialHistoryModel; }  CustodialHistoryModel map(CustodialHistoryType custodialHistory); }
CustodialHistoryMapper { public CustodialHistoryModel map(CustodialHistoryType custodialHistory) { if (custodialHistory == null) { return null; } CustodialHistoryModel custodialHistoryModel = new CustodialHistoryModel(); List<String> collect = custodialHistory.getCustodialHistoryItem().stream() .map(TextType::getValue).collect( Collectors.toList()); custodialHistoryModel.getCustodialHistoryItem().addAll(collect); DataObjectRefType dataObjectRefType = custodialHistory.getCustodialHistoryFile(); if (dataObjectRefType != null) { DataObjectReference custodialHistoryFile = new DataObjectReference(); if(dataObjectRefType.getDataObjectGroupReferenceId() != null){ custodialHistoryFile.setDataObjectGroupReferenceId(dataObjectRefType.getDataObjectGroupReferenceId()); } if(dataObjectRefType.getDataObjectReferenceId() != null){ custodialHistoryFile.setDataObjectReferenceId(dataObjectRefType.getDataObjectReferenceId()); } custodialHistoryModel.setCustodialHistoryFile(custodialHistoryFile); } return custodialHistoryModel; }  CustodialHistoryModel map(CustodialHistoryType custodialHistory);  }