Search in sources :

Example 1 with TnRelationPropertyType

use of org.dbflute.s2dao.metadata.TnRelationPropertyType in project dbflute-core by dbflute.

the class TnBeanMetaDataImpl method getPropertyTypeByAliasName.

public TnPropertyType getPropertyTypeByAliasName(String alias) {
    if (hasPropertyTypeByColumnName(alias)) {
        return getPropertyTypeByColumnName(alias);
    }
    final int index = alias.lastIndexOf('_');
    if (index < 0) {
        String msg = "The alias was not found in the table: table=" + _tableName + " alias=" + alias;
        throw new IllegalStateException(msg);
    }
    final String columnName = alias.substring(0, index);
    final String relnoStr = alias.substring(index + 1);
    int relno = -1;
    try {
        relno = Integer.parseInt(relnoStr);
    } catch (Throwable t) {
        String msg = "The alias was not found in the table: table=" + _tableName + " alias=" + alias;
        throw new IllegalStateException(msg, t);
    }
    final TnRelationPropertyType rpt = getRelationPropertyType(relno);
    if (!rpt.getYourBeanMetaData().hasPropertyTypeByColumnName(columnName)) {
        String msg = "The alias was not found in the table: table=" + _tableName + " alias=" + alias;
        throw new IllegalStateException(msg);
    }
    return rpt.getYourBeanMetaData().getPropertyTypeByColumnName(columnName);
}
Also used : TnRelationPropertyType(org.dbflute.s2dao.metadata.TnRelationPropertyType)

Example 2 with TnRelationPropertyType

use of org.dbflute.s2dao.metadata.TnRelationPropertyType in project dbflute-core by dbflute.

the class TnBeanMetaDataImpl method setupProperty.

protected void setupProperty() {
    // only called in the initialize() process
    final TnPropertyType[] propertyTypes = _propertyTypeFactory.createBeanPropertyTypes();
    for (int i = 0; i < propertyTypes.length; i++) {
        TnPropertyType pt = propertyTypes[i];
        addPropertyType(pt);
        _columnPropertyTypeMap.put(pt.getColumnDbName(), pt);
    }
    final TnRelationPropertyType[] rptTypes = _relationPropertyTypeFactory.createRelationPropertyTypes();
    for (int i = 0; i < rptTypes.length; i++) {
        TnRelationPropertyType rpt = rptTypes[i];
        addRelationPropertyType(rpt);
    }
}
Also used : TnRelationPropertyType(org.dbflute.s2dao.metadata.TnRelationPropertyType) TnPropertyType(org.dbflute.s2dao.metadata.TnPropertyType)

Example 3 with TnRelationPropertyType

use of org.dbflute.s2dao.metadata.TnRelationPropertyType in project dbflute-core by dbflute.

the class TnBeanMetaDataImpl method hasPropertyTypeByAliasName.

public boolean hasPropertyTypeByAliasName(String alias) {
    if (hasPropertyTypeByColumnName(alias)) {
        return true;
    }
    final int index = alias.lastIndexOf('_');
    if (index < 0) {
        return false;
    }
    final String columnName = alias.substring(0, index);
    final String relnoStr = alias.substring(index + 1);
    int relno = -1;
    try {
        relno = Integer.parseInt(relnoStr);
    } catch (Throwable t) {
        return false;
    }
    if (relno >= getRelationPropertyTypeSize()) {
        return false;
    }
    final TnRelationPropertyType rpt = getRelationPropertyType(relno);
    return rpt.getYourBeanMetaData().hasPropertyTypeByColumnName(columnName);
}
Also used : TnRelationPropertyType(org.dbflute.s2dao.metadata.TnRelationPropertyType)

Example 4 with TnRelationPropertyType

use of org.dbflute.s2dao.metadata.TnRelationPropertyType in project dbflute-core by dbflute.

the class TnRelationPropertyTypeFactoryImpl method createRelationPropertyTypes.

// ===================================================================================
// Create Relation
// ===============
public TnRelationPropertyType[] createRelationPropertyTypes() {
    final List<TnRelationPropertyType> relList = new ArrayList<TnRelationPropertyType>(RELATION_SIZE_CAPACITY);
    final DfBeanDesc localBeanDesc = getLocalBeanDesc();
    final List<String> proppertyNameList = localBeanDesc.getProppertyNameList();
    for (String proppertyName : proppertyNameList) {
        final DfPropertyDesc propertyDesc = localBeanDesc.getPropertyDesc(proppertyName);
        if (_stopRelationCreation || !isRelationProperty(propertyDesc)) {
            continue;
        }
        relList.add(createRelationPropertyType(propertyDesc));
    }
    return relList.toArray(new TnRelationPropertyType[relList.size()]);
}
Also used : TnRelationPropertyType(org.dbflute.s2dao.metadata.TnRelationPropertyType) DfPropertyDesc(org.dbflute.helper.beans.DfPropertyDesc) ArrayList(java.util.ArrayList) DfBeanDesc(org.dbflute.helper.beans.DfBeanDesc)

Example 5 with TnRelationPropertyType

use of org.dbflute.s2dao.metadata.TnRelationPropertyType in project dbflute-core by dbflute.

the class TnRelationRowCreatorImpl method createPropertyCache.

// ===================================================================================
// Property Cache Creation
// =======================
/**
 * {@inheritDoc}
 */
public Map<String, Map<String, TnPropertyMapping>> createPropertyCache(Map<String, String> selectColumnMap, Map<String, Map<String, Integer>> selectIndexMap, TnRelationSelector relSelector, TnBeanMetaData baseBmd) throws SQLException {
    // - - - - - - -
    // Entry Point!
    // - - - - - - -
    final Map<String, Map<String, TnPropertyMapping>> relPropCache = newRelationPropertyCache();
    final List<TnRelationPropertyType> relationPropertyTypeList = baseBmd.getRelationPropertyTypeList();
    for (TnRelationPropertyType rpt : relationPropertyTypeList) {
        final String baseSuffix = "";
        final String relationNoSuffix = rpt.getRelationNoSuffixPart();
        final TnRelationRowCreationResource res = createResourceForPropertyCache(rpt, selectColumnMap, selectIndexMap, relPropCache, relSelector, baseSuffix, relationNoSuffix, getLimitRelationNestLevel());
        setupPropertyCache(res);
    }
    return relPropCache;
}
Also used : TnRelationPropertyType(org.dbflute.s2dao.metadata.TnRelationPropertyType) TnRelationRowCreationResource(org.dbflute.s2dao.rowcreator.TnRelationRowCreationResource) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap)

Aggregations

TnRelationPropertyType (org.dbflute.s2dao.metadata.TnRelationPropertyType)10 TnBeanMetaData (org.dbflute.s2dao.metadata.TnBeanMetaData)3 Map (java.util.Map)2 TnRelationRowCache (org.dbflute.s2dao.rowcreator.TnRelationRowCache)2 ArrayList (java.util.ArrayList)1 ConditionBean (org.dbflute.cbean.ConditionBean)1 DBMeta (org.dbflute.dbmeta.DBMeta)1 StringKeyMap (org.dbflute.helper.StringKeyMap)1 DfBeanDesc (org.dbflute.helper.beans.DfBeanDesc)1 DfPropertyDesc (org.dbflute.helper.beans.DfPropertyDesc)1 OutsideSqlContext (org.dbflute.outsidesql.OutsideSqlContext)1 TnPropertyMapping (org.dbflute.s2dao.metadata.TnPropertyMapping)1 TnPropertyType (org.dbflute.s2dao.metadata.TnPropertyType)1 TnRelationKey (org.dbflute.s2dao.rowcreator.TnRelationKey)1 TnRelationRowCreationResource (org.dbflute.s2dao.rowcreator.TnRelationRowCreationResource)1 TnRelationSelector (org.dbflute.s2dao.rowcreator.TnRelationSelector)1