本文整理汇总了Java中com.hp.hpl.jena.rdf.model.Model.write方法的典型用法代码示例。如果您正苦于以下问题:Java Model.write方法的具体用法?Java Model.write怎么用?Java Model.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.rdf.model.Model
的用法示例。
在下文中一共展示了Model.write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rdfWriter
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
static void rdfWriter(Model model, String filename, boolean time) throws FileNotFoundException,
IOException {
//get current date time with Date()
Date now = new Date();
OutputStream out;
if (time) {
out = new FileOutputStream(filename + "_" + now.getHours() + now.getMinutes() + ".rdf");
} else {
out = new FileOutputStream(filename + ".rdf");
}
model.write(out, "RDF/XML");
out.close();
}
示例2: writeModel
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
/**
* Store the Model.
*
* @param Model the model
*/
public void writeModel(Model model) {
try {
System.out.println("\nSaving Model...");
FileOutputStream fos = new FileOutputStream(Configuration.FILEPATH + Configuration.rdfName);
model.write(fos, "RDF/XML-ABBREV", Configuration.FILEPATH + Configuration.rdfName);
fos.close();
}
catch(Exception e) {
e.printStackTrace();
}
}
示例3: subprojectsSellers
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的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());
}
}
示例4: espaSellers
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的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());
}
}
示例5: writeModel
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
/**
* Store the Model.
*
* @param Model
* the model
*/
public void writeModel(Model model) {
try {
System.out.println("\nSaving Model...");
FileOutputStream fos = new FileOutputStream(Configuration.FILEPATH + Configuration.rdfName);
model.write(fos, "RDF/XML-ABBREV", Configuration.FILEPATH + Configuration.rdfName);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: debugTrips
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
private void debugTrips(Model additions, Model subtractions) {
Long numAdd = additions.size();
Long numSub = subtractions.size();
log.info(numAdd.toString() + " triples to add:\n");
additions.write(System.out, "N-TRIPLES");
log.info(numSub.toString() + " triples to delete:\n");
subtractions.write(System.out, "N-TRIPLES");
}
示例7: main
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
public static void main(String[] args) {
// Load assembler specification from file
Model assemblerSpec = FileManager.get().loadModel("doc/example/assembler.ttl");
// Get the model resource
Resource modelSpec = assemblerSpec.createResource(assemblerSpec.expandPrefix(":myModel"));
// Assemble a model
Model m = Assembler.general.openModel(modelSpec);
// Write it to System.out
m.write(System.out);
m.close();
}
示例8: run
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
public void run(CommandLine cmd, SystemLoader loader) throws IOException {
if (cmd.numItems() == 1) {
loader.setJdbcURL(cmd.getItem(0));
}
PrintStream out;
if (cmd.contains(outfileArg)) {
File f = new File(cmd.getArg(outfileArg).getValue());
log.info("Writing to " + f);
out = new PrintStream(new FileOutputStream(f));
} else {
log.info("Writing to stdout");
out = System.out;
}
MappingGenerator generator = loader.openMappingGenerator();
try {
if (cmd.contains(vocabAsOutput)) {
Model model = generator.vocabularyModel();
model.write(out, "TURTLE");
} else {
generator.writeMapping(out);
}
} finally {
loader.closeMappingGenerator();
}
}
示例9: espaSubprojects
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的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());
}
}
示例10: espaBuyers
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的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());
}
}
示例11: exportRfd
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的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());
}
}
示例12: modelToNtripleString
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
public static String modelToNtripleString(Model model){
String syntax = "N-TRIPLES";
StringWriter out = new StringWriter();
model.write(out, syntax);
return out.toString();
}
示例13: main
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
public static void main(String[] args) {
// First, let's set up an in-memory HSQLDB database,
// load a simple SQL database into it, and generate
// a default mapping for this database using the
// W3C Direct Mapping
SystemLoader loader = new SystemLoader();
loader.setJdbcURL("jdbc:hsqldb:mem:test");
loader.setStartupSQLScript("doc/example/simple.sql");
loader.setGenerateW3CDirectMapping(true);
CompiledMapping mapping = loader.getMapping();
// Print some internal stuff that shows how D2RQ maps the
// database to RDF triples
for (TripleRelation internal: mapping.getTripleRelations()) {
System.out.println(internal);
}
// Write the contents of the virtual RDF model as N-Triples
Model model = loader.getModelD2RQ();
model.write(System.out, "N-TRIPLES");
// Important -- close the model!
model.close();
// Now let's load an example mapping file that connects to
// a MySQL database
loader = new SystemLoader();
loader.setMappingFileOrJdbcURL("doc/example/mapping-iswc.ttl");
loader.setFastMode(true);
loader.setSystemBaseURI("http://example.com/");
// Get the virtual model and run a SPARQL query
model = loader.getModelD2RQ();
ResultSet rs = QueryExecutionFactory.create(
"SELECT * {?s ?p ?o} LIMIT 10", model).execSelect();
while (rs.hasNext()) {
System.out.println(rs.next());
}
// Important -- close the model!
model.close();
}
示例14: getModelAsTtl
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
public String getModelAsTtl() {
Model model = createModel();
StringWriter stringWriter = new StringWriter();
model.write(stringWriter, "TTL");
return stringWriter.toString();
}
示例15: extract
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
public static void extract(Model m,String name){
Property groups=m.createProperty("http://www.buildingsmart-tech.org/ifc/IFC4/final#groups");
Property isGroupedBy=m.createProperty("http://www.buildingsmart-tech.org/ifc/IFC4/final#isGroupedBy");
Resource SingleValue=m.createResource("http://www.buildingsmart-tech.org/ifc/IFC4/final#P_SINGLEVALUE");
Model vocabulary=ModelFactory.createDefaultModel();
StmtIterator stmt1=m.listStatements(null, RDFS.comment,(String)null);
StmtIterator stmt2=m.listStatements(null,RDFS.domain,(RDFNode)null);
StmtIterator stmt3=m.listStatements(null,RDFS.range,(RDFNode)null);
StmtIterator stmt4=m.listStatements(null, RDF.type, RDF.Property);
StmtIterator stmt6=m.listStatements(null, RDFS.label, (String)null);
StmtIterator stmt8=m.listStatements(null, groups, (RDFNode)null);
StmtIterator stmt9=m.listStatements(null, isGroupedBy, (RDFNode)null);
vocabulary.add(stmt1);
vocabulary.add(stmt2);
vocabulary.add(stmt3);
vocabulary.add(stmt4);
vocabulary.add(stmt6);
vocabulary.add(stmt8);
vocabulary.add(stmt9);
m.remove(vocabulary);
StmtIterator stmt7=m.listStatements(null, RDF.type, (RDFNode)null);
List<Statement> ss=new ArrayList<Statement>();
while(stmt7.hasNext()){
Statement s=stmt7.next();
if(s.getObject().asResource().getURI().startsWith("http://www.buildingsmart-tech.org/ifc/IFC4/final")){
ss.add(s);
}
}
m.remove(ss);
try {
OutputStream voc=new FileOutputStream("C:\\users\\chi\\desktop\\output\\"+name+".ttl");
OutputStream rule=new FileOutputStream("C:\\users\\chi\\desktop\\output\\"+name+"_rule.ttl");
vocabulary.setNsPrefixes(m.getNsPrefixMap());
vocabulary.write(voc,"TTL");
m.write(rule,"TTL");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}