Search in sources :

Example 11 with DfDocumentProperties

use of org.dbflute.properties.DfDocumentProperties in project dbflute-core by dbflute.

the class DfPropHtmlManager method prepareRequest.

protected DfPropHtmlRequest prepareRequest(Map<String, Object> requestMap, String requestName) {
    final DfPropHtmlRequest request = createPropHtmlRequest(requestMap, requestName);
    final DfDocumentProperties prop = getDocumentProperties();
    final String rootFile = prop.getPropertiesHtmlRootFile(requestMap);
    final Map<String, DfPropHtmlFileAttribute> defaultEnvMap = setupDefaultEnvFamilyProperty(request, requestMap, rootFile);
    assertPropHtmlRootFileExists(defaultEnvMap, requestName, rootFile);
    final Map<String, String> environmentMap = prop.getPropertiesHtmlEnvironmentMap(requestMap);
    final String standardPureFileName = Srl.substringLastRear(rootFile, "/");
    for (Entry<String, String> entry : environmentMap.entrySet()) {
        final String envType = entry.getKey();
        final String envDir = entry.getValue();
        final String envFile;
        if (envDir.endsWith(".properties")) {
            // file name specified
            envFile = envDir;
        } else {
            envFile = envDir + "/" + standardPureFileName;
        }
        setupSpecifiedEnvFamilyProperty(request, requestMap, envFile, envType, defaultEnvMap);
    }
    return request;
}
Also used : DfDocumentProperties(org.dbflute.properties.DfDocumentProperties)

Example 12 with DfDocumentProperties

use of org.dbflute.properties.DfDocumentProperties in project dbflute-core by dbflute.

the class DfPropHtmlManager method createPropHtmlRequest.

protected DfPropHtmlRequest createPropHtmlRequest(Map<String, Object> requestMap, String requestName) {
    final DfDocumentProperties prop = getDocumentProperties();
    final List<String> diffIgnored = prop.getPropertiesHtmlDiffIgnoredKeyList(requestMap);
    final List<String> masked = prop.getPropertiesHtmlMaskedKeyList(requestMap);
    final boolean envOnly = prop.isPropertiesHtmlEnvOnlyFloatLeft(requestMap);
    final String extendsProp = prop.getPropertiesHtmlExtendsPropRequest(requestMap);
    final boolean checkImpOver = prop.isPropertiesHtmlCheckImplicitOverride(requestMap);
    return new DfPropHtmlRequest(requestName, diffIgnored, masked, envOnly, extendsProp, checkImpOver);
}
Also used : DfDocumentProperties(org.dbflute.properties.DfDocumentProperties)

Example 13 with DfDocumentProperties

use of org.dbflute.properties.DfDocumentProperties in project dbflute-core by dbflute.

the class DfPropHtmlPropertyLangElement method getCommentHtmlEncoded.

public String getCommentHtmlEncoded() {
    final DfDocumentProperties prop = DfBuildProperties.getInstance().getDocumentProperties();
    final String resolved = prop.resolveTextForSchemaHtml(_comment);
    return resolved != null ? resolved : "";
}
Also used : DfDocumentProperties(org.dbflute.properties.DfDocumentProperties)

Example 14 with DfDocumentProperties

use of org.dbflute.properties.DfDocumentProperties 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)

Example 15 with DfDocumentProperties

use of org.dbflute.properties.DfDocumentProperties in project dbflute-core by dbflute.

the class DfPmbCommentSetupper method buildExtendedClassDescription.

protected String buildExtendedClassDescription(DfPmbMetaData pmbMetaData, String indent, String lineSep) {
    final DfDocumentProperties docprop = getDocumentProperties();
    final String pmbBizName = pmbMetaData.getBusinessName();
    final StringBuilder sb = new StringBuilder();
    if (pmbMetaData.isTypedParameterBean()) {
        final String bhvClassName = pmbMetaData.getBehaviorClassName();
        final String bhvQueryPath = pmbMetaData.getBehaviorQueryPath();
        final String sqlTitle = docprop.resolveTextForJavaDoc(pmbMetaData.getSqlTitle(), indent);
        sb.append(indent).append("The typed parameter-bean of ").append(pmbBizName).append(". ");
        final String typedDisp = pmbMetaData.buildTypedDisp();
        if (Srl.is_NotNull_and_NotTrimmedEmpty(typedDisp)) {
            sb.append("<span style=\"color: #AD4747\">").append(typedDisp).append("</span>");
        }
        sb.append("<br>").append(lineSep);
        sb.append(indent).append("This is related to \"<span style=\"color: #AD4747\">");
        sb.append(bhvQueryPath).append("</span>\" on ").append(bhvClassName);
        if (Srl.is_NotNull_and_NotTrimmedEmpty(sqlTitle)) {
            sb.append(", <br>").append(lineSep).append(indent);
            sb.append("described as \"").append(sqlTitle).append("\"");
        }
        sb.append(".");
    } else if (pmbMetaData.isRelatedToProcedure()) {
        final String procedureName = pmbMetaData.getProcedureName();
        sb.append(indent).append("The typed parameter-bean of ").append(pmbBizName);
        sb.append(". <br>").append(lineSep);
        sb.append(indent).append("This is related to \"<span style=\"color: #AD4747\">");
        sb.append(procedureName).append("</span>\".");
    } else {
        if (pmbMetaData.isRelatedToBehaviorQuery()) {
            sb.append(indent).append("The simple parameter-bean of ").append(pmbBizName);
            sb.append(". <br>").append(lineSep);
            final String bhvClassName = pmbMetaData.getBehaviorClassName();
            final String bhvQueryPath = pmbMetaData.getBehaviorQueryPath();
            sb.append(indent).append("This is defined at \"<span style=\"color: #AD4747\">");
            sb.append(bhvQueryPath).append("</span>\" on ").append(bhvClassName).append(".");
        } else {
            sb.append(indent).append("The simple parameter-bean of ").append(pmbBizName).append(".");
        }
    }
    // basically unnecessary but against Eclipse default code formatter problem
    sb.append(" <br>");
    sb.append(lineSep);
    return sb.toString();
}
Also used : DfDocumentProperties(org.dbflute.properties.DfDocumentProperties)

Aggregations

DfDocumentProperties (org.dbflute.properties.DfDocumentProperties)34 DfSchemaHtmlBuilder (org.dbflute.logic.doc.schemahtml.DfSchemaHtmlBuilder)4 Map (java.util.Map)3 DfColumnListToStringBuilder (org.dbflute.logic.generate.column.DfColumnListToStringBuilder)3 Entry (java.util.Map.Entry)2 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)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 BigDecimal (java.math.BigDecimal)1 DfBuildProperties (org.dbflute.DfBuildProperties)1 JavaPropertiesProperty (org.dbflute.helper.jprop.JavaPropertiesProperty)1 DfLanguageDependency (org.dbflute.logic.generate.language.DfLanguageDependency)1 DfLanguageGrammar (org.dbflute.logic.generate.language.grammar.DfLanguageGrammar)1 DfBasicProperties (org.dbflute.properties.DfBasicProperties)1