-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from wavemaker/dev-udaya/11.9
Upgraded connector code to support java 17 and compatible with wavema…
- Loading branch information
Showing
8 changed files
with
193 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version: "1.0" | ||
version: "2.0" | ||
name: "excel-connector" | ||
description: "A simple connector excel-connector that can be used in WaveMaker application" | ||
springConfigurationClass: "com.wavemaker.connector.excel.ExcelConnectorConfiguration" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
excel-connector-impl/src/main/java/com/wavemaker/connector/excel/utils/NamingUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.wavemaker.connector.excel.utils; | ||
|
||
import com.wavemaker.commons.util.StringUtils; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
|
||
import java.beans.Introspector; | ||
|
||
public class NamingUtils { | ||
|
||
/** | ||
* Converts a database name (table or column) to a java name. | ||
* eg,Hello_World : helloWorld | ||
* eq,HelloWorld : helloWorld | ||
* | ||
* @return The converted java identifier. | ||
*/ | ||
public static String toJavaIdentifier(final String identifier) { | ||
String rtn = columnToPropertyName(identifier); | ||
int upperIndex = 1; | ||
if (rtn.length() > 1 && Character.isUpperCase(rtn.charAt(1))) { | ||
upperIndex = 2; | ||
} | ||
rtn = rtn.substring(0, upperIndex).toLowerCase() + rtn.substring(upperIndex); | ||
return StringUtils.toJavaIdentifier(rtn); | ||
} | ||
|
||
private static String columnToPropertyName(String identifier) { | ||
String decapitalize = Introspector.decapitalize(ReverseEngineeringStrategyUtil.toUpperCamelCase(identifier)); | ||
return keywordCheck(decapitalize); | ||
} | ||
|
||
private static String keywordCheck(String possibleKeyword) { | ||
if (ReverseEngineeringStrategyUtil.isReservedJavaKeyword(possibleKeyword)) { | ||
possibleKeyword = possibleKeyword + "_"; | ||
} | ||
return possibleKeyword; | ||
} | ||
} |
131 changes: 131 additions & 0 deletions
131
...mpl/src/main/java/com/wavemaker/connector/excel/utils/ReverseEngineeringStrategyUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package com.wavemaker.connector.excel.utils; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class ReverseEngineeringStrategyUtil { | ||
|
||
private static Set<String> RESERVED_KEYWORDS; | ||
|
||
static { | ||
RESERVED_KEYWORDS = new HashSet<>(); | ||
|
||
RESERVED_KEYWORDS.add("abstract"); | ||
RESERVED_KEYWORDS.add("continue"); | ||
RESERVED_KEYWORDS.add("for"); | ||
RESERVED_KEYWORDS.add("new"); | ||
RESERVED_KEYWORDS.add("switch"); | ||
RESERVED_KEYWORDS.add("assert"); | ||
RESERVED_KEYWORDS.add("default"); | ||
RESERVED_KEYWORDS.add("goto"); | ||
RESERVED_KEYWORDS.add("package"); | ||
RESERVED_KEYWORDS.add("synchronized"); | ||
RESERVED_KEYWORDS.add("boolean"); | ||
RESERVED_KEYWORDS.add("do"); | ||
RESERVED_KEYWORDS.add("if"); | ||
RESERVED_KEYWORDS.add("private"); | ||
RESERVED_KEYWORDS.add("this"); | ||
RESERVED_KEYWORDS.add("break"); | ||
RESERVED_KEYWORDS.add("double"); | ||
RESERVED_KEYWORDS.add("implements"); | ||
RESERVED_KEYWORDS.add("protected"); | ||
RESERVED_KEYWORDS.add("throw"); | ||
RESERVED_KEYWORDS.add("byte"); | ||
RESERVED_KEYWORDS.add("else"); | ||
RESERVED_KEYWORDS.add("import"); | ||
RESERVED_KEYWORDS.add("public"); | ||
RESERVED_KEYWORDS.add("throws"); | ||
RESERVED_KEYWORDS.add("case"); | ||
RESERVED_KEYWORDS.add("enum"); | ||
RESERVED_KEYWORDS.add("instanceof"); | ||
RESERVED_KEYWORDS.add("return"); | ||
RESERVED_KEYWORDS.add("transient"); | ||
RESERVED_KEYWORDS.add("catch"); | ||
RESERVED_KEYWORDS.add("extends"); | ||
RESERVED_KEYWORDS.add("int"); | ||
RESERVED_KEYWORDS.add("short"); | ||
RESERVED_KEYWORDS.add("try"); | ||
RESERVED_KEYWORDS.add("char"); | ||
RESERVED_KEYWORDS.add("final"); | ||
RESERVED_KEYWORDS.add("interface"); | ||
RESERVED_KEYWORDS.add("static"); | ||
RESERVED_KEYWORDS.add("void"); | ||
RESERVED_KEYWORDS.add("class"); | ||
RESERVED_KEYWORDS.add("finally"); | ||
RESERVED_KEYWORDS.add("long"); | ||
RESERVED_KEYWORDS.add("strictfp"); | ||
RESERVED_KEYWORDS.add("volatile"); | ||
RESERVED_KEYWORDS.add("const"); | ||
RESERVED_KEYWORDS.add("float"); | ||
RESERVED_KEYWORDS.add("native"); | ||
RESERVED_KEYWORDS.add("super"); | ||
RESERVED_KEYWORDS.add("while"); | ||
} | ||
|
||
private ReverseEngineeringStrategyUtil() { | ||
|
||
} | ||
|
||
/** | ||
* Converts a database name (table or column) to a java name (first letter capitalised). | ||
* employee_name -> EmployeeName. | ||
* | ||
* Derived from middlegen's dbnameconverter. | ||
* | ||
* @param s The database name to convert. | ||
* | ||
* @return The converted database name. | ||
*/ | ||
public static String toUpperCamelCase(String s) { | ||
if ("".equals(s)) { | ||
return s; | ||
} | ||
StringBuffer result = new StringBuffer(); | ||
|
||
boolean capitalize = true; | ||
boolean lastCapital = false; | ||
boolean lastDecapitalized = false; | ||
String p = null; | ||
for (int i = 0; i < s.length(); i++) { | ||
String c = s.substring(i, i + 1); | ||
if ("_".equals(c) || " ".equals(c) || "-".equals(c)) { | ||
capitalize = true; | ||
continue; | ||
} | ||
|
||
if (c.toUpperCase().equals(c)) { | ||
if (lastDecapitalized && !lastCapital) { | ||
capitalize = true; | ||
} | ||
lastCapital = true; | ||
} else { | ||
lastCapital = false; | ||
} | ||
|
||
//if(forceFirstLetter && result.length()==0) capitalize = false; | ||
|
||
if (capitalize) { | ||
if (p == null || !p.equals("_")) { | ||
result.append(c.toUpperCase()); | ||
capitalize = false; | ||
p = c; | ||
} else { | ||
result.append(c.toLowerCase()); | ||
capitalize = false; | ||
p = c; | ||
} | ||
} else { | ||
result.append(c.toLowerCase()); | ||
lastDecapitalized = true; | ||
p = c; | ||
} | ||
|
||
} | ||
String r = result.toString(); | ||
return r; | ||
} | ||
|
||
static public boolean isReservedJavaKeyword(String str) { | ||
return RESERVED_KEYWORDS.contains(str); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters