BdmArticleMapper extends NdkArticleMapper { @Override public void createMods(ModsDefinition mods, Context ctx) { super.createMods(mods, ctx); List<PhysicalDescriptionDefinition> listPhysicalDescription = new ArrayList<>(); for (PhysicalDescriptionDefinition pd : mods.getPhysicalDescription()) { for (FormDefinition form : pd.getForm()) { FormDefinition newFormDefinition = new FormDefinition(); if ("bez média".equals(form.getValue())) { setFormDefinition(form, newFormDefinition, "svazek"); } else if ("počítač".equals(form.getValue())) { setFormDefinition(form, newFormDefinition, "online zdroj"); } else if ("jiný".equals(form.getValue()) && (form.getAuthority() == null || "rdamedia".equals(form.getAuthority()))) { setFormDefinition(form, newFormDefinition, "jiný"); } else { if (form.getAuthority() == null) { form.setAuthority("marcform"); } } PhysicalDescriptionDefinition pdd = new PhysicalDescriptionDefinition(); pdd.getForm().add(newFormDefinition); listPhysicalDescription.add(pdd); } } for (PhysicalDescriptionDefinition pd : listPhysicalDescription) { if (checkNewFormDefinition(pd.getForm().get(0), mods)) { mods.getPhysicalDescription().add(pd); } } setPageInterval(mods); }  @Override void createMods(ModsDefinition mods, Context ctx); @Override ModsWrapper toJsonObject(ModsDefinition mods, Context ctx); @Override ModsDefinition fromJsonObject(ObjectMapper jsMapper, String json, Context ctx); static final String GENRE_ARTICLE_VALUE; static final String GENRE_PEER_REVIEWED_TYPE; }
@Test public void testCreateMods() { String xml = "<mods version='3.5' xmlns='http: + "<physicalDescription> <form>bez média</form> </physicalDescription>" + "<physicalDescription> <form>bez média</form> </physicalDescription>" + "<physicalDescription> <form>počítač</form> </physicalDescription>" + "<physicalDescription> <form>jiný</form> </physicalDescription>" + "<physicalDescription> <form>jiný</form> </physicalDescription>" + "<physicalDescription> <form>audio</form> </physicalDescription>" + "</mods>"; ModsDefinition mods = ModsUtils.unmarshalModsType(new StreamSource(new StringReader(xml))); BdmArticleMapper mapper = new BdmArticleMapper(); Context ctx = new Context("uuid:testId"); mapper.createMods(mods, ctx); int rdamediaSum = 0; int rdacarrierSum = 0; int otherSum = 0; for (PhysicalDescriptionDefinition pd : mods.getPhysicalDescription()) { String authority = pd.getForm().get(0).getAuthority(); if ("rdamedia".equals(authority)) { rdamediaSum++; } else if ("rdacarrier".equals(authority)) { rdacarrierSum++; } else { otherSum++; } } assertEquals(9, mods.getPhysicalDescription().size()); assertEquals(5, rdamediaSum); assertEquals(3, rdacarrierSum); assertEquals(1, otherSum); assertEquals(mods.getPhysicalDescription().size(), rdamediaSum + rdacarrierSum + otherSum); }