You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by "marta-jankovics (via GitHub)" <gi...@apache.org> on 2023/08/07 20:08:58 UTC
[GitHub] [fineract] marta-jankovics opened a new pull request, #3364: FINERACT-1911: Assign Data Table to Transaction - general
marta-jankovics opened a new pull request, #3364:
URL: https://github.com/apache/fineract/pull/3364
## Description
Describe the changes made and why they were made.
Ignore if these details are present on the associated [Apache Fineract JIRA ticket](https://github.com/apache/fineract/pull/1284).
## Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
- [ ] Write the commit message as per https://github.com/apache/fineract/#pull-requests
- [ ] Acknowledge that we will not review PRs that are not passing the build _("green")_ - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
- [ ] Create/update unit or integration tests for verifying the changes made.
- [ ] Follow coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions.
- [ ] Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
- [ ] Submission is not a "code dump". (Large changes can be made "in repository" via a branch. Ask on the developer mailing list for guidance, if required.)
FYI our guidelines for code reviews are at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [fineract] marta-jankovics commented on a diff in pull request #3364: FINERACT-1911: Assign Data Table to Transaction - general
Posted by "marta-jankovics (via GitHub)" <gi...@apache.org>.
marta-jankovics commented on code in PR #3364:
URL: https://github.com/apache/fineract/pull/3364#discussion_r1289803157
##########
fineract-core/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java:
##########
@@ -270,83 +112,167 @@ public boolean getIsColumnIndexed() {
return isColumnIndexed;
}
- public String getColumnDisplayType() {
+ public DisplayType getColumnDisplayType() {
return this.columnDisplayType;
}
+ public String getColumnCode() {
+ return this.columnCode;
+ }
+
+ public List<ResultsetColumnValueData> getColumnValues() {
+ return this.columnValues;
+ }
+
public boolean isDateDisplayType() {
- return "DATE".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.DATE;
}
public boolean isDateTimeDisplayType() {
- return "DATETIME".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.DATETIME;
+ }
+
+ public boolean isTimeDisplayType() {
+ return columnDisplayType == DisplayType.TIME;
}
public boolean isIntegerDisplayType() {
- return "INTEGER".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.INTEGER;
}
public boolean isDecimalDisplayType() {
- return "DECIMAL".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.DECIMAL;
+ }
+
+ public boolean isStringDisplayType() {
+ return columnDisplayType == DisplayType.STRING;
+ }
+
+ public boolean isTextDisplayType() {
+ return columnDisplayType == DisplayType.TEXT;
}
public boolean isBooleanDisplayType() {
- return "BOOLEAN".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.BOOLEAN;
}
public boolean isCodeValueDisplayType() {
- return "CODEVALUE".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.CODEVALUE;
}
public boolean isCodeLookupDisplayType() {
- return "CODELOOKUP".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.CODELOOKUP;
}
public boolean isMandatory() {
- return !isOptional();
- }
-
- public boolean isOptional() {
- return this.isColumnNullable;
+ return !this.isColumnNullable;
}
public boolean hasColumnValues() {
- return !this.columnValues.isEmpty();
+ return columnValues != null && !columnValues.isEmpty();
}
public boolean isColumnValueAllowed(final String match) {
- boolean allowed = false;
for (final ResultsetColumnValueData allowedValue : this.columnValues) {
if (allowedValue.matches(match)) {
- allowed = true;
+ return true;
}
}
- return allowed;
+ return false;
}
- public boolean isColumnValueNotAllowed(final String match) {
- return !isColumnValueAllowed(match);
+ public boolean isColumnCodeAllowed(final Integer match) {
+ for (final ResultsetColumnValueData allowedValue : this.columnValues) {
+ if (allowedValue.codeMatches(match)) {
+ return true;
+ }
+ }
+ return false;
}
- public boolean isColumnCodeNotAllowed(final Integer match) {
- return !isColumnCodeAllowed(match);
+ public boolean hasPrecision(@NotNull DatabaseType dialect) {
+ return columnType.hasPrecision(dialect);
}
- public boolean isColumnCodeAllowed(final Integer match) {
- boolean allowed = false;
- for (final ResultsetColumnValueData allowedValue : this.columnValues) {
- if (allowedValue.codeMatches(match)) {
- allowed = true;
+ // --- Calculation ---
+
+ private String adjustColumnType(String type) {
+ type = type.toUpperCase();
+ switch (type) {
+ case "CLOB":
+ case "ENUM":
+ case "SET":
+ return "VARCHAR";
+ case "NEWDECIMAL":
+ return "DECIMAL";
+ case "LONGLONG":
+ return "BIGINT";
+ case "SHORT":
+ return "SMALLINT";
+ case "TINY":
+ return "TINYINT";
+ case "INT24":
+ return "INT";
+ default:
+ return type;
+ }
+ }
+
+ @NotNull
+ private DisplayType calcDisplayType() {
+ DisplayType displayType = null;
+ if (this.columnCode == null) {
+ displayType = calcColumnDisplayType(columnType);
+ } else {
+ if (columnType.isIntegerType()) {
+ displayType = DisplayType.CODELOOKUP;
+ } else if (columnType.isVarcharType()) {
+ displayType = DisplayType.CODEVALUE;
}
+
}
- return allowed;
+ if (displayType == null) {
+ throw new PlatformDataIntegrityException("error.msg.invalid.lookup.type",
+ "Invalid Lookup Type:" + this.columnType + " - Column Name: " + this.columnName);
+ }
+ return displayType;
}
- public String getColumnCode() {
- return this.columnCode;
+ public static DisplayType calcColumnDisplayType(JdbcJavaType columnType) {
+ if (columnType.isTextType()) {
+ return DisplayType.TEXT;
+ }
+ if (columnType.isStringType()) {
+ return DisplayType.STRING;
+ }
+ if (columnType.isAnyIntegerType()) {
+ return DisplayType.INTEGER;
+ }
+ if (columnType.isAnyFloatType()) {
+ return DisplayType.FLOAT;
+ }
+ if (columnType.isDecimalType()) { // Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
Review Comment:
I do not use drizzle, this is an old comment. There are 3 other places in fineract still with this comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [fineract] adamsaghy commented on a diff in pull request #3364: FINERACT-1911: Assign Data Table to Transaction - general
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #3364:
URL: https://github.com/apache/fineract/pull/3364#discussion_r1289869795
##########
fineract-core/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java:
##########
@@ -270,83 +112,167 @@ public boolean getIsColumnIndexed() {
return isColumnIndexed;
}
- public String getColumnDisplayType() {
+ public DisplayType getColumnDisplayType() {
return this.columnDisplayType;
}
+ public String getColumnCode() {
+ return this.columnCode;
+ }
+
+ public List<ResultsetColumnValueData> getColumnValues() {
+ return this.columnValues;
+ }
+
public boolean isDateDisplayType() {
- return "DATE".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.DATE;
}
public boolean isDateTimeDisplayType() {
- return "DATETIME".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.DATETIME;
+ }
+
+ public boolean isTimeDisplayType() {
+ return columnDisplayType == DisplayType.TIME;
}
public boolean isIntegerDisplayType() {
- return "INTEGER".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.INTEGER;
}
public boolean isDecimalDisplayType() {
- return "DECIMAL".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.DECIMAL;
+ }
+
+ public boolean isStringDisplayType() {
+ return columnDisplayType == DisplayType.STRING;
+ }
+
+ public boolean isTextDisplayType() {
+ return columnDisplayType == DisplayType.TEXT;
}
public boolean isBooleanDisplayType() {
- return "BOOLEAN".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.BOOLEAN;
}
public boolean isCodeValueDisplayType() {
- return "CODEVALUE".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.CODEVALUE;
}
public boolean isCodeLookupDisplayType() {
- return "CODELOOKUP".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.CODELOOKUP;
}
public boolean isMandatory() {
- return !isOptional();
- }
-
- public boolean isOptional() {
- return this.isColumnNullable;
+ return !this.isColumnNullable;
}
public boolean hasColumnValues() {
- return !this.columnValues.isEmpty();
+ return columnValues != null && !columnValues.isEmpty();
}
public boolean isColumnValueAllowed(final String match) {
- boolean allowed = false;
for (final ResultsetColumnValueData allowedValue : this.columnValues) {
if (allowedValue.matches(match)) {
- allowed = true;
+ return true;
}
}
- return allowed;
+ return false;
}
- public boolean isColumnValueNotAllowed(final String match) {
- return !isColumnValueAllowed(match);
+ public boolean isColumnCodeAllowed(final Integer match) {
+ for (final ResultsetColumnValueData allowedValue : this.columnValues) {
+ if (allowedValue.codeMatches(match)) {
+ return true;
+ }
+ }
+ return false;
}
- public boolean isColumnCodeNotAllowed(final Integer match) {
- return !isColumnCodeAllowed(match);
+ public boolean hasPrecision(@NotNull DatabaseType dialect) {
+ return columnType.hasPrecision(dialect);
}
- public boolean isColumnCodeAllowed(final Integer match) {
- boolean allowed = false;
- for (final ResultsetColumnValueData allowedValue : this.columnValues) {
- if (allowedValue.codeMatches(match)) {
- allowed = true;
+ // --- Calculation ---
+
+ private String adjustColumnType(String type) {
+ type = type.toUpperCase();
+ switch (type) {
+ case "CLOB":
+ case "ENUM":
+ case "SET":
+ return "VARCHAR";
+ case "NEWDECIMAL":
+ return "DECIMAL";
+ case "LONGLONG":
+ return "BIGINT";
+ case "SHORT":
+ return "SMALLINT";
+ case "TINY":
+ return "TINYINT";
+ case "INT24":
+ return "INT";
+ default:
+ return type;
+ }
+ }
+
+ @NotNull
+ private DisplayType calcDisplayType() {
+ DisplayType displayType = null;
+ if (this.columnCode == null) {
+ displayType = calcColumnDisplayType(columnType);
+ } else {
+ if (columnType.isIntegerType()) {
+ displayType = DisplayType.CODELOOKUP;
+ } else if (columnType.isVarcharType()) {
+ displayType = DisplayType.CODEVALUE;
}
+
}
- return allowed;
+ if (displayType == null) {
+ throw new PlatformDataIntegrityException("error.msg.invalid.lookup.type",
+ "Invalid Lookup Type:" + this.columnType + " - Column Name: " + this.columnName);
+ }
+ return displayType;
}
- public String getColumnCode() {
- return this.columnCode;
+ public static DisplayType calcColumnDisplayType(JdbcJavaType columnType) {
+ if (columnType.isTextType()) {
+ return DisplayType.TEXT;
+ }
+ if (columnType.isStringType()) {
+ return DisplayType.STRING;
+ }
+ if (columnType.isAnyIntegerType()) {
+ return DisplayType.INTEGER;
+ }
+ if (columnType.isAnyFloatType()) {
+ return DisplayType.FLOAT;
+ }
+ if (columnType.isDecimalType()) { // Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
Review Comment:
I was wondering whether this comment can be removed then, also whether the isDecimal check is up to date for mysql connector / mariadb connector and postgres connector.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [fineract] marta-jankovics commented on a diff in pull request #3364: FINERACT-1911: Assign Data Table to Transaction - general
Posted by "marta-jankovics (via GitHub)" <gi...@apache.org>.
marta-jankovics commented on code in PR #3364:
URL: https://github.com/apache/fineract/pull/3364#discussion_r1289886423
##########
fineract-core/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java:
##########
@@ -270,83 +112,167 @@ public boolean getIsColumnIndexed() {
return isColumnIndexed;
}
- public String getColumnDisplayType() {
+ public DisplayType getColumnDisplayType() {
return this.columnDisplayType;
}
+ public String getColumnCode() {
+ return this.columnCode;
+ }
+
+ public List<ResultsetColumnValueData> getColumnValues() {
+ return this.columnValues;
+ }
+
public boolean isDateDisplayType() {
- return "DATE".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.DATE;
}
public boolean isDateTimeDisplayType() {
- return "DATETIME".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.DATETIME;
+ }
+
+ public boolean isTimeDisplayType() {
+ return columnDisplayType == DisplayType.TIME;
}
public boolean isIntegerDisplayType() {
- return "INTEGER".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.INTEGER;
}
public boolean isDecimalDisplayType() {
- return "DECIMAL".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.DECIMAL;
+ }
+
+ public boolean isStringDisplayType() {
+ return columnDisplayType == DisplayType.STRING;
+ }
+
+ public boolean isTextDisplayType() {
+ return columnDisplayType == DisplayType.TEXT;
}
public boolean isBooleanDisplayType() {
- return "BOOLEAN".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.BOOLEAN;
}
public boolean isCodeValueDisplayType() {
- return "CODEVALUE".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.CODEVALUE;
}
public boolean isCodeLookupDisplayType() {
- return "CODELOOKUP".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.CODELOOKUP;
}
public boolean isMandatory() {
- return !isOptional();
- }
-
- public boolean isOptional() {
- return this.isColumnNullable;
+ return !this.isColumnNullable;
}
public boolean hasColumnValues() {
- return !this.columnValues.isEmpty();
+ return columnValues != null && !columnValues.isEmpty();
}
public boolean isColumnValueAllowed(final String match) {
- boolean allowed = false;
for (final ResultsetColumnValueData allowedValue : this.columnValues) {
if (allowedValue.matches(match)) {
- allowed = true;
+ return true;
}
}
- return allowed;
+ return false;
}
- public boolean isColumnValueNotAllowed(final String match) {
- return !isColumnValueAllowed(match);
+ public boolean isColumnCodeAllowed(final Integer match) {
+ for (final ResultsetColumnValueData allowedValue : this.columnValues) {
+ if (allowedValue.codeMatches(match)) {
+ return true;
+ }
+ }
+ return false;
}
- public boolean isColumnCodeNotAllowed(final Integer match) {
- return !isColumnCodeAllowed(match);
+ public boolean hasPrecision(@NotNull DatabaseType dialect) {
+ return columnType.hasPrecision(dialect);
}
- public boolean isColumnCodeAllowed(final Integer match) {
- boolean allowed = false;
- for (final ResultsetColumnValueData allowedValue : this.columnValues) {
- if (allowedValue.codeMatches(match)) {
- allowed = true;
+ // --- Calculation ---
+
+ private String adjustColumnType(String type) {
+ type = type.toUpperCase();
+ switch (type) {
+ case "CLOB":
+ case "ENUM":
+ case "SET":
+ return "VARCHAR";
+ case "NEWDECIMAL":
+ return "DECIMAL";
+ case "LONGLONG":
+ return "BIGINT";
+ case "SHORT":
+ return "SMALLINT";
+ case "TINY":
+ return "TINYINT";
+ case "INT24":
+ return "INT";
+ default:
+ return type;
+ }
+ }
+
+ @NotNull
+ private DisplayType calcDisplayType() {
+ DisplayType displayType = null;
+ if (this.columnCode == null) {
+ displayType = calcColumnDisplayType(columnType);
+ } else {
+ if (columnType.isIntegerType()) {
+ displayType = DisplayType.CODELOOKUP;
+ } else if (columnType.isVarcharType()) {
+ displayType = DisplayType.CODEVALUE;
}
+
}
- return allowed;
+ if (displayType == null) {
+ throw new PlatformDataIntegrityException("error.msg.invalid.lookup.type",
+ "Invalid Lookup Type:" + this.columnType + " - Column Name: " + this.columnName);
+ }
+ return displayType;
}
- public String getColumnCode() {
- return this.columnCode;
+ public static DisplayType calcColumnDisplayType(JdbcJavaType columnType) {
+ if (columnType.isTextType()) {
+ return DisplayType.TEXT;
+ }
+ if (columnType.isStringType()) {
+ return DisplayType.STRING;
+ }
+ if (columnType.isAnyIntegerType()) {
+ return DisplayType.INTEGER;
+ }
+ if (columnType.isAnyFloatType()) {
+ return DisplayType.FLOAT;
+ }
+ if (columnType.isDecimalType()) { // Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
Review Comment:
The isDecimal check is correct, because JdbcJavaType is dialect independent/aware.
I would not update this PR just for an old code comment removal, but next time when I touch this code I'll take care.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [fineract] adamsaghy commented on a diff in pull request #3364: FINERACT-1911: Assign Data Table to Transaction - general
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #3364:
URL: https://github.com/apache/fineract/pull/3364#discussion_r1289684248
##########
fineract-core/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java:
##########
@@ -270,83 +112,167 @@ public boolean getIsColumnIndexed() {
return isColumnIndexed;
}
- public String getColumnDisplayType() {
+ public DisplayType getColumnDisplayType() {
return this.columnDisplayType;
}
+ public String getColumnCode() {
+ return this.columnCode;
+ }
+
+ public List<ResultsetColumnValueData> getColumnValues() {
+ return this.columnValues;
+ }
+
public boolean isDateDisplayType() {
- return "DATE".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.DATE;
}
public boolean isDateTimeDisplayType() {
- return "DATETIME".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.DATETIME;
+ }
+
+ public boolean isTimeDisplayType() {
+ return columnDisplayType == DisplayType.TIME;
}
public boolean isIntegerDisplayType() {
- return "INTEGER".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.INTEGER;
}
public boolean isDecimalDisplayType() {
- return "DECIMAL".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.DECIMAL;
+ }
+
+ public boolean isStringDisplayType() {
+ return columnDisplayType == DisplayType.STRING;
+ }
+
+ public boolean isTextDisplayType() {
+ return columnDisplayType == DisplayType.TEXT;
}
public boolean isBooleanDisplayType() {
- return "BOOLEAN".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.BOOLEAN;
}
public boolean isCodeValueDisplayType() {
- return "CODEVALUE".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.CODEVALUE;
}
public boolean isCodeLookupDisplayType() {
- return "CODELOOKUP".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.CODELOOKUP;
}
public boolean isMandatory() {
- return !isOptional();
- }
-
- public boolean isOptional() {
- return this.isColumnNullable;
+ return !this.isColumnNullable;
}
public boolean hasColumnValues() {
- return !this.columnValues.isEmpty();
+ return columnValues != null && !columnValues.isEmpty();
}
public boolean isColumnValueAllowed(final String match) {
- boolean allowed = false;
for (final ResultsetColumnValueData allowedValue : this.columnValues) {
if (allowedValue.matches(match)) {
- allowed = true;
+ return true;
}
}
- return allowed;
+ return false;
}
- public boolean isColumnValueNotAllowed(final String match) {
- return !isColumnValueAllowed(match);
+ public boolean isColumnCodeAllowed(final Integer match) {
+ for (final ResultsetColumnValueData allowedValue : this.columnValues) {
+ if (allowedValue.codeMatches(match)) {
+ return true;
+ }
+ }
+ return false;
}
- public boolean isColumnCodeNotAllowed(final Integer match) {
- return !isColumnCodeAllowed(match);
+ public boolean hasPrecision(@NotNull DatabaseType dialect) {
+ return columnType.hasPrecision(dialect);
}
- public boolean isColumnCodeAllowed(final Integer match) {
- boolean allowed = false;
- for (final ResultsetColumnValueData allowedValue : this.columnValues) {
- if (allowedValue.codeMatches(match)) {
- allowed = true;
+ // --- Calculation ---
+
+ private String adjustColumnType(String type) {
+ type = type.toUpperCase();
+ switch (type) {
+ case "CLOB":
+ case "ENUM":
+ case "SET":
+ return "VARCHAR";
+ case "NEWDECIMAL":
+ return "DECIMAL";
+ case "LONGLONG":
+ return "BIGINT";
+ case "SHORT":
+ return "SMALLINT";
+ case "TINY":
+ return "TINYINT";
+ case "INT24":
+ return "INT";
+ default:
+ return type;
+ }
+ }
+
+ @NotNull
+ private DisplayType calcDisplayType() {
+ DisplayType displayType = null;
+ if (this.columnCode == null) {
+ displayType = calcColumnDisplayType(columnType);
+ } else {
+ if (columnType.isIntegerType()) {
+ displayType = DisplayType.CODELOOKUP;
+ } else if (columnType.isVarcharType()) {
+ displayType = DisplayType.CODEVALUE;
}
+
}
- return allowed;
+ if (displayType == null) {
+ throw new PlatformDataIntegrityException("error.msg.invalid.lookup.type",
+ "Invalid Lookup Type:" + this.columnType + " - Column Name: " + this.columnName);
+ }
+ return displayType;
}
- public String getColumnCode() {
- return this.columnCode;
+ public static DisplayType calcColumnDisplayType(JdbcJavaType columnType) {
+ if (columnType.isTextType()) {
+ return DisplayType.TEXT;
+ }
+ if (columnType.isStringType()) {
+ return DisplayType.STRING;
+ }
+ if (columnType.isAnyIntegerType()) {
+ return DisplayType.INTEGER;
+ }
+ if (columnType.isAnyFloatType()) {
+ return DisplayType.FLOAT;
+ }
+ if (columnType.isDecimalType()) { // Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
Review Comment:
we are not using drizzle anymore.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [fineract] adamsaghy commented on a diff in pull request #3364: FINERACT-1911: Assign Data Table to Transaction - general
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #3364:
URL: https://github.com/apache/fineract/pull/3364#discussion_r1289869795
##########
fineract-core/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/ResultsetColumnHeaderData.java:
##########
@@ -270,83 +112,167 @@ public boolean getIsColumnIndexed() {
return isColumnIndexed;
}
- public String getColumnDisplayType() {
+ public DisplayType getColumnDisplayType() {
return this.columnDisplayType;
}
+ public String getColumnCode() {
+ return this.columnCode;
+ }
+
+ public List<ResultsetColumnValueData> getColumnValues() {
+ return this.columnValues;
+ }
+
public boolean isDateDisplayType() {
- return "DATE".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.DATE;
}
public boolean isDateTimeDisplayType() {
- return "DATETIME".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.DATETIME;
+ }
+
+ public boolean isTimeDisplayType() {
+ return columnDisplayType == DisplayType.TIME;
}
public boolean isIntegerDisplayType() {
- return "INTEGER".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.INTEGER;
}
public boolean isDecimalDisplayType() {
- return "DECIMAL".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.DECIMAL;
+ }
+
+ public boolean isStringDisplayType() {
+ return columnDisplayType == DisplayType.STRING;
+ }
+
+ public boolean isTextDisplayType() {
+ return columnDisplayType == DisplayType.TEXT;
}
public boolean isBooleanDisplayType() {
- return "BOOLEAN".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.BOOLEAN;
}
public boolean isCodeValueDisplayType() {
- return "CODEVALUE".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.CODEVALUE;
}
public boolean isCodeLookupDisplayType() {
- return "CODELOOKUP".equalsIgnoreCase(this.columnDisplayType);
+ return columnDisplayType == DisplayType.CODELOOKUP;
}
public boolean isMandatory() {
- return !isOptional();
- }
-
- public boolean isOptional() {
- return this.isColumnNullable;
+ return !this.isColumnNullable;
}
public boolean hasColumnValues() {
- return !this.columnValues.isEmpty();
+ return columnValues != null && !columnValues.isEmpty();
}
public boolean isColumnValueAllowed(final String match) {
- boolean allowed = false;
for (final ResultsetColumnValueData allowedValue : this.columnValues) {
if (allowedValue.matches(match)) {
- allowed = true;
+ return true;
}
}
- return allowed;
+ return false;
}
- public boolean isColumnValueNotAllowed(final String match) {
- return !isColumnValueAllowed(match);
+ public boolean isColumnCodeAllowed(final Integer match) {
+ for (final ResultsetColumnValueData allowedValue : this.columnValues) {
+ if (allowedValue.codeMatches(match)) {
+ return true;
+ }
+ }
+ return false;
}
- public boolean isColumnCodeNotAllowed(final Integer match) {
- return !isColumnCodeAllowed(match);
+ public boolean hasPrecision(@NotNull DatabaseType dialect) {
+ return columnType.hasPrecision(dialect);
}
- public boolean isColumnCodeAllowed(final Integer match) {
- boolean allowed = false;
- for (final ResultsetColumnValueData allowedValue : this.columnValues) {
- if (allowedValue.codeMatches(match)) {
- allowed = true;
+ // --- Calculation ---
+
+ private String adjustColumnType(String type) {
+ type = type.toUpperCase();
+ switch (type) {
+ case "CLOB":
+ case "ENUM":
+ case "SET":
+ return "VARCHAR";
+ case "NEWDECIMAL":
+ return "DECIMAL";
+ case "LONGLONG":
+ return "BIGINT";
+ case "SHORT":
+ return "SMALLINT";
+ case "TINY":
+ return "TINYINT";
+ case "INT24":
+ return "INT";
+ default:
+ return type;
+ }
+ }
+
+ @NotNull
+ private DisplayType calcDisplayType() {
+ DisplayType displayType = null;
+ if (this.columnCode == null) {
+ displayType = calcColumnDisplayType(columnType);
+ } else {
+ if (columnType.isIntegerType()) {
+ displayType = DisplayType.CODELOOKUP;
+ } else if (columnType.isVarcharType()) {
+ displayType = DisplayType.CODEVALUE;
}
+
}
- return allowed;
+ if (displayType == null) {
+ throw new PlatformDataIntegrityException("error.msg.invalid.lookup.type",
+ "Invalid Lookup Type:" + this.columnType + " - Column Name: " + this.columnName);
+ }
+ return displayType;
}
- public String getColumnCode() {
- return this.columnCode;
+ public static DisplayType calcColumnDisplayType(JdbcJavaType columnType) {
+ if (columnType.isTextType()) {
+ return DisplayType.TEXT;
+ }
+ if (columnType.isStringType()) {
+ return DisplayType.STRING;
+ }
+ if (columnType.isAnyIntegerType()) {
+ return DisplayType.INTEGER;
+ }
+ if (columnType.isAnyFloatType()) {
+ return DisplayType.FLOAT;
+ }
+ if (columnType.isDecimalType()) { // Refer org.drizzle.jdbc.internal.mysql.MySQLType.java
Review Comment:
I was wondering whether this comment can be removed then, also whether the isDecimalType check is up to date for mysql connector / mariadb connector and postgres connector.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [fineract] adamsaghy merged pull request #3364: FINERACT-1911: Assign Data Table to Transaction - general
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy merged PR #3364:
URL: https://github.com/apache/fineract/pull/3364
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org