@Override
 public void fields(
     ElementBuilder<FieldCollection, String, MARCElement, MARCContext> builder,
     FieldCollection fields,
     String value) {
   Map<String, Object> codes = (Map<String, Object>) getSettings().get("codes");
   if (codes != null) {
     // position 0 is the selector
     codes = (Map<String, Object>) codes.get("0");
   }
   for (Field field : fields) {
     String data = field.data();
     if (data == null) {
       continue;
     }
     Map<String, Object> m = (Map<String, Object>) codes.get(data.substring(0, 1));
     if (m == null) {
       continue;
     }
     // transform all codes except position 0
     String predicate = (String) m.get("_predicate");
     for (int i = 1; i < data.length(); i++) {
       String ch = data.substring(i, i + 1);
       Map<String, Object> q = (Map<String, Object>) m.get(Integer.toString(i));
       if (q != null) {
         String code = (String) q.get(ch);
         builder.context().resource().add(predicate, code);
       }
     }
   }
 }
Beispiel #2
0
 /**
  * g = Geografikum (Gebietskörperschaft) (NW) 9 = GND-Identifikationsnummer h = Zusatz (W) x =
  * nachgeordneter Teil (W) z = geografische Unterteilung (W)
  *
  * @param builder
  * @param fields
  * @param value
  * @return
  */
 @Override
 public boolean fields(
     ElementBuilder<FieldCollection, String, MABElement, MABContext> builder,
     FieldCollection fields,
     String value) {
   if (value != null) {
     return super.fields(builder, fields, value);
   } else {
     Resource person = builder.context().resource().newResource(DC_CONTRIBUTOR);
     for (Field field : fields) {
       switch (field.subfieldId()) {
         case "g":
           {
             person.add("geoName", field.data());
             break;
           }
         case "h":
           {
             person.add("geoOtherInformation", field.data());
             break;
           }
         case "x":
           {
             person.add("geoSubUnit", field.data());
             break;
           }
         case "z":
           {
             person.add("geoZone", field.data());
             break;
           }
         case "9":
           {
             person.add("geoIdentifier", field.data());
             break;
           }
       }
     }
     return true; // done!
   }
 }