hashmapinc / Drillflow

A dockerized WITSML API Server that is agnostic of the backend.
Apache License 2.0
17 stars 13 forks source link

Convert the wellbore graphql builder to static "get everything logic" #298

Closed cherrera2001 closed 5 years ago

cherrera2001 commented 5 years ago

We will have a file that gets all the possible elements for well and wellbore and then will pass that through the merge logic

cherrera2001 commented 5 years ago

For this card you will want to modify: com.hashmapinc.tempus.witsml.valve.dot.GraphQLQueryConverter::createWellboreQuery

Currently it recursively looks through the query json to build a graphQL query. Instead, we want to follow the pattern of Well and Trajectory and request everything and then do the merge.

This will need to be done in a couple of steps:

1) Add the following to the com.hashmapinc.tempus.witsml.valve.dot.GraphQLQueryConstants:

public static final String WELLBORE_QUERY = 
      "query WellboreQuery($wellboreArgument: WellboreArgument) {\n" +
                    "  wellbores(wellboreArgument: $wellboreArgument) {\n" +
                    "    tvd {\n" +
                    "      datum\n" +
                    "      uom\n" +
                    "      value\n" +
                    "    }\n" +
                    "    shape\n" +
                    "    statusWellbore\n" +
                    "    commonData {\n" +
                    "      privateGroupOnly\n" +
                    "      comments\n" +
                    "      itemState\n" +
                    "      sourceName\n" +
                    "      serviceCategory\n" +
                    "    }\n" +
                    "    tvdKickoff {\n" +
                    "      datum\n" +
                    "      uom\n" +
                    "      value\n" +
                    "    }\n" +
                    "    mdKickoff {\n" +
                    "      datum\n" +
                    "      uom\n" +
                    "      value\n" +
                    "    }\n" +
                    "    mdPlanned {\n" +
                    "      datum\n" +
                    "      uom\n" +
                    "      value\n" +
                    "    }\n" +
                    "    uidWell\n" +
                    "    nameWell\n" +
                    "    mdSubSeaPlanned {\n" +
                    "      datum\n" +
                    "      uom\n" +
                    "      value\n" +
                    "    }\n" +
                    "    dayTarget {\n" +
                    "      uom\n" +
                    "      value\n" +
                    "    }\n" +
                    "    number\n" +
                    "    uid\n" +
                    "    tvdPlanned {\n" +
                    "      datum\n" +
                    "      uom\n" +
                    "      value\n" +
                    "    }\n" +
                    "    tvdSubSeaPlanned {\n" +
                    "      datum\n" +
                    "      uom\n" +
                    "      value\n" +
                    "    }\n" +
                    "    dTimKickoff\n" +
                    "    purposeWellbore\n" +
                    "    typeWellbore\n" +
                    "    md {\n" +
                    "      datum\n" +
                    "      uom\n" +
                    "      value\n" +
                    "    }\n" +
                    "    name\n" +
                    "    suffixAPI\n" +
                    "    numGovt\n" +
                    "  }\n" +
                    "}";

The above static variable represents a full graphQL wellbore query.

The second step is to identify the variables that are possible to query for. For wellbore those are as follows:

The conversion logic should happen as it does for well in com.hashmapinc.tempus.witsml.valve.dot.GraphQLQueryConverter::getWellQuery

Essentially you need to test the incoming json object to see if it has any of the values mentioned above (caution: they are case sensitive). If they have a value, that means that there is search criteria that needs to be put into a variable, so you add it to a wellboreQueryFields JSON object (similar pattern to well).

Once that is done you construct the final query that should look like the following:

{
    "query": "query WellboreQuery($wellboreArgument: WellboreArgument)  { wellbores(wellboreArgument: $wellboreArgument){ tvd { datum uom value } shape statusWellbore commonData { privateGroupOnly comments itemState sourceName serviceCategory } tvdKickoff { datum uom value } mdKickoff { datum uom value } mdPlanned { datum uom value } uidWell nameWell mdSubSeaPlanned { datum uom value } dayTarget { uom value } number uid tvdPlanned { datum uom value } tvdSubSeaPlanned { datum uom value } dTimKickoff purposeWellbore typeWellbore md { datum uom value } name suffixAPI numGovt } }",
    "variables": {
        "wellboreArgument": {}
    }
}

The above represents a full open query with no variables.

Then you return this to the DotDelegator to be called as part of the REST API. Nothing else should have to be changed.