use of org.dbflute.logic.sql2entity.analyzer.DfOutsideSqlFile in project dbflute-core by dbflute.
the class DfSql2EntityTask method getTargetSqlFileList.
// ===================================================================================
// Executing Element
// =================
protected DfOutsideSqlPack getTargetSqlFileList() {
final DfOutsideSqlPack sqlFileList = collectOutsideSqlChecked();
final String specifiedSqlFile = DfSpecifiedSqlFile.getInstance().getSpecifiedSqlFile();
if (specifiedSqlFile != null) {
final DfOutsideSqlPack filteredList = new DfOutsideSqlPack();
for (DfOutsideSqlFile outsideSqlFile : sqlFileList.getOutsideSqlFileList()) {
final String fileName = outsideSqlFile.getPhysicalFile().getName();
if (specifiedSqlFile.equals(fileName)) {
filteredList.add(outsideSqlFile);
}
}
return filteredList;
} else {
return sqlFileList;
}
}
use of org.dbflute.logic.sql2entity.analyzer.DfOutsideSqlFile in project dbflute-core by dbflute.
the class DfBehaviorQueryPathSetupper method gatherBehaviorQueryPathInfo.
/**
* @param behaviorQueryPathMap The empty map of behavior query path. (NotNull)
* @param outsideSqlPack The pack object for outside-SQL file. (NotNull)
*/
protected void gatherBehaviorQueryPathInfo(Map<String, Map<String, String>> behaviorQueryPathMap, DfOutsideSqlPack outsideSqlPack) {
for (DfOutsideSqlFile outsideSqlFile : outsideSqlPack.getOutsideSqlFileList()) {
final DfBqpOutsideSqlFile bqpOutsideSqlFile = new DfBqpOutsideSqlFile(outsideSqlFile);
if (!bqpOutsideSqlFile.isBqp()) {
continue;
}
final Map<String, String> behaviorQueryElement = new LinkedHashMap<String, String>();
final String path = bqpOutsideSqlFile.getFilePath();
behaviorQueryElement.put(KEY_PATH, path);
behaviorQueryElement.put(KEY_SUB_DIRECTORY_PATH, bqpOutsideSqlFile.getSubDirectoryPath());
behaviorQueryElement.put(KEY_ENTITY_NAME, bqpOutsideSqlFile.getEntityName());
behaviorQueryElement.put(KEY_BEHAVIOR_NAME, bqpOutsideSqlFile.getBehaviorName());
behaviorQueryElement.put(KEY_BEHAVIOR_QUERY_PATH, bqpOutsideSqlFile.getBehaviorQueryPath());
if (outsideSqlFile.isSqlAp()) {
behaviorQueryElement.put(KEY_SQLAP, "true");
behaviorQueryElement.put(KEY_SQLAP_PROJECT_NAME, outsideSqlFile.getProjectName());
}
behaviorQueryPathMap.put(path, behaviorQueryElement);
// setup informations in the SQL file
setupInfoInSqlFile(outsideSqlFile, behaviorQueryElement);
}
}
use of org.dbflute.logic.sql2entity.analyzer.DfOutsideSqlFile in project dbflute-core by dbflute.
the class DfSql2EntityTask method showTargetSqlFileInformation.
// ===================================================================================
// SQL File Information
// ====================
protected void showTargetSqlFileInformation(DfOutsideSqlPack outsideSqlPack) {
final StringBuilder sb = new StringBuilder();
sb.append(ln()).append("/- - - - - - - - - - - - - - - - - - - - - - - -");
sb.append(ln()).append("Target SQL files: ").append(outsideSqlPack.size());
sb.append(ln());
for (DfOutsideSqlFile sqlFile : outsideSqlPack.getOutsideSqlFileList()) {
sb.append(ln()).append(" ").append(sqlFile.getPhysicalFile().getName());
}
sb.append(ln()).append("- - - - - - - - - -/");
_log.info(sb.toString());
}
use of org.dbflute.logic.sql2entity.analyzer.DfOutsideSqlFile in project dbflute-core by dbflute.
the class DfSql2EntityTask method initControlContext.
// ===================================================================================
// Prepare Generation
// ==================
@Override
public Context initControlContext() throws Exception {
_log.info("");
_log.info("...Preparing generation of customize-entities and parameter-beans");
_log.info("* * * * * * * * * *");
_log.info("* CustomizeEntity *");
_log.info("* * * * * * * * * *");
final StringBuilder logSb = new StringBuilder();
final Database database = _database;
database.setSql2EntitySchemaData(_schemaData);
database.setPmbMetaDataMap(_sql2entityMeta.getPmbMetaDataMap());
database.setSkipDeleteOldClass(isSkipDeleteOldClass());
final Map<String, DfCustomizeEntityInfo> entityInfoMap = _sql2entityMeta.getEntityInfoMap();
final Set<String> entityNameSet = entityInfoMap.keySet();
for (String entityName : entityNameSet) {
final DfCustomizeEntityInfo entityInfo = entityInfoMap.get(entityName);
final Map<String, DfColumnMeta> metaMap = entityInfo.getColumnMap();
final DfOutsideSqlFile outsideSqlFile = entityInfo.getOutsideSqlFile();
final Table tbl = new Table();
tbl.setSql2EntityCustomize(true);
if (outsideSqlFile != null) {
// basically true but checked just in case
tbl.setSql2EntitySqlFile(outsideSqlFile);
}
tbl.setName(entityInfo.getTableDbName());
if (!entityInfo.needsJavaNameConvert()) {
// basically here (except STRUCT type)
tbl.suppressJavaNameConvert();
}
if (entityInfo.hasNestedCustomizeEntity()) {
// basically when STRUCT type
tbl.setSql2EntityCustomizeHasNested(true);
}
if (entityInfo.isAdditionalSchema()) {
// basically when STRUCT type
tbl.setUnifiedSchema(entityInfo.getAdditionalSchema());
}
tbl.setSql2EntityTypeSafeCursor(entityInfo.isCursorHandling());
buildCustomizeEntityTitle(logSb, entityName, entityInfo);
final StringKeyMap<String> pkMap = getPrimaryKeyMap(entityInfo);
final boolean allCommonColumn = hasAllCommonColumn(metaMap);
final Set<String> columnNameSet = metaMap.keySet();
for (String columnName : columnNameSet) {
final Column column = new Column();
setupColumnName(columnName, column);
// an element removed from pkMap if true
// and a table name related to primary key is returned
final String pkRelatedTableName = setupPrimaryKey(pkMap, entityName, columnName, column);
setupTorqueType(metaMap, columnName, column, allCommonColumn);
setupDbType(metaMap, columnName, column);
setupNotNull(metaMap, columnName, column);
setupColumnSizeContainsDigit(metaMap, columnName, column);
setupColumnComment(metaMap, columnName, column);
setupSql2EntityElement(entityName, entityInfo, metaMap, columnName, column, pkRelatedTableName, logSb);
tbl.addColumn(column);
}
if (!pkMap.isEmpty()) {
// if not-removed columns exist
throwPrimaryKeyNotFoundException(entityName, pkMap, columnNameSet);
}
if (entityInfo.isScalarHandling()) {
// it does not generate an only-one-column entity
// one-way love for utility (just in case)
tbl.setDatabase(database);
processScalarHandling(entityInfo, tbl);
} else if (entityInfo.isDomainHandling()) {
// it does not generate an customize-entity
// one-way love for utility (just in case)
tbl.setDatabase(database);
processDomainHandling(entityInfo, tbl);
} else {
// initialize a class name of the entity for typed parameter-bean
// should be before getting names
database.addTable(tbl);
entityInfo.setEntityClassName(tbl.getExtendedEntityClassName());
entityInfo.setImmutableClassName(tbl.getImmutableExtendedEntityClassName());
}
logSb.append(ln());
}
final String databaseType = getDatabaseTypeFacadeProp().getTargetDatabase();
final AppData appData = new AppData(databaseType);
appData.addDatabase(database);
showCustomizeEntity(logSb);
showParameterBean();
final VelocityContext context = createVelocityContext(appData);
return context;
}
Aggregations