wip data tables
This commit is contained in:
+69
-1
@@ -3,16 +3,23 @@ package org.mifosng.platform.api.data;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.mifosng.platform.exceptions.PlatformDataIntegrityException;
|
||||||
|
|
||||||
public class ResultsetColumnHeader {
|
public class ResultsetColumnHeader {
|
||||||
|
|
||||||
private String columnName;
|
private String columnName;
|
||||||
private String columnType;
|
private String columnType;
|
||||||
private Long columnLength;
|
private Long columnLength;
|
||||||
|
private String columnDisplayTypeNew;
|
||||||
|
// TODO - remove columnDisplayType when Additional Fields functionality
|
||||||
|
// removed and rename columnDisplayTypeNew to columnDisplayType
|
||||||
private String columnDisplayType;
|
private String columnDisplayType;
|
||||||
private boolean isColumnNullable;
|
private boolean isColumnNullable;
|
||||||
private boolean isColumnPrimaryKey;
|
private boolean isColumnPrimaryKey;
|
||||||
private List<String> columnValues = new ArrayList<String>();
|
|
||||||
private List<ResultsetColumnValue> columnValuesNew = new ArrayList<ResultsetColumnValue>();
|
private List<ResultsetColumnValue> columnValuesNew = new ArrayList<ResultsetColumnValue>();
|
||||||
|
// TODO - remove columnValues when Additional Fields functionality removed
|
||||||
|
// and rename columnValuesNew to columnValues
|
||||||
|
private List<String> columnValues = new ArrayList<String>();
|
||||||
|
|
||||||
public ResultsetColumnHeader() {
|
public ResultsetColumnHeader() {
|
||||||
|
|
||||||
@@ -82,4 +89,65 @@ public class ResultsetColumnHeader {
|
|||||||
this.isColumnPrimaryKey = isColumnPrimaryKey;
|
this.isColumnPrimaryKey = isColumnPrimaryKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getColumnDisplayTypeNew() {
|
||||||
|
return columnDisplayTypeNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColumnDisplayTypeNew() {
|
||||||
|
|
||||||
|
if (this.getColumnValuesNew().size() > 0) {
|
||||||
|
|
||||||
|
if (this.getColumnType().equalsIgnoreCase("int")) {
|
||||||
|
this.columnDisplayTypeNew = "CODELOOKUP";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.getColumnType().equalsIgnoreCase("varchar")) {
|
||||||
|
this.columnDisplayTypeNew = "CODEVALUE";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new PlatformDataIntegrityException(
|
||||||
|
"error.msg.invalid.lookup.type", "Invalid Lookup Type:"
|
||||||
|
+ this.getColumnType() + " - Column Name: "
|
||||||
|
+ this.getColumnName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getColumnType().equalsIgnoreCase("varchar") || this.getColumnType().equalsIgnoreCase("char")) {
|
||||||
|
this.columnDisplayTypeNew = "STRING";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getColumnType().equalsIgnoreCase("int")
|
||||||
|
|| this.getColumnType().equalsIgnoreCase("bigint")
|
||||||
|
|| this.getColumnType().equalsIgnoreCase("smallint")
|
||||||
|
|| this.getColumnType().equalsIgnoreCase("mediumint")
|
||||||
|
|| this.getColumnType().equalsIgnoreCase("tinyint")) {
|
||||||
|
this.columnDisplayTypeNew = "INTEGER";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getColumnType().equalsIgnoreCase("date")) {
|
||||||
|
this.columnDisplayTypeNew = "DATE";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getColumnType().equalsIgnoreCase("decimal")) {
|
||||||
|
this.columnDisplayTypeNew = "DECIMAL";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getColumnType().equalsIgnoreCase("text")
|
||||||
|
|| this.getColumnType().equalsIgnoreCase("mediumtext")
|
||||||
|
|| this.getColumnType().equalsIgnoreCase("longtext")
|
||||||
|
|| this.getColumnType().equalsIgnoreCase("tinytext")) {
|
||||||
|
this.columnDisplayTypeNew = "TEXT";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new PlatformDataIntegrityException(
|
||||||
|
"error.msg.unsupported.column.type", "Unsupported Column Type:"
|
||||||
|
+ this.getColumnType() + " - Column Name: "
|
||||||
|
+ this.getColumnName());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-18
@@ -465,8 +465,6 @@ public class ReadWriteNonCoreDataServiceImpl implements
|
|||||||
|
|
||||||
rsch.setColumnType(columnDefinitions.getString("DATA_TYPE"));
|
rsch.setColumnType(columnDefinitions.getString("DATA_TYPE"));
|
||||||
|
|
||||||
rsch.setColumnDisplayType(null);
|
|
||||||
|
|
||||||
/* look for codes */
|
/* look for codes */
|
||||||
if (rsch.getColumnType().equalsIgnoreCase("varchar"))
|
if (rsch.getColumnType().equalsIgnoreCase("varchar"))
|
||||||
addCodesValueIfNecessary(rsch, "_cv");
|
addCodesValueIfNecessary(rsch, "_cv");
|
||||||
@@ -474,6 +472,8 @@ public class ReadWriteNonCoreDataServiceImpl implements
|
|||||||
if (rsch.getColumnType().equalsIgnoreCase("int"))
|
if (rsch.getColumnType().equalsIgnoreCase("int"))
|
||||||
addCodesValueIfNecessary(rsch, "_cd");
|
addCodesValueIfNecessary(rsch, "_cd");
|
||||||
|
|
||||||
|
rsch.setColumnDisplayTypeNew();
|
||||||
|
|
||||||
columnHeaders.add(rsch);
|
columnHeaders.add(rsch);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@@ -539,15 +539,11 @@ public class ReadWriteNonCoreDataServiceImpl implements
|
|||||||
|
|
||||||
writer.append('\"' + columnHeaders.get(j).getColumnName()
|
writer.append('\"' + columnHeaders.get(j).getColumnName()
|
||||||
+ '\"' + ": ");
|
+ '\"' + ": ");
|
||||||
currColType = columnHeaders.get(j).getColumnType();
|
currColType = columnHeaders.get(j).getColumnDisplayTypeNew();
|
||||||
currVal = row.get(j);
|
currVal = row.get(j);
|
||||||
if (currVal != null) {
|
if (currVal != null) {
|
||||||
if (currColType.equals("DECIMAL")
|
if (currColType.equals("DECIMAL")
|
||||||
|| currColType.equals("DOUBLE")
|
|| currColType.equals("INTEGER"))
|
||||||
|| currColType.equals("BIGINT")
|
|
||||||
|| currColType.equals("SMALLINT")
|
|
||||||
|| currColType.equals("TINYINT")
|
|
||||||
|| currColType.equals("INT"))
|
|
||||||
writer.append(currVal);
|
writer.append(currVal);
|
||||||
else
|
else
|
||||||
writer.append('\"' + currVal + '\"');
|
writer.append('\"' + currVal + '\"');
|
||||||
@@ -781,7 +777,7 @@ public class ReadWriteNonCoreDataServiceImpl implements
|
|||||||
// match code value or id
|
// match code value or id
|
||||||
List<ResultsetColumnValue> allowedValues = columnHeader
|
List<ResultsetColumnValue> allowedValues = columnHeader
|
||||||
.getColumnValuesNew();
|
.getColumnValuesNew();
|
||||||
if (columnHeader.getColumnType().equalsIgnoreCase("varchar")) {
|
if (columnHeader.getColumnDisplayTypeNew().equals("CODEVALUE")) {
|
||||||
for (ResultsetColumnValue allowedValue : allowedValues) {
|
for (ResultsetColumnValue allowedValue : allowedValues) {
|
||||||
if (paramValue
|
if (paramValue
|
||||||
.equalsIgnoreCase(allowedValue.getValue()))
|
.equalsIgnoreCase(allowedValue.getValue()))
|
||||||
@@ -799,7 +795,7 @@ public class ReadWriteNonCoreDataServiceImpl implements
|
|||||||
"Validation errors exist.", dataValidationErrors);
|
"Validation errors exist.", dataValidationErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columnHeader.getColumnType().equalsIgnoreCase("int")) {
|
if (columnHeader.getColumnDisplayTypeNew().equals("CODELOOKUP")) {
|
||||||
for (ResultsetColumnValue allowedValue : allowedValues) {
|
for (ResultsetColumnValue allowedValue : allowedValues) {
|
||||||
if (paramValue.equals(Integer.toString(allowedValue
|
if (paramValue.equals(Integer.toString(allowedValue
|
||||||
.getId())))
|
.getId())))
|
||||||
@@ -816,6 +812,7 @@ public class ReadWriteNonCoreDataServiceImpl implements
|
|||||||
"validation.msg.validation.errors.exist",
|
"validation.msg.validation.errors.exist",
|
||||||
"Validation errors exist.", dataValidationErrors);
|
"Validation errors exist.", dataValidationErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new PlatformDataIntegrityException(
|
throw new PlatformDataIntegrityException(
|
||||||
"error.msg.invalid.columnType.", "Code: "
|
"error.msg.invalid.columnType.", "Code: "
|
||||||
+ columnHeader.getColumnName()
|
+ columnHeader.getColumnName()
|
||||||
@@ -824,22 +821,17 @@ public class ReadWriteNonCoreDataServiceImpl implements
|
|||||||
+ " (neither varchar nor int)");
|
+ " (neither varchar nor int)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columnHeader.getColumnType().equalsIgnoreCase("date"))
|
if (columnHeader.getColumnDisplayTypeNew().equals("DATE"))
|
||||||
paramValue = convertFrom(paramValue,
|
paramValue = convertFrom(paramValue,
|
||||||
columnHeader.getColumnName(), dateFormat,
|
columnHeader.getColumnName(), dateFormat,
|
||||||
clientApplicationLocale).toString();
|
clientApplicationLocale).toString();
|
||||||
|
|
||||||
if (columnHeader.getColumnType().equalsIgnoreCase("bigint")
|
if (columnHeader.getColumnDisplayTypeNew().equals("INTEGER"))
|
||||||
|| columnHeader.getColumnType()
|
|
||||||
.equalsIgnoreCase("smallint")
|
|
||||||
|| columnHeader.getColumnType().equalsIgnoreCase("tinyint")
|
|
||||||
|| columnHeader.getColumnType().equalsIgnoreCase("int"))
|
|
||||||
paramValue = convertToInteger(paramValue,
|
paramValue = convertToInteger(paramValue,
|
||||||
columnHeader.getColumnName(), clientApplicationLocale)
|
columnHeader.getColumnName(), clientApplicationLocale)
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
if (columnHeader.getColumnType().equalsIgnoreCase("decimal")
|
if (columnHeader.getColumnDisplayTypeNew().equals("DECIMAL"))
|
||||||
|| columnHeader.getColumnType().equalsIgnoreCase("long"))
|
|
||||||
paramValue = convertFrom(paramValue,
|
paramValue = convertFrom(paramValue,
|
||||||
columnHeader.getColumnName(), clientApplicationLocale)
|
columnHeader.getColumnName(), clientApplicationLocale)
|
||||||
.toString();
|
.toString();
|
||||||
|
|||||||
Reference in New Issue
Block a user