示例#1
0
文件: Turtle.java 项目: xgfd/SSBLD
  /*
   * Converts the Producer Object into an TriG String
   * representation.
   */
  private String convertProducer(Producer producer) {
    StringBuffer result = new StringBuffer();
    // First the uriref for the subject

    result.append(Producer.getPrefixed(producer.getNr()));
    result.append("\n");

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

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

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

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

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

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

    // dc:date
    GregorianCalendar date = new GregorianCalendar();
    date.setTimeInMillis(producer.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 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();
  }