本文整理汇总了Java中com.hp.hpl.jena.rdf.model.InfModel.add方法的典型用法代码示例。如果您正苦于以下问题:Java InfModel.add方法的具体用法?Java InfModel.add怎么用?Java InfModel.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.rdf.model.InfModel
的用法示例。
在下文中一共展示了InfModel.add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subprojectsSellers
import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
public static void subprojectsSellers() {
//services for each table
ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
SubProjectSellersService sub = (SubProjectSellersService) ctx.getBean("subProjectSellersServiceImpl");
List<SubProjectSellers> subProjectSeller = sub.getSubProjectSellers();
//--------------RDF Model--------------//
Model model = ModelFactory.createDefaultModel();
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infModel = ModelFactory.createInfModel(reasoner, model);
model.setNsPrefix("elod", OntologySpecification.elodPrefix);
model.setNsPrefix("gr", OntologySpecification.goodRelationsPrefix);
for (SubProjectSellers subProjectSeller1 : subProjectSeller) {
Resource instanceSeller = infModel.createResource(OntologySpecification.instancePrefix
+ "Organization/" + subProjectSeller1.getSellerId());
Resource instanceSubProject = infModel.createResource(OntologySpecification.instancePrefix
+ "Subproject/" + subProjectSeller1.getOps() + "/" + subProjectSeller1.getSubProjectId());
infModel.add(instanceSeller, RDF.type, OntologySpecification.organizationResource);
infModel.add(instanceSeller, RDF.type, OntologySpecification.businessResource);
infModel.add(instanceSubProject, RDF.type, OntologySpecification.subProjectResource);
instanceSubProject.addProperty(OntologySpecification.seller, instanceSeller);
}
try {
FileOutputStream fout = new FileOutputStream(
"/Users/giovaf/Documents/yds_pilot1/espa_tests/22-02-2016_ouput/subProjectSellersEspa.rdf");
model.write(fout);
} catch (IOException e) {
System.out.println("Exception caught" + e.getMessage());
}
}
示例2: espaSellers
import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
public static void espaSellers() {
ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
SellersService sellers = (SellersService) ctx.getBean("sellersServiceImpl");
List<Sellers> seller = sellers.getSellers();
//--------------RDF Model--------------//
Model model = ModelFactory.createDefaultModel();
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infModel = ModelFactory.createInfModel(reasoner, model);
model.setNsPrefix("elod", OntologySpecification.elodPrefix);
model.setNsPrefix("gr", OntologySpecification.goodRelationsPrefix);
model.setNsPrefix("vcard", OntologySpecification.vcardPrefix);
for (Sellers seller1 : seller) {
Resource instanceSeller = infModel.createResource(OntologySpecification.instancePrefix + "Organization/" + seller1.getId());
infModel.add(instanceSeller, RDF.type, OntologySpecification.organizationResource);
instanceSeller.addProperty(OntologySpecification.name, seller1.getEponimia(), XSDDatatype.XSDstring);
}
try {
FileOutputStream fout = new FileOutputStream(
"/Users/giovaf/Documents/yds_pilot1/espa_tests/22-02-2016_ouput/sellersEspa.rdf");
model.write(fout);
} catch (IOException e) {
System.out.println("Exception caught" + e.getMessage());
}
}
示例3: runInference
import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
private Model runInference(Model data, URL rules, int lineLength, int maxLineLength) throws IOException
{
Reasoner reasoner = new GenericRuleReasoner(Rule.rulesFromURL(rules.toString()));
InfModel inf = ModelFactory.createInfModel(reasoner, data);
// Break long literals (more than lineLength chars) using carriage returns
Model remove = ModelFactory.createDefaultModel();
Model add = ModelFactory.createDefaultModel();
Selector sel = new SimpleSelector(null, null, (String)null);
for(StmtIterator sIt = inf.listStatements(sel); sIt.hasNext();)
{
Statement s = sIt.nextStatement();
if(!s.getObject().isLiteral())
continue;
String l = s.getString();
String lp = paginate(l, lineLength, maxLineLength);
if (lp.length() != l.length())
{
remove.add(s);
add.add(s.getSubject(), s.getPredicate(), lp, s.getLanguage());
}
}
inf.remove(remove);
inf.add(add);
return inf;
}
示例4: espaSubprojects
import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
public static void espaSubprojects() throws ParseException {
//services for each table
ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
SubProjectsService sub = (SubProjectsService) ctx.getBean("subProjectsServiceImpl");
List<SubProjects> subProject = sub.getSubProjects();
//--------------RDF Model--------------//
Model model = ModelFactory.createDefaultModel();
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infModel = ModelFactory.createInfModel(reasoner, model);
model.setNsPrefix("elod", OntologySpecification.elodPrefix);
model.setNsPrefix("gr", OntologySpecification.goodRelationsPrefix);
model.setNsPrefix("dcterms", OntologySpecification.dctermsPrefix);
//number format
DecimalFormat df = new DecimalFormat("0.00");
for (SubProjects subProject1 : subProject) {
Resource instanceCurrency = infModel.createResource("http://linkedeconomy.org/resource/Currency/EUR");
Resource instanceBudgetUps = infModel.createResource(OntologySpecification.instancePrefix
+ "UnitPriceSpecification/BudgetItem/" + subProject1.getOps() + "/" + subProject1.getId());
Resource instanceBudget = infModel.createResource(OntologySpecification.instancePrefix + "BudgetItem/" + subProject1.getOps() + "/" + subProject1.getId());
Resource instanceSubProject = infModel.createResource(OntologySpecification.instancePrefix + "Subproject/" + subProject1.getOps() + "/" + subProject1.getId());
Resource instanceProject = infModel.createResource(OntologySpecification.instancePrefix
+ "Subsidy/" + subProject1.getOps());
DateFormat dfDate = new SimpleDateFormat("dd/MM/yyyy");
DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
java.util.Date stDateStarts;
java.util.Date stDateEnds;
stDateStarts = dfDate.parse(subProject1.getStart());
stDateEnds = dfDate.parse(subProject1.getFinish());
String startDate = df2.format(stDateStarts);
String endDate = df2.format(stDateEnds);
infModel.add(instanceProject, RDF.type, OntologySpecification.projectResource);
infModel.add(instanceBudgetUps, RDF.type, OntologySpecification.priceSpecificationResource);
infModel.add(instanceBudget, RDF.type, OntologySpecification.budgetResource);
infModel.add(instanceSubProject, RDF.type, OntologySpecification.subProjectResource);
instanceProject.addProperty(OntologySpecification.hasRelatedProject, instanceSubProject);
instanceSubProject.addProperty(OntologySpecification.hasRelatedBudgetItem, instanceBudget);
instanceBudget.addProperty(OntologySpecification.price, instanceBudgetUps);
instanceBudgetUps.addProperty(OntologySpecification.hasCurrencyValue, df.format(subProject1.getBudget()), XSDDatatype.XSDfloat);
instanceBudgetUps.addProperty(OntologySpecification.valueAddedTaxIncluded, "true", XSDDatatype.XSDboolean);
instanceBudgetUps.addProperty(OntologySpecification.hasCurrency, instanceCurrency);
instanceSubProject.addProperty(OntologySpecification.startDate, startDate, XSDDatatype.XSDdateTime);
instanceSubProject.addProperty(OntologySpecification.endDate, endDate, XSDDatatype.XSDdateTime);
instanceSubProject.addProperty(OntologySpecification.title, String.valueOf(subProject1.getTitle()), "el");
}
try {
FileOutputStream fout = new FileOutputStream(
"/Users/giovaf/Documents/yds_pilot1/espa_tests/22-02-2016_ouput/subProjectEspa.rdf");
model.write(fout);
} catch (IOException e) {
System.out.println("Exception caught" + e.getMessage());
}
}
示例5: espaBuyers
import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
public static void espaBuyers() {
ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
BuyersService buyers = (BuyersService) ctx.getBean("buyersServiceImpl");
List<Buyers> buyer = buyers.getBuyers();
List<Buyer> projectBuyer = buyers.getProjectBuyers();
//--------------RDF Model--------------//
Model model = ModelFactory.createDefaultModel();
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infModel = ModelFactory.createInfModel(reasoner, model);
model.setNsPrefix("elod", OntologySpecification.elodPrefix);
model.setNsPrefix("gr", OntologySpecification.goodRelationsPrefix);
model.setNsPrefix("vcard", OntologySpecification.vcardPrefix);
for (Buyer projectBuyer1 : projectBuyer) {
Resource instanceBuyer = infModel.createResource(OntologySpecification.instancePrefix + "Organization/" + projectBuyer1.getBuyerId());
Resource instanceProject = infModel.createResource(OntologySpecification.instancePrefix + "Subsidy/" + projectBuyer1.getOps());
infModel.add(instanceBuyer, RDF.type, OntologySpecification.organizationResource);
infModel.add(instanceProject, RDF.type, OntologySpecification.subsidyResource);
instanceProject.addProperty(OntologySpecification.beneficiary, instanceBuyer);
instanceBuyer.addProperty(OntologySpecification.name, String.valueOf(projectBuyer1.getEponimia()), XSDDatatype.XSDstring);
}
try {
FileOutputStream fout = new FileOutputStream(
"/Users/giovaf/Documents/yds_pilot1/espa_tests/22-02-2016_ouput/buyersEspa.rdf");
// /home/svaf/buyersEspa.rdf
// /Users/giovaf/Documents/yds_pilot1/espa_tests/06-01-2016_output/buyersEspa.rdf
model.write(fout);
} catch (IOException e) {
System.out.println("Exception caught" + e.getMessage());
}
}
示例6: exportRfd
import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
/**
*
* Implementation Of Subproject Service layer
* and transformation of Database data to RDF
*
* @throws java.text.ParseException
* @throws java.io.UnsupportedEncodingException
* @throws java.io.FileNotFoundException
*/
public static void exportRfd() throws ParseException, UnsupportedEncodingException, FileNotFoundException, IOException {
//services for each table
ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
SubProjectsService sub = (SubProjectsService) ctx.getBean("subProjectsServiceImpl");
List<SubprojectsProjects> subProject = sub.getInfoSubproject();
//--------------RDF Model--------------//
Model model = ModelFactory.createDefaultModel();
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infModel = ModelFactory.createInfModel(reasoner, model);
model.setNsPrefix("elod", OntologySpecification.elodPrefix);
model.setNsPrefix("gr", OntologySpecification.goodRelationsPrefix);
model.setNsPrefix("dcterms", OntologySpecification.dctermsPrefix);
//number format
DecimalFormat df = new DecimalFormat("0.00");
for (SubprojectsProjects subProject1 : subProject) {
Resource instanceCurrency = infModel.createResource("http://linkedeconomy.org/resource/Currency/EUR");
Resource instanceUps = infModel.createResource(OntologySpecification.instancePrefix
+ "UnitPriceSpecification/" + subProject1.getOps() + "/" + subProject1.getSubprojectId());
Resource instanceBudget = infModel.createResource(OntologySpecification.instancePrefix + "BudgetItem/" + subProject1.getOps() + "/" + subProject1.getSubprojectId());
Resource instanceSubProject = infModel.createResource(OntologySpecification.instancePrefix + "Contract/" + subProject1.getOps() + "/" + subProject1.getSubprojectId());
Resource instanceProject = infModel.createResource(OntologySpecification.instancePrefix
+ "PublicWork/" + subProject1.getOps());
infModel.add(instanceUps, RDF.type, OntologySpecification.priceSpecificationResource);
infModel.add(instanceBudget, RDF.type, OntologySpecification.budgetResource);
infModel.add(instanceSubProject, RDF.type, OntologySpecification.contractResource);
instanceProject.addProperty(OntologySpecification.hasRelatedContract, instanceSubProject);
instanceSubProject.addProperty(OntologySpecification.price, instanceUps);
instanceUps.addProperty(OntologySpecification.hasCurrencyValue, df.format(subProject1.getBudget()), XSDDatatype.XSDfloat);
instanceUps.addProperty(OntologySpecification.valueAddedTaxIncluded, "true", XSDDatatype.XSDboolean);
instanceUps.addProperty(OntologySpecification.hasCurrency, instanceCurrency);
if (subProject1.getStart() != null) {
instanceSubProject.addProperty(OntologySpecification.pcStartDate, subProject1.getStart().replace("/", "-"), XSDDatatype.XSDdate);
}
if (subProject1.getFinish() != null) {
instanceSubProject.addProperty(OntologySpecification.actualEndDate, subProject1.getFinish().replace("/", "-"), XSDDatatype.XSDdate);
}
instanceSubProject.addProperty(OntologySpecification.title, String.valueOf(subProject1.getTitle()), "el");
}
try {
FileOutputStream fout = new FileOutputStream(
CommonVariables.serverPath + "subProjectEspa_"+ CommonVariables.currentDate + ".rdf");
model.write(fout);
fout.close();
} catch (IOException e) {
System.out.println("Exception caught" + e.getMessage());
}
}