use of org.apache.torque.engine.database.model.Column in project dbflute-core by dbflute.
the class DfSPolicyCrossSecretary method getSameNameColumnListMap.
protected Map<String, List<Column>> getSameNameColumnListMap(Database database) {
if (_sameNameColumnListMap != null) {
return _sameNameColumnListMap;
}
// flexible map because column name is treated as flexible in DBFlute (so MEMBER_NAME and MemberName are same-name)
final Map<String, List<Column>> sameNameColumnListMap = StringKeyMap.createAsFlexible();
final List<Table> targetTableList = database.getTableList().stream().filter(tbl -> isTargetTable(tbl)).collect(Collectors.toList());
for (Table myTable : targetTableList) {
final List<Column> columnList = myTable.getColumnList();
for (Column myColumn : columnList) {
if (!isTargetColumn(myColumn)) {
// non-target
continue;
}
final String myName = myColumn.getName();
if (sameNameColumnListMap.containsKey(myName)) {
// registered by the other same-name column
continue;
}
for (Table yourTable : targetTableList) {
final Column yourColumn = yourTable.getColumn(myName);
if (yourColumn != null) {
if (!isTargetColumn(yourColumn)) {
// non-target
continue;
}
List<Column> sameColumnList = sameNameColumnListMap.get(myName);
if (sameColumnList == null) {
sameColumnList = new ArrayList<Column>();
sameColumnList.add(myColumn);
sameNameColumnListMap.put(myName, sameColumnList);
}
sameColumnList.add(yourColumn);
}
}
}
}
_sameNameColumnListMap = sameNameColumnListMap;
return _sameNameColumnListMap;
}
use of org.apache.torque.engine.database.model.Column in project dbflute-core by dbflute.
the class DfLReverseOutputHandler method setupXlsDataTable.
// ===================================================================================
// Xls Data
// ========
protected void setupXlsDataTable(DfDataSet dataSet, Table table, List<Map<String, String>> extractedList, int sheetNumber, List<String> sectionInfoList) {
final List<Map<String, String>> recordList;
{
final String tableInfo = " " + table.getTableDispName() + " (" + extractedList.size() + ")";
_log.info(tableInfo);
sectionInfoList.add(tableInfo);
if (extractedList.size() > _xlsLimit) {
// just in case
recordList = extractedList.subList(0, _xlsLimit);
} else {
recordList = extractedList;
}
}
final DfDataTable dataTable = new DfDataTable(resolveSheetName(table, sheetNumber));
final List<Column> columnList = table.getColumnList();
for (Column column : columnList) {
if (isExceptCommonColumn(column)) {
continue;
}
dataTable.addColumn(column.getName(), DfDtsColumnTypes.STRING);
}
for (Map<String, String> recordMap : recordList) {
final Set<String> columnNameSet = recordMap.keySet();
final DfDataRow dataRow = dataTable.addRow();
for (String columnName : columnNameSet) {
if (!dataTable.hasColumn(columnName)) {
// basically excepted common columns
continue;
}
final String value = recordMap.get(columnName);
dataRow.addValue(columnName, value);
}
}
dataSet.addTable(dataTable);
}
use of org.apache.torque.engine.database.model.Column in project dbflute-core by dbflute.
the class DfColumnListToStringBuilder method getColumnArgsSetupString.
public static String getColumnArgsSetupString(String beanName, List<Column> columnList) {
validateColumnList(columnList);
final boolean hasPrefix = beanName != null;
final String beanPrefix = (hasPrefix ? beanName + "." : "");
final DfLanguageDependency lang = getBasicProperties().getLanguageDependency();
final DfLanguageImplStyle implStyle = lang.getLanguageImplStyle();
String result = "";
for (Iterator<Column> ite = columnList.iterator(); ite.hasNext(); ) {
final Column column = (Column) ite.next();
final String javaName = column.getJavaName();
final String variable = column.getUncapitalisedJavaName();
final String cls = column.getClassificationName();
final String basic;
if (column.isForceClassificationSetting()) {
basic = "set" + javaName + "As" + cls + "(" + variable + ")";
} else {
basic = "set" + javaName + "(" + variable + ")";
}
final String adjusted = implStyle.adjustEntitySetMethodCall(basic, !hasPrefix);
final String setter = beanPrefix + adjusted + ";";
if ("".equals(result)) {
result = setter;
} else {
result = result + setter;
}
}
return result;
}
use of org.apache.torque.engine.database.model.Column in project dbflute-core by dbflute.
the class DfColumnListToStringBuilder method getColumnArgsSetupStringCSharp.
public static String getColumnArgsSetupStringCSharp(String beanName, List<Column> columnList) {
validateColumnList(columnList);
final String beanPrefix = (beanName != null ? beanName + "." : "");
String result = "";
for (Iterator<Column> ite = columnList.iterator(); ite.hasNext(); ) {
final Column column = (Column) ite.next();
final String javaName = column.getJavaName();
final String variable = column.getUncapitalisedJavaName();
final String setter = beanPrefix + javaName + " = " + variable + ";";
if ("".equals(result)) {
result = setter;
} else {
result = result + setter;
}
}
return result;
}
use of org.apache.torque.engine.database.model.Column in project dbflute-core by dbflute.
the class DfColumnListToStringBuilder method getColumnNameCommaString.
public static String getColumnNameCommaString(List<Column> columnList) {
validateColumnList(columnList);
String result = "";
for (Column column : columnList) {
final String name = column.getName();
if ("".equals(result)) {
result = name;
} else {
result = result + ", " + name;
}
}
return result;
}
Aggregations