use of org.dbflute.helper.StringSet in project dbflute-core by dbflute.
the class DfDelimiterDataListedColumnHandler method setupColumnNameList.
public void setupColumnNameList(List<String> columnNameList, DfDelimiterDataFirstLineInfo firstLineInfo, Map<String, DfColumnMeta> columnMetaMap, Map<String, String> defaultValueMap, Predicate<String> needsCheckingColumnDef, Consumer<List<String>> columnDefChecker) {
columnNameList.addAll(firstLineInfo.getColumnNameList());
if (columnNameList.isEmpty()) {
throwDelimiterDataColumnDefNotFoundException(_dataFile, _tableDbName);
}
if (needsCheckingColumnDef.test(_dataDirectory)) {
columnDefChecker.accept(columnNameList);
}
final StringSet columnSet = StringSet.createAsFlexible();
columnSet.addAll(columnNameList);
final List<String> additionalColumnList = new ArrayList<String>();
for (String defaultColumn : defaultValueMap.keySet()) {
if (columnSet.contains(defaultColumn)) {
continue;
}
if (columnMetaMap.containsKey(defaultColumn)) {
// only existing column in DB
additionalColumnList.add(defaultColumn);
}
}
// defined columns + default columns (existing in DB)
columnNameList.addAll(additionalColumnList);
}
use of org.dbflute.helper.StringSet in project dbflute-core by dbflute.
the class DfArrayExtractorOracle method doExtractFlatArrayInfoSecondMap.
// ===================================================================================
// Second Array Info
// =================
protected StringKeyMap<DfTypeArrayInfo> doExtractFlatArrayInfoSecondMap(UnifiedSchema unifiedSchema) {
final StringKeyMap<DfTypeArrayInfo> flatArrayInfoMap = StringKeyMap.createAsFlexibleOrdered();
final List<DfProcedureArgumentInfo> argInfoList = extractProcedureArgumentInfoList(unifiedSchema);
for (int i = 0; i < argInfoList.size(); i++) {
final DfProcedureArgumentInfo argInfo = argInfoList.get(i);
final String argumentName = argInfo.getArgumentName();
if (Srl.is_Null_or_TrimmedEmpty(argumentName)) {
continue;
}
final String dataType = argInfo.getDataType();
if (!isDataTypeArray(dataType)) {
continue;
}
final String typeName = argInfo.getTypeName();
if (Srl.is_Null_or_TrimmedEmpty(typeName)) {
continue;
}
setupFlatArrayInfo(flatArrayInfoMap, argInfoList, argInfo, i);
}
final StringSet allArrayTypeSet = extractSimpleArrayNameSet(unifiedSchema);
for (String allArrayTypeName : allArrayTypeSet) {
if (!flatArrayInfoMap.containsKey(allArrayTypeName)) {
final DfTypeArrayInfo arrayInfo = new DfTypeArrayInfo(unifiedSchema, allArrayTypeName);
// the way to get the info is also unknown
arrayInfo.setElementType("Unknown");
flatArrayInfoMap.put(allArrayTypeName, arrayInfo);
}
}
return flatArrayInfoMap;
}
use of org.dbflute.helper.StringSet in project dbflute-core by dbflute.
the class DfArrayExtractorOracle method extractSimpleArrayNameSet.
// ===================================================================================
// Simple Type Info
// ================
protected StringSet extractSimpleArrayNameSet(UnifiedSchema unifiedSchema) {
final List<Map<String, String>> resultList = selectSimpleArray(unifiedSchema);
final StringSet arrayTypeSet = StringSet.createAsFlexibleOrdered();
for (Map<String, String> map : resultList) {
arrayTypeSet.add(buildArrayTypeName(map.get("TYPE_NAME"), unifiedSchema));
}
return arrayTypeSet;
}
use of org.dbflute.helper.StringSet in project dbflute-core by dbflute.
the class DfSchemaXmlSerializer method helpColumnAdjustment.
protected List<DfColumnMeta> helpColumnAdjustment(DatabaseMetaData dbMeta, DfTableMeta tableMeta, List<DfColumnMeta> columnList) {
if (!canHandleSynonym(tableMeta)) {
return columnList;
}
final DfSynonymMeta synonym = getSynonymMetaInfo(tableMeta);
if (synonym == null) {
// means not synonym or no supplementary info
return columnList;
}
final List<DfColumnMeta> metaInfoList = synonym.getColumnMetaInfoList();
if (metaInfoList.isEmpty()) {
return metaInfoList;
}
if (synonym.isDBLink() && columnList.isEmpty()) {
columnList = metaInfoList;
} else if (metaInfoList.size() != columnList.size()) {
// for Oracle's bug(?), which is following:
// /- - - - - - - - - - - - - - - - - - - - - - - - - - -
// For example, Schema A, B are like this:
// A: FOO table
// B: FOO table, BAR synonym to A's FOO table
// BAR synonym's columns are from both A and B's FOO table.
// (means that BAR synonym has other table's columns)
// Why? my friend, the Oracle JDBC Driver!
// - - - - - - - - - -/
final StringSet columnSet = StringSet.createAsCaseInsensitive();
for (DfColumnMeta columnMeta : metaInfoList) {
columnSet.add(columnMeta.getColumnName());
}
final List<DfColumnMeta> filteredList = new ArrayList<DfColumnMeta>();
for (DfColumnMeta columnMeta : columnList) {
if (columnSet.contains(columnMeta.getColumnName())) {
filteredList.add(columnMeta);
}
}
columnList = filteredList;
}
return columnList;
}
use of org.dbflute.helper.StringSet in project dbflute-core by dbflute.
the class DfAdditionalForeignKeyInitializer method processAllTableFK.
protected void processAllTableFK(String foreignKeyName, String foreignTableName, List<String> foreignColumnNameList, DfAdditionalForeignKeyOption option) {
if (option.isFixedOnlyJoin()) {
String msg = "Cannot use fixedOnlyJoin when all-table FK: " + foreignKeyName;
throw new DfIllegalPropertySettingException(msg);
}
// for check about same-column self reference
final Table foreignTable = getTable(foreignTableName);
final StringSet foreignColumnSet = StringSet.createAsFlexible();
foreignColumnSet.addAll(foreignColumnNameList);
for (Table table : getTableList()) {
final String localTableName = table.getTableDbName();
final List<String> localColumnNameList = getLocalColumnNameList(table, foreignKeyName, foreignTableName, foreignColumnNameList, localTableName, option, true, false);
if (!table.containsColumn(localColumnNameList)) {
continue;
}
// check same-column self reference
final StringSet localColumnSet = StringSet.createAsFlexible();
localColumnSet.addAll(localColumnNameList);
final boolean selfReference = table.getTableDbName().equals(foreignTable.getTableDbName());
if (selfReference && localColumnSet.equalsUnderCharOption(foreignColumnSet)) {
continue;
}
// check same foreign key existence
final String fixedSuffix = option.getFixedSuffix();
final ForeignKey existingFK = table.findExistingForeignKey(foreignTableName, localColumnNameList, foreignColumnNameList, fixedSuffix);
if (existingFK != null) {
_log.info("The foreign key has already set up: " + foreignKeyName + "(" + fixedSuffix + ")");
reflectOptionToExistingFKIfNeeds(foreignKeyName, option, existingFK);
continue;
}
final String currentForeignKeyName = foreignKeyName + "_" + toConstraintPart(localTableName);
setupForeignKeyToTable(currentForeignKeyName, foreignTableName, foreignColumnNameList, table, localColumnNameList, option);
showResult(foreignTableName, foreignColumnNameList, table, localColumnNameList, option);
}
}
Aggregations