当前位置: 首页>>代码示例>>Java>>正文


Java RDFWriter.setProperty方法代码示例

本文整理汇总了Java中com.hp.hpl.jena.rdf.model.RDFWriter.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java RDFWriter.setProperty方法的具体用法?Java RDFWriter.setProperty怎么用?Java RDFWriter.setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hp.hpl.jena.rdf.model.RDFWriter的用法示例。


在下文中一共展示了RDFWriter.setProperty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import com.hp.hpl.jena.rdf.model.RDFWriter; //导入方法依赖的package包/类
@Override
public void write( OutputStream out )
{

	if( null == jenaModel )
	{
		jenaModel = ModelFactory.createDefaultModel();
		jenaModel.setNsPrefix( "rdfs", "http://www.w3.org/2000/01/rdf-schema#" );
		jenaModel.setNsPrefix( "foaf", "http://xmlns.com/foaf/0.1/" );
		jenaModel.setNsPrefix( "dc", "http://purl.org/dc/elements/1.1/" );
	}

	for( FoafPerson person : persons )
	{
		Resource jenaPerson = jenaModel.createResource( FOAF.Person );
		populatePersonProperties( person, jenaPerson );
	}
	
	RDFWriter w = jenaModel.getWriter();
	w.setProperty( "showXmlDeclaration", "true" );
	w.write( jenaModel, out, "RDF/XML" );
	
	
}
 
开发者ID:fogbeam,项目名称:jFriendOfAFriend,代码行数:25,代码来源:JenaFoafModel.java

示例2: write

import com.hp.hpl.jena.rdf.model.RDFWriter; //导入方法依赖的package包/类
public void write(Model model, HttpServletResponse response) throws IOException {
	RDFWriter writer = model.getWriter("RDF/XML-ABBREV");
	writer.setProperty("showXmlDeclaration", "true");
	// From Joseki -- workaround for the j.cook.up bug.
	writer.setProperty("blockRules", "propertyAttr");
	writer.write(model, 
			new OutputStreamWriter(response.getOutputStream(), "utf-8"), null);
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:9,代码来源:ModelResponse.java

示例3: store

import com.hp.hpl.jena.rdf.model.RDFWriter; //导入方法依赖的package包/类
public static void store(Model model, OutputStream out, String sFormat) throws IOException
{
    try {
        RDFWriter w = model.getWriter(sFormat);
        w.setProperty("allowBadURIs", "true");
        w.write(model, out, null);
        out.flush();
    }
    finally {
        out.close();
    }
}
 
开发者ID:hugomanguinhas,项目名称:europeana,代码行数:13,代码来源:JenaUtils.java

示例4: store

import com.hp.hpl.jena.rdf.model.RDFWriter; //导入方法依赖的package包/类
public static void store(Model model, OutputStream out, String sFormat) throws IOException
{
       try {
       	RDFWriter w = model.getWriter(sFormat);
       	w.setProperty("allowBadURIs", "true");
       	w.write(model, out, null);
       	out.flush();
       }
       finally {
       	out.close();
       }
}
 
开发者ID:hugomanguinhas,项目名称:europeana,代码行数:13,代码来源:VocsUtils.java

示例5: saveMetrics

import com.hp.hpl.jena.rdf.model.RDFWriter; //导入方法依赖的package包/类
@Override
public boolean saveMetrics(String format) throws IOException, ConfigurationException, URISyntaxException {
	RDFWriter w = getTheJenaModel().getWriter(format);
	w.setProperty("xmlbase", baseUri);
	FileOutputStream out = new FileOutputStream(filename);
	w.write(getTheJenaModel().getBaseModel(), out, baseUri);
	out.close();
	SadlUtils su = new SadlUtils();
	configMgr.addMapping(su.fileNameToFileUrl(filename), baseUri, null, false, "SRL_Metrics");
	return true;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:12,代码来源:MetricsProcessor.java

示例6: showQueryResults

import com.hp.hpl.jena.rdf.model.RDFWriter; //导入方法依赖的package包/类
private void showQueryResults(String queryString, HttpServletRequest request, HttpServletResponse response) 
		throws IOException {
	Query query = QueryFactory.create(queryString);
	if(query.isSelectType() || query.isDescribeType()) {
		Config config = new Config(request);
		ResultsFormat fmt = ResultsFormat.lookup(request.getParameter("format"));
		Dataset tdbstore = TDBFactory.createDataset(config.getTripleStoreDir());
		QueryExecution qexec = QueryExecutionFactory.create(query, tdbstore);
		qexec.getContext().set(TDB.symUnionDefaultGraph, true);
		if(query.isSelectType()) {
 			ResultSet results = qexec.execSelect();
 			if(fmt == null) {
 				out.print(queryString+"\n");
 				ResultSetFormatter.out(out, results, query);
 			}
 			else
 				ResultSetFormatter.output(out, results, fmt);
		}
		else {
		  Model model = qexec.execDescribe();
       RDFWriter rdfWriter = model.getWriter("RDF/XML-ABBREV");
       rdfWriter.setProperty("showXmlDeclaration", "true");
       rdfWriter.setProperty("tab", "6");
       rdfWriter.write(model, out, null);
		}
	}
	else {
		out.print("Only select or describe queries allowed");
	}
}
 
开发者ID:IKCAP,项目名称:turbosoft,代码行数:31,代码来源:SparqlEndpoint.java

示例7: changeNamespace2

import com.hp.hpl.jena.rdf.model.RDFWriter; //导入方法依赖的package包/类
/**
    * JE: starting an attempt to do the relocation through String reading and writing:
    * The ideal case is that in the generated files, the namespace appears exactly twice:
    * in xmlns and in xml:base.
    * But it depends on the actual seed.
    * Two versions would be possible:
    * OntModel.write( OutputStream out ) / OntModel.write( Writer writer ) 
    * new Model().read( InputStream in, String base ) / new Model().read(Reader reader, String base)
    * So far this is less efficient (and less elegant) than the modifications above
    */
   public OntModel changeNamespace2( String base2 ) {
OntModel model = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
try {
    //Charset defaultCharset = Charset.forName("UTF8");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    //StringWriter sout = new StringWriter();
    RDFWriter writer = modifiedModel.getWriter("RDF/XML-ABBREV");
    writer.setProperty( "showXmlDeclaration","true" );
    writer.setProperty( "relativeURIs", "" );//faster 26.6 -> 26.03 (?)
    // -------- critical section
    // I am curious: isn't it possible to set new ns here? Apparently NO
    writer.setProperty( "xmlbase", modifiedOntologyNS );
    modifiedModel.setNsPrefix( "", modifiedOntologyNS );
    renameOntology( modifiedModel, modifiedOntologyNS, modifiedOntologyNS );
    // --------
    writer.write( modifiedModel.getBaseModel(), out, "");
    //writer.write( modifiedModel.getBaseModel(), sout, "");
    String serial = out.toString( "UTF8" );
    //StringBuffer serial = sout.getBuffer();
    // Can be printed right away
    String sout = serial.replace( modifiedOntologyNS, base2 ); // Does not work well with StringBuffer
    // JE: This part below is unnecessary if we just want to print the result and close the story
    // But suppressing it makes problems even in random...
    // Using the read allocate as much as before
    //InputStream in = null; from the string
    ByteArrayInputStream in = new ByteArrayInputStream( sout.getBytes("UTF8") );
    model.read( in, null );
} catch ( Exception ex ) { //UnsupportedEncodingException;
    ex.printStackTrace(); 
}
return model;
   }
 
开发者ID:dozed,项目名称:align-api-project,代码行数:43,代码来源:BasicAlterator.java

示例8: importOpenData

import com.hp.hpl.jena.rdf.model.RDFWriter; //导入方法依赖的package包/类
/**
 * Imports a private dataset in Open Data format (DCAT).
 *
 * @param authorization   authorization string.
 * @param dcatInputStream
 * @return
 * @throws java.text.ParseException
 * @throws com.fasterxml.jackson.core.JsonProcessingException
 */
@POST
@Path("/importOpenData")
@ApiOperation(
        value = "Import Open Data."
)
@ApiResponses(value = {
    @ApiResponse(code = 401, message = "Unauthorized"),
    @ApiResponse(code = 500, message = "Internal server error")
})
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
@Produces(MediaType.APPLICATION_JSON)
public Response importOpenData(@HeaderParam("Authorization") String authorization,
        InputStream dcatInputStream) throws ParseException, JsonProcessingException {
    log.info(MGS_IMPORT_OPENDATA);
    model = ModelFactory.createDefaultModel(); // new allocation of the model, not sure if really needed
    model.read(dcatInputStream, null);

    StringWriter res = new StringWriter();
    RDFWriter writer = model.getWriter("RDF/XML");
    writer.setProperty("showXmlDeclaration", true);
    writer.write(model, res, null);

    log.debug("Serialized RDF result:\n" + res);

    ResIterator iterator = model.listSubjects();

    List<Resource> resourcesList = iterator.toList();

    String datasetId = "";

    for (Resource resource : resourcesList) {
        if (resource.getURI() != null && resource.getURI().startsWith(URI_DATASET)) {
            Dataset dataset = new Dataset();
            dataset.setId(resource.getProperty(dctIdentifier).getString());
            dataset.setName(resource.getProperty(dctTitle).getString());
            dataset.setDescription(resource.getProperty(dctDescription).getString());
            dataset.setType("Default type");
            Date dt = format.parse(resource.getProperty(dctIssued).getString());
            dataset.setCreationDate(dt.getTime() / 1000);
            dt = format.parse(resource.getProperty(dctModified).getString());
            dataset.setLastModifiedDate(dt.getTime() / 1000);
            dataset.setPermissions(new ArrayList<Permission>());
            // get owner
            String str = resource.getProperty(dctPublisher).getObject().toString();
            String id[] = str.split("#");
            dataset.setOwner(id[id.length - 1]);
            // get status
            dataset.setStatus("public");
            // get readonly
            dataset.setReadOnly(false);
            // get structure
            dataset.setStructure(new DatasetStructure());
            log.debug("here's the dataset: " + dataset.toString());
            datasetId = INSTANCE.getDatasetService().createDataset(dataset);
            break; // exit while the dataset is completed
        }
    }

    return Response.ok(datasetId, MediaType.APPLICATION_JSON).build();
}
 
开发者ID:FiwareTIConsoft,项目名称:fiware-metaware,代码行数:70,代码来源:DatasetRestSrv.java


注:本文中的com.hp.hpl.jena.rdf.model.RDFWriter.setProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。