@Test public void translateQueryResponseTestWithReturnElementsAll() 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 = "{\"country\":\"US\",\"dTimLicense\":\"2001-05-15T13:20:00+00:00\",\"numLicense\":\"Company License Number\",\"county\":\"Montgomery\",\"waterDepth\":{\"uom\":\"ft\",\"value\":520},\"operator\":\"Operating Company\",\"pcInterest\":{\"uom\":\"%\",\"value\":65},\"dTimPa\":\"2001-07-15T15:30:00+00:00\",\"uid\":\"randy\",\"nameLegal\":\"Company Legal Name\",\"block\":\"Block Name\",\"state\":\"TX\",\"operatorDiv\":\"Division Name\",\"groundElevation\":{\"uom\":\"FT\",\"value\":250},\"commonData\":{\"comments\":\"These are the comments associated with the Well data object.\",\"dTimLastChange\":\"2019-01-30T14:09:27.268843+00:00\",\"acquisitionTimeZone\":[],\"defaultDatum\":{\"value\":\"Kelly Bushing\",\"uidRef\":\"KB\"},\"itemState\":\"PLAN\",\"extensionNameValue\":[],\"dTimCreation\":\"2019-01-24T16:59:38.88059+00:00\"},\"timeZone\":\"-06:00\",\"statusWell\":\"DRILLING\",\"purposeWell\":\"EXPLORATION\",\"numAPI\":\"123-543-987AZ\",\"referencePoint\":[{\"uid\":\"SRP1\",\"name\":\"Slot Bay Centre\",\"location\":[{\"uid\":\"loc-1\",\"easting\":{\"uom\":\"m\",\"value\":425366.47},\"wellCRS\":{\"value\":\"ED50 \\/ UTM Zone 31N\",\"uidRef\":\"proj1\"},\"extensionNameValue\":[],\"northing\":{\"uom\":\"m\",\"value\":6623781.95}},{\"uid\":\"loc-2\",\"wellCRS\":{\"value\":\"WellOneWSP\",\"uidRef\":\"localWell1\"},\"localY\":{\"uom\":\"m\",\"value\":-3.74},\"description\":\"Location of the Site Reference Point with respect to the well surface point\",\"localX\":{\"uom\":\"m\",\"value\":12.63},\"extensionNameValue\":[]}],\"type\":\"Site Reference Point\",\"extensionNameValue\":[]},{\"elevation\":{\"datum\":\"SL\",\"uom\":\"FT\",\"value\":-118.4},\"uid\":\"WRP2\",\"measuredDepth\":{\"datum\":\"KB\",\"uom\":\"FT\",\"value\":173.09},\"name\":\"Sea Bed\",\"location\":[{\"uid\":\"loc-1\",\"easting\":{\"uom\":\"m\",\"value\":425353.84},\"wellCRS\":{\"value\":\"ED50 \\/ UTM Zone 31N\",\"uidRef\":\"proj1\"},\"extensionNameValue\":[],\"northing\":{\"uom\":\"m\",\"value\":6623785.69}},{\"uid\":\"loc-2\",\"wellCRS\":{\"value\":\"ED50\",\"uidRef\":\"geog1\"},\"latitude\":{\"uom\":\"dega\",\"value\":59.743844},\"extensionNameValue\":[],\"longitude\":{\"uom\":\"dega\",\"value\":1.67198083}}],\"type\":\"Well Reference Point\",\"extensionNameValue\":[]}],\"wellLocation\":[{\"uid\":\"loc-1\",\"easting\":{\"uom\":\"m\",\"value\":425353.84},\"wellCRS\":{\"value\":\"ED50 \\/ UTM Zone 31N\",\"uidRef\":\"proj1\"},\"description\":\"Location of well surface point in projected system.\",\"extensionNameValue\":[],\"northing\":{\"uom\":\"m\",\"value\":6623785.69}}],\"wellheadElevation\":{\"uom\":\"FT\",\"value\":500},\"field\":\"Big Field\",\"dTimSpud\":\"2001-05-31T08:15:00+00:00\",\"wellCRS\":[{\"uid\":\"geog1\",\"geodeticCRS\":{\"value\":\"4230\",\"uidRef\":\"4230\"},\"name\":\"ED50\",\"description\":\"ED50 system with EPSG code 4230.\",\"extensionNameValue\":[]},{\"uid\":\"proj1\",\"mapProjectionCRS\":{\"value\":\"ED50 \\/ UTM Zone 31N\",\"uidRef\":\"23031\"},\"name\":\"ED50 \\/ UTM Zone 31N\",\"extensionNameValue\":[]},{\"uid\":\"localWell1\",\"localCRS\":{\"usesWellAsOrigin\":true,\"xRotationCounterClockwise\":false,\"yAxisAzimuth\":{\"uom\":\"dega\",\"northDirection\":\"GRID_NORTH\",\"value\":0}},\"name\":\"WellOneWSP\",\"extensionNameValue\":[]}],\"district\":\"District Name\",\"name\":\"6507\\/7-A-42\",\"numGovt\":\"Govt-Number\",\"region\":\"Region Name\",\"wellDatum\":[{\"elevation\":{\"datum\":\"SL\",\"uom\":\"FT\",\"value\":78.5},\"uid\":\"KB\",\"code\":\"KB\",\"kind\":[],\"name\":\"Kelly Bushing\",\"extensionNameValue\":[]},{\"uid\":\"SL\",\"code\":\"SL\",\"datumName\":{\"namingSystem\":\"EPSG\",\"code\":\"5106\",\"value\":\"Caspian Sea\"},\"kind\":[],\"name\":\"Sea Level\",\"extensionNameValue\":[]}]}"; Map<String, String> optionsIn = new HashMap<>(); optionsIn.put("returnElements", "all"); 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("Company License Number", objWell.getNumLicense()); }
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
    );  }