Search in sources :

Example 1 with DfLanguageDependency

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

the class ForeignKey method filterDynamicFixedConditionParameterType.

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

Example 2 with DfLanguageDependency

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

the class DfFixedConditionDynamicAnalyzer method filterDynamicFixedConditionParameterType.

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

Example 3 with DfLanguageDependency

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

the class DfColumnListToStringBuilder method getColumnArgsSetupPropertyString.

public static String getColumnArgsSetupPropertyString(String beanName, List<Column> columnList) {
    validateColumnList(columnList);
    final boolean hasPrefix = beanName != null;
    final String beanPrefix = (hasPrefix ? beanName + "." : "");
    final DfLanguageDependency lang = getBasicProperties().getLanguageDependency();
    final DfLanguageImplStyle implStyle = lang.getLanguageImplStyle();
    String result = "";
    for (Iterator<Column> ite = columnList.iterator(); ite.hasNext(); ) {
        final Column column = (Column) ite.next();
        final String javaName = column.getJavaName();
        final String variable = column.getUncapitalisedJavaName();
        final String cls = column.getClassificationName();
        final String basic;
        if (column.isForceClassificationSetting()) {
            basic = "set" + javaName + "As" + cls + "(" + variable + ")";
        } else {
            basic = "set" + javaName + "(" + variable + ")";
        }
        final String adjusted = implStyle.adjustEntitySetPropertyCall(basic, !hasPrefix);
        final String setter = beanPrefix + adjusted + ";";
        if ("".equals(result)) {
            result = setter;
        } else {
            result = result + setter;
        }
    }
    return result;
}
Also used : Column(org.apache.torque.engine.database.model.Column) DfLanguageDependency(org.dbflute.logic.generate.language.DfLanguageDependency) DfLanguageImplStyle(org.dbflute.logic.generate.language.implstyle.DfLanguageImplStyle)

Example 4 with DfLanguageDependency

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

the class DfParameterBeanResolver 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 5 with DfLanguageDependency

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

the class DfBqpBehaviorFile method writeBehaviorQueryPath.

// ===================================================================================
// Write
// =====
/**
 * @param resourceElementMap The map of resource element. (NotNull)
 */
protected void writeBehaviorQueryPath(Map<String, Map<String, String>> resourceElementMap) {
    final String encoding = getBasicProperties().getSourceFileEncoding();
    final String lineSep = getBasicProperties().getSourceCodeLineSeparator();
    final DfLanguageDependency lang = getBasicProperties().getLanguageDependency();
    final DfLanguageGrammar grammar = lang.getLanguageGrammar();
    final String behaviorQueryPathBeginMark = getBasicProperties().getBehaviorQueryPathBeginMark();
    final String behaviorQueryPathEndMark = getBasicProperties().getBehaviorQueryPathEndMark();
    final DfDocumentProperties docprop = getDocumentProperties();
    final StringBuilder sb = new StringBuilder();
    String lineString = null;
    BufferedReader br = null;
    try {
        br = new BufferedReader(new InputStreamReader(new FileInputStream(_bsbhvFile), encoding));
        boolean targetArea = false;
        boolean done = false;
        while (true) {
            lineString = br.readLine();
            if (lineString == null) {
                if (targetArea) {
                    String msg = "The end mark of behavior query path was not found: bsbhvFile=" + _bsbhvFile;
                    throw new IllegalStateException(msg);
                }
                break;
            }
            if (targetArea) {
                if (lineString.contains(behaviorQueryPathEndMark)) {
                    targetArea = false;
                } else {
                    continue;
                }
            }
            sb.append(lineString).append(lineSep);
            if (!done && lineString.contains(behaviorQueryPathBeginMark)) {
                targetArea = true;
                final String adjustedIndent = grammar.adjustClassElementIndent("    ");
                for (Entry<String, Map<String, String>> entry : resourceElementMap.entrySet()) {
                    final String behaviorQueryPath = entry.getKey();
                    final Map<String, String> behaviorQueryElementMap = entry.getValue();
                    final StringBuilder defSb = new StringBuilder();
                    final String keyTitle = DfBehaviorQueryPathSetupper.KEY_TITLE;
                    final String title = behaviorQueryElementMap.get(keyTitle);
                    if (title != null && title.trim().length() > 0) {
                        final String comment = buildJavaDocComment(grammar, docprop, title, adjustedIndent);
                        defSb.append(comment).append(lineSep);
                    }
                    defSb.append(adjustedIndent);
                    defSb.append(grammar.getPublicStaticFinal());
                    final String keySubDirectoryPath = DfBehaviorQueryPathSetupper.KEY_SUB_DIRECTORY_PATH;
                    final String subDirectoryPath = behaviorQueryElementMap.get(keySubDirectoryPath);
                    final String pathJavaNativeType = "String";
                    defSb.append(" ");
                    if (Srl.is_NotNull_and_NotTrimmedEmpty(subDirectoryPath)) {
                        final String subDirectoryName = Srl.replace(subDirectoryPath, "/", "_");
                        final String subDirectoryValue = Srl.replace(subDirectoryPath, "/", ":");
                        String variable = "PATH_" + subDirectoryName + "_" + behaviorQueryPath;
                        defSb.append(grammar.buildVariableSimpleDefinition(pathJavaNativeType, variable));
                        defSb.append(" = \"");
                        defSb.append(subDirectoryValue).append(":").append(behaviorQueryPath);
                        defSb.append("\";");
                    } else {
                        String variable = "PATH_" + behaviorQueryPath;
                        defSb.append(grammar.buildVariableSimpleDefinition(pathJavaNativeType, variable));
                        defSb.append(" = \"").append(behaviorQueryPath).append("\";");
                    }
                    defSb.append(lineSep);
                    sb.append(defSb);
                }
                done = true;
            }
        }
        if (!done) {
            _log.warn("*The mark of behavior query path was not found: " + _bsbhvFile);
        }
    } catch (IOException e) {
        String msg = "BufferedReader.readLine() threw the exception: current line=" + lineString;
        throw new IllegalStateException(msg, e);
    } finally {
        if (br != null) {
            try {
                br.close();
            } catch (IOException ignored) {
                _log.warn(ignored.getMessage());
            }
        }
    }
    BufferedWriter bw = null;
    try {
        bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(_bsbhvFile), encoding));
        bw.write(sb.toString());
        bw.flush();
    } catch (UnsupportedEncodingException e) {
        String msg = "The encoding is unsupported: encoding=" + encoding;
        throw new IllegalStateException(msg, e);
    } catch (FileNotFoundException e) {
        String msg = "The file of base behavior was not found: bsbhvFile=" + _bsbhvFile;
        throw new IllegalStateException(msg, e);
    } catch (IOException e) {
        String msg = "BufferedWriter.write() threw the exception: bsbhvFile=" + _bsbhvFile;
        throw new IllegalStateException(msg, e);
    } finally {
        if (bw != null) {
            try {
                bw.close();
            } catch (IOException ignored) {
                _log.warn(ignored.getMessage());
            }
        }
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) BufferedWriter(java.io.BufferedWriter) FileOutputStream(java.io.FileOutputStream) BufferedReader(java.io.BufferedReader) OutputStreamWriter(java.io.OutputStreamWriter) DfLanguageGrammar(org.dbflute.logic.generate.language.grammar.DfLanguageGrammar) DfLanguageDependency(org.dbflute.logic.generate.language.DfLanguageDependency) DfDocumentProperties(org.dbflute.properties.DfDocumentProperties) Map(java.util.Map)

Aggregations

DfLanguageDependency (org.dbflute.logic.generate.language.DfLanguageDependency)27 DfLanguagePropertyPackageResolver (org.dbflute.logic.generate.language.pkgstyle.DfLanguagePropertyPackageResolver)8 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