public static Offering convertOffering(Resource resource, Float price) { Offering offering = new Offering(); offering.setId(resource.getLocalName()); if (resource.hasProperty(label)) { offering.setName(resource.getProperty(label).getString()); } else { offering.setName(resource.getLocalName()); } if (resource.hasProperty(comment)) { offering.setDescription(resource.getProperty(comment).getString()); } // get included services StmtIterator iter = resource.listProperties(includes); // System.out.println(iter.toList().size()); while (iter.hasNext()) { Resource service = iter.next().getResource(); offering = addFeatures(service, offering); } // get offering price offering = getOfferingPrice(price, offering); return offering; }
public static Offering addServiceFeatures(Resource service, Offering offering) { ArrayList<QualitativeFeature> qualFeatures = offering.getQualitativeFeatures(); ArrayList<QuantitativeFeature> quantFeatures = offering.getQuantitativeFeatures(); /*//adding the offering provider if(service.hasProperty(hasProvider)){ Resource provider = service.getPropertyResourceValue(hasProvider); if(provider.hasProperty(page)) offering.setURL(provider.getProperty(page).getString()); }*/ // get qualitativeFeatures StmtIterator iter = service.listProperties(qualitativeProductOrServiceProperty); // System.out.println(iter.toList().size()); while (iter.hasNext()) { Resource feature = iter.next().getObject().asResource(); qualFeatures.addAll(convertQualitativeFeatures(feature)); } // get quantitative StmtIterator iter2 = service.listProperties(quantitativeProductOrServiceProperty); // System.out.println(iter.toList().size()); while (iter2.hasNext()) { Resource feature = iter2.next().getObject().asResource(); quantFeatures.addAll(convertQuantitativeFeatures(feature)); } return offering; }
// does not use priceCaps that may exist private static Offering getOfferingPrice(Float price, Offering offering) { HashMap<String, String> attributes = new HashMap<String, String>(); attributes.put("price", Float.toString(price)); offering.setAttributes(attributes); return offering; }