Search in sources :

Example 1 with ForeignInfo

use of org.dbflute.dbmeta.info.ForeignInfo in project dbflute-core by dbflute.

the class AbstractSqlClause method createSelectedSelectColumnInfo.

protected Map<String, SelectedRelationColumn> createSelectedSelectColumnInfo(String foreignTableAliasName, String localTableDbName, String foreignPropertyName, String localRelationPath) {
    final DBMeta dbmeta = findDBMeta(localTableDbName);
    final ForeignInfo foreignInfo = dbmeta.findForeignInfo(foreignPropertyName);
    final int relationNo = foreignInfo.getRelationNo();
    String nextRelationPath = RELATION_PATH_DELIMITER + relationNo;
    if (localRelationPath != null) {
        nextRelationPath = localRelationPath + nextRelationPath;
    }
    final Map<String, SelectedRelationColumn> resultMap = new LinkedHashMap<String, SelectedRelationColumn>();
    final DBMeta foreignDBMeta = foreignInfo.getForeignDBMeta();
    final List<ColumnInfo> columnInfoList = foreignDBMeta.getColumnInfoList();
    for (ColumnInfo columnInfo : columnInfoList) {
        final String columnDbName = columnInfo.getColumnDbName();
        final SelectedRelationColumn selectColumnInfo = new SelectedRelationColumn();
        selectColumnInfo.setTableAliasName(foreignTableAliasName);
        selectColumnInfo.setColumnInfo(columnInfo);
        selectColumnInfo.setRelationNoSuffix(nextRelationPath);
        resultMap.put(columnDbName, selectColumnInfo);
    }
    return resultMap;
}
Also used : ForeignInfo(org.dbflute.dbmeta.info.ForeignInfo) DBMeta(org.dbflute.dbmeta.DBMeta) SelectedRelationColumn(org.dbflute.cbean.sqlclause.select.SelectedRelationColumn) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with ForeignInfo

use of org.dbflute.dbmeta.info.ForeignInfo in project dbflute-core by dbflute.

the class AbstractDBMeta method cfi.

protected // relation name
ForeignInfo cfi(// relation name
String constraintName, // relation name
String foreignPropertyName, // DB meta
DBMeta localDbm, // DB meta
DBMeta foreignDbm, // relation attribute
Map<ColumnInfo, ColumnInfo> localForeignColumnInfoMap, // relation attribute
int relationNo, // relation attribute
Class<?> propertyAccessType, // relation type
boolean oneToOne, // relation type
boolean bizOneToOne, // relation type
boolean referrerAsOne, // relation type
boolean additionalFK, // fixed condition
String fixedCondition, // fixed condition
List<String> dynamicParameterList, // fixed condition
boolean fixedInline, // various info
String reversePropertyName, // various info
boolean canBeNullObject) {
    // createForeignInfo()
    final Class<?> realPt = chooseForeignPropertyAccessType(foreignDbm, propertyAccessType);
    final PropertyMethodFinder propertyMethodFinder = createForeignPropertyMethodFinder();
    return new ForeignInfo(constraintName, foreignPropertyName, localDbm, foreignDbm, localForeignColumnInfoMap, relationNo, realPt, oneToOne, bizOneToOne, referrerAsOne, additionalFK, fixedCondition, dynamicParameterList, fixedInline, reversePropertyName, canBeNullObject, propertyMethodFinder);
}
Also used : ForeignInfo(org.dbflute.dbmeta.info.ForeignInfo) PropertyMethodFinder(org.dbflute.dbmeta.property.PropertyMethodFinder)

Example 3 with ForeignInfo

use of org.dbflute.dbmeta.info.ForeignInfo in project dbflute-core by dbflute.

the class AbstractDBMeta method getForeignInfoRelationNoKeyMap.

/**
 * Get the relation-no key map of foreign information.
 * @return The unordered map of foreign information. (NotNull, EmptyAllowed, ReadOnly)
 */
protected Map<Integer, ForeignInfo> getForeignInfoRelationNoKeyMap() {
    if (_foreignInfoRelationNoKeyMap != null) {
        return _foreignInfoRelationNoKeyMap;
    }
    final List<ForeignInfo> foreignInfoList = getForeignInfoList();
    synchronized (this) {
        if (_foreignInfoRelationNoKeyMap != null) {
            return _foreignInfoRelationNoKeyMap;
        }
        final Map<Integer, ForeignInfo> map = newConcurrentHashMap();
        for (ForeignInfo foreignInfo : foreignInfoList) {
            map.put(foreignInfo.getRelationNo(), foreignInfo);
        }
        _foreignInfoRelationNoKeyMap = Collections.unmodifiableMap(map);
        return _foreignInfoRelationNoKeyMap;
    }
}
Also used : ForeignInfo(org.dbflute.dbmeta.info.ForeignInfo)

Example 4 with ForeignInfo

use of org.dbflute.dbmeta.info.ForeignInfo in project dbflute-core by dbflute.

the class AbstractDBMeta method getForeignInfoList.

/**
 * {@inheritDoc}
 */
public List<ForeignInfo> getForeignInfoList() {
    if (_foreignInfoList != null) {
        return _foreignInfoList;
    }
    synchronized (this) {
        if (_foreignInfoList != null) {
            return _foreignInfoList;
        }
        final Method[] methods = this.getClass().getMethods();
        final List<ForeignInfo> workingList = newArrayList();
        final String prefix = "foreign";
        final Class<ForeignInfo> returnType = ForeignInfo.class;
        for (Method method : methods) {
            if (method.getName().startsWith(prefix) && returnType.equals(method.getReturnType())) {
                workingList.add((ForeignInfo) DfReflectionUtil.invoke(method, this, null));
            }
        }
        _foreignInfoList = Collections.unmodifiableList(workingList);
        return _foreignInfoList;
    }
}
Also used : ForeignInfo(org.dbflute.dbmeta.info.ForeignInfo) Method(java.lang.reflect.Method)

Example 5 with ForeignInfo

use of org.dbflute.dbmeta.info.ForeignInfo in project dbflute-core by dbflute.

the class AbstractDBMeta method getForeignInfoFlexibleMap.

/**
 * Get the flexible map of foreign information.
 * @return The flexible map of foreign information. (NotNull, EmptyAllowed, ReadOnly)
 */
protected Map<String, ForeignInfo> getForeignInfoFlexibleMap() {
    if (_foreignInfoFlexibleMap != null) {
        return _foreignInfoFlexibleMap;
    }
    final List<ForeignInfo> foreignInfoList = getForeignInfoList();
    synchronized (this) {
        if (_foreignInfoFlexibleMap != null) {
            return _foreignInfoFlexibleMap;
        }
        final StringKeyMap<ForeignInfo> map = createFlexibleConcurrentMap();
        for (ForeignInfo foreignInfo : foreignInfoList) {
            map.put(foreignInfo.getForeignPropertyName(), foreignInfo);
        }
        _foreignInfoFlexibleMap = Collections.unmodifiableMap(map);
        return _foreignInfoFlexibleMap;
    }
}
Also used : ForeignInfo(org.dbflute.dbmeta.info.ForeignInfo)

Aggregations

ForeignInfo (org.dbflute.dbmeta.info.ForeignInfo)20 DBMeta (org.dbflute.dbmeta.DBMeta)8 LinkedHashMap (java.util.LinkedHashMap)4 ColumnInfo (org.dbflute.dbmeta.info.ColumnInfo)4 ArrayList (java.util.ArrayList)3 RelationInfo (org.dbflute.dbmeta.info.RelationInfo)3 List (java.util.List)2 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 Entity (org.dbflute.Entity)1 ConditionQuery (org.dbflute.cbean.ConditionQuery)1 FixedConditionResolver (org.dbflute.cbean.sqlclause.join.FixedConditionResolver)1 SelectedRelationColumn (org.dbflute.cbean.sqlclause.select.SelectedRelationColumn)1 TableSqlName (org.dbflute.dbmeta.name.TableSqlName)1 PropertyMethodFinder (org.dbflute.dbmeta.property.PropertyMethodFinder)1 DBMetaNotFoundException (org.dbflute.exception.DBMetaNotFoundException)1 DfPropertyAccessor (org.dbflute.helper.beans.DfPropertyAccessor)1 RelationOptionalFactory (org.dbflute.optional.RelationOptionalFactory)1 IndexOfInfo (org.dbflute.util.Srl.IndexOfInfo)1