コード例 #1
0
ファイル: Turtle.java プロジェクト: xgfd/SSBLD
  /*
   * Converts the ProductFeature Object into an TriG String
   * representation.
   */
  private String convertProductFeature(ProductFeature pf) {
    StringBuffer result = new StringBuffer();
    // First the uriref for the subject

    result.append(ProductFeature.getPrefixed(pf.getNr()));
    result.append("\n");

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

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

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

    // dc:publisher
    result.append(
        createTriplePO(
            DC.prefixed("publisher"),
            createURIref(BSBM.getStandardizationInstitution(pf.getPublisher()))));

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

    return result.toString();
  }
コード例 #2
0
ファイル: Turtle.java プロジェクト: xgfd/SSBLD
  /*
   * 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();
  }
コード例 #3
0
ファイル: Turtle.java プロジェクト: xgfd/SSBLD
  /*
   * Converts the Person Object into an TriG String
   * representation.
   */
  private String convertPerson(Person person, ObjectBundle bundle) {
    StringBuffer result = new StringBuffer();
    // First the uriref for the subject

    result.append(Person.getPrefixed(person.getNr(), bundle.getPublisherNum()));
    result.append("\n");

    // rdf:type
    result.append(createTriplePO(RDF.prefixed("type"), FOAF.prefixed("Person")));

    // foaf:name
    result.append(createTriplePO(FOAF.prefixed("name"), createLiteral(person.getName())));

    // foaf:mbox_sha1sum
    result.append(
        createTriplePO(FOAF.prefixed("mbox_sha1sum"), createLiteral(person.getMbox_sha1sum())));

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

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

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

    return result.toString();
  }
コード例 #4
0
ファイル: Turtle.java プロジェクト: xgfd/SSBLD
  /*
   * Converts the Review Object into an TriG String
   * representation.
   */
  private String convertReview(Review review, ObjectBundle bundle) {
    StringBuffer result = new StringBuffer();
    // First the uriref for the subject

    result.append(Review.getPrefixed(review.getNr(), bundle.getPublisherNum()));
    result.append("\n");

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

    // bsbm:reviewFor
    result.append(
        createTriplePO(
            BSBM.prefixed("reviewFor"),
            Product.getPrefixed(review.getProduct(), review.getProducerOfProduct())));

    // rev:reviewer
    result.append(
        createTriplePO(
            REV.prefixed("reviewer"),
            Person.getPrefixed(review.getPerson(), review.getPublisher())));

    // dc:title
    result.append(createTriplePO(DC.prefixed("title"), createLiteral(review.getTitle())));

    // rev:text
    result.append(
        createTriplePO(
            REV.prefixed("text"),
            createLanguageLiteral(review.getText(), ISO3166.language[review.getLanguage()])));

    // bsbm:ratingX
    Integer[] ratings = review.getRatings();
    for (int i = 0, j = 1; i < ratings.length; i++, j++) {
      Integer value = ratings[i];
      if (value != null)
        result.append(
            createTriplePO(
                BSBM.getRatingPrefix(j),
                //                        createDataTypeLiteral(value.toString(),
                // XSD.prefixed("integer"))
                value.toString()));
    }

    // bsbm:reviewDate
    GregorianCalendar reviewDate = new GregorianCalendar();
    reviewDate.setTimeInMillis(review.getReviewDate());
    String reviewDateString = DateGenerator.formatDateTime(reviewDate);
    result.append(
        createTriplePO(
            BSBM.prefixed("reviewDate"),
            createDataTypeLiteral(reviewDateString, XSD.prefixed("dateTime"))));

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

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

    return result.toString();
  }
コード例 #5
0
ファイル: Turtle.java プロジェクト: xgfd/SSBLD
  /*
   * Converts the Product Object into an TriG String
   * representation.
   */
  private String convertProduct(Product product) {
    StringBuffer result = new StringBuffer();
    // First the uriref for the subject

    result.append(Product.getPrefixed(product.getNr(), product.getProducer()));
    result.append("\n");

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

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

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

    // bsbm:productType
    if (forwardChaining) {
      ProductType pt = product.getProductType();
      while (pt != null) {
        result.append(createTriplePO(RDF.prefixed("type"), pt.getPrefixed()));
        pt = pt.getParent();
      }
    } else {
      result.append(createTriplePO(RDF.prefixed("type"), product.getProductType().getPrefixed()));
    }

    // bsbm:productPropertyNumeric
    Integer[] ppn = product.getProductPropertyNumeric();
    for (int i = 0, j = 1; i < ppn.length; i++, j++) {
      Integer value = ppn[i];
      if (value != null)
        result.append(
            createTriplePO(
                BSBM.getProductPropertyNumericPrefix(j),
                //                        createDataTypeLiteral(value.toString(),
                // XSD.prefixed("integer"))
                value.toString()));
    }

    // bsbm:productPropertyTextual
    String[] ppt = product.getProductPropertyTextual();
    for (int i = 0, j = 1; i < ppt.length; i++, j++) {
      String value = ppt[i];
      if (value != null)
        result.append(
            createTriplePO(
                BSBM.getProductPropertyTextualPrefix(j),
                createDataTypeLiteral(value, XSD.prefixed("string"))));
    }

    // bsbm:productFeature
    Iterator<Integer> pf = product.getFeatures().iterator();
    while (pf.hasNext()) {
      Integer value = pf.next();
      result.append(
          createTriplePO(BSBM.prefixed("productFeature"), ProductFeature.getPrefixed(value)));
    }

    // bsbm:producer
    result.append(
        createTriplePO(BSBM.prefixed("producer"), Producer.getPrefixed(product.getProducer())));

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

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

    return result.toString();
  }
コード例 #6
0
ファイル: Turtle.java プロジェクト: xgfd/SSBLD
  /*
   * 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();
  }