• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JSON类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.jena.atlas.json.JSON的典型用法代码示例。如果您正苦于以下问题:Java JSON类的具体用法?Java JSON怎么用?Java JSON使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JSON类属于org.apache.jena.atlas.json包,在下文中一共展示了JSON类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getConcept

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
/**
 * Return the concept with the supplied URI with pref label, uri and type fields populated
 * @param conceptUri - the concept to be returned
 * @return - the requested concept 
 * @throws OEClientException - an error has occurred contacting the server
 */
public Concept getConcept(String conceptUri) throws OEClientException {
	logger.info("getConcept entry: {}", conceptUri);

	Map<String, String> queryParameters = new HashMap<String, String>();
	queryParameters.put("properties", basicProperties);
	queryParameters.put("path", getPathParameter(conceptUri));
	Invocation.Builder invocationBuilder = getInvocationBuilder(getApiURL(), queryParameters);

	Date startDate = new Date();
	logger.info("getConcept making call  : {}", startDate.getTime());
	Response response = invocationBuilder.get();
	logger.info("getConcept call complete: {}", startDate.getTime());

	logger.info("getConceptDetails - status: {}", response.getStatus());
	if (response.getStatus() == 200) {
		String stringResponse = response.readEntity(String.class);
		if (logger.isDebugEnabled()) logger.debug("getConceptDetails: jsonResponse {}", stringResponse);
		JsonObject jsonResponse = JSON.parse(stringResponse);
		return new Concept(this, jsonResponse.get("@graph").getAsArray().get(0).getAsObject());
	} else {
		throw new OEClientException(String.format("Error(%d) %s from server", response.getStatus(), response.getStatusInfo().toString()));
	}
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:30,代码来源:OEClientReadOnly.java


示例2: getConceptByIdentifier

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
/**
 * Return the concept with the supplied identifier
 * @param identifier - the unique identifier for the concept (not the URI)
 * @return - the requested concept
 * @throws OEClientException - an error has occurred contacting the server
 */
public Concept getConceptByIdentifier(Identifier identifier) throws OEClientException {
	logger.info("getConceptByIdentifier entry: {}", identifier);

	String url = getModelURL() + "/skos:Concept/meta:transitiveInstance";

	Map<String, String> queryParameters = new HashMap<String, String>();
	queryParameters.put("properties", basicProperties);
	queryParameters.put("filters", String.format("subject(exists %s \"%s\")", getWrappedUri(identifier.getUri()), identifier.getValue()));
	Invocation.Builder invocationBuilder = getInvocationBuilder(url, queryParameters);

	Date startDate = new Date();
	logger.info("getConceptByIdentifier making call  : {}", startDate.getTime());
	Response response = invocationBuilder.get();
	logger.info("getConceptByIdentifier call complete: {}", startDate.getTime());

	logger.info("getConceptByIdentifier - status: {}", response.getStatus());
	if (response.getStatus() == 200) {
		String stringResponse = response.readEntity(String.class);
		if (logger.isDebugEnabled()) logger.debug("getConceptByIdentifier: jsonResponse {}", stringResponse);
		JsonObject jsonResponse = JSON.parse(stringResponse);
		return new Concept(this, jsonResponse.get("@graph").getAsArray().get(0).getAsObject());
	} else {
		throw new OEClientException(String.format("Error(%d) %s from server", response.getStatus(), response.getStatusInfo().toString()));
	}
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:32,代码来源:OEClientReadOnly.java


示例3: populateRelatedConceptUris

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
public void populateRelatedConceptUris(String relationshipUri, Concept concept) throws OEClientException {
	logger.info("populateNarrowerConceptURIs entry: {}", concept.getUri());

	Map<String, String> queryParameters = new HashMap<String, String>();
	queryParameters.put("properties", getWrappedUri(relationshipUri));
	Invocation.Builder invocationBuilder = getInvocationBuilder(getResourceURL(concept.getUri()), queryParameters);

	Date startDate = new Date();
	logger.info("populateNarrowerConceptURIs making call  : {}", startDate.getTime());
	Response response = invocationBuilder.get();
	logger.info("populateNarrowerConceptURIs call complete: {}", startDate.getTime());

	logger.info("populateNarrowerConceptURIs - status: {}", response.getStatus());
	if (response.getStatus() == 200) {
		String stringResponse = response.readEntity(String.class);
		if (logger.isDebugEnabled()) logger.debug("populateNarrowerConceptURIs: jsonResponse {}", stringResponse);
		JsonObject jsonResponse = JSON.parse(stringResponse);
		concept.populateRelatedConceptUris(relationshipUri, jsonResponse.get("@graph").getAsArray().get(0).getAsObject());
	} else {
		throw new OEClientException(String.format("Error(%d) %s from server", response.getStatus(), response.getStatusInfo().toString()));
	}
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:23,代码来源:OEClientReadOnly.java


示例4: populateMetadata

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
public void populateMetadata(String metadataUri, Concept concept) throws OEClientException {
	logger.info("populateMetadata entry: {}", concept.getUri());

	Map<String, String> queryParameters = new HashMap<String, String>();
	queryParameters.put("properties", getWrappedUri(metadataUri));
	Invocation.Builder invocationBuilder = getInvocationBuilder(getResourceURL(concept.getUri()), queryParameters);

	Date startDate = new Date();
	logger.info("populateMetadata making call  : {}", startDate.getTime());
	Response response = invocationBuilder.get();
	logger.info("populateMetadata call complete: {}", startDate.getTime());

	logger.info("populateMetadata - status: {}", response.getStatus());
	if (response.getStatus() == 200) {
		String stringResponse = response.readEntity(String.class);
		if (logger.isDebugEnabled()) logger.debug("populateNarrowerConceptURIs: jsonResponse {}", stringResponse);
		JsonObject jsonResponse = JSON.parse(stringResponse);
		concept.populateMetadata(metadataUri, jsonResponse.get("@graph").getAsArray().get(0).getAsObject());
	} else {
		throw new OEClientException(String.format("Error(%d) %s from server", response.getStatus(), response.getStatusInfo().toString()));
	}
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:23,代码来源:OEClientReadOnly.java


示例5: json

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
public static void json(HttpServletRequest req, HttpServletResponse resp, JsonValue responseContent) {
    try { 
        resp.setHeader(HttpNames.hCacheControl, "no-cache");
        resp.setHeader(HttpNames.hContentType,  WebContent.contentTypeJSON);
        resp.setStatus(HttpSC.OK_200);
        try(ServletOutputStream out = resp.getOutputStream(); IndentedWriter b = new IndentedWriter(out); ) {
            b.setFlatMode(true);
            JSON.write(b, responseContent);
            b.ensureStartOfLine();
            b.flush();
            out.write('\n');
        }
    } catch (IOException ex) {
        LOG.warn("json: IOException", ex);
        try { 
            resp.sendError(HttpSC.INTERNAL_SERVER_ERROR_500, "Internal server error");
        } catch (IOException ex2) {}
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:20,代码来源:S_JSON.java


示例6: getFieldAsObject

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
private static JsonObject getFieldAsObject(JsonObject arg, String field) {
    try {
        if ( ! arg.hasKey(field) ) {
            LOG.warn("Bad request: Missing Field: "+field+" Arg: "+JSON.toStringFlat(arg)) ;
            throw new DeltaBadRequestException("Missing field: "+field) ;
        }
        JsonValue jv = arg.get(field) ;
        if ( ! jv.isObject() ) {
            
        }
        return jv.getAsObject();
    } catch (JsonException ex) {
        LOG.warn("Bad request: Field: "+field+" Arg: "+JSON.toStringFlat(arg)) ;
        throw new DeltaBadRequestException("Bad field '"+field+"' : "+arg.get(field)) ;
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:17,代码来源:S_DRPC.java


示例7: run

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
@Override
public void run(Model results) throws Exception {
	Resource testCase = getResource();
	String queryString = JenaUtil.getStringProperty(testCase, SH.select);
	Model model = testCase.getModel();
	JsonObject expectedJSON = JSON.parse(JenaUtil.getStringProperty(testCase, DASH.expectedResult));
	
	for(TestCaseContextFactory contextFactory : contextFactories) {
		TestCaseContext context = contextFactory.createContext();
		context.setUpTestContext();
		try {
			String actual = createResultSetJSON(queryString, model);
			JsonObject actualJSON = JSON.parse(actual);
			if(!actualJSON.equals(expectedJSON)) {
				createFailure(results, "Mismatching result set. Actual: " + actual, context);
				return;
			}
		}
		finally {
			context.tearDownTestContext();
		}
	}
	createResult(results, DASH.SuccessTestCaseResult);
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:25,代码来源:QueryTestCaseType.java


示例8: getAllModels

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
public Collection<Model> getAllModels() throws OEClientException {
	logger.info("getAllModels entry");
	
	String url = getApiURL() + "/sys/sys:Model/rdf:instance";
	logger.info("getAllModels URL: {}", url);
	Map<String, String> queryParameters = new HashMap<String, String>();
	queryParameters.put("properties", "meta:displayName,meta:graphUri");

	Invocation.Builder invocationBuilder = getInvocationBuilder(url, queryParameters);

	Date startDate = new Date();
	logger.info("getAllModels making call  : {}", startDate.getTime());
	Response response = invocationBuilder.get();
	logger.info("getAllModels call complete: {}", startDate.getTime());

	logger.info("getAllModels - status: {}", response.getStatus());

	if (response.getStatus() == 200) {
		String stringResponse = response.readEntity(String.class);
		if (logger.isInfoEnabled()) logger.info("getAllModels: jsonResponse {}", stringResponse);
		JsonObject jsonResponse = JSON.parse(stringResponse);
		JsonArray jsonArray = jsonResponse.get("@graph").getAsArray();
		Collection<Model> models = new ArrayList<Model>();
		Iterator<JsonValue> jsonValueIterator = jsonArray.iterator();
		while (jsonValueIterator.hasNext()) {
			JsonObject modelObject = jsonValueIterator.next().getAsObject();
			models.add(new Model(modelObject));
		}
		return models;
	} else {
		throw new OEClientException(String.format("Error(%d) %s from server", response.getStatus(), response.getStatusInfo().toString()));
	}
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:34,代码来源:OEClientReadOnly.java


示例9: getRelationshipTypes

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
private Collection<RelationshipType> getRelationshipTypes(String parentType) throws OEClientException {
	logger.info("getRelationshipTypes entry: {}", parentType);

	Map<String, String> queryParameters = new HashMap<String, String>();
	queryParameters.put("properties", "rdfs:label,owl:inverseOf,rdfs:subPropertyOf,owl:inverseOf/rdfs:label,owl:inverseOf/rdfs:subPropertyOf");
	Invocation.Builder invocationBuilder = getInvocationBuilder(getModelURL() + "/" + parentType +"/meta:transitiveSubProperty", queryParameters);

	Date startDate = new Date();
	logger.info("getRelationshipTypes making call  : {}", startDate.getTime());
	Response response = invocationBuilder.get();
	logger.info("getRelationshipTypes call complete: {}", startDate.getTime());

	logger.info("getRelationshipTypes - status: {}", response.getStatus());
	if (response.getStatus() == 200) {
		String stringResponse = response.readEntity(String.class);
		if (logger.isInfoEnabled()) logger.info("getConceptClasses: jsonResponse {}", stringResponse);
		JsonObject jsonResponse = JSON.parse(stringResponse);
		JsonArray jsonArray = jsonResponse.get("@graph").getAsArray();
		Collection<RelationshipType> relationshipTypes = new HashSet<RelationshipType>();
		Iterator<JsonValue> jsonValueIterator = jsonArray.iterator();
		while (jsonValueIterator.hasNext()) {
			relationshipTypes.add(new RelationshipType(this, jsonValueIterator.next().getAsObject()));
		}
		return relationshipTypes;
	} else {
		throw new OEClientException(String.format("Error(%d) %s from server", response.getStatus(), response.getStatusInfo().toString()));
	}
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:29,代码来源:OEClientReadOnly.java


示例10: getConceptClasses

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
/**
 * Return all concept classes
 * @return - a collection containing all concept classes
 * @throws OEClientException - an error has occurred contacting the server
 */
public Collection<ConceptClass> getConceptClasses(int limit) throws OEClientException {
	logger.info("getConceptClasses entry");

	Map<String, String> queryParameters = new HashMap<String, String>();
	queryParameters.put("properties", "rdfs:label,rdfs:subClassOf");
	queryParameters.put("limit", Integer.toString(limit));
	Invocation.Builder invocationBuilder = getInvocationBuilder(getModelURL() + "/skos:Concept/meta:transitiveSubClass", queryParameters);

	Date startDate = new Date();
	logger.info("getConceptClasses making call  : {}", startDate.getTime());
	Response response = invocationBuilder.get();
	logger.info("getConceptClasses call complete: {}", startDate.getTime());

	logger.info("getConceptClasses - status: {}", response.getStatus());
	if (response.getStatus() == 200) {
		String stringResponse = response.readEntity(String.class);
		if (logger.isInfoEnabled()) logger.info("getConceptClasses: jsonResponse {}", stringResponse);
		JsonObject jsonResponse = JSON.parse(stringResponse);
		JsonArray jsonArray = jsonResponse.get("@graph").getAsArray();
		Collection<ConceptClass> conceptClasses = new HashSet<ConceptClass>();
		Iterator<JsonValue> jsonValueIterator = jsonArray.iterator();
		while (jsonValueIterator.hasNext()) {
			conceptClasses.add(new ConceptClass(this, jsonValueIterator.next().getAsObject()));
		}
		return conceptClasses;
	} else {
		throw new OEClientException(String.format("Error(%d) %s from server", response.getStatus(), response.getStatusInfo().toString()));
	}
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:35,代码来源:OEClientReadOnly.java


示例11: testVocabularyManagement

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
@Test
public void testVocabularyManagement() throws Exception {
	RESTResource resource;
	String ontoId;

	Map<String,String> parameters = new HashMap<String,String>();
	
	// POST vocabulary
	String ontoUri = "http://purl.oclc.org/NET/ssnx/qu/qu-rec20";
	InputStream uriStream = new ByteArrayInputStream(ontoUri.getBytes("UTF-8"));
	resource = vch.post(new URI(baseUri + "/vocab"), parameters, uriStream);
	ontoId = resource.path;

	Assert.assertTrue("QU ontology not registered", VocabularyUtils.containsVocabulary(ontoUri));
	
	// GET vocabulary by SPARQL query
	parameters.clear();
	parameters.put("query", "?s ?p ?o");
	resource = vch.get(new URI(baseUri + "/vocab"), parameters);
	
	JsonValue ontoIds = JSON.parseAny(resource.content);
	Assert.assertTrue("Vocabulary collection is not an array", ontoIds.isArray());
	Assert.assertTrue("Vocabulary imports were not added", ontoIds.getAsArray().size() > 1);
	Assert.assertTrue("QU ontology not found", ontoIds.getAsArray().contains(new JsonString(ontoId)));
	
	// GET vocabulary by id
	VocabularyHandler vh = new VocabularyHandler(ontoId, ThingDirectory.servers);
	resource = vh.get(new URI(baseUri + ontoId), null);
	
	ByteArrayInputStream byteStream = new ByteArrayInputStream(resource.content.getBytes());
	Model m = ModelFactory.createDefaultModel();
	m.read(byteStream, "", "Turtle");
	Assert.assertFalse("QU ontology definition is not valid", m.isEmpty());

	// DELETE vocabulary
	vh.delete(new URI(baseUri + ontoId), null, null);
	Assert.assertFalse("QU ontology not deleted", VocabularyUtils.containsVocabulary(ontoUri));
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:39,代码来源:ThingWebRepoTest.java


示例12: handleMissingConfigFile

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
private static void handleMissingConfigFile(Path path) {
    //throw new DeltaConfigException("No such file: "+path.toString());
    JsonObject obj = JSONX.buildObject(b->{
        b.key(F_VERSION).value(DeltaConst.SYSTEM_VERSION);
        // Default log provider
        b.key(F_LOG_TYPE).value(DeltaConst.LOG_FILE);
    });
    try ( IndentedWriter out = new IndentedWriter(Files.newOutputStream(path)); ) {
        JSON.write(out, obj);
        out.ensureStartOfLine();
    } catch (IOException ex) { IO.exception(ex); }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:13,代码来源:LocalServerConfig.java


示例13: makeDataSource

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
/**
 * Create a {@link DataSource} by reading the "source.cfg" file"
 * @param dataSourceArea The directory where the DataSources details are stored.
 * @return DataSource
 */
public static DataSource makeDataSource(Path dataSourceArea) {
    JsonObject sourceObj = JSON.read(dataSourceArea.resolve(DeltaConst.DS_CONFIG).toString());
    DataSourceDescription dsd = DataSourceDescription.fromJson(sourceObj);
    Id id = dsd.getId();
    String baseStr = dsd.getName();
    String uriStr = dsd.getUri(); 
    DataSource dataSource = DataSource.connect(id, uriStr, baseStr, dataSourceArea);
    return dataSource ;
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:15,代码来源:Cfg.java


示例14: synchronized

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
private Id createDataSource$(PatchStore patchStore, DataSourceDescription dsd) {
    synchronized(lock) {
        Path sourcePath = null;
        if ( ! patchStore.isEphemeral() ) {
            Location sourceArea = dataSourceArea(serverRoot, dsd.getName());
            sourcePath = IOX.asPath(sourceArea);

            // Checking.
            // The area can exist, but it must not be formatted for a DataSource 
            //        if ( sourceArea.exists() )
            //            throw new DeltaException("Area already exists");

            if ( Cfg.isMinimalDataSource(LOG, sourcePath) )
                throw new DeltaBadRequestException("DataSource area already exists at: "+sourceArea);
            if ( ! Cfg.isEnabled(sourcePath) )
                throw new DeltaBadRequestException("DataSource area disabled: "+sourceArea);

            String patchesDirName = sourceArea.getPath(DeltaConst.LOG);
            if ( FileOps.exists(patchesDirName) )
                throw new DeltaBadRequestException("DataSource area does not have a configuration but does have a patches area.");

            String dataDirName = sourceArea.getPath(DeltaConst.DATA);
            if ( FileOps.exists(dataDirName) )
                throw new DeltaBadRequestException("DataSource area has a likely looking database already");

            // Create source.cfg.
            JsonObject obj = dsd.asJson();
            LOG.info(JSON.toStringFlat(obj));
            try (OutputStream out = Files.newOutputStream(sourcePath.resolve(DeltaConst.DS_CONFIG))) {
                JSON.write(out, obj);
            } catch (IOException ex)  { throw IOX.exception(ex); }
        }
        // XXX Pass in dsd
        DataSource newDataSource = DataSource.connect(dsd.getId(), dsd.getUri(), dsd.getName(), sourcePath);
        dataRegistry.put(dsd.getId(), newDataSource);
        return dsd.getId() ;
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:39,代码来源:LocalServer.java


示例15: getFieldAsString

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
private static String getFieldAsString(JsonObject arg, String field, boolean required) {
    try {
        if ( ! arg.hasKey(field) ) {
            if ( required ) {
                LOG.warn("Bad request: Missing Field: "+field+" Arg: "+JSON.toStringFlat(arg)) ;
                throw new DeltaBadRequestException("Missing field: "+field) ;
            }
            return null;
        }
        return arg.get(field).getAsString().value() ;
    } catch (JsonException ex) {
        LOG.warn("Bad request: Field not a string: "+field+" Arg: "+JSON.toStringFlat(arg)) ;
        throw new DeltaBadRequestException("Bad field '"+field+"' : "+arg.get(field)) ;
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:16,代码来源:S_DRPC.java


示例16: append

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
@Override
public long append(Id dsRef, RDFPatch patch) {
    checkLink();
    
    long t1 = System.currentTimeMillis();
    String str = retry(()->{
                        RDFChangesHTTP remote = createRDFChanges(dsRef);
                        // [NET] Network point
                        // If not re-applyable, we need a copy.
                        patch.apply(remote);
                        return remote.getResponse();
                    }, 
                    ()->patch.repeatable(),
                    ()->"Retry append patch.", ()->"Failed to append patch : "+dsRef);
    long t2 = System.currentTimeMillis();
    long elapsed_ms = (t2-t1);
    if ( str != null ) {
        try {
            JsonObject obj = JSON.parse(str);
            int version = obj.get(DeltaConst.F_VERSION).getAsNumber().value().intValue();
            return version;
        } catch (Exception ex) {
            FmtLog.warn(this.getClass(), "[%s] Error in response body : %s", dsRef, ex.getMessage());
        }
    } else {
        FmtLog.warn(this.getClass(), "[%s] No response body", dsRef);
    }
    // No response body or syntax error.
    return -1;
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:31,代码来源:DeltaLinkHTTP.java


示例17: testVocabularyManagement

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
@Test
public void testVocabularyManagement() throws Exception {
	RESTResource resource;
	String ontoId;

	Map<String,String> parameters = new HashMap<String,String>();
	
	// POST vocabulary
	String ontoUri = "http://purl.oclc.org/NET/ssnx/qu/qu-rec20";
	InputStream uriStream = new ByteArrayInputStream(ontoUri.getBytes("UTF-8"));
	resource = vch.post(new URI(baseUri + "/vocab"), parameters, uriStream);
	ontoId = resource.path;

	Assert.assertTrue("QU ontology not registered", VocabularyUtils.containsVocabulary(ontoUri));
	
	// GET vocabulary by SPARQL query
	parameters.clear();
	parameters.put("query", "?s ?p ?o");
	resource = vch.get(new URI(baseUri + "/vocab"), parameters);
	
	JsonValue ontoIds = JSON.parseAny(resource.content);
	Assert.assertTrue("Vocabulary collection is not an array", ontoIds.isArray());
	Assert.assertTrue("Vocabulary imports were not added", ontoIds.getAsArray().size() > 1);
	Assert.assertTrue("QU ontology not found", ontoIds.getAsArray().contains(new JsonString(ontoId)));
	
	// GET vocabulary by id
	VocabularyHandler vh = new VocabularyHandler(ontoId, Repository.servers);
	resource = vh.get(new URI(baseUri + ontoId), null);
	
	ByteArrayInputStream byteStream = new ByteArrayInputStream(resource.content.getBytes());
	Model m = ModelFactory.createDefaultModel();
	m.read(byteStream, "", "Turtle");
	Assert.assertFalse("QU ontology definition is not valid", m.isEmpty());

	// DELETE vocabulary
	vh.delete(new URI(baseUri + ontoId), null, null);
	Assert.assertFalse("QU ontology not deleted", VocabularyUtils.containsVocabulary(ontoUri));
}
 
开发者ID:thingweb,项目名称:thingweb-repository,代码行数:39,代码来源:ThingWebRepoTest.java


示例18: getRequestStatus

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
public static String getRequestStatus(String uuid) throws InterruptedException, ExecutionException{
	if (computeResourceDirectory.get(uuid) != null){
		if (!finishedResources.contains(uuid)){
    		Future<String> handler = computingResources.get(uuid);
    		if (handler.isDone()){
    			String result = handler.get();
    			computeResourceDirectory.remove(uuid);
    			computeResourceDirectory.put(uuid, result);
    			
    			JsonObject jobj = JSON.parse(result);
    			String outcome = jobj.get("Outcome").getAsString().value();
    			if (outcome.contains("SUCCESS")){
    				successfulResources.add(uuid);
    			} else {
    				failedResources.add(uuid);
    			}
    			
    			finishedResources.add(uuid);
    		} 
		}
		return computeResourceDirectory.get(uuid);
	} else {
		StringBuilder sb = new StringBuilder();
    	sb.append("{");
		sb.append("\"Agent\": \"" + BASE_URI + "\", ");
    	sb.append("\"RequestID\": \"" + uuid + "\", ");
    	sb.append("\"Error\": \"Request ID not Found\"");
    	sb.append("}");
    	return sb.toString();
	}
}
 
开发者ID:EIS-Bonn,项目名称:Luzzu,代码行数:32,代码来源:Main.java


示例19: getAllTasks

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
/**
 * getAllTasks
 * @return all the tasks present for this model
 * @throws OEClientException - an error has occurred contacting the server
 */
public Collection<Task> getAllTasks() throws OEClientException {
	logger.info("getAllTasks entry");

	String url = getModelSysURL();
	logger.info("getAllTasks URL: {}", url);

	Map<String, String> queryParameters = new HashMap<String, String>();
	queryParameters.put("properties", "meta:hasTask/(meta:graphUri|meta:displayName)");
	queryParameters.put("filters", "subject_hasTask(notExists rdf:type sem:ORTTask)");

	Invocation.Builder invocationBuilder = getInvocationBuilder(url, queryParameters);

	Date startDate = new Date();
	logger.info("getAllTasks making call  : {}", startDate.getTime());
	Response response = invocationBuilder.get();
	logger.info("getAllTasks call complete: {}", startDate.getTime());

	logger.info("getAllTasks - status: {}", response.getStatus());

	if (response.getStatus() == 200) {
		String stringResponse = response.readEntity(String.class);
		if (logger.isInfoEnabled()) logger.info("getAllTasks: jsonResponse {}", stringResponse);
		JsonObject jsonResponse = JSON.parse(stringResponse);
		JsonArray jsonArray = jsonResponse.get("@graph").getAsArray();
		Collection<Task> tasks = new ArrayList<Task>();
		Iterator<JsonValue> jsonValueIterator = jsonArray.iterator();
		while (jsonValueIterator.hasNext()) {
			JsonObject modelData = jsonValueIterator.next().getAsObject();
			JsonArray taskArray = modelData.get("meta:hasTask").getAsArray();
			Iterator<JsonValue> jsonTaskIterator = taskArray.iterator();
			while (jsonTaskIterator.hasNext()) {
				tasks.add(new Task(jsonTaskIterator.next().getAsObject()));
			}
		}
		return tasks;
	} else {
		throw new OEClientException(String.format("Error(%d) %s from server", response.getStatus(), response.getStatusInfo().toString()));
	}
	
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:46,代码来源:OEClientReadOnly.java


示例20: getChangesSince

import org.apache.jena.atlas.json.JSON; //导入依赖的package包/类
public Collection<ChangeRecord> getChangesSince(Date date) throws OEClientException {

			StringBuilder stringBuilder = new StringBuilder(baseURL);
			if (!baseURL.endsWith("/")) stringBuilder.append("/");
			stringBuilder.append("api/");
			stringBuilder.append("t/");
			stringBuilder.append(token);
			stringBuilder.append("/tch");
			stringBuilder.append(modelUri);
			stringBuilder.append("/teamwork:Change/rdf:instance");
			
			String url = stringBuilder.toString();
			logger.debug("getChangesSince: '{}'", url);

			Map<String, String> queryParameters = new HashMap<String, String>();
			queryParameters.put("properties", "?triple/(teamwork:subject|teamwork:predicate|teamwork:object),sem:committed");
			queryParameters.put("filters", String.format("subject(sem:committed >= \"%s\"^^xsd:dateTime)", date.toInstant().toString()));
			queryParameters.put("sort", "sem:committed");
			
			Invocation.Builder invocationBuilder = getInvocationBuilder(url, queryParameters);

			Date startDate = new Date();
			logger.info("getChangesSince making call  : {}", startDate.getTime());
			Response response = invocationBuilder.get();
			logger.info("getChangesSince call complete: {}", startDate.getTime());

			logger.info("getChangesSince - status: {}", response.getStatus());

 			if (response.getStatus() == 200) {
 				String stringResponse = response.readEntity(String.class);
 				if (logger.isInfoEnabled()) logger.info("getChangesSince: jsonResponse {}", stringResponse);
 				JsonObject jsonResponse = JSON.parse(stringResponse);
 				JsonArray jsonArray = jsonResponse.get("@graph").getAsArray();
 				Collection<ChangeRecord> changeRecords = new ArrayList<ChangeRecord>();
 				Iterator<JsonValue> jsonValueIterator = jsonArray.iterator();
 				while (jsonValueIterator.hasNext()) {
 					changeRecords.add(new ChangeRecord(this, jsonValueIterator.next().getAsObject()));
 				}
 				return changeRecords;
 			} else {
 				throw new OEClientException(String.format("Error(%d) %s from server", response.getStatus(), response.getStatusInfo().toString()));
 			}
	}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:44,代码来源:OEClientReadOnly.java



注:本文中的org.apache.jena.atlas.json.JSON类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NagiosPassiveCheckSender类代码示例发布时间:2022-05-23
下一篇:
Java Toolable类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap