org.apache.jena.atlas.json.JsonObject Java Examples
The following examples show how to use
org.apache.jena.atlas.json.JsonObject.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtendedQGramsBlocking.java From JedAIToolkit with Apache License 2.0 | 6 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj1 = new JsonObject(); obj1.put("class", "java.lang.Integer"); obj1.put("name", getParameterName(0)); obj1.put("defaultValue", "6"); obj1.put("minValue", "2"); obj1.put("maxValue", "6"); obj1.put("stepValue", "1"); obj1.put("description", getParameterDescription(0)); final JsonObject obj2 = new JsonObject(); obj2.put("class", "java.lang.Float"); obj2.put("name", getParameterName(1)); obj2.put("defaultValue", "0.95"); obj2.put("minValue", "0.8"); obj2.put("maxValue", "0.95"); obj2.put("stepValue", "0.05"); obj2.put("description", getParameterDescription(1)); final JsonArray array = new JsonArray(); array.add(obj1); array.add(obj2); return array; }
Example #2
Source File: DataSourceDescription.java From rdf-delta with Apache License 2.0 | 6 votes |
public static DataSourceDescription fromJson(JsonObject obj) { String idStr = JSONX.getStrOrNull(obj, F_ID); if ( idStr == null ) throw new DeltaException("Missing \"id:\" in DataSourceDescription JSON"); String name = JSONX.getStrOrNull(obj, F_NAME); if ( name == null ) { @SuppressWarnings("deprecation") String n = JSONX.getStrOrNull(obj, F_BASE); // Compatibility. Log.warn(DataSourceDescription.class, "Deprecated: Use of field name \"base\" - change to \"name\""); name = n; } if ( name == null ) throw new DeltaException("Missing \"name:\" in DataSourceDescription JSON"); String uri = JSONX.getStrOrNull(obj, F_URI); return new DataSourceDescription(Id.fromString(idStr), name, uri); }
Example #3
Source File: ComparisonsBasedBlockPurging.java From JedAIToolkit with Apache License 2.0 | 6 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj = new JsonObject(); obj.put("class", "java.lang.Float"); obj.put("name", getParameterName(0)); obj.put("defaultValue", "1.0"); obj.put("minValue", "1.0"); obj.put("maxValue", "2.0"); obj.put("stepValue", "0.01"); obj.put("description", getParameterDescription(0)); final JsonArray array = new JsonArray(); array.add(obj); return array; }
Example #4
Source File: BlockFiltering.java From JedAIToolkit with Apache License 2.0 | 6 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj = new JsonObject(); obj.put("class", "java.lang.Float"); obj.put("name", getParameterName(0)); obj.put("defaultValue", "0.8"); obj.put("minValue", "0.025"); obj.put("maxValue", "1.0"); obj.put("stepValue", "0.025"); obj.put("description", getParameterDescription(0)); final JsonArray array = new JsonArray(); array.add(obj); return array; }
Example #5
Source File: SizeBasedBlockPurging.java From JedAIToolkit with Apache License 2.0 | 6 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj = new JsonObject(); obj.put("class", "java.lang.Float"); obj.put("name", getParameterName(0)); obj.put("defaultValue", "0.005"); obj.put("minValue", "0.001"); obj.put("maxValue", "0.200"); obj.put("stepValue", "0.005"); obj.put("description", getParameterDescription(0)); final JsonArray array = new JsonArray(); array.add(obj); return array; }
Example #6
Source File: CanopyClustering.java From JedAIToolkit with Apache License 2.0 | 6 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj1 = new JsonObject(); obj1.put("class", "java.lang.float"); obj1.put("name", getParameterName(0)); obj1.put("defaultValue", "0.5"); obj1.put("minValue", "0.1"); obj1.put("maxValue", "0.9"); obj1.put("stepValue", "0.05"); obj1.put("description", getParameterDescription(0)); final JsonObject obj2 = new JsonObject(); obj2.put("class", "java.lang.float"); obj2.put("name", getParameterName(1)); obj2.put("defaultValue", "0.75"); obj2.put("minValue", "0.2"); obj2.put("maxValue", "0.95"); obj2.put("stepValue", "0.05"); obj2.put("description", getParameterDescription(1)); final JsonArray array = new JsonArray(); array.add(obj1); array.add(obj2); return array; }
Example #7
Source File: PatchStoreZk.java From rdf-delta with Apache License 2.0 | 6 votes |
private List<DataSourceDescription> listDataSourcesZkPath_alt(String logsPath) { List<String> logNames = Zk.zkSubNodes(client, logsPath); Stream<DataSourceDescription> descriptions = logNames.stream() .map(name->{ FmtLog.info(LOGZK, "[%d] listDataSources: %s", instance, name); String logDsd = ZKPaths.makePath(ZkConst.pLogs, name, ZkConst.nDsd); JsonObject obj = zkFetchJson(client, logDsd); if ( obj == null ) { FmtLog.info(LOGZK, "[%d] listDataSourcesZkPath: %s: no DSD", instance, name); return null; } DataSourceDescription dsd = DataSourceDescription.fromJson(obj); return dsd; }) .filter(Objects::nonNull) ; return ListUtils.toList(descriptions); }
Example #8
Source File: S_DRPC.java From rdf-delta with Apache License 2.0 | 6 votes |
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)) ; } }
Example #9
Source File: EntityHDTRDFReader.java From JedAIToolkit with Apache License 2.0 | 6 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj1 = new JsonObject(); obj1.put("class", "java.lang.String"); obj1.put("name", getParameterName(0)); obj1.put("defaultValue", "-"); obj1.put("minValue", "-"); obj1.put("maxValue", "-"); obj1.put("stepValue", "-"); obj1.put("description", getParameterDescription(0)); final JsonObject obj2 = new JsonObject(); obj2.put("class", "java.util.Set<String>"); obj2.put("name", getParameterName(1)); obj2.put("defaultValue", "-"); obj2.put("minValue", "-"); obj2.put("maxValue", "-"); obj2.put("stepValue", "-"); obj2.put("description", getParameterDescription(1)); final JsonArray array = new JsonArray(); array.add(obj1); array.add(obj2); return array; }
Example #10
Source File: EntityRDFReader.java From JedAIToolkit with Apache License 2.0 | 6 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj1 = new JsonObject(); obj1.put("class", "java.lang.String"); obj1.put("name", getParameterName(0)); obj1.put("defaultValue", "-"); obj1.put("minValue", "-"); obj1.put("maxValue", "-"); obj1.put("stepValue", "-"); obj1.put("description", getParameterDescription(0)); final JsonObject obj2 = new JsonObject(); obj2.put("class", "java.util.Set<String>"); obj2.put("name", getParameterName(1)); obj2.put("defaultValue", "-"); obj2.put("minValue", "-"); obj2.put("maxValue", "-"); obj2.put("stepValue", "-"); obj2.put("description", getParameterDescription(1)); final JsonArray array = new JsonArray(); array.add(obj1); array.add(obj2); return array; }
Example #11
Source File: EntityXMLreader.java From JedAIToolkit with Apache License 2.0 | 6 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj1 = new JsonObject(); obj1.put("class", "java.lang.String"); obj1.put("name", getParameterName(0)); obj1.put("defaultValue", "-"); obj1.put("minValue", "-"); obj1.put("maxValue", "-"); obj1.put("stepValue", "-"); obj1.put("description", getParameterDescription(0)); final JsonObject obj2 = new JsonObject(); obj2.put("class", "java.util.Set<String>"); obj2.put("name", getParameterName(1)); obj2.put("defaultValue", "-"); obj2.put("minValue", "-"); obj2.put("maxValue", "-"); obj2.put("stepValue", "-"); obj2.put("description", getParameterDescription(1)); final JsonArray array = new JsonArray(); array.add(obj1); array.add(obj2); return array; }
Example #12
Source File: AbstractTokenBasedJoin.java From JedAIToolkit with Apache License 2.0 | 6 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj = new JsonObject(); obj.put("class", "java.lang.Float"); obj.put("name", getParameterName(0)); obj.put("defaultValue", "0.8"); obj.put("minValue", "0.025"); obj.put("maxValue", "1.0"); obj.put("stepValue", "0.025"); obj.put("description", getParameterDescription(0)); final JsonArray array = new JsonArray(); array.add(obj); return array; }
Example #13
Source File: AbstractCharacterBasedJoin.java From JedAIToolkit with Apache License 2.0 | 6 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj = new JsonObject(); obj.put("class", "java.lang.Integer"); obj.put("name", getParameterName(0)); obj.put("defaultValue", "3"); obj.put("minValue", "1"); obj.put("maxValue", "10"); obj.put("stepValue", "1"); obj.put("description", getParameterDescription(0)); final JsonArray array = new JsonArray(); array.add(obj); return array; }
Example #14
Source File: DataState.java From rdf-delta with Apache License 2.0 | 6 votes |
private static JsonObject stateToJson(Id datasource, String name, String uri, LocalStorageType storage, Version version, Id patchId) { String x = ""; if ( patchId != null ) x = patchId.asPlainString(); String patchStr = x; return JSONX.buildObject(builder->{ builder .pair(F_VERSION, version.asJson()) .pair(F_ID, patchStr) .pair(F_NAME, name) .pair(F_DATASOURCE, datasource.asPlainString()); if ( storage != null ) builder.pair(F_STORAGE, storage.typeName()); if ( uri != null ) builder.pair(F_URI, uri); }); }
Example #15
Source File: DeltaLinkHTTP.java From rdf-delta with Apache License 2.0 | 6 votes |
@Override public Id newDataSource(String name, String uri) { Objects.requireNonNull(name); if ( ! DeltaOps.isValidName(name) ) throw new IllegalArgumentException("Invalid data source name: '"+name+"'"); JsonObject arg = JSONX.buildObject((b) -> { b.key(DeltaConst.F_NAME).value(name); if ( uri != null ) b.key(DeltaConst.F_URI).value(uri); }); JsonObject obj = rpc(DeltaConst.OP_CREATE_DS, arg); // Exists? Id dsRef = idFromJson(obj); listeners.forEach(listener->listener.newDataSource(dsRef, name)); return dsRef; }
Example #16
Source File: GlobalProgressiveSortedNeighborhood.java From JedAIToolkit with Apache License 2.0 | 6 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj1 = new JsonObject(); obj1.put("class", "java.lang.Integer"); obj1.put("name", getParameterName(0)); obj1.put("defaultValue", "10000"); obj1.put("minValue", "1000"); obj1.put("maxValue", "1000000"); obj1.put("stepValue", "1000"); obj1.put("description", getParameterDescription(0)); final JsonObject obj2 = new JsonObject(); obj2.put("class", "java.lang.Integer"); obj2.put("name", getParameterName(1)); obj2.put("defaultValue", "5"); obj1.put("minValue", "1"); obj1.put("maxValue", "10"); obj1.put("stepValue", "1"); obj2.put("description", getParameterDescription(1)); final JsonArray array = new JsonArray(); array.add(obj1); array.add(obj2); return array; }
Example #17
Source File: PatchStoreZk.java From rdf-delta with Apache License 2.0 | 6 votes |
private List<DataSourceDescription> listDataSourcesZkPath(String logsPath) { List<DataSourceDescription> descriptions = new ArrayList<>(); List<String> logNames = Zk.zkSubNodes(client, logsPath); if ( logNames == null ) return Collections.emptyList(); for ( String name: logNames) { String logDsd = zkPath(ZkConst.pLogs, name, ZkConst.nDsd); JsonObject obj = zkFetchJson(client, logDsd); if ( obj == null ) { FmtLog.info(LOGZK, "[%d] listDataSourcesZkPath: %s: no DSD", instance, name); continue; } DataSourceDescription dsd = DataSourceDescription.fromJson(obj); descriptions.add(dsd); }; return descriptions; }
Example #18
Source File: AbstractHashBasedPrioritization.java From JedAIToolkit with Apache License 2.0 | 6 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj1 = new JsonObject(); obj1.put("class", "java.lang.Integer"); obj1.put("name", getParameterName(0)); obj1.put("defaultValue", "10000"); obj1.put("minValue", "1000"); obj1.put("maxValue", "1000000"); obj1.put("stepValue", "1000"); obj1.put("description", getParameterDescription(0)); final JsonObject obj2 = new JsonObject(); obj2.put("class", "org.scify.jedai.utilities.enumerations.WeightingScheme"); obj2.put("name", getParameterName(1)); obj2.put("defaultValue", "org.scify.jedai.utilities.enumerations.WeightingScheme.JS"); obj2.put("minValue", "-"); obj2.put("maxValue", "-"); obj2.put("stepValue", "-"); obj2.put("description", getParameterDescription(1)); final JsonArray array = new JsonArray(); array.add(obj1); array.add(obj2); return array; }
Example #19
Source File: LSHSuperBitBlocking.java From JedAIToolkit with Apache License 2.0 | 6 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj1 = new JsonObject(); obj1.put("class", "java.lang.Integer"); obj1.put("name", getParameterName(0)); obj1.put("defaultValue", "5"); obj1.put("minValue", "2"); obj1.put("maxValue", "10"); obj1.put("stepValue", "1"); obj1.put("description", getParameterDescription(0)); final JsonObject obj2 = new JsonObject(); obj2.put("class", "java.lang.Integer"); obj2.put("name", getParameterName(1)); obj2.put("defaultValue", "30"); obj2.put("minValue", "10"); obj2.put("maxValue", "100"); obj2.put("stepValue", "10"); obj2.put("description", getParameterDescription(1)); final JsonArray array = new JsonArray(); array.add(obj1); array.add(obj2); return array; }
Example #20
Source File: ExtendedSuffixArraysBlocking.java From JedAIToolkit with Apache License 2.0 | 6 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj1 = new JsonObject(); obj1.put("class", "java.lang.Integer"); obj1.put("name", getParameterName(0)); obj1.put("defaultValue", "6"); obj1.put("minValue", "2"); obj1.put("maxValue", "6"); obj1.put("stepValue", "1"); obj1.put("description", getParameterDescription(0)); final JsonObject obj2 = new JsonObject(); obj2.put("class", "java.lang.Integer"); obj2.put("name", getParameterName(1)); obj2.put("defaultValue", "39"); obj2.put("minValue", "2"); obj2.put("maxValue", "100"); obj2.put("stepValue", "1"); obj2.put("description", getParameterDescription(1)); final JsonArray array = new JsonArray(); array.add(obj1); array.add(obj2); return array; }
Example #21
Source File: SuffixArraysBlocking.java From JedAIToolkit with Apache License 2.0 | 6 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj1 = new JsonObject(); obj1.put("class", "java.lang.Integer"); obj1.put("name", getParameterName(0)); obj1.put("defaultValue", "6"); obj1.put("minValue", "2"); obj1.put("maxValue", "6"); obj1.put("stepValue", "1"); obj1.put("description", getParameterDescription(0)); final JsonObject obj2 = new JsonObject(); obj2.put("class", "java.lang.Integer"); obj2.put("name", getParameterName(1)); obj2.put("defaultValue", "53"); obj2.put("minValue", "2"); obj2.put("maxValue", "100"); obj2.put("stepValue", "1"); obj2.put("description", getParameterDescription(1)); final JsonArray array = new JsonArray(); array.add(obj1); array.add(obj2); return array; }
Example #22
Source File: PatchLogIndexZk.java From rdf-delta with Apache License 2.0 | 5 votes |
private void stateOrInit() { synchronized(lock) { JsonObject obj = getWatchedState(); if ( obj != null ) jsonSetState(obj); else initState(); if ( version == DeltaConst.VERSION_UNSET ) save(DeltaConst.VERSION_INIT, current, previous); } }
Example #23
Source File: TestDeltaServerConfig.java From rdf-delta with Apache License 2.0 | 5 votes |
private void roundTrip(DeltaServerConfig c) { JsonObject obj = c.asJSON(); DeltaServerConfig c2 = DeltaServerConfig.create(obj); if ( ! c.equals(c2) ) { System.out.println("c : "+c.zkMode); System.out.println("c2 : "+c2.zkMode); JSON.write(obj); JSON.write(c2.asJSON()); } assertEquals(c, c2); }
Example #24
Source File: DeltaLinkHTTP.java From rdf-delta with Apache License 2.0 | 5 votes |
@Override public PatchLogInfo getPatchLogInfo(Id dsRef) { JsonObject arg = JSONX.buildObject((b) -> { b.key(DeltaConst.F_DATASOURCE).value(dsRef.asPlainString()); }); return getPatchLogInfo(arg); }
Example #25
Source File: JsonLogEntry.java From rdf-delta with Apache License 2.0 | 5 votes |
/** Encode a log entry as a JSON object */ public static JsonObject logEntryToJson(long version, Id patch, Id prev) { return JSONX.buildObject(b->{ b.pair(fVersion, version); if ( patch != null ) b.pair(fId, patch.asPlainString()); if ( prev != null ) b.pair(fPrevious, prev.asPlainString()); }); }
Example #26
Source File: PatchLogIndexZk.java From rdf-delta with Apache License 2.0 | 5 votes |
private void save(long version, Id patch, Id prev) { newState(version, patch, prev); JsonObject x = stateToJson(version, patch, prev); byte[] bytes = JSONX.asBytes(x); if ( patch != null ) { // [META] // Record the basic header - (version, id, prev) - for validation. if ( keepHeaderInfo ) Zk.zkCreateSet(client, headerPath(patch), bytes); // Write version->id mapping. Zk.zkCreateSet(client, versionPath(version), patch.asBytes()); } Zk.zkSet(client, statePath, bytes); }
Example #27
Source File: GtDblpRdfAcmCsvReader.java From JedAIToolkit with Apache License 2.0 | 5 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj1 = new JsonObject(); obj1.put("class", "java.lang.String"); obj1.put("name", getParameterName(0)); obj1.put("defaultValue", "-"); obj1.put("minValue", "-"); obj1.put("maxValue", "-"); obj1.put("stepValue", "-"); obj1.put("description", getParameterDescription(0)); final JsonObject obj2 = new JsonObject(); obj2.put("class", "java.lang.Boolean"); obj2.put("name", getParameterName(1)); obj2.put("defaultValue", "false"); obj2.put("minValue", "-"); obj2.put("maxValue", "-"); obj2.put("stepValue", "-"); obj2.put("description", getParameterDescription(1)); final JsonObject obj3 = new JsonObject(); obj3.put("class", "java.lang.Character"); obj3.put("name", getParameterName(2)); obj3.put("defaultValue", ","); obj3.put("minValue", "-"); obj3.put("maxValue", "-"); obj3.put("stepValue", "-"); obj3.put("description", getParameterDescription(2)); final JsonArray array = new JsonArray(); array.add(obj1); array.add(obj2); array.add(obj3); return array; }
Example #28
Source File: DeltaLinkHTTP.java From rdf-delta with Apache License 2.0 | 5 votes |
@Override public Id copyDataSource(Id dsRef, String oldName, String newName) { JsonObject arg = JSONX.buildObject((b) -> { b.key(DeltaConst.F_DATASOURCE).value(dsRef.asPlainString()); b.key(DeltaConst.F_SRC_NAME).value(oldName); b.key(DeltaConst.F_DST_NAME).value(newName); }); JsonObject obj = rpc(DeltaConst.OP_COPY_DS, arg); Id dsRef2 = idFromJson(obj); listeners.forEach(listener->listener.copyDataSource(dsRef, oldName, newName)); return dsRef2; }
Example #29
Source File: DeltaLinkHTTP.java From rdf-delta with Apache License 2.0 | 5 votes |
@Override public List<DataSourceDescription> listDescriptions() { JsonObject obj = rpc(DeltaConst.OP_LIST_DSD, emptyObject); JsonArray array = obj.get(DeltaConst.F_ARRAY).getAsArray(); List<DataSourceDescription> x = array.stream() .map(jv->getDataSourceDescription(jv.getAsObject())) .collect(Collectors.toList()) ; return x ; }
Example #30
Source File: QGramsBlocking.java From JedAIToolkit with Apache License 2.0 | 5 votes |
@Override public JsonArray getParameterConfiguration() { final JsonObject obj1 = new JsonObject(); obj1.put("class", "java.lang.Integer"); obj1.put("name", getParameterName(0)); obj1.put("defaultValue", "6"); obj1.put("minValue", "2"); obj1.put("maxValue", "6"); obj1.put("stepValue", "1"); obj1.put("description", getParameterDescription(0)); final JsonArray array = new JsonArray(); array.add(obj1); return array; }