Search in sources :

Example 11 with ColumnSqlName

use of org.dbflute.dbmeta.name.ColumnSqlName in project dbflute-core by dbflute.

the class SqlClauseMySql method buildMatchCondition.

// [DBFlute-0.9.5]
// ===================================================================================
// Full-Text Search
// ================
/**
 * Build a condition string of match statement for full-text search. <br>
 * Bind variable is unused because the condition value should be literal in MySQL.
 * @param textColumnList The list of text column. (NotNull, NotEmpty, StringColumn, TargetTableColumn)
 * @param conditionValue The condition value embedded without binding (by MySQL restriction) but escaped. (NotNull)
 * @param modifier The modifier of full-text search. (NullAllowed: If the value is null, No modifier specified)
 * @param tableDbName The DB name of the target table. (NotNull)
 * @param aliasName The alias name of the target table. (NotNull)
 * @return The condition string of match statement. (NotNull)
 */
public String buildMatchCondition(List<ColumnInfo> textColumnList, String conditionValue, FullTextSearchModifier modifier, String tableDbName, String aliasName) {
    assertTextColumnList(textColumnList);
    assertVariousTextSearchResource(conditionValue, modifier, tableDbName, aliasName);
    final StringBuilder sb = new StringBuilder();
    int index = 0;
    for (ColumnInfo columnInfo : textColumnList) {
        if (columnInfo == null) {
            continue;
        }
        assertTextColumnTable(tableDbName, columnInfo);
        assertTextColumnType(tableDbName, columnInfo);
        final ColumnSqlName columnSqlName = columnInfo.getColumnSqlName();
        if (index > 0) {
            sb.append(",");
        }
        sb.append(aliasName).append(".").append(columnSqlName);
        ++index;
    }
    sb.insert(0, "match(").append(") against ('");
    sb.append(escapeMatchConditionValue(conditionValue)).append("'");
    if (modifier != null) {
        sb.append(" ").append(modifier.code());
    }
    sb.append(")");
    return sb.toString();
}
Also used : ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo)

Example 12 with ColumnSqlName

use of org.dbflute.dbmeta.name.ColumnSqlName in project dbflute-core by dbflute.

the class AbstractConditionQuery method doRegIQ.

protected void doRegIQ(ConditionKey key, Object value, ConditionValue cvalue, String columnDbName, ConditionOption option) {
    if (!prepareQueryChecked(key, value, cvalue, columnDbName).newClause()) {
        return;
    }
    final DBMeta dbmeta = xgetDBMetaProvider().provideDBMetaChecked(asTableDbName());
    final ColumnInfo columnInfo = dbmeta.findColumnInfo(columnDbName);
    final String propertyName = columnInfo.getPropertyName();
    final String uncapPropName = initUncap(propertyName);
    // If Java, it is necessary to use uncapPropName!
    final String location = xgetLocation(uncapPropName);
    key.setupConditionValue(xcreateQueryModeProvider(), cvalue, value, location, option);
    final ColumnSqlName columnSqlName = columnInfo.getColumnSqlName();
    final ColumnFunctionCipher cipher = xgetSqlClause().findColumnFunctionCipher(columnInfo);
    if (isBaseQuery()) {
        xgetSqlClause().registerBaseTableInlineWhereClause(columnSqlName, key, cvalue, cipher, option);
    } else {
        final String aliasName = xgetAliasName();
        xgetSqlClause().registerOuterJoinInlineWhereClause(aliasName, columnSqlName, key, cvalue, cipher, option, _onClause);
    }
}
Also used : ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) DBMeta(org.dbflute.dbmeta.DBMeta) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) ColumnFunctionCipher(org.dbflute.cbean.cipher.ColumnFunctionCipher)

Example 13 with ColumnSqlName

use of org.dbflute.dbmeta.name.ColumnSqlName in project dbflute-core by dbflute.

the class HpCalcSpecification method buildStatementAsSqlName.

// ===================================================================================
// Statement
// =========
/**
 * {@inheritDoc}
 */
public String buildStatementAsSqlName(String aliasName) {
    // e.g. VaryingUpdate, VaryingQueryUdpate
    final ColumnSqlName columnSqlName = getResolvedSpecifiedColumnSqlName();
    if (columnSqlName == null) {
        // very rare case, e.g. DreamCruise
        String msg = "Specified column is not found or too many columns are specified: " + aliasName;
        throw new IllegalConditionBeanOperationException(msg);
    }
    final String columnExp = (aliasName != null ? aliasName : "") + columnSqlName.toString();
    final boolean removeCalcAlias = aliasName == null;
    return doBuildStatement(columnExp, null, removeCalcAlias);
}
Also used : ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Example 14 with ColumnSqlName

use of org.dbflute.dbmeta.name.ColumnSqlName in project dbflute-core by dbflute.

the class ConditionKey method resolveCompoundColumn.

protected ColumnRealName resolveCompoundColumn(ColumnRealName baseRealName, ConditionOption option) {
    if (option == null || !option.hasCompoundColumn()) {
        return baseRealName;
    }
    if (!option.hasStringConnector()) {
        // basically no way
        String msg = "The option should have string connector when compound column is specified: " + option;
        throw new IllegalConditionBeanOperationException(msg);
    }
    final List<SpecifiedColumn> compoundColumnList = option.getCompoundColumnList();
    final List<ColumnRealName> realNameList = new ArrayList<ColumnRealName>();
    // already cipher
    realNameList.add(doResolveCompoundColumnOption(option, baseRealName));
    for (SpecifiedColumn specifiedColumn : compoundColumnList) {
        realNameList.add(doResolveCompoundColumnOption(option, doResolveCompoundColumnCipher(option, specifiedColumn)));
    }
    final OnQueryStringConnector stringConnector = option.getStringConnector();
    final String connected = stringConnector.connect(realNameList.toArray());
    return ColumnRealName.create(null, new ColumnSqlName(connected));
}
Also used : ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException) ArrayList(java.util.ArrayList) SpecifiedColumn(org.dbflute.cbean.dream.SpecifiedColumn) ColumnRealName(org.dbflute.dbmeta.name.ColumnRealName) OnQueryStringConnector(org.dbflute.dbway.OnQueryStringConnector)

Example 15 with ColumnSqlName

use of org.dbflute.dbmeta.name.ColumnSqlName in project dbflute-core by dbflute.

the class TnAbstractPropertyTypeFactory method createPropertyType.

protected TnPropertyType createPropertyType(DfPropertyDesc propertyDesc) {
    final ValueType valueType = getValueType(propertyDesc);
    final String columnDbName = getColumnDbName(propertyDesc);
    final ColumnSqlName columnSqlName = getColumnSqlName(columnDbName);
    final ColumnInfo entityColumnInfo = getEntityColumnInfo(columnDbName);
    return new TnPropertyTypeImpl(propertyDesc, valueType, columnDbName, columnSqlName, entityColumnInfo);
}
Also used : ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) ValueType(org.dbflute.jdbc.ValueType) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) TnPropertyTypeImpl(org.dbflute.s2dao.metadata.impl.TnPropertyTypeImpl)

Aggregations

ColumnSqlName (org.dbflute.dbmeta.name.ColumnSqlName)28 ColumnInfo (org.dbflute.dbmeta.info.ColumnInfo)14 ColumnRealName (org.dbflute.dbmeta.name.ColumnRealName)8 DBMeta (org.dbflute.dbmeta.DBMeta)5 SpecifiedColumn (org.dbflute.cbean.dream.SpecifiedColumn)4 IllegalConditionBeanOperationException (org.dbflute.exception.IllegalConditionBeanOperationException)3 TnPropertyType (org.dbflute.s2dao.metadata.TnPropertyType)3 LinkedHashMap (java.util.LinkedHashMap)2 SqlClause (org.dbflute.cbean.sqlclause.SqlClause)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ConditionBean (org.dbflute.cbean.ConditionBean)1 ColumnFunctionCipher (org.dbflute.cbean.cipher.ColumnFunctionCipher)1 SelectedRelationColumn (org.dbflute.cbean.sqlclause.select.SelectedRelationColumn)1 OnQueryStringConnector (org.dbflute.dbway.OnQueryStringConnector)1 StringKeyMap (org.dbflute.helper.StringKeyMap)1 ValueType (org.dbflute.jdbc.ValueType)1 TnPropertyTypeImpl (org.dbflute.s2dao.metadata.impl.TnPropertyTypeImpl)1