本文整理汇总了Java中com.hp.hpl.jena.rdf.model.InfModel.createResource方法的典型用法代码示例。如果您正苦于以下问题:Java InfModel.createResource方法的具体用法?Java InfModel.createResource怎么用?Java InfModel.createResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.rdf.model.InfModel
的用法示例。
在下文中一共展示了InfModel.createResource方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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());
}
}
示例4: 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());
}
}
示例5: 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());
}
}
示例6: main
import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex6-data.ttl");
Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel,
ReasonerVocabulary.RDFS_DEFAULT);
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
Resource theFirmNode = infmodel.createResource("http://www.example.org/example#TheFirm");
String queryString = "SELECT ?s ?z WHERE { ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?z }" ;
QuerySolutionMap initialBinding = new QuerySolutionMap();
initialBinding.add("s", theFirmNode );
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, infmodel, initialBinding) ;
QueryExecUtils.executeQuery(qexec);
System.out.println( "\n----------\ndone" );
}
示例7: main
import com.hp.hpl.jena.rdf.model.InfModel; //导入方法依赖的package包/类
public static void main( String[] args )
{
// load some data that uses RDFS
Model data = FileManager.get().loadModel("file:data/input/turtle/ex2-data.ttl");
// InfModel infmodel = ModelFactory.createRDFSModel(data);
Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel,
ReasonerVocabulary.RDFS_DEFAULT);
InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
StmtIterator sIter = infmodel.listStatements();
while( sIter.hasNext() )
{
Statement stmt = sIter.nextStatement();
System.out.println( PrintUtil.print(stmt));
}
System.out.println( "\n\n******************************\n\n" );
Resource O = infmodel.createResource( "http://www.example.com/shop#Shirts" );
/*
Selector selector = new SimpleSelector((Resource)null, (Property)null, O);
StmtIterator siter2 = infmodel.listStatements( selector );
while( siter2.hasNext() )
{
Statement stmt = siter2.nextStatement();
System.out.println( PrintUtil.print(stmt));
}
*/
System.out.println( "\n\n******************************\n\n" );
/*
Property P = infmodel.createProperty( "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" );
Selector selector2 = new SimpleSelector((Resource)null, (Property)P, O);
StmtIterator siter3 = infmodel.listStatements( selector2 );
while( siter3.hasNext() )
{
Statement stmt = siter3.nextStatement();
System.out.println( PrintUtil.print(stmt));
}
*/
System.out.println( "done" );
}