use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class AbstractConditionBean method xcreateColQyClause.
// -----------------------------------------------------
// Create ColQyClause
// ------------------
protected <CB extends ConditionBean> QueryClause xcreateColQyClause(final String leftColumn, final String operand, final String rightColumn, final HpCalcSpecification<CB> rightCalcSp) {
return new QueryClause() {
@Override
public String toString() {
final String leftExp = resolveColumnExp(rightCalcSp.getLeftCalcSp(), leftColumn);
final String rightExp = resolveColumnExp(rightCalcSp, rightColumn);
return xbuildColQyClause(leftExp, operand, rightExp);
}
protected String resolveColumnExp(HpCalcSpecification<CB> calcSp, String columnExp) {
final String resolvedExp;
if (calcSp != null) {
final String statement = calcSp.buildStatementToSpecifidName(columnExp);
if (statement != null) {
// exists calculation
assertCalculationColumnType(calcSp);
// cipher already resolved
resolvedExp = statement;
} else {
final ColumnInfo columnInfo = calcSp.getSpecifiedColumnInfo();
if (columnInfo != null) {
// means plain column
resolvedExp = decryptIfNeeds(columnInfo, columnExp);
} else {
// deriving sub-query
resolvedExp = columnExp;
}
}
} else {
resolvedExp = columnExp;
}
return resolvedExp;
}
protected void assertCalculationColumnType(HpCalcSpecification<CB> calcSp) {
if (calcSp.hasConvert()) {
// because it may be Date type
return;
}
final ColumnInfo columnInfo = calcSp.getResolvedSpecifiedColumnInfo();
if (columnInfo != null) {
// basically true but checked just in case
if (!columnInfo.isObjectNativeTypeNumber()) {
// *simple message because other types may be supported at the future
String msg = "Not number column specified: " + columnInfo;
throw new ColumnQueryCalculationUnsupportedColumnTypeException(msg);
}
}
}
};
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class AbstractConditionBean method inviteDerivedToDreamCruise.
/**
* {@inheritDoc}
*/
public SpecifiedColumn inviteDerivedToDreamCruise(String derivedAlias) {
if (!xisDreamCruiseShip()) {
String msg = "This invitation is only allowed by Dream Cruise Ship: " + derivedAlias;
throw new IllegalConditionBeanOperationException(msg);
}
final SqlClause portClause = xgetDreamCruiseDeparturePort().getSqlClause();
if (!portClause.hasSpecifiedDerivingSubQuery(derivedAlias)) {
String msg = "Not found the derived info by the argument 'derivedAlias': " + derivedAlias;
throw new IllegalArgumentException(msg);
}
final ColumnInfo columnInfo = portClause.getSpecifiedDerivingColumnInfo(derivedAlias);
if (columnInfo == null) {
String msg = "Not found the derived column by the argument 'derivedAlias': " + derivedAlias;
throw new IllegalArgumentException(msg);
}
return new SpecifiedColumn(null, columnInfo, this, derivedAlias, true);
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class HpAbstractSpecification method doEveryColumn.
// ===================================================================================
// Theme Column
// ============
// -----------------------------------------------------
// Every Column
// ------------
protected void doEveryColumn() {
if (hasSpecifiedColumn()) {
throwSpecifyEveryColumnAlreadySpecifiedColumnException();
}
callQuery();
final boolean specifiedUpdateUse = isSpecifiedUpdateUse();
final List<ColumnInfo> columnInfoList = getColumnInfoList();
for (ColumnInfo columnInfo : columnInfoList) {
// primary key specification in BatchUpdate is not allowed
if (!(specifiedUpdateUse && columnInfo.isPrimary())) {
doColumn(columnInfo.getColumnDbName());
}
}
_alreadySpecifiedEveryColumn = true;
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class HpAbstractSpecification method doExceptRecordMetaColumn.
// -----------------------------------------------------
// Except Column
// -------------
protected void doExceptRecordMetaColumn() {
if (hasSpecifiedColumn()) {
throwSpecifyExceptColumnAlreadySpecifiedColumnException();
}
callQuery();
final boolean specifiedUpdateUse = isSpecifiedUpdateUse();
final List<ColumnInfo> columnInfoList = getColumnInfoList();
for (ColumnInfo columnInfo : columnInfoList) {
// this specification in BatchUpdate is non-sense but just in case
if (!isRecordMetaColumn(columnInfo) && !(specifiedUpdateUse && columnInfo.isPrimary())) {
doColumn(columnInfo.getColumnDbName());
}
}
_alreadySpecifiedExceptColumn = true;
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class MetaHandlingEntityToMapMapper method mappingToColumnValueMap.
// ===================================================================================
// Mapping
// =======
public Map<String, Object> mappingToColumnValueMap(List<ColumnInfo> columnInfoList) {
final Map<String, Object> valueMap = newLinkedHashMapSized(columnInfoList.size());
final Set<String> specifiedProperties = _entity.myspecifiedProperties();
final boolean nonSpChecked = !specifiedProperties.isEmpty();
for (ColumnInfo columnInfo : columnInfoList) {
final String columnName = columnInfo.getColumnDbName();
final Object value;
if (nonSpChecked && !specifiedProperties.contains(columnInfo.getPropertyName())) {
// non-specified column
// to avoid non-specified check
value = null;
} else {
value = columnInfo.read(_entity);
}
valueMap.put(columnName, value);
}
return valueMap;
}
Aggregations