Commit 9de5b164 authored by devesh bajpai's avatar devesh bajpai
Browse files

enable tahgs attribute to be copied from raw to wks

parent 308ff5c7
Pipeline #24544 failed with stages
in 2 minutes and 47 seconds
......@@ -26,7 +26,7 @@ import io.datatree.Tree;
/**
* This class do transformation of raw record to wks record
*
*
*/
@Component
public class WksTransformator {
......@@ -42,6 +42,7 @@ public class WksTransformator {
private static final String RAW_RECORD_NOT_PRESENT = "Raw record not present";
private static final String VERSION = "version";
private static final String ANCESTRY = "ancestry";
private static final String TAGS = "tags";
private static final String PARENTS = "parents";
private static final String ID = "id";
private static final String KIND = "kind";
......@@ -49,7 +50,7 @@ public class WksTransformator {
private static final String WKS_SCHEMA_KIND_NOT_PRESENT = "WKS Schema kind is not present in mappings";
private static final String RELATIONSHIPS = "data.relationships";
private static final String RELATIONSHIP_MAPPING_PENDING = "Relationship mapping pending";
@Autowired
private RelationshipBlockHandler relationshipBlockHandler;
......@@ -57,7 +58,7 @@ public class WksTransformator {
* This method receive raw records in form of {@link Tree} and mappings in
* {@link Array} of {@link MappingsModel}. Then according to path in mappings
* and value in rawRecordTree it creates transformedTree.
*
*
* @param transformRequest
* @return transformedTree
* @throws ApplicationException
......@@ -65,7 +66,7 @@ public class WksTransformator {
public TransformationResult transform(TransformRequest transformRequest) throws ApplicationException {
Tree rawRecordTree = transformRequest.getRawRecordTree();
MappingsModel mappings = transformRequest.getMappingsModel();
validateRawRecord(rawRecordTree);
validateMappings(mappings);
......@@ -75,10 +76,20 @@ public class WksTransformator {
transformedTree.putObject(KIND, createWksKind(mappings.getTargetSchemaKind(), rawRecordTree.get(ID).asString()));
transformedTree.putObject(ACL, rawRecordTree.get(ACL));
transformedTree.putObject(LEGAL, rawRecordTree.get(LEGAL));
transformedTree = copyTagsAttribute(rawRecordTree, transformedTree);
return transformRelationshipBlock(transformRequest, transformedTree);
}
private Tree copyTagsAttribute(Tree rawRecordTree, Tree transformedTree) {
Tree result = transformedTree.clone();
Tree tagsTree = rawRecordTree.get(TAGS);
if(tagsTree!= null && !(tagsTree.isNull() || tagsTree.isEmpty())){
result.putObject(TAGS, rawRecordTree.get(TAGS));
}
return result;
}
private TransformationResult transformRelationshipBlock(
TransformRequest transformRequest, Tree transformedTreeFromPreviousStage) {
TransformationResult transformationResult = new TransformationResult();
......@@ -100,7 +111,7 @@ public class WksTransformator {
transformationResult.setTransformedTree(transformedTree);
return transformationResult;
}
private UpdatedRelationshipBlock updateRelationshipBlockWithWKSIds(Tree rawRelationshipBlockTree, String targetSchemaKind) {
return relationshipBlockHandler.updateRelationshipBlockWithWksIds(rawRelationshipBlockTree, targetSchemaKind);
}
......@@ -206,7 +217,7 @@ public class WksTransformator {
}
return missingAttributes;
}
private RelationshipStatus populateRelationshipStatus(
TransformRequest transformRequest,
Tree transformedTree,
......
......@@ -47,6 +47,7 @@ public class WksTransformatorTest {
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 RAW_RECORD_WITH_TAGS_FILE_NAME = "raw_record_with_tags.json";
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";
......@@ -55,6 +56,7 @@ public class WksTransformatorTest {
private static final String RAW_RECORD_WITH_ANCESTRY_PARENT_NULL_FILE_NAME = "raw_record_with_ancestry_parent_null.json";
private static final String RAW_RECORD_WITH_ANCESTRY_EMPTY_PARENT_FILE_NAME = "raw_record_with_ancestry_empty_parent.json";
private static final String TRANSFORMED_RECORD_FILE_NAME = "transformed_record.json";
private static final String TRANSFORMED_RECORD_WITH_TAGS_FILE_NAME = "transformed_record_with_tags.json";
private static final String TRANSFORMED_RECORD_WITHOUT_META_FILE_NAME = "transformed_record_without_meta.json";
private static final String WKS_SCHEMA_KIND_NOT_PRESENT = "WKS Schema kind is not present in mappings";
private static final String RAW_RECORD_NOT_PRESENT = "Raw record not present";
......@@ -156,6 +158,17 @@ public class WksTransformatorTest {
assertEqualTree(expectedTransformedTree, transformationResult.getTransformedTree());
}
@Test
public void verifyTagsAttributeIsCopiedFromRawToWKS() throws IOException, ApplicationException {
Tree rawRecordTree = findJsonTree(RAW_RECORD_WITH_TAGS_FILE_NAME);
MappingsModel mappings = findAttributeMappingModelArray(MAPPING_FILE_NAME);
Tree expectedTransformedTree = findJsonTree(TRANSFORMED_RECORD_WITH_TAGS_FILE_NAME);
TransformationResult transformationResult = transformator.transform(new TransformRequest(rawRecordTree, mappings));
assertTrue(!transformationResult.getTransformedTree().isEmpty());
assertEqualTree(expectedTransformedTree, transformationResult.getTransformedTree());
}
@Test
public void testTransformWithValidRawData() throws IOException, ApplicationException {
Tree rawRecordTree = findJsonTree(RAW_RECORD_FILE_NAME);
......
{
"data": {
"rawAttribute1": 456979.06,
"rawAttribute2": 6782712.41,
"rawAttribute3": "6/6/2007 14:29",
"rawAttribute4 'Char'": 5,
"rawAttribute5 [abc]": "",
"rawAttribute6": "61 10 30.2673\"N",
"rawAttribute7": "AB",
"rawAttribute8": "'ABC'",
"rawAttribute9 abc jkl xyz": true,
"rawAttribute10": {},
"rawAttribute11": {
"a": "FeatureCollection",
"types": [
{
"b": {
"type": "Point",
"c": [
"NaN",
"NaN"
]
},
"type": "Feature",
"d": {}
}
]
},
"_rawAttribute12": 525821960,
"rawAttribute13": 42.7,
"rawAttribute14": "abc_jkl_xyz",
"_rawAttribute15": "abc1:jkl:abc_jkl_xyz",
"RAWATTRIBUTE16 (JK)": 2415.8,
"rawAttribute17": {
"a": "NaN",
"b": "NaN"
},
"Raw Attribute 18 (CDE)": 2246.5
},
"meta": [
{
"kind": "Unit",
"name": "m",
"persistableReference": "{\"scaleOffset\":{\"scale\":1.0,\"offset\":0.0},\"symbol\":\"m\",\"baseMeasurement\":{\"ancestry\":\"Length\",\"type\":\"UM\"},\"type\":\"USO\"}",
"propertyNames": [
"rawAttribute1",
"rawAttribute6",
"rawAttribute3"
]
},
{
"kind": "CRS",
"name": "ED50 * EPSG-Nor N62 2001 / UTM zone 31N [23031,1612]",
"persistableReference": "{\"lateBoundCRS\":{\"wkt\":\"PROJCS[\\\"ED_1950_UTM_Zone_31N\\\",GEOGCS[\\\"GCS_European_1950\\\",DATUM[\\\"D_European_1950\\\",SPHEROID[\\\"International_1924\\\",6378388.0,297.0]],PRIMEM[\\\"Greenwich\\\",0.0],UNIT[\\\"Degree\\\",0.0174532925199433]],PROJECTION[\\\"Transverse_Mercator\\\"],PARAMETER[\\\"False_Easting\\\",500000.0],PARAMETER[\\\"False_Northing\\\",0.0],PARAMETER[\\\"Central_Meridian\\\",3.0],PARAMETER[\\\"Scale_Factor\\\",0.9996],PARAMETER[\\\"Latitude_Of_Origin\\\",0.0],UNIT[\\\"Meter\\\",1.0],AUTHORITY[\\\"EPSG\\\",23031]]\",\"ver\":\"PE_10_3_1\",\"name\":\"ED_1950_UTM_Zone_31N\",\"authCode\":{\"auth\":\"EPSG\",\"code\":\"23031\"},\"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 / UTM zone 31N [23031,1612]\",\"authCode\":{\"auth\":\"\",\"code\":\"23031023\"},\"type\":\"EBC\"}",
"propertyNames": [
"rawAttribute17.a",
"rawAttribute17.b"
]
},
{
"kind": "CRS",
"name": "ED50 * EPSG-Nor N62 2001 [4230,1612]",
"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": [
"rawAttribute2",
"rawAttribute19"
]
}
],
"id": "part1:source:entity-uniqueId",
"version": 39429347234,
"kind": "part1:source:entity:1.0.0",
"acl": {
"viewers": [
"data.default.viewers@part1.dev.com"
],
"owners": [
"data.default.owners@part1.dev.com"
]
},
"ancestry": {
"parents": [
":source:uniqueId:123456789"
]
},
"legal": {
"legaltags": [
"part1-1-abc-test"
],
"otherRelevantDataCountries": [
"IN"
],
"status": "compliant"
},
"tags": {
"items": [
{
"dataflowId": "12345"
}
]
}
}
\ No newline at end of file
{
"data" : {
"wksAttribute1" : {
"x" : 456979.06
},
"wksAttribute2" : {
"y" : 6782712.41
},
"wksAttribute3" : "6/6/2007 14:29",
"wksAttribute4 'Char'" : 5,
"wksAttribute6" : "61 10 30.2673\"N",
"wksAttribute7" : "AB",
"wksAttribute8" : "'ABC'",
"wksAttribute9 abc jkl xyz" : true,
"wksAttribute10" : { },
"wksAttribute11" : {
"a" : "FeatureCollection",
"types" : [ {
"b" : {
"type" : "Point",
"c" : [ "NaN", "NaN" ]
},
"type" : "Feature",
"d" : { }
} ]
},
"_wksAttribute12" : 525821960,
"wksAttribute13" : 42.7,
"wksAttribute14" : "abc_jkl_xyz",
"wksAttribute15" : "abc1:jkl:abc_jkl_xyz",
"WKSATTRIBUTE16 (JK)" : 2415.8,
"wksAttribute17" : {
"a" : "NaN",
"b" : "NaN"
},
"Wks Attribute 18 (CDE)" : 2246.5
},
"meta" : [ {
"kind" : "Unit",
"name" : "m",
"persistableReference" : "{\"scaleOffset\":{\"scale\":1.0,\"offset\":0.0},\"symbol\":\"m\",\"baseMeasurement\":{\"ancestry\":\"Length\",\"type\":\"UM\"},\"type\":\"USO\"}",
"propertyNames" : [ "wksAttribute1.x", "wksAttribute6", "wksAttribute3" ]
}, {
"kind" : "CRS",
"name" : "ED50 * EPSG-Nor N62 2001 / UTM zone 31N [23031,1612]",
"persistableReference" : "{\"lateBoundCRS\":{\"wkt\":\"PROJCS[\\\"ED_1950_UTM_Zone_31N\\\",GEOGCS[\\\"GCS_European_1950\\\",DATUM[\\\"D_European_1950\\\",SPHEROID[\\\"International_1924\\\",6378388.0,297.0]],PRIMEM[\\\"Greenwich\\\",0.0],UNIT[\\\"Degree\\\",0.0174532925199433]],PROJECTION[\\\"Transverse_Mercator\\\"],PARAMETER[\\\"False_Easting\\\",500000.0],PARAMETER[\\\"False_Northing\\\",0.0],PARAMETER[\\\"Central_Meridian\\\",3.0],PARAMETER[\\\"Scale_Factor\\\",0.9996],PARAMETER[\\\"Latitude_Of_Origin\\\",0.0],UNIT[\\\"Meter\\\",1.0],AUTHORITY[\\\"EPSG\\\",23031]]\",\"ver\":\"PE_10_3_1\",\"name\":\"ED_1950_UTM_Zone_31N\",\"authCode\":{\"auth\":\"EPSG\",\"code\":\"23031\"},\"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 / UTM zone 31N [23031,1612]\",\"authCode\":{\"auth\":\"\",\"code\":\"23031023\"},\"type\":\"EBC\"}",
"propertyNames" : [ "wksAttribute17.a", "wksAttribute17.b" ]
}, {
"kind" : "CRS",
"name" : "ED50 * EPSG-Nor N62 2001 [4230,1612]",
"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:wks:entity-3b9edab584ccc863c1dec7f1f5cf89c70d312020.part1.wks.entity.1",
"ancestry" : {
"parents" : [ "part1:source:entity-uniqueId:39429347234" ]
},
"kind" : "part1:wks:entity:1.0.0",
"acl" : {
"viewers" : [ "data.default.viewers@part1.dev.com" ],
"owners" : [ "data.default.owners@part1.dev.com" ]
},
"legal" : {
"legaltags" : [ "part1-1-abc-test" ],
"otherRelevantDataCountries" : [ "IN" ],
"status" : "compliant"
},
"tags": {
"items": [
{
"dataflowId": "12345"
}
]
}
}
\ No newline at end of file
Supports Markdown
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