當前位置: 首頁>>代碼示例>>Java>>正文


Java Model.write方法代碼示例

本文整理匯總了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();
}
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:14,代碼來源:DataRdfizer.java

示例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();
	}
	
}
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:19,代碼來源:RdfActions.java

示例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());
        }
    }
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:37,代碼來源:SubprojectsSellersImpl.java

示例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());
        }
    }
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:31,代碼來源:SellersImpl.java

示例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();
	}

}
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:19,代碼來源:RdfActionsForSubprojects.java

示例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");
}
 
開發者ID:lawlesst,項目名稱:karma2vivo,代碼行數:9,代碼來源:Batch.java

示例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();
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:16,代碼來源:AssemblerExample.java

示例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();
	}
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:28,代碼來源:generate_mapping.java

示例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());
        }
    }
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:61,代碼來源:SubProjectsImpl.java

示例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());
        }
    }
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:43,代碼來源:BuyersImpl.java

示例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());
    }
}
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:67,代碼來源:SubProjectsImpl.java

示例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();
}
 
開發者ID:lawlesst,項目名稱:karma2vivo,代碼行數:7,代碼來源:ModelUtils.java

示例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();
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:43,代碼來源:SystemLoaderExample.java

示例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();
}
 
開發者ID:mehmandarov,項目名稱:zebra-puzzle-workshop,代碼行數:7,代碼來源:Exercise2.java

示例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();
	}
	
}
 
開發者ID:BenzclyZhang,項目名稱:BimSPARQL,代碼行數:44,代碼來源:VocabularyExtract.java


注:本文中的com.hp.hpl.jena.rdf.model.Model.write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。