Esempio n. 1
0
 @Override
 public String data(String predicate, Resource resource, String property, String value) {
   if ("IdentifierZDB".equals(predicate)) {
     if ("value".equals(property)) {
       if (value.startsWith("(DE-599)")) {
         resource.add("identifierEKI", value.substring(8));
         return null;
       } else if (value.startsWith("(OCoLC)")) {
         resource.add("identifierOCLC", value.substring(7).replaceAll("\\-", "").toLowerCase());
         return null;
       } else {
         int pos = value.indexOf(')');
         String prefix = pos > 0 ? value.substring(1, pos).toUpperCase() : "";
         value = pos > 0 ? value.substring(pos + 1) : value;
         resource.add("identifier" + prefix, value.replaceAll("\\-", "").toLowerCase());
         return null;
       }
     }
   }
   return value;
 }
Esempio n. 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!
   }
 }
Esempio n. 3
0
  private void push(URI uri) throws Exception {
    if (uri == null) {
      return;
    }
    InputStream in = factory.open(uri);
    if (in == null) {
      throw new IOException("unable to open " + uri);
    }
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"))) {
      String title = null;
      List<String> author = new LinkedList();
      String year = null;
      String journal = null;
      String issn = null;
      String volume = null;
      String issue = null;
      String pagination = null;
      String doi = null;
      String publisher = null;
      String line;
      while ((line = reader.readLine()) != null) {
        if (line.isEmpty()) {
          continue;
        }
        if ('%' != line.charAt(0)) {
          continue;
        }
        char ch = line.charAt(1);
        switch (ch) {
          case 'D':
            {
              year = line.substring(3).trim();
              break;
            }
          case 'T':
            {
              title = line.substring(3).trim();
              break;
            }
          case '@':
            {
              issn = line.substring(3).trim();
              break;
            }
          case 'J':
            {
              journal = line.substring(3).trim();
              break;
            }
          case 'A':
            {
              author.add(line.substring(3).trim());
              break;
            }
          case 'V':
            {
              volume = line.substring(3).trim();
              break;
            }
          case 'N':
            {
              issue = line.substring(3).trim();
              break;
            }
          case 'P':
            {
              pagination = line.substring(3).trim();
              break;
            }
          case 'R':
            {
              doi = line.substring(3).trim();
              break;
            }
          case 'I':
            {
              publisher = line.substring(3).trim();
              break;
            }
          case 'U':
            {
              // URL (DOI resolver)
              break;
            }
          case 'K':
            {
              // keywords
              break;
            }
          case '0':
            {
              // record type
              break;
            }
          case '8':
            {
              // day
              break;
            }
          case 'G':
            {
              // language
              break;
            }
          default:
            {
              logger.warn("unknown tag: " + line);
            }
        }
      }
      // create bibliographic key

      String key =
          author.isEmpty()
              ? null
              : new WorkAuthor().authorName(author.get(0)).workName(title).createIdentifier();

      IRI dereferencable =
          IRI.builder().scheme("http").host("xbib.info").path("/doi/").fragment(doi).build();

      Resource r =
          resourceContext
              .newResource()
              .id(dereferencable)
              .a(FABIO_ARTICLE)
              .add("xbib:key", key)
              .add("prism:doi", doi)
              .add("dc:title", title);
      for (String a : author) {
        r.add("dc:creator", a);
      }
      r.add("prism:publicationDate", new SimpleLiteral<>(year).type(Literal.GYEAR));
      r.newResource(FRBR_EMBODIMENT).a(FABIO_PERIODICAL_VOLUME).add("prism:volume", volume);
      r.newResource(FRBR_EMBODIMENT).a(FABIO_PERIODICAL_ISSUE).add("prism:number", issue);
      r.newResource(FRBR_EMBODIMENT).a(FABIO_PRINT_OBJECT).add("prism:pageRange", pagination);
      r.newResource(FRBR_PARTOF)
          .a(FABIO_JOURNAL)
          .add("prism:publicationName", journal)
          .add("prism:issn", issn)
          .add("dc:publisher", publisher);
      resourceContext
          .resource()
          .id(
              IRI.builder()
                  .scheme("http")
                  .host(index)
                  .query(type)
                  .fragment(resourceContext.resource().id().getFragment())
                  .build());
      out.output(resourceContext, resourceContext.contentBuilder());
    }
  }