Java Code Examples for com.google.gson.JsonArray#getAsJsonArray()
The following examples show how to use
com.google.gson.JsonArray#getAsJsonArray() .
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: BusinessMappingServiceImpl.java From Insights with Apache License 2.0 | 6 votes |
@Override public JsonObject getAllHierarchyDetails() { Neo4jDBHandler dbHandler = new Neo4jDBHandler(); String query = "MATCH (n:METADATA:DATATAGGING) return n"; GraphResponse response; JsonArray parentArray = new JsonArray(); try { response = dbHandler.executeCypherQuery(query); JsonArray rows = response.getJson().get("results").getAsJsonArray().get(0).getAsJsonObject().get("data") .getAsJsonArray(); JsonArray asJsonArray = rows.getAsJsonArray(); JsonObject jsonObject = populateHierarchyDetails(asJsonArray); parentArray.add(jsonObject); } catch (GraphDBException e) { log.error(e); return PlatformServiceUtil.buildFailureResponse(ErrorMessage.DB_INSERTION_FAILED); } return PlatformServiceUtil.buildSuccessResponseWithData(parentArray); }
Example 2
Source File: HierarchyDetailsService.java From Insights with Apache License 2.0 | 6 votes |
@RequestMapping(value = "/getAllHierarchyDetails", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public JsonObject getAllHierarchyDetails() { Neo4jDBHandler dbHandler = new Neo4jDBHandler(); String query = "MATCH (n:METADATA:DATATAGGING) return n"; GraphResponse response; JsonArray parentArray = new JsonArray(); try { response = dbHandler.executeCypherQuery(query); JsonArray rows = response.getJson().get("results").getAsJsonArray().get(0).getAsJsonObject().get("data") .getAsJsonArray(); JsonArray asJsonArray = rows.getAsJsonArray(); JsonObject jsonObject = populateHierarchyDetails(asJsonArray); parentArray.add(jsonObject); } catch (GraphDBException e) { log.error(e); return PlatformServiceUtil.buildFailureResponse(ErrorMessage.DB_INSERTION_FAILED); } return PlatformServiceUtil.buildSuccessResponseWithData(parentArray); }
Example 3
Source File: EntityImportViewBuilder.java From cuba with Apache License 2.0 | 6 votes |
/** * Builds a EntityImportView that contains properties from all collection members. * If the first member contains the property A, and the second one contains a property B then a result view will contain * both properties A and B. Views for nested collections (2nd level compositions) are also merged. * @param jsonArray a JsonArray * @param metaClass a metaClass of entities that are in the jsonArray * @return an EntityImportView */ protected EntityImportView buildFromJsonArray(JsonArray jsonArray, MetaClass metaClass) { List<EntityImportView> viewsForArrayElements = new ArrayList<>(); for (JsonElement arrayElement : jsonArray.getAsJsonArray()) { EntityImportView viewForArrayElement = buildFromJsonObject(arrayElement.getAsJsonObject(), metaClass); viewsForArrayElements.add(viewForArrayElement); } EntityImportView resultView = viewsForArrayElements.isEmpty() ? new EntityImportView(metaClass.getJavaClass()) : viewsForArrayElements.get(0); if (viewsForArrayElements.size() > 1) { for (int i = 1; i < viewsForArrayElements.size(); i++) { resultView = mergeViews(resultView, viewsForArrayElements.get(i)); } } return resultView; }
Example 4
Source File: MeshNetworkDeserializer.java From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Returns a list of nodes de-serializing the json array containing the provisioners * * @param context deserializer context * @param json json array object containing the provisioners * @param meshUuid network provisionerUuid * @return List of nodes */ private List<Provisioner> deserializeProvisioners(@NonNull final JsonDeserializationContext context, @NonNull final JsonArray json, @NonNull final String meshUuid) { List<Provisioner> provisioners = new ArrayList<>(); final JsonArray jsonProvisioners = json.getAsJsonArray(); for (int i = 0; i < jsonProvisioners.size(); i++) { final JsonObject jsonProvisioner = jsonProvisioners.get(i).getAsJsonObject(); final String name = jsonProvisioner.get("provisionerName").getAsString(); final String uuid = jsonProvisioner.get("UUID").getAsString().toUpperCase(); final String provisionerUuid = MeshParserUtils.formatUuid(uuid); if (provisionerUuid == null) throw new IllegalArgumentException("Invalid Mesh Provisioning/Configuration " + "Database, invalid provisioner uuid."); final List<AllocatedUnicastRange> unicastRanges = deserializeAllocatedUnicastRange(context, jsonProvisioner); List<AllocatedGroupRange> groupRanges = new ArrayList<>(); if (jsonProvisioner.has("allocatedGroupRange")) { if (!jsonProvisioner.get("allocatedGroupRange").isJsonNull()) { groupRanges = deserializeAllocatedGroupRange(context, jsonProvisioner); } } List<AllocatedSceneRange> sceneRanges = new ArrayList<>(); if (jsonProvisioner.has("allocatedSceneRange")) { if (!jsonProvisioner.get("allocatedSceneRange").isJsonNull()) { sceneRanges = deserializeAllocatedSceneRange(context, jsonProvisioner); } } final Provisioner provisioner = new Provisioner(provisionerUuid, unicastRanges, groupRanges, sceneRanges, meshUuid); provisioner.setProvisionerName(name); provisioners.add(provisioner); } return provisioners; }
Example 5
Source File: BusinessMappingServiceImpl.java From Insights with Apache License 2.0 | 5 votes |
private JsonArray getCurrentRecords(String uuid, Neo4jDBHandler dbHandler) throws GraphDBException { String cypherQuery = " MATCH (n :METADATA:BUSINESSMAPPING) WHERE n.uuid='" + uuid + "' RETURN n"; GraphResponse graphResponse = dbHandler.executeCypherQuery(cypherQuery); JsonArray rows = graphResponse.getJson().get("results").getAsJsonArray().get(0).getAsJsonObject().get("data") .getAsJsonArray(); JsonArray asJsonArray = rows.getAsJsonArray(); return asJsonArray; }
Example 6
Source File: DataProcessorUtil.java From Insights with Apache License 2.0 | 5 votes |
private void getCurrentRecords(List<String> combo, Neo4jDBHandler dbHandler) throws GraphDBException { String cypherQuery = " MATCH (n :METADATA:DATATAGGING) RETURN n"; GraphResponse graphResponse = dbHandler.executeCypherQuery(cypherQuery); JsonArray rows = graphResponse.getJson().get("results").getAsJsonArray().get(0).getAsJsonObject().get("data") .getAsJsonArray(); JsonArray asJsonArray = rows.getAsJsonArray(); buildExistingBuToolCombinationList(combo, asJsonArray); }
Example 7
Source File: InferenceDataProviderController.java From Insights with Apache License 2.0 | 5 votes |
@RequestMapping(value = "/data", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public JsonArray getInferenceData(HttpServletRequest request) { LOG.debug( " inside getInferenceData call /datasource/inference/data ============================================== "); String input = null; List<InsightsInference> inferences = null; try { input = request.getReader().lines().collect(Collectors.joining(System.lineSeparator())); } catch (Exception e) { LOG.error(e); } JsonArray result = new JsonArray(); JsonArray inferenceInputFromPanel = new JsonParser().parse(input).getAsJsonArray(); for(JsonElement jsonElemFromDS: inferenceInputFromPanel.getAsJsonArray()) { String schedule = jsonElemFromDS.getAsJsonObject().get("vectorSchedule").getAsString(); String vectorType = jsonElemFromDS.getAsJsonObject().get("vectorType").getAsString(); LOG.debug(" for vector type " + vectorType); if (vectorType == null || "".equalsIgnoreCase(vectorType)) { inferences = insightsInferenceService.getInferenceDetails(schedule); } else { inferences = insightsInferenceService.getInferenceDetailsVectorWise(schedule, vectorType); } JsonObject responseOutputFromES = PlatformServiceUtil.buildSuccessResponseWithData(inferences); for(JsonElement jsonElemES : responseOutputFromES.get("data").getAsJsonArray()) { if(((JsonObject) jsonElemES).get("heading").getAsString().equals( jsonElemFromDS.getAsJsonObject().get("vectorType").getAsString())) { result.add(jsonElemES.getAsJsonObject()); break; } } } return result; }