Search in sources :

Example 1 with DfOutsideSqlLocation

use of org.dbflute.logic.sql2entity.analyzer.DfOutsideSqlLocation in project dbflute-core by dbflute.

the class DfOutsideSqlProperties method getSqlLocationList.

public List<DfOutsideSqlLocation> getSqlLocationList() {
    if (_outsideSqlLocationList != null) {
        return _outsideSqlLocationList;
    }
    _outsideSqlLocationList = new ArrayList<DfOutsideSqlLocation>();
    // basically unused
    final String mainProjectName = "main";
    final String mainDir = getMainSqlDirectory();
    final String mainOutput = getSql2EntityOutputDirectory();
    _outsideSqlLocationList.add(createOutsideSqlLocation(mainProjectName, mainDir, mainOutput, false, false));
    final Object obj = getApplicationOutsideSqlMap();
    if (!(obj instanceof Map<?, ?>)) {
        String msg = "The property 'applicationOutsideSqlMap' should be Map: " + obj.getClass();
        throw new DfIllegalPropertyTypeException(msg);
    }
    @SuppressWarnings("unchecked") final Map<String, Map<String, String>> sqlApMap = (Map<String, Map<String, String>>) obj;
    if (sqlApMap.isEmpty()) {
        return _outsideSqlLocationList;
    }
    final DfLanguageDependency lang = getBasicProperties().getLanguageDependency();
    final String defaultSqlDirectory = lang.getOutsideSqlDirectory();
    final String defaultMainProgramDirectory = lang.getMainProgramDirectory();
    for (Entry<String, Map<String, String>> entry : sqlApMap.entrySet()) {
        final String applicationDir = entry.getKey();
        final Map<String, String> elementMap = entry.getValue();
        // basically for display
        final String projectName;
        {
            final String lastName = Srl.substringLastRear(applicationDir, "/");
            if (Srl.is_Null_or_TrimmedEmpty(lastName) || Srl.equalsPlain(lastName, ".", "..")) {
                projectName = applicationDir;
            } else {
                projectName = lastName;
            }
        }
        final String sqlDirectory;
        {
            String plainDir = elementMap.get("sqlDirectory");
            if (Srl.is_Null_or_TrimmedEmpty(plainDir)) {
                plainDir = defaultSqlDirectory;
            }
            sqlDirectory = doGetSqlDirectory(applicationDir + "/" + plainDir);
        }
        final String sql2EntityOutputDirectory;
        {
            String plainDir = elementMap.get("sql2EntityOutputDirectory");
            if (Srl.is_Null_or_TrimmedEmpty(plainDir)) {
                plainDir = defaultMainProgramDirectory;
            }
            sql2EntityOutputDirectory = applicationDir + "/" + plainDir;
        }
        final boolean suppressDirectoryCheck;
        {
            String value = elementMap.get("isSuppressDirectoryCheck");
            if (Srl.is_NotNull_and_NotTrimmedEmpty(value) && value.trim().equalsIgnoreCase("true")) {
                suppressDirectoryCheck = true;
            } else {
                suppressDirectoryCheck = false;
            }
        }
        final DfOutsideSqlLocation sqlApLocation = createOutsideSqlLocation(projectName, sqlDirectory, sql2EntityOutputDirectory, true, suppressDirectoryCheck);
        _outsideSqlLocationList.add(sqlApLocation);
    }
    return _outsideSqlLocationList;
}
Also used : DfIllegalPropertyTypeException(org.dbflute.exception.DfIllegalPropertyTypeException) DfOutsideSqlLocation(org.dbflute.logic.sql2entity.analyzer.DfOutsideSqlLocation) Map(java.util.Map) DfLanguageDependency(org.dbflute.logic.generate.language.DfLanguageDependency)

Aggregations

Map (java.util.Map)1 DfIllegalPropertyTypeException (org.dbflute.exception.DfIllegalPropertyTypeException)1 DfLanguageDependency (org.dbflute.logic.generate.language.DfLanguageDependency)1 DfOutsideSqlLocation (org.dbflute.logic.sql2entity.analyzer.DfOutsideSqlLocation)1