/**
* Sets the multiple row data in the data table to the data session buffer
*
* <pre>
* ##################################
* AUTOGENERATED CODE
* ##################################
* </pre>
*
* @param dataSession
* The dataSession instance, which is the container for SDK
* handles.
* @param dataTable
* List of List of Objects. Each List of Objects represents a
* single row.
*/
public void setProcDataToPlatform(DataSession dataSession, List<List<Object>> dataTable) throws SDKException {
for (int row = 0; row < dataTable.size(); row++) {
List<Object> rowData = dataTable.get(row);
for (int col = 0; col < dataTable.get(0).size(); col++) {
DataAttributes pDataAttributes = new DataAttributes();
pDataAttributes.setDataSetId(0);
pDataAttributes.setColumnIndex(col);
pDataAttributes.setRowIndex(row);
Object data = rowData.get(col);
String dataType = sfList.get(col).getDataType();
String columnName = sfList.get(col).getName();
if (dataType.equalsIgnoreCase("string") || dataType.equalsIgnoreCase("text")) {
if (data == null) {
pDataAttributes.setLength(0);
dataSession.setStringData((String) data, pDataAttributes);
} else {
String text = data.toString();
int fieldLength = sfList.get(col).getPrecision();
if (text.length() > fieldLength) {
pDataAttributes.setLength(fieldLength);
pDataAttributes.setIndicator(EIndicator.TRUNCATED);
dataSession.setStringData(text.substring(0, fieldLength), pDataAttributes);
} else {
pDataAttributes.setLength(text.length());
pDataAttributes.setIndicator(EIndicator.VALID);
}
dataSession.setStringData(text, pDataAttributes);
}
} else if (dataType.compareToIgnoreCase("double") == 0) {
if (data instanceof Double) {
pDataAttributes.setIndicator(EIndicator.VALID);
} else if (data instanceof Number) {
pDataAttributes.setIndicator(EIndicator.VALID);
data = ((Number) data).doubleValue();
} else if (data == null) {
pDataAttributes.setIndicator(EIndicator.NULL);
} else {
logger.logMessage(EMessageLevel.MSG_ERROR, ELogLevel.TRACE_NONE,
"Data for column [" + columnName + "] of type [" + dataType + "] "
+ "should be a of type [" + Number.class.getName() + "] or its sub-types.");
data = null;
}
dataSession.setDoubleData((Double) data, pDataAttributes);
} else if (dataType.compareToIgnoreCase("float") == 0) {
if (data instanceof Float) {
pDataAttributes.setIndicator(EIndicator.VALID);
} else if (data instanceof Number) {
pDataAttributes.setIndicator(EIndicator.VALID);
data = ((Number) data).floatValue();
} else if (data == null) {
pDataAttributes.setIndicator(EIndicator.NULL);
} else {
logger.logMessage(EMessageLevel.MSG_ERROR, ELogLevel.TRACE_NONE,
"Data for column [" + columnName + "] of type [" + dataType + "] "
+ "should be a of type [" + Number.class.getName() + "] or its sub-types.");
data = null;
}
dataSession.setFloatData((Float) data, pDataAttributes);
} else if (dataType.compareToIgnoreCase("long") == 0) {
if (data instanceof Long) {
pDataAttributes.setIndicator(EIndicator.VALID);
} else if (data instanceof Number) {
pDataAttributes.setIndicator(EIndicator.VALID);
data = ((Number) data).longValue();
} else if (data == null) {
pDataAttributes.setIndicator(EIndicator.NULL);
} else {
logger.logMessage(EMessageLevel.MSG_ERROR, ELogLevel.TRACE_NONE,
"Data for column [" + columnName + "] of type [" + dataType + "] "
+ "should be a of type [" + Number.class.getName() + "] or its sub-types.");
data = null;
}
dataSession.setLongData((Long) data, pDataAttributes);
} else if (dataType.compareToIgnoreCase("short") == 0) {
if (data instanceof Short)
pDataAttributes.setIndicator(EIndicator.VALID);
else if (data instanceof Number) {
pDataAttributes.setIndicator(EIndicator.VALID);
data = ((Number) data).shortValue();
} else if (data == null) {
pDataAttributes.setIndicator(EIndicator.NULL);
} else {
logger.logMessage(EMessageLevel.MSG_ERROR, ELogLevel.TRACE_NONE,
"Data for column [" + columnName + "] of type [" + dataType + "] "
+ "should be a of type [" + Number.class.getName() + "] or its sub-types.");
data = null;
}
dataSession.setShortData((Short) data, pDataAttributes);
} else if (dataType.compareToIgnoreCase("integer") == 0) {
if (data instanceof Integer) {
pDataAttributes.setIndicator(EIndicator.VALID);
} else if (data instanceof Number) {
pDataAttributes.setIndicator(EIndicator.VALID);
data = ((Number) data).intValue();
} else if (data == null) {
pDataAttributes.setIndicator(EIndicator.NULL);
} else {
logger.logMessage(EMessageLevel.MSG_ERROR, ELogLevel.TRACE_NONE,
"Data for column [" + columnName + "] of type [" + dataType + "] "
+ "should be a of type [" + Number.class.getName() + "] or its sub-types.");
data = null;
}
dataSession.setIntData((Integer) data, pDataAttributes);
} else if (dataType.compareToIgnoreCase("bigint") == 0) {
if (data instanceof Long) {
pDataAttributes.setIndicator(EIndicator.VALID);
} else if (data instanceof Number) {
pDataAttributes.setIndicator(EIndicator.VALID);
data = ((Number) data).longValue();
} else if (data == null) {
pDataAttributes.setIndicator(EIndicator.NULL);
} else {
logger.logMessage(EMessageLevel.MSG_ERROR, ELogLevel.TRACE_NONE,
"Data for column [" + columnName + "] of type [" + dataType + "] "
+ "should be a of type [" + Number.class.getName() + "] or its sub-types.");
data = null;
}
dataSession.setLongData((Long) data, pDataAttributes);
} else if (dataType.compareToIgnoreCase("date/time") == 0) {
if (data instanceof Timestamp) {
pDataAttributes.setIndicator(EIndicator.VALID);
} else if (data instanceof Date) {
pDataAttributes.setIndicator(EIndicator.VALID);
Timestamp ts = new Timestamp(((Date) data).getTime());
data = ts;
} else if (data instanceof Time) {
pDataAttributes.setIndicator(EIndicator.VALID);
Timestamp ts = new Timestamp(((Time) data).getTime());
data = ts;
} else if (data == null) {
pDataAttributes.setIndicator(EIndicator.NULL);
} else {
logger.logMessage(EMessageLevel.MSG_ERROR, ELogLevel.TRACE_NONE,
"Data for column [" + columnName + "] of type [" + dataType + "]"
+ " should be a of type [" + Timestamp.class.getName() + "].");
data = null;
}
dataSession.setDateTimeData((Timestamp) data, pDataAttributes);
} else if (dataType.compareToIgnoreCase("binary") == 0) {
if (data instanceof byte[]) {
pDataAttributes.setLength(((byte[]) data).length);
pDataAttributes.setIndicator(EIndicator.VALID);
} else if (data == null) {
pDataAttributes.setIndicator(EIndicator.NULL);
} else {
logger.logMessage(EMessageLevel.MSG_DEBUG, ELogLevel.TRACE_VERBOSE_DATA, "Data for type ["
+ dataType + "] should be a of type [" + byte[].class.getName() + "].");
data = null;
}
dataSession.setBinaryData((byte[]) data, pDataAttributes);
} else if (dataType.compareToIgnoreCase("decimal") == 0) {
if (data instanceof BigDecimal) {
pDataAttributes.setIndicator(EIndicator.VALID);
} else if (data == null) {
pDataAttributes.setIndicator(EIndicator.NULL);
} else {
logger.logMessage(EMessageLevel.MSG_DEBUG, ELogLevel.TRACE_VERBOSE_DATA, "Data for type ["
+ dataType + "] should be a of type [" + BigDecimal.class.getName() + "].");
data = null;
}
dataSession.setBigDecimalData((BigDecimal) data, pDataAttributes);
}
}
}
}