Show Data Mapping Model Problems

This example shows you how to detect problems that may be in your data mapping model. Problems can be directly in the DataMapping instance or any of its child elements (like FieldMapping).

For demonstration purposes, a model with existing problems has been intentionally created.

Java Code Listing

package com.northconcepts.datapipeline.foundations.examples.datamapping;

import com.northconcepts.datapipeline.foundations.datamapping.DataMapping;
import com.northconcepts.datapipeline.foundations.datamapping.FieldMapping;

public class ShowDataMappingProblems {

    public static void main(String[] args) {
        DataMapping mapping = createDataMapping();
        System.out.println("----------------Direct DataMapping Problems------------------");
        System.out.println("----------------All DataMapping Problems------------------");

    public static DataMapping createDataMapping() {
                return new DataMapping()
                        .addFieldMapping(new FieldMapping("order", "${source.orderid}"))
                        .addFieldMapping(new FieldMapping("owner", "${source.customerid}"))
                        .addCondition("length(customerid) > 3")
                        .addFieldMapping(new FieldMapping("first_name", "${source.customer_fname}")
                                .setCondition("length(customer_fname) > 3"))
                        .addFieldMapping(new FieldMapping("last_name", "${source.customer_lname}"))
                        .addFieldMapping(new FieldMapping("last_name", "${source.customer_lname}"))
                        .addFieldMapping(new FieldMapping("name", "${target.first_name} + ' ' + ${source.customer_initial} + '. ' +${target.last_name}"))
                        .addFieldMapping(new FieldMapping("phone", "${source.customer-contact}"))
                        .addFieldMapping(new FieldMapping("email", "${source.customer-email}"))
                        .addFieldMapping(new FieldMapping("isActive", "${source.customer-active}"));

Code Walkthrough

  1. createDataMapping() method is used to create the data mapping model with an empty name and different field mappings are added to it.
  2. A duplicate field mapping last_name has also been added which will result in problems as will be seen in the output.
  3. mapping.getDataMappingProblems() will get problems only present in the model not including those in its child elements.
  4. mapping.getDataMappingProblems(true) will get all problems in the model including those in its child elements such as the field mappings.


----------------Direct DataMapping Problems------------------
  "details" : "Required dataMapping name is null or empty"
}, {
  "details" : "Duplicate field mapping \"last_name\""
----------------All DataMapping Problems------------------
  "details" : "Required dataMapping name is null or empty"
}, {
  "details" : "Duplicate field mapping \"last_name\""

All Examples

Mobile Analytics