@Test public void generateProperGraphQLQueryUUIDUidMapping() throws Exception { String queryXML = TestUtilities.getResourceAsString("trajectoryGraphql/trajectoryGraphqlQuery1411.xml"); ObjTrajectory obj = ((ObjTrajectorys) WitsmlMarshal.deserialize(queryXML, ObjTrajectorys.class)).getTrajectory().get(0); String graphQLQuery = GraphQLQueryConverter.getWellboreAndWellUuidQuery(obj); assertNotNull(graphQLQuery); assertTrue(graphQLQuery.contains("\"arg\": {\n" + " \"uid\": \"uidWellbore\",\n" + " \"uidWell\": \"uidWell\"")); }
public static String getWellboreAndWellUuidQuery(AbstractWitsmlObject wmlObject){ JSONObject payload = new JSONObject(); String jsonString1411 = wmlObject.getJSONString("1.4.1.1"); JSONObject wmlObjJson = new JSONObject(jsonString1411); JSONObject queryFields = new JSONObject(); if (wmlObjJson.has("uidWellbore") && !JsonUtil.isEmpty(wmlObjJson.get("uidWellbore"))) queryFields.put("uid", wmlObjJson.get("uidWellbore")); if (wmlObjJson.has("uidWell") && !JsonUtil.isEmpty(wmlObjJson.get("uidWell"))) queryFields.put("uidWell", wmlObjJson.get("uidWell")); JSONObject variables = new JSONObject(); variables.put("arg", queryFields); payload.put("variables", variables); payload.put("query", GraphQLQueryConstants.WELLBORE_AND_WELL_UUID_QUERY); return payload.toString(2); }
GraphQLQueryConverter { public static String getWellboreAndWellUuidQuery(AbstractWitsmlObject wmlObject){ JSONObject payload = new JSONObject(); String jsonString1411 = wmlObject.getJSONString("1.4.1.1"); JSONObject wmlObjJson = new JSONObject(jsonString1411); JSONObject queryFields = new JSONObject(); if (wmlObjJson.has("uidWellbore") && !JsonUtil.isEmpty(wmlObjJson.get("uidWellbore"))) queryFields.put("uid", wmlObjJson.get("uidWellbore")); if (wmlObjJson.has("uidWell") && !JsonUtil.isEmpty(wmlObjJson.get("uidWell"))) queryFields.put("uidWell", wmlObjJson.get("uidWell")); JSONObject variables = new JSONObject(); variables.put("arg", queryFields); payload.put("variables", variables); payload.put("query", GraphQLQueryConstants.WELLBORE_AND_WELL_UUID_QUERY); return payload.toString(2); } }
GraphQLQueryConverter { public static String getWellboreAndWellUuidQuery(AbstractWitsmlObject wmlObject){ JSONObject payload = new JSONObject(); String jsonString1411 = wmlObject.getJSONString("1.4.1.1"); JSONObject wmlObjJson = new JSONObject(jsonString1411); JSONObject queryFields = new JSONObject(); if (wmlObjJson.has("uidWellbore") && !JsonUtil.isEmpty(wmlObjJson.get("uidWellbore"))) queryFields.put("uid", wmlObjJson.get("uidWellbore")); if (wmlObjJson.has("uidWell") && !JsonUtil.isEmpty(wmlObjJson.get("uidWell"))) queryFields.put("uidWell", wmlObjJson.get("uidWell")); JSONObject variables = new JSONObject(); variables.put("arg", queryFields); payload.put("variables", variables); payload.put("query", GraphQLQueryConstants.WELLBORE_AND_WELL_UUID_QUERY); return payload.toString(2); }  }
GraphQLQueryConverter { public static String getWellboreAndWellUuidQuery(AbstractWitsmlObject wmlObject){ JSONObject payload = new JSONObject(); String jsonString1411 = wmlObject.getJSONString("1.4.1.1"); JSONObject wmlObjJson = new JSONObject(jsonString1411); JSONObject queryFields = new JSONObject(); if (wmlObjJson.has("uidWellbore") && !JsonUtil.isEmpty(wmlObjJson.get("uidWellbore"))) queryFields.put("uid", wmlObjJson.get("uidWellbore")); if (wmlObjJson.has("uidWell") && !JsonUtil.isEmpty(wmlObjJson.get("uidWell"))) queryFields.put("uidWell", wmlObjJson.get("uidWell")); JSONObject variables = new JSONObject(); variables.put("arg", queryFields); payload.put("variables", variables); payload.put("query", GraphQLQueryConstants.WELLBORE_AND_WELL_UUID_QUERY); return payload.toString(2); }  static String getQuery(AbstractWitsmlObject wmlObject); static String getQuery(AbstractWitsmlObject wmlObject, String wellboreUuid); static String getWellboreAndWellUuidQuery(AbstractWitsmlObject wmlObject); static String getWellboreNameQuery(AbstractWitsmlObject wmlObject); static String getWellNameQuery(AbstractWitsmlObject wmlObject); }
GraphQLQueryConverter { public static String getWellboreAndWellUuidQuery(AbstractWitsmlObject wmlObject){ JSONObject payload = new JSONObject(); String jsonString1411 = wmlObject.getJSONString("1.4.1.1"); JSONObject wmlObjJson = new JSONObject(jsonString1411); JSONObject queryFields = new JSONObject(); if (wmlObjJson.has("uidWellbore") && !JsonUtil.isEmpty(wmlObjJson.get("uidWellbore"))) queryFields.put("uid", wmlObjJson.get("uidWellbore")); if (wmlObjJson.has("uidWell") && !JsonUtil.isEmpty(wmlObjJson.get("uidWell"))) queryFields.put("uidWell", wmlObjJson.get("uidWell")); JSONObject variables = new JSONObject(); variables.put("arg", queryFields); payload.put("variables", variables); payload.put("query", GraphQLQueryConstants.WELLBORE_AND_WELL_UUID_QUERY); return payload.toString(2); }  static String getQuery(AbstractWitsmlObject wmlObject); static String getQuery(AbstractWitsmlObject wmlObject, String wellboreUuid); static String getWellboreAndWellUuidQuery(AbstractWitsmlObject wmlObject); static String getWellboreNameQuery(AbstractWitsmlObject wmlObject); static String getWellNameQuery(AbstractWitsmlObject wmlObject);  }