@Test public void translateQueryResponseTestIdOnly() throws Exception{ AbstractWitsmlObject wmlObject = WitsmlMarshal.deserializeFromJSON( "{\"country\":\"\",\"groundElevation\":{\"datum\":null,\"uom\":null,\"value\":null},\"commonData\":{\"privateGroupOnly\":null,\"comments\":\"\",\"acquisitionTimeZone\":[],\"dTimLastChange\":null,\"extensionAny\":null,\"defaultDatum\":{\"value\":\"\",\"uidRef\":\"\"},\"itemState\":null,\"sourceName\":null,\"extensionNameValue\":[],\"serviceCategory\":null,\"dTimCreation\":null},\"county\":\"\",\"timeZone\":\"\",\"waterDepth\":{\"uom\":\"\",\"value\":null},\"numAPI\":\"\",\"operator\":\"\",\"pcInterest\":{\"uom\":\"\",\"value\":null},\"referencePoint\":[{\"elevation\":{\"datum\":\"\",\"uom\":null,\"value\":null},\"uid\":\"\",\"measuredDepth\":{\"datum\":\"\",\"uom\":null,\"value\":null},\"name\":\"\",\"location\":[{\"uid\":\"\",\"easting\":{\"uom\":\"\",\"value\":null},\"wellCRS\":{\"value\":\"\",\"uidRef\":\"\"},\"latitude\":{\"uom\":\"\",\"value\":null},\"localY\":{\"uom\":\"\",\"value\":null},\"description\":\"\",\"localX\":{\"uom\":\"\",\"value\":null},\"extensionNameValue\":[],\"northing\":{\"uom\":\"\",\"value\":null},\"longitude\":{\"uom\":\"\",\"value\":null}}],\"type\":\"\",\"extensionNameValue\":[]}],\"wellLocation\":[{\"uid\":\"\",\"easting\":{\"uom\":\"\",\"value\":null},\"wellCRS\":{\"value\":\"\",\"uidRef\":\"\"},\"description\":\"\",\"extensionNameValue\":[],\"northing\":{\"uom\":\"\",\"value\":null}}],\"uid\":\"randy\",\"wellheadElevation\":{\"datum\":null,\"uom\":null,\"value\":null},\"field\":\"\",\"wellCRS\":[{\"uid\":\"\",\"localCRS\":{\"yAxisAzimuth\":{\"uom\":\"\",\"northDirection\":null,\"value\":null}},\"mapProjectionCRS\":{\"value\":\"\",\"uidRef\":\"\"},\"geodeticCRS\":{\"value\":\"\",\"uidRef\":\"\"},\"name\":\"\",\"description\":\"\",\"extensionNameValue\":[]}],\"nameLegal\":\"\",\"district\":\"\",\"numGovt\":\"\",\"block\":\"\",\"state\":\"\",\"region\":\"\",\"operatorDiv\":\"\",\"wellDatum\":[{\"elevation\":{\"datum\":\"\",\"uom\":null,\"value\":null},\"uid\":\"\",\"datumName\":{\"namingSystem\":\"\",\"code\":\"\",\"value\":\"\"},\"kind\":[],\"name\":\"\",\"extensionNameValue\":[]}]}", com.hashmapinc.tempus.WitsmlObjects.v1411.ObjWell.class); String responseString = "{\"name\":\"BIG Well 0116\",\"nameLegal\":\"Company Legal Name\",\"numLicense\":\"Company License Number\",\"numGovt\":\"Govt-Number\",\"field\":\"Big Field\",\"country\":\"US\",\"state\":\"TX\",\"county\":\"Montgomery\",\"region\":\"Region Name\",\"district\":\"District Name\",\"block\":\"Block Name\",\"timeZone\":\"-06:00\",\"operator\":\"Operating Company\",\"operatorDiv\":\"Division Name\",\"pcInterest\":{\"value\":65,\"uom\":\"%\"},\"numAPI\":\"123-543-987AZ\",\"statusWell\":\"DRILLING\",\"purposeWell\":\"EXPLORATION\",\"wellheadElevation\":{\"value\":500,\"uom\":\"FT\",\"datum\":null},\"wellDatum\":[{\"name\":\"Kelly Bushing\",\"code\":\"KB\",\"kind\":[],\"elevation\":{\"value\":78.5,\"uom\":\"FT\",\"datum\":\"SL\"},\"extensionNameValue\":[],\"uid\":\"KB\"},{\"name\":\"Sea Level\",\"code\":\"SL\",\"datumName\":{\"value\":\"Caspian Sea\",\"namingSystem\":\"EPSG\",\"code\":\"5106\"},\"kind\":[],\"extensionNameValue\":[],\"uid\":\"SL\"}],\"groundElevation\":{\"value\":250,\"uom\":\"FT\",\"datum\":null},\"waterDepth\":{\"value\":520,\"uom\":\"ft\"},\"wellLocation\":[{\"wellCRS\":{\"value\":\"ED50 / UTM Zone 31N\",\"uidRef\":\"proj1\"},\"easting\":{\"value\":425353.84,\"uom\":\"m\"},\"northing\":{\"value\":6623785.69,\"uom\":\"m\"},\"description\":\"Location of well surface point in projected system.\",\"extensionNameValue\":[],\"uid\":\"loc-1\"}],\"referencePoint\":[{\"name\":\"Slot Bay Centre\",\"type\":\"Site Reference Point\",\"location\":[{\"wellCRS\":{\"value\":\"ED50 / UTM Zone 31N\",\"uidRef\":\"proj1\"},\"easting\":{\"value\":425366.47,\"uom\":\"m\"},\"northing\":{\"value\":6623781.95,\"uom\":\"m\"},\"extensionNameValue\":[],\"uid\":\"loc-1\"},{\"wellCRS\":{\"value\":\"WellOneWSP\",\"uidRef\":\"localWell1\"},\"localX\":{\"value\":12.63,\"uom\":\"m\"},\"localY\":{\"value\":-3.74,\"uom\":\"m\"},\"description\":\"Location of the Site Reference Point with respect to the well surface point\",\"extensionNameValue\":[],\"uid\":\"loc-2\"}],\"extensionNameValue\":[],\"uid\":\"SRP1\"},{\"name\":\"Sea Bed\",\"type\":\"Well Reference Point\",\"elevation\":{\"value\":-118.4,\"uom\":\"FT\",\"datum\":\"SL\"},\"measuredDepth\":{\"value\":173.09,\"uom\":\"FT\",\"datum\":\"KB\"},\"location\":[{\"wellCRS\":{\"value\":\"ED50 / UTM Zone 31N\",\"uidRef\":\"proj1\"},\"easting\":{\"value\":425353.84,\"uom\":\"m\"},\"northing\":{\"value\":6623785.69,\"uom\":\"m\"},\"extensionNameValue\":[],\"uid\":\"loc-1\"},{\"wellCRS\":{\"value\":\"ED50\",\"uidRef\":\"geog1\"},\"latitude\":{\"value\":59.743844,\"uom\":\"dega\"},\"longitude\":{\"value\":1.67198083,\"uom\":\"dega\"},\"extensionNameValue\":[],\"uid\":\"loc-2\"}],\"extensionNameValue\":[],\"uid\":\"WRP2\"}],\"wellCRS\":[{\"name\":\"ED50\",\"geodeticCRS\":{\"value\":\"4230\",\"uidRef\":\"4230\"},\"description\":\"ED50 system with EPSG code 4230.\",\"extensionNameValue\":[],\"uid\":\"geog1\"},{\"name\":\"ED50 / UTM Zone 31N\",\"mapProjectionCRS\":{\"value\":\"ED50 / UTM Zone 31N\",\"uidRef\":\"23031\"},\"extensionNameValue\":[],\"uid\":\"proj1\"},{\"name\":\"WellOneWSP\",\"localCRS\":{\"yAxisAzimuth\":{\"value\":0,\"uom\":\"dega\",\"northDirection\":\"GRID_NORTH\"}},\"extensionNameValue\":[],\"uid\":\"localWell1\"}],\"uid\":\"W-0116\"}"; Map<String, String> optionsIn = new HashMap<>(); optionsIn.put("returnElements", "id-only"); AbstractWitsmlObject abstractWitsmlObject = DotTranslator.translateQueryResponse(wmlObject, responseString, optionsIn); assertTrue(abstractWitsmlObject instanceof com.hashmapinc.tempus.WitsmlObjects.v1411.ObjWell); com.hashmapinc.tempus.WitsmlObjects.v1411.ObjWell objWell = (com.hashmapinc.tempus.WitsmlObjects.v1411.ObjWell) abstractWitsmlObject; assertEquals("123-543-987AZ", objWell.getNumAPI()); assertEquals("Govt-Number", objWell.getNumGovt()); assertEquals("BIG Well 0116", objWell.getName()); }
public static AbstractWitsmlObject translateQueryResponse( AbstractWitsmlObject wmlObject, String jsonResponseString, Map<String, String> optionsIn ) throws ValveException, DatatypeConfigurationException { JSONObject queryJson; if ("1.4.1.1".equals(wmlObject.getVersion())) { queryJson = new JSONObject(wmlObject.getJSONString("1.4.1.1")); } else { queryJson = new JSONObject(wmlObject.getJSONString("1.3.1.1")); } JSONObject responseJson = new JSONObject(jsonResponseString); String result = responseJson.toString(); if ( "requested".equals(optionsIn.get("returnElements")) || "id-only".equals(optionsIn.get("returnElements")) ) { if ("id-only".equals(optionsIn.get("returnElements"))) { queryJson = QueryTemplateProvider.getIDOnly(wmlObject.getObjectType()); } result = JsonUtil.merge(queryJson, responseJson).toString(); } result = result.replaceAll("\"dtimTrajStart\":","\"dTimTrajStart\":"); result = result.replaceAll("\"dtimTrajEnd\":","\"dTimTrajEnd\":"); result = result.replaceAll("\"dtimStn\":","\"dTimStn\":"); LOG.finest("Converting DoT JSON response to valid XML string"); try { switch ( wmlObject.getObjectType() ) { case "well": return WitsmlMarshal.deserializeFromJSON( result, ObjWell.class); case "wellbore": return WitsmlMarshal.deserializeFromJSON( result, ObjWellbore.class); case "trajectory": ObjTrajectory traj = WitsmlMarshal.deserializeFromJSON(result, ObjTrajectory.class); if("station-location-only".equals(optionsIn.get("returnElements")) || "data-only".equals(optionsIn.get("returnElements"))) { return buildStationOnlyTrajectory(traj); } else if ("header-only".equals(optionsIn.get("returnElements"))) { traj.setTrajectoryStation(null); return traj; } return traj; case "log": if ("1.3.1.1".equals(wmlObject.getVersion())) { return WitsmlMarshal.deserializeFromJSON(result, com.hashmapinc.tempus.WitsmlObjects.v1311.ObjLog.class); } else { return WitsmlMarshal.deserializeFromJSON(result, ObjLog.class); } default: throw new ValveException("unsupported object type"); } } catch (IOException ioe) { throw new ValveException(ioe.getMessage()); } }
DotTranslator { public static AbstractWitsmlObject translateQueryResponse( AbstractWitsmlObject wmlObject, String jsonResponseString, Map<String, String> optionsIn ) throws ValveException, DatatypeConfigurationException { JSONObject queryJson; if ("1.4.1.1".equals(wmlObject.getVersion())) { queryJson = new JSONObject(wmlObject.getJSONString("1.4.1.1")); } else { queryJson = new JSONObject(wmlObject.getJSONString("1.3.1.1")); } JSONObject responseJson = new JSONObject(jsonResponseString); String result = responseJson.toString(); if ( "requested".equals(optionsIn.get("returnElements")) || "id-only".equals(optionsIn.get("returnElements")) ) { if ("id-only".equals(optionsIn.get("returnElements"))) { queryJson = QueryTemplateProvider.getIDOnly(wmlObject.getObjectType()); } result = JsonUtil.merge(queryJson, responseJson).toString(); } result = result.replaceAll("\"dtimTrajStart\":","\"dTimTrajStart\":"); result = result.replaceAll("\"dtimTrajEnd\":","\"dTimTrajEnd\":"); result = result.replaceAll("\"dtimStn\":","\"dTimStn\":"); LOG.finest("Converting DoT JSON response to valid XML string"); try { switch ( wmlObject.getObjectType() ) { case "well": return WitsmlMarshal.deserializeFromJSON( result, ObjWell.class); case "wellbore": return WitsmlMarshal.deserializeFromJSON( result, ObjWellbore.class); case "trajectory": ObjTrajectory traj = WitsmlMarshal.deserializeFromJSON(result, ObjTrajectory.class); if("station-location-only".equals(optionsIn.get("returnElements")) || "data-only".equals(optionsIn.get("returnElements"))) { return buildStationOnlyTrajectory(traj); } else if ("header-only".equals(optionsIn.get("returnElements"))) { traj.setTrajectoryStation(null); return traj; } return traj; case "log": if ("1.3.1.1".equals(wmlObject.getVersion())) { return WitsmlMarshal.deserializeFromJSON(result, com.hashmapinc.tempus.WitsmlObjects.v1311.ObjLog.class); } else { return WitsmlMarshal.deserializeFromJSON(result, ObjLog.class); } default: throw new ValveException("unsupported object type"); } } catch (IOException ioe) { throw new ValveException(ioe.getMessage()); } } }
DotTranslator { public static AbstractWitsmlObject translateQueryResponse( AbstractWitsmlObject wmlObject, String jsonResponseString, Map<String, String> optionsIn ) throws ValveException, DatatypeConfigurationException { JSONObject queryJson; if ("1.4.1.1".equals(wmlObject.getVersion())) { queryJson = new JSONObject(wmlObject.getJSONString("1.4.1.1")); } else { queryJson = new JSONObject(wmlObject.getJSONString("1.3.1.1")); } JSONObject responseJson = new JSONObject(jsonResponseString); String result = responseJson.toString(); if ( "requested".equals(optionsIn.get("returnElements")) || "id-only".equals(optionsIn.get("returnElements")) ) { if ("id-only".equals(optionsIn.get("returnElements"))) { queryJson = QueryTemplateProvider.getIDOnly(wmlObject.getObjectType()); } result = JsonUtil.merge(queryJson, responseJson).toString(); } result = result.replaceAll("\"dtimTrajStart\":","\"dTimTrajStart\":"); result = result.replaceAll("\"dtimTrajEnd\":","\"dTimTrajEnd\":"); result = result.replaceAll("\"dtimStn\":","\"dTimStn\":"); LOG.finest("Converting DoT JSON response to valid XML string"); try { switch ( wmlObject.getObjectType() ) { case "well": return WitsmlMarshal.deserializeFromJSON( result, ObjWell.class); case "wellbore": return WitsmlMarshal.deserializeFromJSON( result, ObjWellbore.class); case "trajectory": ObjTrajectory traj = WitsmlMarshal.deserializeFromJSON(result, ObjTrajectory.class); if("station-location-only".equals(optionsIn.get("returnElements")) || "data-only".equals(optionsIn.get("returnElements"))) { return buildStationOnlyTrajectory(traj); } else if ("header-only".equals(optionsIn.get("returnElements"))) { traj.setTrajectoryStation(null); return traj; } return traj; case "log": if ("1.3.1.1".equals(wmlObject.getVersion())) { return WitsmlMarshal.deserializeFromJSON(result, com.hashmapinc.tempus.WitsmlObjects.v1311.ObjLog.class); } else { return WitsmlMarshal.deserializeFromJSON(result, ObjLog.class); } default: throw new ValveException("unsupported object type"); } } catch (IOException ioe) { throw new ValveException(ioe.getMessage()); } }  }
DotTranslator { public static AbstractWitsmlObject translateQueryResponse( AbstractWitsmlObject wmlObject, String jsonResponseString, Map<String, String> optionsIn ) throws ValveException, DatatypeConfigurationException { JSONObject queryJson; if ("1.4.1.1".equals(wmlObject.getVersion())) { queryJson = new JSONObject(wmlObject.getJSONString("1.4.1.1")); } else { queryJson = new JSONObject(wmlObject.getJSONString("1.3.1.1")); } JSONObject responseJson = new JSONObject(jsonResponseString); String result = responseJson.toString(); if ( "requested".equals(optionsIn.get("returnElements")) || "id-only".equals(optionsIn.get("returnElements")) ) { if ("id-only".equals(optionsIn.get("returnElements"))) { queryJson = QueryTemplateProvider.getIDOnly(wmlObject.getObjectType()); } result = JsonUtil.merge(queryJson, responseJson).toString(); } result = result.replaceAll("\"dtimTrajStart\":","\"dTimTrajStart\":"); result = result.replaceAll("\"dtimTrajEnd\":","\"dTimTrajEnd\":"); result = result.replaceAll("\"dtimStn\":","\"dTimStn\":"); LOG.finest("Converting DoT JSON response to valid XML string"); try { switch ( wmlObject.getObjectType() ) { case "well": return WitsmlMarshal.deserializeFromJSON( result, ObjWell.class); case "wellbore": return WitsmlMarshal.deserializeFromJSON( result, ObjWellbore.class); case "trajectory": ObjTrajectory traj = WitsmlMarshal.deserializeFromJSON(result, ObjTrajectory.class); if("station-location-only".equals(optionsIn.get("returnElements")) || "data-only".equals(optionsIn.get("returnElements"))) { return buildStationOnlyTrajectory(traj); } else if ("header-only".equals(optionsIn.get("returnElements"))) { traj.setTrajectoryStation(null); return traj; } return traj; case "log": if ("1.3.1.1".equals(wmlObject.getVersion())) { return WitsmlMarshal.deserializeFromJSON(result, com.hashmapinc.tempus.WitsmlObjects.v1311.ObjLog.class); } else { return WitsmlMarshal.deserializeFromJSON(result, ObjLog.class); } default: throw new ValveException("unsupported object type"); } } catch (IOException ioe) { throw new ValveException(ioe.getMessage()); } }  static AbstractWitsmlObject get1311WitsmlObject(AbstractWitsmlObject wmlObj); static AbstractWitsmlObject translateQueryResponse( AbstractWitsmlObject wmlObject,
                                                               String jsonResponseString,
                                                               Map<String, String> optionsIn ); static AbstractWitsmlObject createFsRQueryResponse( String jsonResponseString,
                                                               AbstractWitsmlObject witsmlObject ); static String consolidateObjectsToXML(
            ArrayList<AbstractWitsmlObject> witsmlObjects,
            String version,
            String objectType
    ); }
DotTranslator { public static AbstractWitsmlObject translateQueryResponse( AbstractWitsmlObject wmlObject, String jsonResponseString, Map<String, String> optionsIn ) throws ValveException, DatatypeConfigurationException { JSONObject queryJson; if ("1.4.1.1".equals(wmlObject.getVersion())) { queryJson = new JSONObject(wmlObject.getJSONString("1.4.1.1")); } else { queryJson = new JSONObject(wmlObject.getJSONString("1.3.1.1")); } JSONObject responseJson = new JSONObject(jsonResponseString); String result = responseJson.toString(); if ( "requested".equals(optionsIn.get("returnElements")) || "id-only".equals(optionsIn.get("returnElements")) ) { if ("id-only".equals(optionsIn.get("returnElements"))) { queryJson = QueryTemplateProvider.getIDOnly(wmlObject.getObjectType()); } result = JsonUtil.merge(queryJson, responseJson).toString(); } result = result.replaceAll("\"dtimTrajStart\":","\"dTimTrajStart\":"); result = result.replaceAll("\"dtimTrajEnd\":","\"dTimTrajEnd\":"); result = result.replaceAll("\"dtimStn\":","\"dTimStn\":"); LOG.finest("Converting DoT JSON response to valid XML string"); try { switch ( wmlObject.getObjectType() ) { case "well": return WitsmlMarshal.deserializeFromJSON( result, ObjWell.class); case "wellbore": return WitsmlMarshal.deserializeFromJSON( result, ObjWellbore.class); case "trajectory": ObjTrajectory traj = WitsmlMarshal.deserializeFromJSON(result, ObjTrajectory.class); if("station-location-only".equals(optionsIn.get("returnElements")) || "data-only".equals(optionsIn.get("returnElements"))) { return buildStationOnlyTrajectory(traj); } else if ("header-only".equals(optionsIn.get("returnElements"))) { traj.setTrajectoryStation(null); return traj; } return traj; case "log": if ("1.3.1.1".equals(wmlObject.getVersion())) { return WitsmlMarshal.deserializeFromJSON(result, com.hashmapinc.tempus.WitsmlObjects.v1311.ObjLog.class); } else { return WitsmlMarshal.deserializeFromJSON(result, ObjLog.class); } default: throw new ValveException("unsupported object type"); } } catch (IOException ioe) { throw new ValveException(ioe.getMessage()); } }  static AbstractWitsmlObject get1311WitsmlObject(AbstractWitsmlObject wmlObj); static AbstractWitsmlObject translateQueryResponse( AbstractWitsmlObject wmlObject,
                                                               String jsonResponseString,
                                                               Map<String, String> optionsIn ); static AbstractWitsmlObject createFsRQueryResponse( String jsonResponseString,
                                                               AbstractWitsmlObject witsmlObject ); static String consolidateObjectsToXML(
            ArrayList<AbstractWitsmlObject> witsmlObjects,
            String version,
            String objectType
    );  }