Search in sources :

Example 1 with ColumnNullObjectable

use of org.dbflute.dbmeta.accessory.ColumnNullObjectable in project dbflute-core by dbflute.

the class TnRowCreatorExtension method adjustCreatedRow.

// ===================================================================================
// Fix Row
// =======
/**
 * Adjust created row. (clearing modified info, ...)
 * @param row The row of result list. (NotNull)
 * @param checkNonSp Does is use the check of access to non-specified column?
 * @param colNullObj Does is use the handling of column null object?
 * @param basePointBmd The bean meta data of the row for base-point table. (NotNull)
 * @param cb The condition-bean for the select. (NullAllowed: when not condition-bean select)
 */
public static void adjustCreatedRow(final Object row, boolean checkNonSp, boolean colNullObj, TnBeanMetaData basePointBmd, ConditionBean cb) {
    // _/_/_/_/_/_/_/_/_/_/
    if (row instanceof Entity) {
        final Entity entity = (Entity) row;
        // _/_/_/_/_/_/_/_/_/_/
        if (checkNonSp) {
            // contains enabled by CB and using SpecifyColumn
            entity.modifiedToSpecified();
            // _/_/_/_/_/_/_/_/_/_/
            if (colNullObj && cb != null) {
                // check 'cb' just in case
                final SqlClause sqlClause = cb.getSqlClause();
                for (ColumnInfo columnInfo : sqlClause.getLocalSpecifiedNullObjectColumnSet()) {
                    entity.myspecifyProperty(columnInfo.getPropertyName());
                }
            }
        }
        // only table that has null object target column is object-able (generated as it)
        if (colNullObj && entity instanceof ColumnNullObjectable) {
            ((ColumnNullObjectable) entity).enableColumnNullObject();
        }
        // clear modified properties for update process using selected entity
        entity.clearModifiedInfo();
        // mark as select to determine the entity is selected or user-created
        // basically for e.g. determine columns of batch insert
        entity.markAsSelect();
    } else {
        // not DBFlute entity
        // actually any bean meta data can be accepted
        // because only it gets modified properties
        basePointBmd.getModifiedPropertyNames(row).clear();
    }
}
Also used : Entity(org.dbflute.Entity) SqlClause(org.dbflute.cbean.sqlclause.SqlClause) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) ColumnNullObjectable(org.dbflute.dbmeta.accessory.ColumnNullObjectable)

Example 2 with ColumnNullObjectable

use of org.dbflute.dbmeta.accessory.ColumnNullObjectable in project dbflute-core by dbflute.

the class TnRelationRowCreatorExtension method adjustCreatedRelationRow.

/**
 * Adjust created row for relation tables.
 * @param relationRow The relation row of tables related to the base-point table. (NotNull)
 * @param relationNoSuffix The suffix of relation no, e.g. _0, _1_3. (NotNull)
 * @param relSelector The selector of relation, which has various determination. (NotNull)
 * @param rpt The property type of the relation. (NotNull)
 */
public static void adjustCreatedRelationRow(Object relationRow, String relationNoSuffix, TnRelationSelector relSelector, TnRelationPropertyType rpt) {
    // *similar implementation for base-point row exists, see it for the details
    if (relationRow instanceof Entity) {
        final Entity entity = (Entity) relationRow;
        // check access to non-specified-column
        if (// not allowed
        !relSelector.isNonSpecifiedColumnAccessAllowed(relationNoSuffix) && relSelector.isUsingSpecifyColumnInRelation(relationNoSuffix)) {
            // and use SpecifyColumn
            // so check it
            entity.modifiedToSpecified();
            // adjust specification for column null object handling
            final Set<ColumnInfo> nullObjectColumnSet = relSelector.getRelationSpecifiedNullObjectColumnSet(relationNoSuffix);
            for (ColumnInfo columnInfo : nullObjectColumnSet) {
                // might be empty loop if no null object
                entity.myspecifyProperty(columnInfo.getPropertyName());
            }
        }
        // enable the handling of column null object if allowed and object-able
        if (relSelector.isColumnNullObjectEnabled(relationNoSuffix) && entity instanceof ColumnNullObjectable) {
            ((ColumnNullObjectable) entity).enableColumnNullObject();
        }
        // clear modified properties for update process using selected entity
        entity.clearModifiedInfo();
        // mark as select to determine the entity is selected or user-created
        // basically for e.g. determine columns of batch insert
        entity.markAsSelect();
    } else {
        // not DBFlute entity
        // actually any bean meta data can be accepted
        // because only it gets modified properties
        rpt.getYourBeanMetaData().getModifiedPropertyNames(relationRow).clear();
    }
}
Also used : Entity(org.dbflute.Entity) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) ColumnNullObjectable(org.dbflute.dbmeta.accessory.ColumnNullObjectable)

Aggregations

Entity (org.dbflute.Entity)2 ColumnNullObjectable (org.dbflute.dbmeta.accessory.ColumnNullObjectable)2 ColumnInfo (org.dbflute.dbmeta.info.ColumnInfo)2 SqlClause (org.dbflute.cbean.sqlclause.SqlClause)1