Search in sources :

Example 36 with ColumnInfo

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

the class HpDerivingSubQueryInfo method extractDerivingColumnInfo.

public ColumnInfo extractDerivingColumnInfo() {
    final SqlClause subQuerySqlClause = _derivedReferrer.getSubQuerySqlClause();
    final ColumnInfo columnInfo = subQuerySqlClause.getSpecifiedColumnInfoAsOne();
    if (columnInfo != null) {
        return columnInfo;
    }
    // nested
    return subQuerySqlClause.getSpecifiedDerivingColumnInfoAsOne();
}
Also used : SqlClause(org.dbflute.cbean.sqlclause.SqlClause) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo)

Example 37 with ColumnInfo

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

the class ConditionKey method doResolveCompoundColumnCipher.

protected ColumnRealName doResolveCompoundColumnCipher(ConditionOption option, SpecifiedColumn specifiedColumn) {
    final GearedCipherManager cipherManager = option.getGearedCipherManager();
    final ColumnRealName specifiedName = specifiedColumn.toColumnRealName();
    if (cipherManager != null && !specifiedColumn.isDerived()) {
        final ColumnInfo columnInfo = specifiedColumn.getColumnInfo();
        final ColumnFunctionCipher cipher = cipherManager.findColumnFunctionCipher(columnInfo);
        if (cipher != null) {
            return toColumnRealName(cipher.decrypt(specifiedName.toString()));
        } else {
            return specifiedName;
        }
    } else {
        return specifiedName;
    }
}
Also used : ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) ColumnFunctionCipher(org.dbflute.cbean.cipher.ColumnFunctionCipher) GearedCipherManager(org.dbflute.cbean.cipher.GearedCipherManager) ColumnRealName(org.dbflute.dbmeta.name.ColumnRealName)

Example 38 with ColumnInfo

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

the class AbstractBehaviorWritable method helpReloadPrimaryKeyIfUniqueByIfNeeds.

protected <RESULT extends ENTITY> void helpReloadPrimaryKeyIfUniqueByIfNeeds(RESULT entity, UpdateOption<CB> option) {
    if (option == null || !option.isReloadPrimaryKeyIfUniqueBy()) {
        return;
    }
    final Set<String> uniqueProp = entity.myuniqueDrivenProperties();
    if (uniqueProp.isEmpty()) {
        // updated by PK normally
        return;
    }
    final DBMeta dbmeta = entity.asDBMeta();
    if (!dbmeta.hasPrimaryKey()) {
        // no PK table but has unique key
        return;
    }
    final CB cb = newConditionBean();
    final List<ColumnInfo> pkList = dbmeta.getPrimaryInfo().getPrimaryColumnList();
    for (ColumnInfo pk : pkList) {
        cb.invokeSpecifyColumn(pk.getPropertyName());
    }
    for (String uq : uniqueProp) {
        cb.localCQ().invokeQueryEqual(uq, dbmeta.findColumnInfo(uq).read(entity));
    }
    final Entity read = readEntityWithDeletedCheck(cb);
    dbmeta.acceptPrimaryKeyMap(entity, dbmeta.extractPrimaryKeyMap(read));
}
Also used : Entity(org.dbflute.Entity) DBMeta(org.dbflute.dbmeta.DBMeta) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo)

Example 39 with ColumnInfo

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

the class AbstractBehaviorReadable method xdoHelpExtractSetInternally.

protected <LOCAL_ENTITY extends Entity, COLUMN, COLLECTION extends Collection<COLUMN>> COLLECTION xdoHelpExtractSetInternally(List<LOCAL_ENTITY> localEntityList, String propertyName, COLLECTION collection) {
    assertObjectNotNull("localEntityList", localEntityList);
    assertObjectNotNull("propertyName", propertyName);
    final ColumnInfo columnInfo = asDBMeta().findColumnInfo(propertyName);
    for (LOCAL_ENTITY entity : localEntityList) {
        final COLUMN column = columnInfo.read(entity);
        if (column != null) {
            collection.add(column);
        }
    }
    return collection;
}
Also used : ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo)

Example 40 with ColumnInfo

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

the class AbstractBehaviorReadable method assertEntityNotNullAndHasPrimaryKeyValue.

/**
 * Assert that the entity has primary-key value. e.g. insert(), update(), delete()
 * @param entity The instance of entity to be checked. (NotNull)
 */
protected void assertEntityNotNullAndHasPrimaryKeyValue(Entity entity) {
    assertEntityNotNull(entity);
    final Set<String> uniqueDrivenPropSet = entity.myuniqueDrivenProperties();
    if (uniqueDrivenPropSet.isEmpty()) {
        // PK, basically here
        if (!entity.hasPrimaryKeyValue()) {
            createBhvExThrower().throwEntityPrimaryKeyNotFoundException(entity);
        }
    } else {
        // unique-driven
        for (String prop : uniqueDrivenPropSet) {
            final ColumnInfo columnInfo = asDBMeta().findColumnInfo(prop);
            if (columnInfo != null) {
                final Object value = columnInfo.read(entity);
                if (value == null) {
                    createBhvExThrower().throwEntityUniqueKeyNotFoundException(entity);
                }
            }
        }
    }
}
Also used : ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo)

Aggregations

ColumnInfo (org.dbflute.dbmeta.info.ColumnInfo)73 DBMeta (org.dbflute.dbmeta.DBMeta)27 ColumnSqlName (org.dbflute.dbmeta.name.ColumnSqlName)14 Entity (org.dbflute.Entity)8 SpecifiedColumn (org.dbflute.cbean.dream.SpecifiedColumn)7 SqlClause (org.dbflute.cbean.sqlclause.SqlClause)7 ArrayList (java.util.ArrayList)6 LinkedHashMap (java.util.LinkedHashMap)5 PrimaryInfo (org.dbflute.dbmeta.info.PrimaryInfo)5 ColumnRealName (org.dbflute.dbmeta.name.ColumnRealName)5 List (java.util.List)4 ForeignInfo (org.dbflute.dbmeta.info.ForeignInfo)4 HashSet (java.util.HashSet)3 ColumnFunctionCipher (org.dbflute.cbean.cipher.ColumnFunctionCipher)3 IllegalConditionBeanOperationException (org.dbflute.exception.IllegalConditionBeanOperationException)3 Method (java.lang.reflect.Method)2 LocalDate (java.time.LocalDate)2 LocalDateTime (java.time.LocalDateTime)2 Collection (java.util.Collection)2 Date (java.util.Date)2