}
Template template = allTemplateMap.get(templateId);
for (String colName : colValueMap.keySet()) {
Field validField = null;
try {
if (colName.startsWith("field") && colValueMap.get(colName) != null && colValueMap.get(colName).length() > 0) {
String fieldIdStr = "";
if (templateFieldNameCache == null ) {
if (templateFieldNameMap.get(templateId) == null) {
Map<String, String> fieldNameMap = new FieldNameAccessSessionMySQL().queryTemplateFieldMap(templateId.getValue());
templateFieldNameMap.put(templateId, fieldNameMap);
}
fieldIdStr = templateFieldNameMap.get(templateId).get(colName);
}else {
fieldIdStr = templateFieldNameCache.get(colName);
}
UUID fieldId = DataAccessFactory.getInstance().createUUID(fieldIdStr);
validField = template.getField(fieldId);
if (validField == null) {
// System.out.println("can not find field in assembleData ,fieldIdStr :" + fieldIdStr );
continue;
}
if (validField.getType().equals(Type.t_selection))
{
if (validField.getDataType().equals(DataType.dt_single))
{
UUID dataValidId = DataAccessFactory.getInstance().createUUID(colValueMap.get(colName));
objectMapUUID.put(fieldId, dataValidId);
objectMapName.put(validField.getName(), dataValidId);
}
else if (validField.getDataType().equals(DataType.dt_multiple))
{
String [] alldatas = colValueMap.get(colName).split(",");
UUID[] dataValidIds = new UUID[alldatas.length];
for (int i = 0; i < alldatas.length; i++) {
dataValidIds[i] = DataAccessFactory.getInstance().createUUID(alldatas[i]);
}
objectMapUUID.put(fieldId, dataValidIds);
objectMapName.put(validField.getName(), dataValidIds);
}
}
else if (validField.getType().equals(Type.t_reference))
{
if (validField.getDataType().equals(DataType.dt_single))
{
UUID dataValidId = DataAccessFactory.getInstance().createUUID(colValueMap.get(colName));
objectMapUUID.put(fieldId, dataValidId);
objectMapName.put(validField.getName(), dataValidId);
}
else if (validField.getDataType().equals(DataType.dt_multiple))
{
String [] alldatas = colValueMap.get(colName).split(",");
UUID[] dataValidIds = new UUID[alldatas.length];
for (int i = 0; i < alldatas.length; i++) {
dataValidIds[i] = DataAccessFactory.getInstance().createUUID(alldatas[i]);
}
objectMapUUID.put(fieldId, dataValidIds);
objectMapName.put(validField.getName(), dataValidIds);
}
}
else if (validField.getType().equals(Type.t_input))
{
if (validField.getDataType().equals(DataType.dt_integer))
{
objectMapUUID.put(fieldId, Integer.parseInt(colValueMap.get(colName)));
objectMapName.put(validField.getName(), Integer.parseInt(colValueMap.get(colName)));
}
else if (validField.getDataType().equals(DataType.dt_double))
{
objectMapUUID.put(fieldId, Double.parseDouble(colValueMap.get(colName)));
objectMapName.put(validField.getName(), Double.parseDouble(colValueMap.get(colName)));
}
else if (validField.getDataType().equals(DataType.dt_float))
{
objectMapUUID.put(fieldId, Float.parseFloat(colValueMap.get(colName)));
objectMapName.put(validField.getName(), Float.parseFloat(colValueMap.get(colName)));
}
else if (validField.getDataType().equals(DataType.dt_long))
{
objectMapUUID.put(fieldId, Long.parseLong(colValueMap.get(colName)));
objectMapName.put(validField.getName(), Long.parseLong(colValueMap.get(colName)));
}
else if (validField.getDataType().equals(DataType.dt_string) || validField.getDataType().equals(DataType.dt_text) || validField.getDataType().equals(DataType.dt_editor))
{
objectMapUUID.put(fieldId, colValueMap.get(colName));
objectMapName.put(validField.getName(), colValueMap.get(colName));
}
else if(validField.getDataType().equals(DataType.dt_timestamp))
{
Date date = Date.valueOf(colValueMap.get(colName));
objectMapUUID.put(fieldId, date);
objectMapName.put(validField.getName(), date);
}
}
else if (validField.getType().equals(Type.t_attachment))
{
String[] alldatas = colValueMap.get(colName).split(",");
UUID[] dataValidIds = new UUID[alldatas.length];
for (int i = 0; i < alldatas.length; i++) {
dataValidIds[i] = DataAccessFactory.getInstance().createUUID(alldatas[i]);
}
objectMapUUID.put(fieldId, dataValidIds);
objectMapName.put(validField.getName(), dataValidIds);
}
}
} catch (Exception e) {
System.out.println("data assemble error! dataid:" + data.getId().getValue() + " templateid:" + data.getTemplateId().getValue() + " fieldid:" + validField.getId().getValue() );
e.printStackTrace();
}
}
data.setObjectMapUUID(objectMapUUID);