Data normalization

The mapping file is loaded by the MobilityConfig class and is accessed by using either the getMapping_list() method or the getPos_mapping_list() method. The getPos_mapping_list() method returns data mapping for the CSV format data, and the getMapping_list() method returns data mapping for data that is in the XML or URL format.

The following code example normalizes car probe data in CSV format and calls a process class that uses the normalized parameters:

this.pos_mapping_list = config.getPos_mapping_list();

Mapping m = pos_mapping_list.get(data[0]);
HashMap<String,String> list = (m != null) ? m.getList() : null;
String[] data = csvLine.split(",");

// normalize data model
IDataParameters parameters =
        new CarProbeParameters(mm, def_n_tenant, def_tenant, config.getRm());
if(parameters.getPosParameters(data, list)) {
    if(parameters.isAsync()) {
        // Async call
    } else {
        // call process asynchronously
        IProbeDataProcess p = m.getP_process();
        Collection<Action> actions =
            (Collection<Action>) p.processCarProbe((CarProbeParameters)parameters);
                 :
    }
}

The following code example normalizes XML formatted car probe data and also calls a process module that uses the normalized parameters:

this. mapping_list = config.getMapping_list();

Mapping m = mapping_list.get(cmd);

// normalize data model
IDataParameters parameters =
    new CarProbeParameters(mm, def_n_tenant, def_tenant, config.getRm());
if(parameters.getParameters(headers, data, mapping_list)) {
    if(parameters.isAsync()) {
        // Async call
    } else {
        // call process asynchronously
        ProbeDataProcess p = m.getP_process();
        Collection<Action> actions =
            (Collection<Action>) p.processCarProbe((CarProbeParameters)parameters);
                 :
    }
}

The implementation class of IDataParameters is an input of a process module. It converts data, checks the validity of the values, and stores the values.

The following table shows the standard implementations of the IDataParameters class:

Command IDataParameters implementation class
SEND_CAR_PROBE com.ibm.mobility.autodrive.parameter.CarProbeParameters
SEND_EVENT com.ibm.mobility.autodrive.parameter.SendEventParameters
QUERY_EVENT com.ibm.mobility.autodrive.parameter.QueryEventParameters