@Test public void testCreateMods_FixIssuance() { ModsDefinition mods = new ModsDefinition(); NdkPeriodicalMapper mapper = new NdkPeriodicalMapper(); Context ctx = EasyMock.createMock(Context.class); EasyMock.expect(ctx.getPid()).andReturn("uuid:testId").anyTimes(); EasyMock.replay(ctx); OriginInfoDefinition oi = new OriginInfoDefinition(); oi.getIssuance().add(IssuanceDefinition.SERIAL); mods.getOriginInfo().add(oi); mapper.createMods(mods, ctx); assertEquals(Arrays.asList(IssuanceDefinition.CONTINUING), mods.getOriginInfo().get(0).getIssuance()); }
@Override public void createMods(ModsDefinition mods, Context ctx) { super.createMods(mods, ctx); List<TypeOfResourceDefinition> typeOfResources = mods.getTypeOfResource(); TypeOfResourceDefinition reqTypeOfResource = null; for (TypeOfResourceDefinition typeOfResource : typeOfResources) { if ("text".equals(typeOfResource.getValue())) { reqTypeOfResource = typeOfResource; break; } } if (reqTypeOfResource == null) { TypeOfResourceDefinition type = new TypeOfResourceDefinition(); type.setValue("text"); typeOfResources.add(0, type); } addGenre(mods); OriginInfoDefinition reqOriginInfo = null; List<OriginInfoDefinition> originInfos = mods.getOriginInfo(); for (OriginInfoDefinition oi : originInfos) { reqOriginInfo = oi; List<IssuanceDefinition> issuances = oi.getIssuance(); IssuanceDefinition reqIssuance = null; for (Iterator<IssuanceDefinition> it = issuances.iterator(); it.hasNext();) { IssuanceDefinition issuance = it.next(); if (IssuanceDefinition.SERIAL == issuance) { it.remove(); continue; } if (IssuanceDefinition.CONTINUING == issuance) { reqIssuance = issuance; break; } } if (reqIssuance == null) { issuances.add(0, IssuanceDefinition.CONTINUING); } List<PlaceDefinition> places = oi.getPlace(); for (PlaceDefinition place : places) { List<PlaceTermDefinition> placeTerms = place.getPlaceTerm(); for (PlaceTermDefinition placeTerm : placeTerms) { if (placeTerm.getType() == null) { placeTerm.setType(CodeOrText.TEXT); } } } for(DateOtherDefinition dateOther : oi.getDateOther()){ dateOther.setType(oi.getEventType()); } } if (reqOriginInfo == null) { reqOriginInfo = new OriginInfoDefinition(); reqOriginInfo.getIssuance().add(IssuanceDefinition.CONTINUING); originInfos.add(reqOriginInfo); } List<PhysicalDescriptionDefinition> physicalDescriptions = mods.getPhysicalDescription(); PhysicalDescriptionDefinition reqPhysicalDescription = null; FormDefinition reqForm = null; for (PhysicalDescriptionDefinition pd : physicalDescriptions) { reqPhysicalDescription = pd; List<FormDefinition> forms = pd.getForm(); for (FormDefinition form : forms) { if ("print".equals(form.getValue())) { if (!ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM.equals(form.getAuthority())) { form.setAuthority(ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM); } reqForm = form; } if (ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_RDAMEDIA.equals(form.getAuthority())) { form.setType("media"); } else if (ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_RDACARRIER.equals(form.getAuthority())) { form.setType("carrier"); } else { form.setType(null); } } if (reqForm == null) { reqForm = new FormDefinition(); reqForm.setAuthority(ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM); reqForm.setValue("print"); forms.add(0, reqForm); } } if (reqPhysicalDescription == null) { reqForm = new FormDefinition(); reqForm.setAuthority(ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM); reqForm.setValue("print"); reqPhysicalDescription = new PhysicalDescriptionDefinition(); reqPhysicalDescription.getForm().add(reqForm); physicalDescriptions.add(reqPhysicalDescription); } List<ClassificationDefinition> classifications = mods.getClassification(); for (ClassificationDefinition classification : classifications) { repairAuthorityInClassification(classification); } List<LocationDefinition> locations = mods.getLocation(); for (LocationDefinition location : locations) { List<PhysicalLocationDefinition> physicals = location.getPhysicalLocation(); for (PhysicalLocationDefinition physical : physicals) { if (physical.getAuthority() == null) { physical.setAuthority("siglaADR"); } } } fillLanguage(mods); fillAbstract(mods); fillRecordInfo(mods); }
NdkPeriodicalMapper extends RdaNdkMapper { @Override public void createMods(ModsDefinition mods, Context ctx) { super.createMods(mods, ctx); List<TypeOfResourceDefinition> typeOfResources = mods.getTypeOfResource(); TypeOfResourceDefinition reqTypeOfResource = null; for (TypeOfResourceDefinition typeOfResource : typeOfResources) { if ("text".equals(typeOfResource.getValue())) { reqTypeOfResource = typeOfResource; break; } } if (reqTypeOfResource == null) { TypeOfResourceDefinition type = new TypeOfResourceDefinition(); type.setValue("text"); typeOfResources.add(0, type); } addGenre(mods); OriginInfoDefinition reqOriginInfo = null; List<OriginInfoDefinition> originInfos = mods.getOriginInfo(); for (OriginInfoDefinition oi : originInfos) { reqOriginInfo = oi; List<IssuanceDefinition> issuances = oi.getIssuance(); IssuanceDefinition reqIssuance = null; for (Iterator<IssuanceDefinition> it = issuances.iterator(); it.hasNext();) { IssuanceDefinition issuance = it.next(); if (IssuanceDefinition.SERIAL == issuance) { it.remove(); continue; } if (IssuanceDefinition.CONTINUING == issuance) { reqIssuance = issuance; break; } } if (reqIssuance == null) { issuances.add(0, IssuanceDefinition.CONTINUING); } List<PlaceDefinition> places = oi.getPlace(); for (PlaceDefinition place : places) { List<PlaceTermDefinition> placeTerms = place.getPlaceTerm(); for (PlaceTermDefinition placeTerm : placeTerms) { if (placeTerm.getType() == null) { placeTerm.setType(CodeOrText.TEXT); } } } for(DateOtherDefinition dateOther : oi.getDateOther()){ dateOther.setType(oi.getEventType()); } } if (reqOriginInfo == null) { reqOriginInfo = new OriginInfoDefinition(); reqOriginInfo.getIssuance().add(IssuanceDefinition.CONTINUING); originInfos.add(reqOriginInfo); } List<PhysicalDescriptionDefinition> physicalDescriptions = mods.getPhysicalDescription(); PhysicalDescriptionDefinition reqPhysicalDescription = null; FormDefinition reqForm = null; for (PhysicalDescriptionDefinition pd : physicalDescriptions) { reqPhysicalDescription = pd; List<FormDefinition> forms = pd.getForm(); for (FormDefinition form : forms) { if ("print".equals(form.getValue())) { if (!ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM.equals(form.getAuthority())) { form.setAuthority(ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM); } reqForm = form; } if (ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_RDAMEDIA.equals(form.getAuthority())) { form.setType("media"); } else if (ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_RDACARRIER.equals(form.getAuthority())) { form.setType("carrier"); } else { form.setType(null); } } if (reqForm == null) { reqForm = new FormDefinition(); reqForm.setAuthority(ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM); reqForm.setValue("print"); forms.add(0, reqForm); } } if (reqPhysicalDescription == null) { reqForm = new FormDefinition(); reqForm.setAuthority(ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM); reqForm.setValue("print"); reqPhysicalDescription = new PhysicalDescriptionDefinition(); reqPhysicalDescription.getForm().add(reqForm); physicalDescriptions.add(reqPhysicalDescription); } List<ClassificationDefinition> classifications = mods.getClassification(); for (ClassificationDefinition classification : classifications) { repairAuthorityInClassification(classification); } List<LocationDefinition> locations = mods.getLocation(); for (LocationDefinition location : locations) { List<PhysicalLocationDefinition> physicals = location.getPhysicalLocation(); for (PhysicalLocationDefinition physical : physicals) { if (physical.getAuthority() == null) { physical.setAuthority("siglaADR"); } } } fillLanguage(mods); fillAbstract(mods); fillRecordInfo(mods); } }
NdkPeriodicalMapper extends RdaNdkMapper { @Override public void createMods(ModsDefinition mods, Context ctx) { super.createMods(mods, ctx); List<TypeOfResourceDefinition> typeOfResources = mods.getTypeOfResource(); TypeOfResourceDefinition reqTypeOfResource = null; for (TypeOfResourceDefinition typeOfResource : typeOfResources) { if ("text".equals(typeOfResource.getValue())) { reqTypeOfResource = typeOfResource; break; } } if (reqTypeOfResource == null) { TypeOfResourceDefinition type = new TypeOfResourceDefinition(); type.setValue("text"); typeOfResources.add(0, type); } addGenre(mods); OriginInfoDefinition reqOriginInfo = null; List<OriginInfoDefinition> originInfos = mods.getOriginInfo(); for (OriginInfoDefinition oi : originInfos) { reqOriginInfo = oi; List<IssuanceDefinition> issuances = oi.getIssuance(); IssuanceDefinition reqIssuance = null; for (Iterator<IssuanceDefinition> it = issuances.iterator(); it.hasNext();) { IssuanceDefinition issuance = it.next(); if (IssuanceDefinition.SERIAL == issuance) { it.remove(); continue; } if (IssuanceDefinition.CONTINUING == issuance) { reqIssuance = issuance; break; } } if (reqIssuance == null) { issuances.add(0, IssuanceDefinition.CONTINUING); } List<PlaceDefinition> places = oi.getPlace(); for (PlaceDefinition place : places) { List<PlaceTermDefinition> placeTerms = place.getPlaceTerm(); for (PlaceTermDefinition placeTerm : placeTerms) { if (placeTerm.getType() == null) { placeTerm.setType(CodeOrText.TEXT); } } } for(DateOtherDefinition dateOther : oi.getDateOther()){ dateOther.setType(oi.getEventType()); } } if (reqOriginInfo == null) { reqOriginInfo = new OriginInfoDefinition(); reqOriginInfo.getIssuance().add(IssuanceDefinition.CONTINUING); originInfos.add(reqOriginInfo); } List<PhysicalDescriptionDefinition> physicalDescriptions = mods.getPhysicalDescription(); PhysicalDescriptionDefinition reqPhysicalDescription = null; FormDefinition reqForm = null; for (PhysicalDescriptionDefinition pd : physicalDescriptions) { reqPhysicalDescription = pd; List<FormDefinition> forms = pd.getForm(); for (FormDefinition form : forms) { if ("print".equals(form.getValue())) { if (!ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM.equals(form.getAuthority())) { form.setAuthority(ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM); } reqForm = form; } if (ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_RDAMEDIA.equals(form.getAuthority())) { form.setType("media"); } else if (ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_RDACARRIER.equals(form.getAuthority())) { form.setType("carrier"); } else { form.setType(null); } } if (reqForm == null) { reqForm = new FormDefinition(); reqForm.setAuthority(ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM); reqForm.setValue("print"); forms.add(0, reqForm); } } if (reqPhysicalDescription == null) { reqForm = new FormDefinition(); reqForm.setAuthority(ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM); reqForm.setValue("print"); reqPhysicalDescription = new PhysicalDescriptionDefinition(); reqPhysicalDescription.getForm().add(reqForm); physicalDescriptions.add(reqPhysicalDescription); } List<ClassificationDefinition> classifications = mods.getClassification(); for (ClassificationDefinition classification : classifications) { repairAuthorityInClassification(classification); } List<LocationDefinition> locations = mods.getLocation(); for (LocationDefinition location : locations) { List<PhysicalLocationDefinition> physicals = location.getPhysicalLocation(); for (PhysicalLocationDefinition physical : physicals) { if (physical.getAuthority() == null) { physical.setAuthority("siglaADR"); } } } fillLanguage(mods); fillAbstract(mods); fillRecordInfo(mods); }  }
NdkPeriodicalMapper extends RdaNdkMapper { @Override public void createMods(ModsDefinition mods, Context ctx) { super.createMods(mods, ctx); List<TypeOfResourceDefinition> typeOfResources = mods.getTypeOfResource(); TypeOfResourceDefinition reqTypeOfResource = null; for (TypeOfResourceDefinition typeOfResource : typeOfResources) { if ("text".equals(typeOfResource.getValue())) { reqTypeOfResource = typeOfResource; break; } } if (reqTypeOfResource == null) { TypeOfResourceDefinition type = new TypeOfResourceDefinition(); type.setValue("text"); typeOfResources.add(0, type); } addGenre(mods); OriginInfoDefinition reqOriginInfo = null; List<OriginInfoDefinition> originInfos = mods.getOriginInfo(); for (OriginInfoDefinition oi : originInfos) { reqOriginInfo = oi; List<IssuanceDefinition> issuances = oi.getIssuance(); IssuanceDefinition reqIssuance = null; for (Iterator<IssuanceDefinition> it = issuances.iterator(); it.hasNext();) { IssuanceDefinition issuance = it.next(); if (IssuanceDefinition.SERIAL == issuance) { it.remove(); continue; } if (IssuanceDefinition.CONTINUING == issuance) { reqIssuance = issuance; break; } } if (reqIssuance == null) { issuances.add(0, IssuanceDefinition.CONTINUING); } List<PlaceDefinition> places = oi.getPlace(); for (PlaceDefinition place : places) { List<PlaceTermDefinition> placeTerms = place.getPlaceTerm(); for (PlaceTermDefinition placeTerm : placeTerms) { if (placeTerm.getType() == null) { placeTerm.setType(CodeOrText.TEXT); } } } for(DateOtherDefinition dateOther : oi.getDateOther()){ dateOther.setType(oi.getEventType()); } } if (reqOriginInfo == null) { reqOriginInfo = new OriginInfoDefinition(); reqOriginInfo.getIssuance().add(IssuanceDefinition.CONTINUING); originInfos.add(reqOriginInfo); } List<PhysicalDescriptionDefinition> physicalDescriptions = mods.getPhysicalDescription(); PhysicalDescriptionDefinition reqPhysicalDescription = null; FormDefinition reqForm = null; for (PhysicalDescriptionDefinition pd : physicalDescriptions) { reqPhysicalDescription = pd; List<FormDefinition> forms = pd.getForm(); for (FormDefinition form : forms) { if ("print".equals(form.getValue())) { if (!ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM.equals(form.getAuthority())) { form.setAuthority(ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM); } reqForm = form; } if (ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_RDAMEDIA.equals(form.getAuthority())) { form.setType("media"); } else if (ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_RDACARRIER.equals(form.getAuthority())) { form.setType("carrier"); } else { form.setType(null); } } if (reqForm == null) { reqForm = new FormDefinition(); reqForm.setAuthority(ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM); reqForm.setValue("print"); forms.add(0, reqForm); } } if (reqPhysicalDescription == null) { reqForm = new FormDefinition(); reqForm.setAuthority(ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM); reqForm.setValue("print"); reqPhysicalDescription = new PhysicalDescriptionDefinition(); reqPhysicalDescription.getForm().add(reqForm); physicalDescriptions.add(reqPhysicalDescription); } List<ClassificationDefinition> classifications = mods.getClassification(); for (ClassificationDefinition classification : classifications) { repairAuthorityInClassification(classification); } List<LocationDefinition> locations = mods.getLocation(); for (LocationDefinition location : locations) { List<PhysicalLocationDefinition> physicals = location.getPhysicalLocation(); for (PhysicalLocationDefinition physical : physicals) { if (physical.getAuthority() == null) { physical.setAuthority("siglaADR"); } } } fillLanguage(mods); fillAbstract(mods); fillRecordInfo(mods); }  @Override void createMods(ModsDefinition mods, Context ctx); }
NdkPeriodicalMapper extends RdaNdkMapper { @Override public void createMods(ModsDefinition mods, Context ctx) { super.createMods(mods, ctx); List<TypeOfResourceDefinition> typeOfResources = mods.getTypeOfResource(); TypeOfResourceDefinition reqTypeOfResource = null; for (TypeOfResourceDefinition typeOfResource : typeOfResources) { if ("text".equals(typeOfResource.getValue())) { reqTypeOfResource = typeOfResource; break; } } if (reqTypeOfResource == null) { TypeOfResourceDefinition type = new TypeOfResourceDefinition(); type.setValue("text"); typeOfResources.add(0, type); } addGenre(mods); OriginInfoDefinition reqOriginInfo = null; List<OriginInfoDefinition> originInfos = mods.getOriginInfo(); for (OriginInfoDefinition oi : originInfos) { reqOriginInfo = oi; List<IssuanceDefinition> issuances = oi.getIssuance(); IssuanceDefinition reqIssuance = null; for (Iterator<IssuanceDefinition> it = issuances.iterator(); it.hasNext();) { IssuanceDefinition issuance = it.next(); if (IssuanceDefinition.SERIAL == issuance) { it.remove(); continue; } if (IssuanceDefinition.CONTINUING == issuance) { reqIssuance = issuance; break; } } if (reqIssuance == null) { issuances.add(0, IssuanceDefinition.CONTINUING); } List<PlaceDefinition> places = oi.getPlace(); for (PlaceDefinition place : places) { List<PlaceTermDefinition> placeTerms = place.getPlaceTerm(); for (PlaceTermDefinition placeTerm : placeTerms) { if (placeTerm.getType() == null) { placeTerm.setType(CodeOrText.TEXT); } } } for(DateOtherDefinition dateOther : oi.getDateOther()){ dateOther.setType(oi.getEventType()); } } if (reqOriginInfo == null) { reqOriginInfo = new OriginInfoDefinition(); reqOriginInfo.getIssuance().add(IssuanceDefinition.CONTINUING); originInfos.add(reqOriginInfo); } List<PhysicalDescriptionDefinition> physicalDescriptions = mods.getPhysicalDescription(); PhysicalDescriptionDefinition reqPhysicalDescription = null; FormDefinition reqForm = null; for (PhysicalDescriptionDefinition pd : physicalDescriptions) { reqPhysicalDescription = pd; List<FormDefinition> forms = pd.getForm(); for (FormDefinition form : forms) { if ("print".equals(form.getValue())) { if (!ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM.equals(form.getAuthority())) { form.setAuthority(ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM); } reqForm = form; } if (ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_RDAMEDIA.equals(form.getAuthority())) { form.setType("media"); } else if (ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_RDACARRIER.equals(form.getAuthority())) { form.setType("carrier"); } else { form.setType(null); } } if (reqForm == null) { reqForm = new FormDefinition(); reqForm.setAuthority(ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM); reqForm.setValue("print"); forms.add(0, reqForm); } } if (reqPhysicalDescription == null) { reqForm = new FormDefinition(); reqForm.setAuthority(ModsConstants.VALUE_PHYSICALDESCRIPTION_FORM_MARCFORM); reqForm.setValue("print"); reqPhysicalDescription = new PhysicalDescriptionDefinition(); reqPhysicalDescription.getForm().add(reqForm); physicalDescriptions.add(reqPhysicalDescription); } List<ClassificationDefinition> classifications = mods.getClassification(); for (ClassificationDefinition classification : classifications) { repairAuthorityInClassification(classification); } List<LocationDefinition> locations = mods.getLocation(); for (LocationDefinition location : locations) { List<PhysicalLocationDefinition> physicals = location.getPhysicalLocation(); for (PhysicalLocationDefinition physical : physicals) { if (physical.getAuthority() == null) { physical.setAuthority("siglaADR"); } } } fillLanguage(mods); fillAbstract(mods); fillRecordInfo(mods); }  @Override void createMods(ModsDefinition mods, Context ctx);  }