Search in sources :

Example 16 with DfLanguageDependency

use of org.dbflute.logic.generate.language.DfLanguageDependency in project dbflute-core by dbflute.

the class DfParameterAutoDetectAssist method resolvePackageNameExceptUtil.

protected String resolvePackageNameExceptUtil(String typeName) {
    final DfLanguageDependency lang = getBasicProperties().getLanguageDependency();
    final DfLanguagePropertyPackageResolver resolver = lang.getLanguagePropertyPackageResolver();
    return resolver.resolvePackageNameExceptUtil(typeName);
}
Also used : DfLanguageDependency(org.dbflute.logic.generate.language.DfLanguageDependency) DfLanguagePropertyPackageResolver(org.dbflute.logic.generate.language.pkgstyle.DfLanguagePropertyPackageResolver)

Example 17 with DfLanguageDependency

use of org.dbflute.logic.generate.language.DfLanguageDependency in project dbflute-core by dbflute.

the class DfBqpOutsideSqlFile method doAnalyze.

protected void doAnalyze() {
    final String exbhvMark;
    {
        final String exbhvPackage;
        if (isApplicationBehaviorProject()) {
            exbhvPackage = getLibraryBehaviorPackage();
        } else {
            exbhvPackage = getBasicProperties().getExtendedBehaviorPackage();
        }
        final String exbhvName = Srl.substringLastRear(exbhvPackage, ".");
        final DfLanguageDependency lang = getBasicProperties().getLanguageDependency();
        final DfLanguageClassPackage pkg = lang.getLanguageClassPackage();
        final String sqlPackage;
        if (getOutsideSqlProperties().isSqlPackageValid()) {
            final String pureSqlPackage = getOutsideSqlProperties().getSqlPackage();
            if (pureSqlPackage.endsWith(exbhvName)) {
                // contains 'exbhv'
                sqlPackage = Srl.substringLastFront(pureSqlPackage, ".");
            } else {
                sqlPackage = pureSqlPackage;
            }
        } else {
            sqlPackage = Srl.substringLastFront(exbhvPackage, ".");
        }
        exbhvMark = pkg.buildExtendedBehaviorPackageMark(sqlPackage, exbhvName);
    }
    // both types are target
    final String bhvSuffix = "Bhv";
    final String bhvApSuffix = getApplicationBehaviorAdditionalSuffix();
    final Pattern bqpPattern = Pattern.compile(".+" + exbhvMark + ".+" + bhvSuffix + "_.+.sql$");
    final Pattern bqpApPattern = Pattern.compile(".+" + exbhvMark + ".+" + bhvApSuffix + "_.+.sql$");
    final String path = getSlashPath(_outsideSqlFile.getPhysicalFile());
    final Matcher matcher = bqpPattern.matcher(path);
    final Matcher matcherAp = bqpApPattern.matcher(path);
    final String foundSuffix;
    if (matcher.matches()) {
        foundSuffix = bhvSuffix;
    } else if (matcherAp.matches()) {
        foundSuffix = bhvApSuffix;
    } else {
        _bqp = false;
        return;
    }
    _bqp = true;
    String simpleFileName = path.substring(path.lastIndexOf(exbhvMark) + exbhvMark.length());
    if (simpleFileName.contains("/")) {
        _subDirectoryPath = simpleFileName.substring(0, simpleFileName.lastIndexOf("/"));
        simpleFileName = simpleFileName.substring(simpleFileName.lastIndexOf("/") + "/".length());
    }
    final int behaviorNameMarkIndex = simpleFileName.indexOf(foundSuffix + "_");
    final int behaviorNameEndIndex = behaviorNameMarkIndex + foundSuffix.length();
    final int behaviorQueryPathStartIndex = behaviorNameMarkIndex + (foundSuffix + "_").length();
    final int behaviorQueryPathEndIndex = simpleFileName.lastIndexOf(".sql");
    _entityName = simpleFileName.substring(0, behaviorNameMarkIndex);
    _behaviorName = simpleFileName.substring(0, behaviorNameEndIndex);
    _behaviorQueryPath = simpleFileName.substring(behaviorQueryPathStartIndex, behaviorQueryPathEndIndex);
    _filePath = path;
    if (_outsideSqlFile.isSqlAp()) {
        _sqlAp = true;
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) DfLanguageDependency(org.dbflute.logic.generate.language.DfLanguageDependency) DfLanguageClassPackage(org.dbflute.logic.generate.language.pkgstyle.DfLanguageClassPackage)

Example 18 with DfLanguageDependency

use of org.dbflute.logic.generate.language.DfLanguageDependency in project dbflute-core by dbflute.

the class DfPmbGenerationHandler method getSuperClassDefinition.

public String getSuperClassDefinition(String className) {
    assertArgumentPmbMetaDataClassName(className);
    if (!hasSuperClassDefinition(className)) {
        return "";
    }
    final DfPmbMetaData metaData = findPmbMetaData(className);
    final String superClassName = metaData.getSuperClassName();
    final DfLanguageDependency lang = getBasicProperties().getLanguageDependency();
    final String extendsMark = lang.getLanguageGrammar().getExtendsMark();
    return " " + extendsMark + " " + superClassName;
}
Also used : DfLanguageDependency(org.dbflute.logic.generate.language.DfLanguageDependency)

Example 19 with DfLanguageDependency

use of org.dbflute.logic.generate.language.DfLanguageDependency in project dbflute-core by dbflute.

the class DfLastaFluteProperties method reflectApplicationOutsideSqlMap.

// ===================================================================================
// Application OutsideSql
// ======================
public void reflectApplicationOutsideSqlMap(Map<String, Map<String, String>> appOutqlMap) {
    final Map<String, Object> lastafluteMap = getLastafluteMap();
    @SuppressWarnings("unchecked") final Map<String, Map<String, Object>> appMap = (Map<String, Map<String, Object>>) lastafluteMap.get("appMap");
    if (appMap == null) {
        // just in case
        return;
    }
    show("/===========================================================================");
    show("...Loading application outsideSql settings from lastafluteMap.");
    final DfLanguageDependency lang = getBasicProperties().getLanguageDependency();
    final String resourceDirectory = lang.getMainResourceDirectory();
    final String programDirectory = lang.getMainProgramDirectory();
    for (Entry<String, Map<String, Object>> entry : appMap.entrySet()) {
        final Map<String, Object> map = entry.getValue();
        if (map != null) {
            final String path = (String) map.get("path");
            if (path != null && !path.equals("..")) {
                // e.g. except DBFlute central project e.g. harbor
                final Map<String, String> elementMap = newLinkedHashMap();
                elementMap.put("sqlDirectory", resourceDirectory);
                elementMap.put("sql2EntityOutputDirectory", programDirectory);
                // because of automatic settings
                elementMap.put("isSuppressDirectoryCheck", "true");
                show("...Reflecting application outsideSql: " + path + ", " + elementMap);
                appOutqlMap.put(path, elementMap);
            }
        }
    }
    show("==========/");
}
Also used : Map(java.util.Map) DfLanguageDependency(org.dbflute.logic.generate.language.DfLanguageDependency)

Example 20 with DfLanguageDependency

use of org.dbflute.logic.generate.language.DfLanguageDependency 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

DfLanguageDependency (org.dbflute.logic.generate.language.DfLanguageDependency)26 DfLanguagePropertyPackageResolver (org.dbflute.logic.generate.language.pkgstyle.DfLanguagePropertyPackageResolver)7 Column (org.apache.torque.engine.database.model.Column)4 Map (java.util.Map)3 DfLanguageGrammar (org.dbflute.logic.generate.language.grammar.DfLanguageGrammar)3 DfLanguageImplStyle (org.dbflute.logic.generate.language.implstyle.DfLanguageImplStyle)3 DfLanguageClassPackage (org.dbflute.logic.generate.language.pkgstyle.DfLanguageClassPackage)3 DfBasicProperties (org.dbflute.properties.DfBasicProperties)3 FileNotFoundException (java.io.FileNotFoundException)2 DfLittleAdjustmentProperties (org.dbflute.properties.DfLittleAdjustmentProperties)2 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 OutputStreamWriter (java.io.OutputStreamWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1