Search in sources :

Example 1 with DfAdditionalSchemaInfo

use of org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo in project dbflute-core by dbflute.

the class Table method doHasAllCommonColumn.

protected boolean doHasAllCommonColumn() {
    if (isAdditionalSchema()) {
        final DfDatabaseProperties prop = getDatabaseProperties();
        final DfAdditionalSchemaInfo schemaInfo = prop.getAdditionalSchemaInfo(_unifiedSchema);
        if (schemaInfo.isSuppressCommonColumn()) {
            return false;
        }
    }
    final List<String> commonColumnNameList = getCommonColumnProperties().getCommonColumnNameList();
    if (commonColumnNameList.isEmpty()) {
        return false;
    }
    for (String commonColumnName : commonColumnNameList) {
        if (getCommonColumnProperties().isCommonColumnConversion(commonColumnName)) {
            final Column col = findMyCommonColumn(commonColumnName);
            if (col == null) {
                return false;
            }
        } else {
            if (!_columnMap.containsKey(commonColumnName)) {
                return false;
            }
        }
    }
    return true;
}
Also used : DfAdditionalSchemaInfo(org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo) DfDatabaseProperties(org.dbflute.properties.DfDatabaseProperties)

Example 2 with DfAdditionalSchemaInfo

use of org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo in project dbflute-core by dbflute.

the class UnifiedSchema method judgeSchema.

protected UnifiedSchema judgeSchema() {
    final DfDatabaseProperties databaseProp = getDatabaseProperties();
    final UnifiedSchema mainSchema = databaseProp.getDatabaseSchema();
    if (equals(mainSchema)) {
        asMainSchema();
    } else {
        final DfAdditionalSchemaInfo info = databaseProp.getAdditionalSchemaInfo(this);
        if (info != null) {
            asAdditionalSchema();
            if (info.getUnifiedSchema().isCatalogAdditionalSchema()) {
                asCatalogAdditionalSchema();
            }
        } else {
            asUnknownSchema();
        }
    }
    return this;
}
Also used : DfAdditionalSchemaInfo(org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo) DfDatabaseProperties(org.dbflute.properties.DfDatabaseProperties)

Example 3 with DfAdditionalSchemaInfo

use of org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo in project dbflute-core by dbflute.

the class DfProcedureExtractor method setupAdditionalSchemaProcedure.

// -----------------------------------------------------
// Additional Schema
// -----------------
protected void setupAdditionalSchemaProcedure(DfSchemaSource dataSource, List<DfProcedureMeta> procedureList) throws SQLException {
    if (_suppressAdditionalSchema) {
        return;
    }
    final DfDatabaseProperties databaseProp = getProperties().getDatabaseProperties();
    final List<UnifiedSchema> additionalSchemaList = databaseProp.getAdditionalSchemaList();
    for (UnifiedSchema additionalSchema : additionalSchemaList) {
        final DfAdditionalSchemaInfo schemaInfo = databaseProp.getAdditionalSchemaInfo(additionalSchema);
        if (schemaInfo.isSuppressProcedure()) {
            continue;
        }
        final List<DfProcedureMeta> additionalProcedureList = getPlainProcedureList(dataSource, additionalSchema);
        procedureList.addAll(additionalProcedureList);
    }
}
Also used : DfAdditionalSchemaInfo(org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DfProcedureMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta) DfDatabaseProperties(org.dbflute.properties.DfDatabaseProperties)

Example 4 with DfAdditionalSchemaInfo

use of org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo in project dbflute-core by dbflute.

the class DfProcedureExtractor method isSynonymAllowedSchema.

protected boolean isSynonymAllowedSchema(DfProcedureSynonymMeta procedureSynonymMetaInfo) {
    final DfSynonymMeta synonymMetaInfo = procedureSynonymMetaInfo.getSynonymMetaInfo();
    final UnifiedSchema synonymOwner = synonymMetaInfo.getSynonymOwner();
    final DfDatabaseProperties databaseProperties = getProperties().getDatabaseProperties();
    final DfAdditionalSchemaInfo additionalSchemaInfo = databaseProperties.getAdditionalSchemaInfo(synonymOwner);
    if (additionalSchemaInfo != null) {
        return additionalSchemaInfo.hasObjectTypeSynonym();
    } else {
        // as main schema
        return databaseProperties.hasObjectTypeSynonym();
    }
}
Also used : DfSynonymMeta(org.dbflute.logic.jdbc.metadata.info.DfSynonymMeta) DfAdditionalSchemaInfo(org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DfDatabaseProperties(org.dbflute.properties.DfDatabaseProperties)

Example 5 with DfAdditionalSchemaInfo

use of org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo in project dbflute-core by dbflute.

the class DfDatabaseProperties method getAdditionalSchemaMap.

protected Map<String, DfAdditionalSchemaInfo> getAdditionalSchemaMap() {
    if (_additionalSchemaMap != null) {
        return _additionalSchemaMap;
    }
    assertOldStyleAdditionalSchema();
    _additionalSchemaMap = StringKeyMap.createAsCaseInsensitive();
    final Map<String, Object> additionalSchemaMap = getVairousStringKeyMap("additionalSchemaMap");
    if (additionalSchemaMap.isEmpty()) {
        return _additionalSchemaMap;
    }
    final Set<Entry<String, Object>> entrySet = additionalSchemaMap.entrySet();
    for (Entry<String, Object> entry : entrySet) {
        final String identifiedSchema = entry.getKey();
        final Object obj = entry.getValue();
        if (obj == null) {
            String msg = "The value of schema in the property 'additionalSchemaMap' should be required:";
            msg = msg + " identifiedSchema=" + identifiedSchema;
            msg = msg + " additionalSchemaMap=" + additionalSchemaMap;
            throw new DfRequiredPropertyNotFoundException(msg);
        }
        if (!(obj instanceof Map<?, ?>)) {
            String msg = "The type of schema value in the property 'additionalSchemaMap' should be Map:";
            msg = msg + " type=" + DfTypeUtil.toClassTitle(obj) + " value=" + obj;
            throw new DfIllegalPropertyTypeException(msg);
        }
        @SuppressWarnings("unchecked") final Map<String, Object> elementMap = (Map<String, Object>) obj;
        final DfAdditionalSchemaInfo info = new DfAdditionalSchemaInfo();
        final String catalog;
        final boolean explicitCatalog;
        if (identifiedSchema.contains(".")) {
            catalog = Srl.substringFirstFront(identifiedSchema, ".");
            explicitCatalog = true;
        } else {
            // as main catalog
            catalog = getDatabaseCatalog();
            explicitCatalog = false;
        }
        final String schema = filterDatabaseSchema(Srl.substringFirstRear(identifiedSchema, "."));
        final UnifiedSchema unifiedSchema = createAsAdditionalSchema(catalog, schema, explicitCatalog);
        info.setUnifiedSchema(unifiedSchema);
        setupAdditionalSchemaObjectTypeTargetList(info, elementMap);
        setupAdditionalSchemaTableExceptList(info, elementMap);
        setupAdditionalSchemaTableTargetList(info, elementMap);
        setupAdditionalSchemaColumnExceptList(info, elementMap);
        info.setSuppressCommonColumn(isProperty("isSuppressCommonColumn", false, elementMap));
        info.setSuppressProcedure(isProperty("isSuppressProcedure", false, elementMap));
        _additionalSchemaMap.put(unifiedSchema.getIdentifiedSchema(), info);
    }
    return _additionalSchemaMap;
}
Also used : DfRequiredPropertyNotFoundException(org.dbflute.exception.DfRequiredPropertyNotFoundException) Entry(java.util.Map.Entry) DfIllegalPropertyTypeException(org.dbflute.exception.DfIllegalPropertyTypeException) DfAdditionalSchemaInfo(org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap)

Aggregations

DfAdditionalSchemaInfo (org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo)7 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)4 DfDatabaseProperties (org.dbflute.properties.DfDatabaseProperties)4 Entry (java.util.Map.Entry)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 DfIllegalPropertyTypeException (org.dbflute.exception.DfIllegalPropertyTypeException)1 DfRequiredPropertyNotFoundException (org.dbflute.exception.DfRequiredPropertyNotFoundException)1 StringKeyMap (org.dbflute.helper.StringKeyMap)1 DfProcedureMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)1 DfSynonymMeta (org.dbflute.logic.jdbc.metadata.info.DfSynonymMeta)1