Search in sources :

Example 51 with Field

use of org.talend.hl7.Field in project atlasmap by atlasmap.

the class BaseModuleValidationService method validateMapMapping.

protected void validateMapMapping(Mapping mapping, List<Validation> validations) {
    Field sourceField = null;
    Field targetField = null;
    String mappingId = mapping.getId();
    if (mapping != null && mapping.getInputField() != null && mapping.getInputField().size() > 0) {
        sourceField = mapping.getInputField().get(0);
        if (getMode() == AtlasModuleMode.SOURCE && matchDocIdOrNull(sourceField.getDocId())) {
            validateField(mappingId, sourceField, FieldDirection.SOURCE, validations);
        }
    }
    if (mapping != null && mapping.getOutputField() != null && mapping.getOutputField().size() > 0) {
        targetField = mapping.getOutputField().get(0);
        if (getMode() == AtlasModuleMode.TARGET && matchDocIdOrNull(targetField.getDocId())) {
            validateField(mappingId, targetField, FieldDirection.TARGET, validations);
        }
    }
    if (sourceField != null && targetField != null && getMode() == AtlasModuleMode.SOURCE && matchDocIdOrNull(sourceField.getDocId())) {
        // FIXME Run only for SOURCE to avoid duplicate validation...
        // we should convert per module validations to plugin style
        validateSourceAndTargetTypes(mappingId, sourceField, targetField, validations);
    }
}
Also used : Field(io.atlasmap.v2.Field)

Example 52 with Field

use of org.talend.hl7.Field in project atlasmap by atlasmap.

the class SchemaInspectorTest method inspectJsonSchemaGeo.

// examples from json-schema.org
@Test
public void inspectJsonSchemaGeo() throws Exception {
    final String schema = new String(Files.readAllBytes(Paths.get("src/test/resources/inspect/schema/geo.json")));
    JsonDocument document = inspectionService.inspectJsonSchema(schema);
    List<Field> fields = document.getFields().getField();
    JsonField f = (JsonField) fields.get(0);
    assertEquals("latitude", f.getName());
    assertEquals("/latitude", f.getPath());
    assertEquals(FieldType.NUMBER, f.getFieldType());
    f = (JsonField) fields.get(1);
    assertEquals("longitude", f.getName());
    assertEquals("/longitude", f.getPath());
    assertEquals(FieldType.NUMBER, f.getFieldType());
}
Also used : Field(io.atlasmap.v2.Field) JsonField(io.atlasmap.json.v2.JsonField) JsonField(io.atlasmap.json.v2.JsonField) JsonDocument(io.atlasmap.json.v2.JsonDocument) Test(org.junit.Test)

Example 53 with Field

use of org.talend.hl7.Field in project atlasmap by atlasmap.

the class SchemaInspectorTest method doInspectJsonSchemaCard.

private void doInspectJsonSchemaCard(String schema) throws Exception {
    JsonDocument document = inspectionService.inspectJsonSchema(schema);
    List<Field> fields = document.getFields().getField();
    JsonField f = (JsonField) fields.get(0);
    assertEquals("fn", f.getName());
    assertEquals("/fn", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(1);
    assertEquals("familyName", f.getName());
    assertEquals("/familyName", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(2);
    assertEquals("givenName", f.getName());
    assertEquals("/givenName", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(3);
    assertEquals("additionalName", f.getName());
    assertEquals("/additionalName", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    assertEquals(CollectionType.LIST, f.getCollectionType());
    f = (JsonField) fields.get(4);
    assertEquals("honorificPrefix", f.getName());
    assertEquals("/honorificPrefix", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    assertEquals(CollectionType.LIST, f.getCollectionType());
    f = (JsonField) fields.get(5);
    assertEquals("honorificSuffix", f.getName());
    assertEquals("/honorificSuffix", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    assertEquals(CollectionType.LIST, f.getCollectionType());
    f = (JsonField) fields.get(6);
    assertEquals("nickname", f.getName());
    assertEquals("/nickname", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(7);
    assertEquals("url", f.getName());
    assertEquals("/url", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonComplexType) fields.get(8);
    assertEquals("email", f.getName());
    assertEquals("/email", f.getPath());
    assertEquals(FieldType.COMPLEX, f.getFieldType());
    List<JsonField> emailfields = ((JsonComplexType) f).getJsonFields().getJsonField();
    f = emailfields.get(0);
    assertEquals("type", f.getName());
    assertEquals("/email/type", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = emailfields.get(1);
    assertEquals("value", f.getName());
    assertEquals("/email/value", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonComplexType) fields.get(9);
    assertEquals("tel", f.getName());
    assertEquals("/tel", f.getPath());
    assertEquals(FieldType.COMPLEX, f.getFieldType());
    List<JsonField> telfields = ((JsonComplexType) f).getJsonFields().getJsonField();
    f = telfields.get(0);
    assertEquals("type", f.getName());
    assertEquals("/tel/type", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = telfields.get(1);
    assertEquals("value", f.getName());
    assertEquals("/tel/value", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonComplexType) fields.get(10);
    assertEquals("adr", f.getName());
    assertEquals("/adr", f.getPath());
    assertEquals(FieldType.COMPLEX, f.getFieldType());
    List<JsonField> addrfields = ((JsonComplexType) f).getJsonFields().getJsonField();
    f = addrfields.get(0);
    assertEquals("post-office-box", f.getName());
    assertEquals("/adr/post-office-box", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = addrfields.get(1);
    assertEquals("extended-address", f.getName());
    assertEquals("/adr/extended-address", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = addrfields.get(2);
    assertEquals("street-address", f.getName());
    assertEquals("/adr/street-address", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = addrfields.get(3);
    assertEquals("locality", f.getName());
    assertEquals("/adr/locality", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = addrfields.get(4);
    assertEquals("region", f.getName());
    assertEquals("/adr/region", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = addrfields.get(5);
    assertEquals("postal-code", f.getName());
    assertEquals("/adr/postal-code", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = addrfields.get(6);
    assertEquals("country-name", f.getName());
    assertEquals("/adr/country-name", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonComplexType) fields.get(11);
    assertEquals("geo", f.getName());
    assertEquals("/geo", f.getPath());
    assertEquals(FieldType.COMPLEX, f.getFieldType());
    List<JsonField> geofields = ((JsonComplexType) f).getJsonFields().getJsonField();
    f = geofields.get(0);
    assertEquals("latitude", f.getName());
    assertEquals("/geo/latitude", f.getPath());
    assertEquals(FieldType.NUMBER, f.getFieldType());
    f = geofields.get(1);
    assertEquals("longitude", f.getName());
    assertEquals("/geo/longitude", f.getPath());
    assertEquals(FieldType.NUMBER, f.getFieldType());
    f = (JsonField) fields.get(12);
    assertEquals("tz", f.getName());
    assertEquals("/tz", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(13);
    assertEquals("photo", f.getName());
    assertEquals("/photo", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(14);
    assertEquals("logo", f.getName());
    assertEquals("/logo", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(15);
    assertEquals("sound", f.getName());
    assertEquals("/sound", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(16);
    assertEquals("bday", f.getName());
    assertEquals("/bday", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(17);
    assertEquals("title", f.getName());
    assertEquals("/title", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(18);
    assertEquals("role", f.getName());
    assertEquals("/role", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonComplexType) fields.get(19);
    assertEquals("org", f.getName());
    assertEquals("/org", f.getPath());
    assertEquals(FieldType.COMPLEX, f.getFieldType());
    List<JsonField> orgfields = ((JsonComplexType) f).getJsonFields().getJsonField();
    f = orgfields.get(0);
    assertEquals("organizationName", f.getName());
    assertEquals("/org/organizationName", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = orgfields.get(1);
    assertEquals("organizationUnit", f.getName());
    assertEquals("/org/organizationUnit", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
}
Also used : Field(io.atlasmap.v2.Field) JsonField(io.atlasmap.json.v2.JsonField) JsonField(io.atlasmap.json.v2.JsonField) JsonDocument(io.atlasmap.json.v2.JsonDocument)

Example 54 with Field

use of org.talend.hl7.Field in project atlasmap by atlasmap.

the class SchemaInspectorTest method doInspectJsonSchemaCalendar.

private void doInspectJsonSchemaCalendar(String instance) throws Exception {
    JsonDocument document = inspectionService.inspectJsonSchema(instance);
    List<Field> fields = document.getFields().getField();
    JsonField f = (JsonField) fields.get(0);
    assertEquals("dtstart", f.getName());
    assertEquals("/dtstart", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(1);
    assertEquals("dtend", f.getName());
    assertEquals("/dtend", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(2);
    assertEquals("summary", f.getName());
    assertEquals("/summary", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(3);
    assertEquals("location", f.getName());
    assertEquals("/location", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(4);
    assertEquals("url", f.getName());
    assertEquals("/url", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(5);
    assertEquals("duration", f.getName());
    assertEquals("/duration", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(6);
    assertEquals("rdate", f.getName());
    assertEquals("/rdate", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(7);
    assertEquals("rrule", f.getName());
    assertEquals("/rrule", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(8);
    assertEquals("category", f.getName());
    assertEquals("/category", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(9);
    assertEquals("description", f.getName());
    assertEquals("/description", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonComplexType) fields.get(10);
    assertEquals("geo", f.getName());
    assertEquals("/geo", f.getPath());
    assertEquals(FieldType.COMPLEX, f.getFieldType());
    List<JsonField> geofields = ((JsonComplexType) f).getJsonFields().getJsonField();
    f = geofields.get(0);
    assertEquals("latitude", f.getName());
    assertEquals("/geo/latitude", f.getPath());
    assertEquals(FieldType.NUMBER, f.getFieldType());
    f = geofields.get(1);
    assertEquals("longitude", f.getName());
    assertEquals("/geo/longitude", f.getPath());
    assertEquals(FieldType.NUMBER, f.getFieldType());
}
Also used : Field(io.atlasmap.v2.Field) JsonField(io.atlasmap.json.v2.JsonField) JsonField(io.atlasmap.json.v2.JsonField) JsonDocument(io.atlasmap.json.v2.JsonDocument)

Example 55 with Field

use of org.talend.hl7.Field in project atlasmap by atlasmap.

the class SchemaInspectorTest method inspectJsonSchemaAddress.

@Test
public void inspectJsonSchemaAddress() throws Exception {
    final String schema = new String(Files.readAllBytes(Paths.get("src/test/resources/inspect/schema/address.json")));
    JsonDocument document = inspectionService.inspectJsonSchema(schema);
    List<Field> fields = document.getFields().getField();
    JsonField f = (JsonField) fields.get(0);
    assertEquals("post-office-box", f.getName());
    assertEquals("/post-office-box", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(1);
    assertEquals("extended-address", f.getName());
    assertEquals("/extended-address", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(2);
    assertEquals("street-address", f.getName());
    assertEquals("/street-address", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(3);
    assertEquals("locality", f.getName());
    assertEquals("/locality", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(4);
    assertEquals("region", f.getName());
    assertEquals("/region", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(5);
    assertEquals("postal-code", f.getName());
    assertEquals("/postal-code", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
    f = (JsonField) fields.get(6);
    assertEquals("country-name", f.getName());
    assertEquals("/country-name", f.getPath());
    assertEquals(FieldType.STRING, f.getFieldType());
}
Also used : Field(io.atlasmap.v2.Field) JsonField(io.atlasmap.json.v2.JsonField) JsonField(io.atlasmap.json.v2.JsonField) JsonDocument(io.atlasmap.json.v2.JsonDocument) Test(org.junit.Test)

Aggregations

Field (io.atlasmap.v2.Field)60 JavaField (io.atlasmap.java.v2.JavaField)15 Mapping (io.atlasmap.v2.Mapping)15 AtlasMapping (io.atlasmap.v2.AtlasMapping)14 SimpleField (io.atlasmap.v2.SimpleField)14 BaseMapping (io.atlasmap.v2.BaseMapping)12 JavaEnumField (io.atlasmap.java.v2.JavaEnumField)11 Test (org.junit.Test)11 JsonField (io.atlasmap.json.v2.JsonField)8 LookupTable (io.atlasmap.v2.LookupTable)8 XmlField (io.atlasmap.xml.v2.XmlField)7 AtlasException (io.atlasmap.api.AtlasException)6 ConstantField (io.atlasmap.v2.ConstantField)6 AtlasConversionException (io.atlasmap.api.AtlasConversionException)5 JsonDocument (io.atlasmap.json.v2.JsonDocument)5 PropertyField (io.atlasmap.v2.PropertyField)5 ArrayList (java.util.ArrayList)5 AtlasInternalSession (io.atlasmap.spi.AtlasInternalSession)4 AtlasModule (io.atlasmap.spi.AtlasModule)3 FieldType (io.atlasmap.v2.FieldType)3