Beispiel #1
0
  /*
   * Converts the Vendor Object into an TriG String
   * representation.
   */
  private String convertVendor(Vendor vendor) {
    StringBuffer result = new StringBuffer();
    // First the uriref for the subject

    result.append(Vendor.getPrefixed(vendor.getNr()));
    result.append("\n");

    // rdf:type
    result.append(createTriplePO(RDF.prefixed("type"), BSBM.prefixed("Vendor")));

    // rdfs:label
    result.append(createTriplePO(RDFS.prefixed("label"), createLiteral(vendor.getLabel())));

    // rdfs:comment
    result.append(createTriplePO(RDFS.prefixed("comment"), createLiteral(vendor.getComment())));

    // foaf:homepage
    result.append(createTriplePO(FOAF.prefixed("homepage"), createURIref(vendor.getHomepage())));

    // bsbm:country
    result.append(
        createTriplePO(
            BSBM.prefixed("country"), createURIref(ISO3166.find(vendor.getCountryCode()))));

    // dc:publisher
    result.append(
        createTriplePO(DC.prefixed("publisher"), Vendor.getPrefixed(vendor.getPublisher())));

    // dc:date
    GregorianCalendar date = new GregorianCalendar();
    date.setTimeInMillis(vendor.getPublishDate());
    String dateString = DateGenerator.formatDate(date);
    result.append(
        createTriplePOEnd(
            DC.prefixed("date"), createDataTypeLiteral(dateString, XSD.prefixed("date"))));

    return result.toString();
  }
Beispiel #2
0
  /*
   * Converts the Offer Object into an TriG String
   * representation.
   */
  private String convertOffer(Offer offer) {
    StringBuffer result = new StringBuffer();
    // First the uriref for the subject

    result.append(offer.getPrefixed());
    result.append("\n");

    // rdf:type
    result.append(createTriplePO(RDF.prefixed("type"), BSBM.prefixed("Offer")));

    // bsbm:product
    int productNr = offer.getProduct();
    int producerNr = Generator.getProducerOfProduct(productNr);
    result.append(
        createTriplePO(BSBM.prefixed("product"), Product.getPrefixed(productNr, producerNr)));

    // bsbm:vendor
    result.append(createTriplePO(BSBM.prefixed("vendor"), Vendor.getPrefixed(offer.getVendor())));

    // bsbm:price
    result.append(
        createTriplePO(
            BSBM.prefixed("price"),
            //                createDataTypeLiteral(offer.getPriceString(),BSBM.prefixed("USD"))
            offer.getPriceString() + "e0"));

    // bsbm:validFrom
    GregorianCalendar validFrom = new GregorianCalendar();
    validFrom.setTimeInMillis(offer.getValidFrom());
    String validFromString = DateGenerator.formatDateTime(validFrom);
    result.append(
        createTriplePO(
            BSBM.prefixed("validFrom"),
            createDataTypeLiteral(validFromString, XSD.prefixed("dateTime"))));

    // bsbm:validTo
    GregorianCalendar validTo = new GregorianCalendar();
    validTo.setTimeInMillis(offer.getValidTo());
    String validToString = DateGenerator.formatDateTime(validTo);
    result.append(
        createTriplePO(
            BSBM.prefixed("validTo"),
            createDataTypeLiteral(validToString, XSD.prefixed("dateTime"))));

    // bsbm:deliveryDays
    result.append(
        createTriplePO(
            BSBM.prefixed("deliveryDays"),
            //                createDataTypeLiteral(offer.getDeliveryDays().toString(),
            // XSD.prefixed("integer"))
            offer.getDeliveryDays().toString()));

    // bsbm:offerWebpage
    result.append(
        createTriplePO(BSBM.prefixed("offerWebpage"), createURIref(offer.getOfferWebpage())));

    // dc:publisher
    result.append(
        createTriplePO(DC.prefixed("publisher"), Vendor.getPrefixed(offer.getPublisher())));

    // dc:date
    GregorianCalendar date = new GregorianCalendar();
    date.setTimeInMillis(offer.getPublishDate());
    String dateString = DateGenerator.formatDate(date);
    result.append(
        createTriplePOEnd(
            DC.prefixed("date"), createDataTypeLiteral(dateString, XSD.prefixed("date"))));

    return result.toString();
  }