use of org.dbflute.properties.DfOutsideSqlProperties in project dbflute-core by dbflute.
the class DfProcedureExecutionMetaExtractor method extractExecutionMetaData.
// ===================================================================================
// Process
// =======
public void extractExecutionMetaData(DataSource dataSource, List<DfProcedureMeta> procedureList) throws SQLException {
final DfOutsideSqlProperties prop = getProperties().getOutsideSqlProperties();
for (DfProcedureMeta procedure : procedureList) {
final String procedureFullQualifiedName = procedure.getProcedureFullQualifiedName();
final String procedureSchemaQualifiedName = procedure.getProcedureSchemaQualifiedName();
final String procedureName = procedure.getProcedureName();
if (prop.isExecutionMetaProcedureName(procedureFullQualifiedName) || prop.isExecutionMetaProcedureName(procedureSchemaQualifiedName) || prop.isExecutionMetaProcedureName(procedureName)) {
doExtractExecutionMetaData(dataSource, procedure);
}
}
}
use of org.dbflute.properties.DfOutsideSqlProperties in project dbflute-core by dbflute.
the class DfProcedureExtractor method setupProcedureSynonym.
// -----------------------------------------------------
// Procedure Synonym
// -----------------
protected void setupProcedureSynonym(List<DfProcedureMeta> procedureList) {
if (_procedureSynonymDataSource == null) {
return;
}
final DfOutsideSqlProperties prop = getOutsideSqlProperties();
final ProcedureSynonymHandlingType handlingType = prop.getProcedureSynonymHandlingType();
if (handlingType.equals(ProcedureSynonymHandlingType.NONE)) {
return;
}
final DfProcedureSynonymExtractor extractor = createProcedureSynonymExtractor();
if (extractor == null) {
// unsupported at the database
return;
}
final Map<String, DfProcedureSynonymMeta> procedureSynonymMap = extractor.extractProcedureSynonymMap();
if (handlingType.equals(ProcedureSynonymHandlingType.INCLUDE)) {
// only add procedure synonyms to the procedure list
} else if (handlingType.equals(ProcedureSynonymHandlingType.SWITCH)) {
log("...Clearing normal procedures: count=" + procedureList.size());
// because of switch
procedureList.clear();
} else {
String msg = "Unexpected handling type of procedure sysnonym: " + handlingType;
throw new IllegalStateException(msg);
}
log("...Adding procedure synonyms as procedure: count=" + procedureSynonymMap.size());
final List<DfProcedureMeta> procedureSynonymList = new ArrayList<DfProcedureMeta>();
for (Entry<String, DfProcedureSynonymMeta> entry : procedureSynonymMap.entrySet()) {
final DfProcedureSynonymMeta metaInfo = entry.getValue();
if (!isSynonymAllowedSchema(metaInfo)) {
continue;
}
// merge synonym to procedure (create copied instance)
final String beforeName = metaInfo.getProcedureMetaInfo().buildProcedureLoggingName();
final DfProcedureMeta mergedProcedure = metaInfo.createMergedProcedure();
final String afterName = mergedProcedure.buildProcedureLoggingName();
log(" " + beforeName + " to " + afterName);
procedureSynonymList.add(mergedProcedure);
}
procedureList.addAll(procedureSynonymList);
}
use of org.dbflute.properties.DfOutsideSqlProperties in project dbflute-core by dbflute.
the class DfProcedureExtractor method setupProcedureToDBLinkIncluded.
// -----------------------------------------------------
// Included Procedure to DBLink
// ----------------------------
protected void setupProcedureToDBLinkIncluded(List<DfProcedureMeta> procedureList) {
if (_procedureToDBLinkDataSource == null) {
return;
}
final DfProcedureNativeTranslatorOracle translator = new DfProcedureNativeTranslatorOracle(_procedureToDBLinkDataSource);
final DfOutsideSqlProperties prop = getOutsideSqlProperties();
final List<String> procedureNameToDBLinkList = prop.getTargetProcedureNameToDBLinkList();
for (String propertyName : procedureNameToDBLinkList) {
final String packageName;
final String procedureName;
final String dbLinkName;
final String nameResource;
if (propertyName.contains(".")) {
packageName = Srl.substringLastFront(propertyName, ".");
nameResource = Srl.substringLastRear(propertyName, ".");
} else {
packageName = null;
nameResource = propertyName;
}
procedureName = Srl.substringLastFront(nameResource, "@");
dbLinkName = Srl.substringLastRear(nameResource, "@");
final DfProcedureMeta meta = translator.translateProcedureToDBLink(packageName, procedureName, dbLinkName, this);
if (meta == null) {
throwProcedureToDBLinkTranslationFailureException(propertyName, packageName, procedureName, dbLinkName);
}
meta.setIncludedProcedureToDBLink(true);
procedureList.add(meta);
}
}
use of org.dbflute.properties.DfOutsideSqlProperties in project dbflute-core by dbflute.
the class Table method switchSql2EntityDtoMapperOutputDirectory.
public void switchSql2EntityDtoMapperOutputDirectory() {
final DfOutsideSqlProperties prop = getProperties().getOutsideSqlProperties();
if (_sql2EntitySqlFile != null && _sql2EntitySqlFile.isSqlAp()) {
prop.switchSql2EntityOutputDirectory(_sql2EntitySqlFile.getSql2EntityOutputDirectory());
} else {
final String outputDirectory = getProperties().getSimpleDtoProperties().getDtoMapperOutputDirectory();
prop.switchSql2EntityOutputDirectory(outputDirectory);
}
}
use of org.dbflute.properties.DfOutsideSqlProperties in project dbflute-core by dbflute.
the class DfOutsideSqlTestTask method getSqlFileRunner.
protected DfSqlFileRunnerExecute getSqlFileRunner(final DfRunnerInformation runInfo) {
final String nonTargetMark = "df:x";
final DBDef currentDBDef = getDatabaseTypeFacadeProp().getCurrentDBDef();
return new DfSqlFileRunnerExecute(runInfo, getDataSource()) {
protected DfOutsideSqlChecker _outsideSqlChecker;
@Override
protected String filterSql(String sql) {
// /- - - - - - - - - - - - - - - - - - - - - - - - - -
// check parameter comments in the SQL before filtering
// - - - - - - - - - -/
checkParameterComment(_sqlFile, sql);
// filter comments if it needs.
if (!currentDBDef.dbway().isBlockCommentSupported()) {
sql = removeBlockComment(sql);
}
if (!currentDBDef.dbway().isLineCommentSupported()) {
sql = removeLineComment(sql);
}
return super.filterSql(sql);
}
protected String removeBlockComment(final String sql) {
return Srl.removeBlockComment(sql);
}
protected String removeLineComment(final String sql) {
return Srl.removeLineComment(sql);
}
@Override
protected boolean isTargetSql(String sql) {
final String entityName = getEntityName(sql);
if (entityName != null && nonTargetMark.equalsIgnoreCase(entityName)) {
// non-target SQL
_nonTargetSqlFileSet.add(_sqlFile);
_log.info("...Skipping the SQL by non-target mark '" + nonTargetMark + "'");
return false;
}
return super.isTargetSql(sql);
}
@Override
protected void traceSql(String sql) {
_log.info("SQL:" + ln() + sql);
}
@Override
protected void traceResult(int goodSqlCount, int totalSqlCount) {
_log.info(" -> success=" + goodSqlCount + " failure=" + (totalSqlCount - goodSqlCount) + ln());
}
protected String getEntityName(final String sql) {
return getTargetString(sql, "#");
}
protected String getTargetString(final String sql, final String mark) {
final List<String> targetList = getTargetList(sql, mark);
return !targetList.isEmpty() ? targetList.get(0) : null;
}
protected List<String> getTargetList(final String sql, final String mark) {
if (sql == null || sql.trim().length() == 0) {
String msg = "The sql is invalid: " + sql;
throw new IllegalArgumentException(msg);
}
final List<String> betweenBeginEndMarkList = getListBetweenBeginEndMark(sql, "--" + mark, mark);
if (!betweenBeginEndMarkList.isEmpty()) {
return betweenBeginEndMarkList;
} else {
// basically for MySQL
return getListBetweenBeginEndMark(sql, "-- " + mark, mark);
}
}
protected List<String> getListBetweenBeginEndMark(String targetStr, String beginMark, String endMark) {
final List<ScopeInfo> scopeList = Srl.extractScopeList(targetStr, beginMark, endMark);
final List<String> resultList = DfCollectionUtil.newArrayList();
for (ScopeInfo scope : scopeList) {
resultList.add(scope.getContent());
}
return resultList;
}
protected void checkParameterComment(File sqlFile, String sql) {
final DfOutsideSqlProperties outsideSqlProp = getOutsideSqlProperties();
if (outsideSqlProp.isSuppressParameterCommentCheck()) {
return;
}
if (_outsideSqlChecker == null) {
_outsideSqlChecker = createOutsideSqlChecker(outsideSqlProp);
}
_outsideSqlChecker.check(sqlFile.getName(), sql);
}
};
}
Aggregations