use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class AbstractDBMeta method searchPrimaryInfo.
/**
* {@inheritDoc}
*/
public OptionalObject<PrimaryInfo> searchPrimaryInfo(Collection<ColumnInfo> columnInfoList) {
// exception if no PK
final PrimaryInfo primaryInfo = getPrimaryInfo();
final Set<ColumnInfo> colSet = new HashSet<ColumnInfo>(columnInfoList);
final List<ColumnInfo> pkList = primaryInfo.getPrimaryColumnList();
for (ColumnInfo pk : pkList) {
if (!colSet.contains(pk)) {
return OptionalObject.ofNullable(null, () -> {
throwSpecifiedColumnNotPrimaryException(columnInfoList, pkList);
});
}
}
return OptionalObject.of(primaryInfo);
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class AbstractDBMeta method setupKeyToLowerMap.
protected Map<String, String> setupKeyToLowerMap(boolean dbNameKey) {
final Map<String, String> map;
if (dbNameKey) {
map = newConcurrentHashMap(getTableDbName().toLowerCase(), getTablePropertyName());
} else {
map = newConcurrentHashMap(getTablePropertyName().toLowerCase(), getTableDbName());
}
final Method[] methods = this.getClass().getMethods();
final String columnInfoMethodPrefix = "column";
try {
for (Method method : methods) {
final String name = method.getName();
if (!name.startsWith(columnInfoMethodPrefix)) {
continue;
}
final ColumnInfo columnInfo = (ColumnInfo) method.invoke(this);
final String dbName = columnInfo.getColumnDbName();
final String propertyName = columnInfo.getPropertyName();
if (dbNameKey) {
map.put(dbName.toLowerCase(), propertyName);
} else {
map.put(propertyName.toLowerCase(), dbName);
}
}
return Collections.unmodifiableMap(map);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class AbstractDBMeta method findColumnInfo.
/**
* {@inheritDoc}
*/
public ColumnInfo findColumnInfo(String columnFlexibleName) {
assertStringNotNullAndNotTrimmedEmpty("columnFlexibleName", columnFlexibleName);
final Map<String, ColumnInfo> flexibleMap = getColumnInfoFlexibleMap();
final ColumnInfo columnInfo = flexibleMap.get(columnFlexibleName);
if (columnInfo == null) {
final String notice = "The column info was not found.";
final String keyName = "Column";
throwDBMetaNotFoundException(notice, keyName, columnFlexibleName, flexibleMap.keySet());
}
return columnInfo;
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class AbstractDBMeta method doConvertToEntity.
protected <ENTITY extends Entity> void doConvertToEntity(ENTITY entity, Map<String, ? extends Object> columnMap, boolean pkOnly) {
final List<ColumnInfo> columnInfoList = pkOnly ? getPrimaryInfo().getPrimaryColumnList() : getColumnInfoList();
final MetaHandlingMapToEntityMapper mapper = createMetaHandlingMapToEntityMapper(columnMap);
mapper.mappingToEntity(entity, columnMap, columnInfoList);
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class AbstractDBMeta method doSearchMetaInfoList.
protected <INFO> List<INFO> doSearchMetaInfoList(Collection<ColumnInfo> columnInfoList, List<INFO> infoList, Function<INFO, Collection<ColumnInfo>> oneArgLambda) {
if (infoList.isEmpty()) {
return DfCollectionUtil.emptyList();
}
final Set<ColumnInfo> specifiedColSet = new HashSet<ColumnInfo>(columnInfoList);
final List<INFO> foundInfoList = newArrayListSized(infoList.size());
for (INFO info : infoList) {
final Collection<ColumnInfo> columnList = oneArgLambda.apply(info);
boolean notFound = false;
for (ColumnInfo metaCol : columnList) {
if (!specifiedColSet.contains(metaCol)) {
notFound = true;
break;
}
}
if (!notFound) {
foundInfoList.add(info);
}
}
return Collections.unmodifiableList(foundInfoList);
}
Aggregations