Commit cd3905be authored by devesh bajpai's avatar devesh bajpai
Browse files

Merge branch 'get-wks-kind-from-mapping' into 'master'

Get wks kind from mapping

See merge request !52
parents 6152ad29 c8978436
Pipeline #38726 passed with stages
in 31 minutes and 20 seconds
package org.opengroup.osdu.wks.model;
import java.util.Arrays;
import java.util.List;
public class AutomationConstants {
public static final String CONTENT_TYPE = "Content-Type";
public static final String DATA_PARTITION_ID = "data-partition-id";
public static final String AUTHORIZATION = "Authorization";
public static final String ON_BEHALF_OF = "on-behalf-of";
public static final String CORRELATION_ID = "correlation-id";
public static final String APPLICATION_JSON = "application/json";
public static final String WKS_KIND = "wks";
public static final String APP_KEY = "AppKey";
public static final String DATA_PARTITION_ID_VALUE = System.getProperty("DATA_PARTITION_ID", System.getenv("DATA_PARTITION_ID")); // "opendes";
public static final String POST_SCHEMA_ENDPOINT = "/schema";
public static final String POST_ENDPOINT = "/records";
public static final String GET_ENDPOINT = "/records/";
public static final String DELETE_ENDPOINT = "/records/";
public static final long RECORD_SEARCH_MAX_TIMEOUT_SEC = 60;
public static final String RECORD_CREATED = "201";
public static final String REQUEST_SUCCESS = "200";
public static final String REQUEST_SUCCESS_NO_CONTENT = "204";
public static final String RECORD_NOT_FOUND = "404";
public static final String COLON_SEPARATOR = ":";
public static final String DASH = "-";
public static final String POINT = ".";
public static final String OS_TARGET_SCHEMA_KIND_TENANT = getEnvironmentVariableOrDefaultValue("OS_TARGET_SCHEMA_KIND_TENANT", "opendes:wks:wellbore:1.3.1");
public static final String OS_TARGET_SCHEMA_KIND = getEnvironmentVariableOrDefaultValue("OS_TARGET_SCHEMA_KIND", "slb:wks:wellbore:1.3.1");
public static final List<String> OS_TARGET_SCHEMA_KIND_IHS = Arrays.asList("slb:wks:log:2.3.1", "abc:wks:log:3.2.1");
public static final List<String> OS_TARGET_SCHEMA_KIND_OGA = Arrays.asList("slb:wks:well:4.3.1", "slb:wks:well:5.1.0", "abc:wks:well:1.5.1");
public static final List<String> OS_TARGET_SCHEMA_KIND_IHS_WELL = Arrays.asList("abc:wks:log:3.2.1", "slb:wks:log:2.3.1", "slb:wks:well:2.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_IHS_WELLBORE = Arrays.asList("abc:wks:log:3.2.1", "npl:wks:log:2.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_PETREL_WELL = Arrays.asList("slb:wks:well:1.0.0", "abc:wks:well:1.5.1", "slb:wks:wellbore:1.0.0", "slb:wks:well:4.3.1");
public static final List<String> OS_TARGET_SCHEMA_KIND_AT_LOG = Arrays.asList("slb:wks:log:1.0.0", "abc:wks:log:1.0.7", "slb:wks:well:1.0.0", "slb:wks:log:4.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_AT_WELL = Arrays.asList("slb:wks:well:1.0.0", "slb:wks:wellbore:1.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_OGA_LOG = Arrays.asList("slb:wks:log:1.0.0", "slb:wks:well:1.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_PETREL_WELLSET = Arrays.asList("slb:wks:wellset:1.0.0", "slb:wks:wellbore:1.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_AT_LOGSET = Arrays.asList("slb:wks:logset:1.0.0", "slb:wks:well:1.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_PETREL_WELLSET1 = Arrays.asList("slb:wks:well:1.0.0", "abc:wks:well:1.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_AT_LOGSET1 = Arrays.asList("slb:wks:log:1.0.0", "abc:wks:log:1.0.0");
public static final long INDEXING_TIMEOUT = 60;
public static final String TENANT_NAME_PLACEHOLDER = "<tenant_name>";
public static final String ACL_VIEWERS_GROUP = "<acl_viewers>";
public static final String ACL_OWNERS_GROUP = "<acl_owners>";
public static final String CLOUD_DOMAIN = "<cloud_domain>";
public static final String LEGAL_TAGS = "<legal_tags>";
public static final String RECORD_ID = "<record_id.>";
public static final String TENANT_NAME_PLACEHOLDER_VALUE = System.getProperty("TENANT_NAME",
System.getenv("TENANT_NAME"));
public static final String ACL_VIEWERS_GROUP_VALUE = System.getProperty("ACL_VIEWERS",
System.getenv("ACL_VIEWERS"));
public static final String ACL_OWNERS_GROUP_VALUE = System.getProperty("ACL_OWNERS", System.getenv("ACL_OWNERS"));
public static final String CLOUD_DOMAIN_VALUE = System.getProperty("DOMAIN", System.getenv("DOMAIN"));
public static final String LEGAL_TAGS_VALUE = System.getProperty("LEGAL_TAG", System.getenv("LEGAL_TAG"));
public static final String SCHEMA_URL = System.getProperty("HOST", System.getenv("HOST")) + "/api/schema-service/v1";
private static String getEnvironmentVariableOrDefaultValue(String key, String defaultValue) {
String environmentVariable = System.getProperty(key, System.getenv(key));
if (environmentVariable == null) {
environmentVariable = defaultValue;
}
return environmentVariable;
}
}
package org.opengroup.osdu.wks.model;
import java.util.Arrays;
import java.util.List;
public class AutomationConstants {
public static final String CONTENT_TYPE = "Content-Type";
public static final String DATA_PARTITION_ID = "data-partition-id";
public static final String AUTHORIZATION = "Authorization";
public static final String ON_BEHALF_OF = "on-behalf-of";
public static final String CORRELATION_ID = "correlation-id";
public static final String APPLICATION_JSON = "application/json";
public static final String WKS_KIND = "wks";
public static final String APP_KEY = "AppKey";
public static final String DATA_PARTITION_ID_VALUE = System.getProperty("DATA_PARTITION_ID", System.getenv("DATA_PARTITION_ID")); // "opendes";
public static final String POST_SCHEMA_ENDPOINT = "/schema";
public static final String POST_ENDPOINT = "/records";
public static final String GET_ENDPOINT = "/records/";
public static final String DELETE_ENDPOINT = "/records/";
public static final long RECORD_SEARCH_MAX_TIMEOUT_SEC = 60;
public static final String RECORD_CREATED = "201";
public static final String REQUEST_SUCCESS = "200";
public static final String REQUEST_SUCCESS_NO_CONTENT = "204";
public static final String RECORD_NOT_FOUND = "404";
public static final String COLON_SEPARATOR = ":";
public static final String DASH = "-";
public static final String POINT = ".";
public static final String OS_TARGET_SCHEMA_KIND_TENANT = getEnvironmentVariableOrDefaultValue("OS_TARGET_SCHEMA_KIND_TENANT", "opendes:wks:wellbore:1.3.1");
public static final String OS_TARGET_SCHEMA_KIND = getEnvironmentVariableOrDefaultValue("OS_TARGET_SCHEMA_KIND", "slb:wks:wellbore:1.3.1");
public static final List<String> OS_TARGET_SCHEMA_KIND_IHS = Arrays.asList("slb:wks:log:2.3.1", "abc:wks:log:3.2.1");
public static final List<String> OS_TARGET_SCHEMA_KIND_OGA = Arrays.asList("slb:wks:well:4.3.1", "slb:wks:well:5.1.0", "abc:wks:well:1.5.1");
public static final List<String> OS_TARGET_SCHEMA_KIND_IHS_WELL = Arrays.asList("abc:wks:log:3.2.1", "slb:wks:log:2.3.1", "slb:wks:well:2.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_IHS_WELLBORE = Arrays.asList("abc:wks:log:3.2.1", "npl:wks:log:2.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_PETREL_WELL = Arrays.asList("slb:wks:well:1.0.0", "abc:wks:well:1.5.1", "slb:wks:wellbore:1.0.0", "slb:wks:well:4.3.1");
public static final List<String> OS_TARGET_SCHEMA_KIND_AT_LOG = Arrays.asList("slb:wks:log:1.0.0", "abc:wks:log:1.0.7", "slb:wks:well:1.0.0", "slb:wks:log:4.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_AT_WELL = Arrays.asList("slb:wks:well:1.0.0", "slb:wks:wellbore:1.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_OGA_LOG = Arrays.asList("slb:wks:log:1.0.0", "slb:wks:well:1.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_PETREL_WELLSET = Arrays.asList("slb:wks:wellset:1.0.0", "slb:wks:wellbore:1.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_AT_LOGSET = Arrays.asList("slb:wks:logset:1.0.0", "slb:wks:well:1.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_PETREL_WELLSET1 = Arrays.asList("slb:wks:well:1.0.0", "abc:wks:well:1.0.0");
public static final List<String> OS_TARGET_SCHEMA_KIND_AT_LOGSET1 = Arrays.asList("slb:wks:log:1.0.0", "abc:wks:log:1.0.0");
public static final long INDEXING_TIMEOUT = 60;
public static final String TENANT_NAME_PLACEHOLDER = "<tenant_name>";
public static final String ACL_VIEWERS_GROUP = "<acl_viewers>";
public static final String ACL_OWNERS_GROUP = "<acl_owners>";
public static final String CLOUD_DOMAIN = "<cloud_domain>";
public static final String LEGAL_TAGS = "<legal_tags>";
public static final String RECORD_ID = "<record_id.>";
public static final String TENANT_NAME_PLACEHOLDER_VALUE = System.getProperty("TENANT_NAME",
System.getenv("TENANT_NAME"));
public static final String ACL_VIEWERS_GROUP_VALUE = System.getProperty("ACL_VIEWERS",
System.getenv("ACL_VIEWERS"));
public static final String ACL_OWNERS_GROUP_VALUE = System.getProperty("ACL_OWNERS", System.getenv("ACL_OWNERS"));
public static final String CLOUD_DOMAIN_VALUE = System.getProperty("DOMAIN", System.getenv("DOMAIN"));
public static final String LEGAL_TAGS_VALUE = System.getProperty("LEGAL_TAG", System.getenv("LEGAL_TAG"));
public static final String SCHEMA_URL = System.getProperty("HOST", System.getenv("HOST")) + "/api/schema-service/v1";
private static String getEnvironmentVariableOrDefaultValue(String key, String defaultValue) {
String environmentVariable = System.getProperty(key, System.getenv(key));
if (environmentVariable == null) {
environmentVariable = defaultValue;
}
return environmentVariable;
}
}
......@@ -226,7 +226,6 @@ public class IntegrationTestStepDefs implements En {
List<HttpResponse> httpResponseList = this.context.getResponseList();
for(int i=0; i<httpResponseList.size(); i++) {
String expectedKind = AutomationConstants.OS_TARGET_SCHEMA_KIND_IHS.get(i);
expectedKind = AutomationConstants.TENANT_NAME_PLACEHOLDER_VALUE + expectedKind.substring(expectedKind.indexOf(AutomationConstants.COLON_SEPARATOR));
String actualKind = new JsonPath(httpResponseList.get(i).getBody()).get("kind").toString();
assertEquals(expectedKind, actualKind);
}
......
......@@ -97,7 +97,7 @@ public class WksTransformer {
Tree transformedTree = copyTagsAttribute(rawRecordTree,transformedTreeFromPreviousStage);
transformedTree.putObject(ID, createRecordId(rawRecordTree, targetSchemaKind));
transformedTree.putObject(ANCESTRY + Constants.POINT + PARENTS, fetchParent(rawRecordTree));
transformedTree.putObject(KIND, createWksKind(targetSchemaKind, rawRecordTree.get(ID).asString()));
transformedTree.putObject(KIND, targetSchemaKind);
transformedTree.putObject(ACL, rawRecordTree.get(ACL));
transformedTree.putObject(LEGAL, rawRecordTree.get(LEGAL));
......@@ -193,11 +193,6 @@ public class WksTransformer {
return WksIdGenerator.createRecordId(rawRecordTree.get(ID).asString(), wksSchemaKind);
}
private String createWksKind(String wksSchemaKind, String rawRecordId) {
String[] idStrArr = rawRecordId.split(Constants.COLON_SEPARATOR);
return idStrArr[0] + wksSchemaKind.substring(wksSchemaKind.indexOf(Constants.COLON_SEPARATOR));
}
private String[] fetchParent(Tree rawRecordTree) {
String parent = rawRecordTree.get(ID).asString() + Constants.COLON_SEPARATOR + Long.valueOf(rawRecordTree
.get(VERSION)
......
......@@ -350,8 +350,8 @@ public class RelationshipBlockHandler {
String rawRecordId = rawRecordTree.get(RelationshipConstants.ID).asString();
String rawRecordVersion = rawRecordTree.get("version").asString();
Kind rawKind = new Kind(rawRecordTree.get("kind").asString());
// For wks kind targetSchemaAuthority should be used but due to current limitation be have to use raw record authority
Kind wksKind = new Kind(rawKind.getAuthority(), Constants.WKS_KIND, rawKind.getEntityType(), "*");
String targetSchemaAuthority = targetSchemaKindValue.substring(0, targetSchemaKindValue.indexOf(Constants.COLON_SEPARATOR));
Kind wksKind = new Kind(targetSchemaAuthority, Constants.WKS_KIND, rawKind.getEntityType(), "*");
SearchQuery searchQuery = new SearchByAncestryQuery(rawRecordId, rawRecordVersion);
return new SearchRequestPayload(wksKind, searchQuery);
}
......
......@@ -56,7 +56,7 @@ public class WksTransformerTest {
private static final String UNIT_TEST_RESOURCES_FOLDER_PATH = "/unit_test_resources/";
private static final String MAPPING_FILE_NAME = "mapping.json";
private static final String RAW_RECORD_FILE_NAME = "raw_record.json";
private static final String TARGET_SCHEMA_KIND = "part1:wks:entity:1.0.0";
private static final String TARGET_SCHEMA_KIND = "part2:wks:entity:1.0.0";
private static final String RAW_RECORD_WITHOUT_META_FILE_NAME = "raw_record_without_meta.json";
private static final String RAW_RECORD_WITH_EMPTY_META_FILE_NAME = "raw_record_with_empty_meta.json";
private static final String RAW_RECORD_WITH_NO_ANCESTRY_FILE_NAME = "raw_record_with_no_ancestry.json";
......
......@@ -8,7 +8,7 @@
"schemaVersionMajor": 1
},
"targetSchema": {
"authority": "part1",
"authority": "part2",
"source": "wks",
"entityType": "entity",
"schemaVersionMajor": 1
......
......@@ -51,11 +51,11 @@
"persistableReference" : "{\"lateBoundCRS\":{\"wkt\":\"GEOGCS[\\\"GCS_European_1950\\\",DATUM[\\\"D_European_1950\\\",SPHEROID[\\\"International_1924\\\",6378388.0,297.0]],PRIMEM[\\\"Greenwich\\\",0.0],UNIT[\\\"Degree\\\",0.0174532925199433],AUTHORITY[\\\"EPSG\\\",4230]]\",\"ver\":\"PE_10_3_1\",\"name\":\"GCS_European_1950\",\"authCode\":{\"auth\":\"EPSG\",\"code\":\"4230\"},\"type\":\"LBC\"},\"singleCT\":{\"wkt\":\"GEOGTRAN[\\\"ED_1950_To_WGS_1984_23\\\",GEOGCS[\\\"GCS_European_1950\\\",DATUM[\\\"D_European_1950\\\",SPHEROID[\\\"International_1924\\\",6378388.0,297.0]],PRIMEM[\\\"Greenwich\\\",0.0],UNIT[\\\"Degree\\\",0.0174532925199433]],GEOGCS[\\\"GCS_WGS_1984\\\",DATUM[\\\"D_WGS_1984\\\",SPHEROID[\\\"WGS_1984\\\",6378137.0,298.257223563]],PRIMEM[\\\"Greenwich\\\",0.0],UNIT[\\\"Degree\\\",0.0174532925199433]],METHOD[\\\"Position_Vector\\\"],PARAMETER[\\\"X_Axis_Translation\\\",-116.641],PARAMETER[\\\"Y_Axis_Translation\\\",-56.931],PARAMETER[\\\"Z_Axis_Translation\\\",-110.559],PARAMETER[\\\"X_Axis_Rotation\\\",0.893],PARAMETER[\\\"Y_Axis_Rotation\\\",0.921],PARAMETER[\\\"Z_Axis_Rotation\\\",-0.917],PARAMETER[\\\"Scale_Difference\\\",-3.52],AUTHORITY[\\\"EPSG\\\",1612]]\",\"ver\":\"PE_10_3_1\",\"name\":\"ED_1950_To_WGS_1984_23\",\"authCode\":{\"auth\":\"EPSG\",\"code\":\"1612\"},\"type\":\"ST\"},\"ver\":\"PE_10_3_1\",\"name\":\"ED50 * EPSG-Nor N62 2001 [4230,1612]\",\"authCode\":{\"auth\":\"\",\"code\":\"4230023\"},\"type\":\"EBC\"}",
"propertyNames" : [ "wksAttribute2.y" ]
} ],
"id" : "part1:entity:wks-3b9edab584ccc863c1dec7f1f5cf89c70d312020.part1.wks.entity.1",
"id" : "part1:entity:wks-3b9edab584ccc863c1dec7f1f5cf89c70d312020.part2.wks.entity.1",
"ancestry" : {
"parents" : [ "part1:source:entity-uniqueId:39429347234" ]
},
"kind" : "part1:wks:entity:1.0.0",
"kind" : "part2:wks:entity:1.0.0",
"acl" : {
"viewers" : [ "data.default.viewers@part1.dev.com" ],
"owners" : [ "data.default.owners@part1.dev.com" ]
......
......@@ -51,11 +51,11 @@
"persistableReference" : "{\"lateBoundCRS\":{\"wkt\":\"GEOGCS[\\\"GCS_European_1950\\\",DATUM[\\\"D_European_1950\\\",SPHEROID[\\\"International_1924\\\",6378388.0,297.0]],PRIMEM[\\\"Greenwich\\\",0.0],UNIT[\\\"Degree\\\",0.0174532925199433],AUTHORITY[\\\"EPSG\\\",4230]]\",\"ver\":\"PE_10_3_1\",\"name\":\"GCS_European_1950\",\"authCode\":{\"auth\":\"EPSG\",\"code\":\"4230\"},\"type\":\"LBC\"},\"singleCT\":{\"wkt\":\"GEOGTRAN[\\\"ED_1950_To_WGS_1984_23\\\",GEOGCS[\\\"GCS_European_1950\\\",DATUM[\\\"D_European_1950\\\",SPHEROID[\\\"International_1924\\\",6378388.0,297.0]],PRIMEM[\\\"Greenwich\\\",0.0],UNIT[\\\"Degree\\\",0.0174532925199433]],GEOGCS[\\\"GCS_WGS_1984\\\",DATUM[\\\"D_WGS_1984\\\",SPHEROID[\\\"WGS_1984\\\",6378137.0,298.257223563]],PRIMEM[\\\"Greenwich\\\",0.0],UNIT[\\\"Degree\\\",0.0174532925199433]],METHOD[\\\"Position_Vector\\\"],PARAMETER[\\\"X_Axis_Translation\\\",-116.641],PARAMETER[\\\"Y_Axis_Translation\\\",-56.931],PARAMETER[\\\"Z_Axis_Translation\\\",-110.559],PARAMETER[\\\"X_Axis_Rotation\\\",0.893],PARAMETER[\\\"Y_Axis_Rotation\\\",0.921],PARAMETER[\\\"Z_Axis_Rotation\\\",-0.917],PARAMETER[\\\"Scale_Difference\\\",-3.52],AUTHORITY[\\\"EPSG\\\",1612]]\",\"ver\":\"PE_10_3_1\",\"name\":\"ED_1950_To_WGS_1984_23\",\"authCode\":{\"auth\":\"EPSG\",\"code\":\"1612\"},\"type\":\"ST\"},\"ver\":\"PE_10_3_1\",\"name\":\"ED50 * EPSG-Nor N62 2001 [4230,1612]\",\"authCode\":{\"auth\":\"\",\"code\":\"4230023\"},\"type\":\"EBC\"}",
"propertyNames" : [ "wksAttribute2.y" ]
} ],
"id": "part1:entity:wks-3b9edab584ccc863c1dec7f1f5cf89c70d312020.part1.wks.entity.1",
"id": "part1:entity:wks-3b9edab584ccc863c1dec7f1f5cf89c70d312020.part2.wks.entity.1",
"ancestry" : {
"parents" : [ "part1:source:entity-uniqueId:39429347234" ]
},
"kind" : "part1:wks:entity:1.0.0",
"kind" : "part2:wks:entity:1.0.0",
"acl" : {
"viewers" : [ "data.default.viewers@part1.dev.com" ],
"owners" : [ "data.default.owners@part1.dev.com" ]
......
......@@ -35,11 +35,11 @@
},
"Wks Attribute 18 (CDE)" : 2246.5
},
"id" : "part1:entity:wks-3b9edab584ccc863c1dec7f1f5cf89c70d312020.part1.wks.entity.1",
"id" : "part1:entity:wks-3b9edab584ccc863c1dec7f1f5cf89c70d312020.part2.wks.entity.1",
"ancestry" : {
"parents" : [ "part1:source:entity-uniqueId:39429347234" ]
},
"kind" : "part1:wks:entity:1.0.0",
"kind" : "part2:wks:entity:1.0.0",
"acl" : {
"viewers" : [ "data.default.viewers@part1.dev.com" ],
"owners" : [ "data.default.owners@part1.dev.com" ]
......
{
"id" : "part1:entity:wks-066f2079ed2f81f02a550b91140d4d7d68b1adf0.part1.wks.entity.1",
"id" : "part1:entity:wks-066f2079ed2f81f02a550b91140d4d7d68b1adf0.part2.wks.entity.1",
"ancestry" : {
"parents" : [ "part1:source:wellbore-dGVzdFdlbGxfYXV0b19hdHRlbXB0Ng:1568075751408965" ]
},
"kind" : "part1:wks:entity:1.0.0",
"kind" : "part2:wks:entity:1.0.0",
"acl" : {
"viewers" : [ "data.default.viewers@part1.dev.com" ],
"owners" : [ "data.default.owners@part1.dev.com" ]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment