Search in sources :

Example 6 with DfBasicProperties

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

the class DfSchemaXmlReader method doCreateAsCoreTo.

public static DfSchemaXmlReader doCreateAsCoreTo(DfGenetateXmlReadingFilter readingFilter) {
    final DfBasicProperties basicProp = DfBuildProperties.getInstance().getBasicProperties();
    final DfSchemaXmlFacadeProp facadeProp = basicProp.getSchemaXmlFacadeProp();
    final String schemaXml = facadeProp.getProejctSchemaXMLFile();
    return doCreateAs(schemaXml, readingFilter);
}
Also used : DfBasicProperties(org.dbflute.properties.DfBasicProperties) DfSchemaXmlFacadeProp(org.dbflute.properties.facade.DfSchemaXmlFacadeProp)

Example 7 with DfBasicProperties

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

the class DfSchemaXmlSerializer method createAsCore.

/**
 * Create instance as core process (that is JDBC task).
 * @param dataSource The data source of the database. (NotNull)
 * @return The new instance. (NotNull)
 */
public static DfSchemaXmlSerializer createAsCore(DfSchemaSource dataSource) {
    final DfBuildProperties buildProp = DfBuildProperties.getInstance();
    final DfBasicProperties basicProp = buildProp.getBasicProperties();
    final DfSchemaXmlFacadeProp facadeProp = basicProp.getSchemaXmlFacadeProp();
    final String schemaXml = facadeProp.getProejctSchemaXMLFile();
    final String historyFile = facadeProp.getProjectSchemaHistoryFile();
    final DfSchemaXmlSerializer serializer = newSerializer(dataSource, schemaXml, historyFile);
    final DfDocumentProperties docProp = buildProp.getDocumentProperties();
    final String craftMetaDir = docProp.getCoreCraftMetaDir();
    serializer.enableCraftDiff(dataSource, craftMetaDir, DfCraftDiffAssertDirection.ROLLING_NEXT);
    // to avoid getting nonsense differences in JDBC task
    serializer.keepDefinitionOrderAsPrevious();
    return serializer;
}
Also used : DfDocumentProperties(org.dbflute.properties.DfDocumentProperties) DfBasicProperties(org.dbflute.properties.DfBasicProperties) DfSchemaXmlFacadeProp(org.dbflute.properties.facade.DfSchemaXmlFacadeProp) DfBuildProperties(org.dbflute.DfBuildProperties)

Example 8 with DfBasicProperties

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

the class DfBasicPropertiesTest method test_extendedConditionBeanPackage_without_conditionBeanPackage.

public void test_extendedConditionBeanPackage_without_conditionBeanPackage() {
    // ## Arrange ##
    Properties prop = new Properties();
    prop.setProperty("torque.packageBase", "test.base");
    prop.setProperty("torque.extendedConditionBeanPackage", "extended.cbean");
    DfBasicProperties packageProperties = new DfBasicProperties(prop);
    // ## Act ##
    String extendedConditionBeanPackage = packageProperties.getExtendedConditionBeanPackage();
    // ## Assert ##
    assertEquals("test.base.extended.cbean", extendedConditionBeanPackage);
}
Also used : Properties(java.util.Properties) DfBasicProperties(org.dbflute.properties.DfBasicProperties) DfBasicProperties(org.dbflute.properties.DfBasicProperties)

Example 9 with DfBasicProperties

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

the class DfProcedureMeta method buildProcedureSqlName.

public String buildProcedureSqlName() {
    if (Srl.is_NotNull_and_NotTrimmedEmpty(_procedureSqlName)) {
        return _procedureSqlName;
    }
    final DfBasicProperties prop = getBasicProperties();
    final String sqlName = getProcedureSchema().buildSqlName(getProcedureName());
    if (prop.isDatabaseDB2() && !sqlName.contains(".")) {
        // patch
        // DB2 needs schema prefix for calling procedures
        // (actually executed and confirmed result)
        _procedureSqlName = getProcedureSchema().buildSchemaQualifiedName(sqlName);
    } else {
        _procedureSqlName = sqlName;
    }
    if (prop.isDatabaseSQLServer()) {
        // SQLServer returns 'sp_foo;1'
        _procedureSqlName = Srl.substringLastFront(_procedureSqlName, ";");
    }
    return _procedureSqlName;
}
Also used : DfBasicProperties(org.dbflute.properties.DfBasicProperties)

Example 10 with DfBasicProperties

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

the class DfBehaviorQueryPathSetupper method doCreateBhvFileResourceMap.

/**
 * @param behaviorQueryPathMap The map of behavior query path. (NotNull)
 * @return The map of base behavior resource. (NotNull)
 * @throws DfBehaviorNotFoundException When the behavior is not found.
 */
protected Map<File, Map<String, Map<String, String>>> doCreateBhvFileResourceMap(Map<String, Map<String, String>> behaviorQueryPathMap, boolean reflectOnly) {
    if (behaviorQueryPathMap.isEmpty()) {
        return new HashMap<File, Map<String, Map<String, String>>>();
    }
    final DfBasicProperties basicProp = getBasicProperties();
    final File bsbhvDir = findBsBhvDirOrWarining();
    if (bsbhvDir == null) {
        // warning-only ending
        return new HashMap<File, Map<String, Map<String, String>>>();
    }
    final Map<String, File> bsbhvFileMap = createBsBhvFileMap(bsbhvDir);
    final Map<File, Map<String, Map<String, String>>> reflectResourceMap = new HashMap<File, Map<String, Map<String, String>>>();
    for (Entry<String, Map<String, String>> entry : behaviorQueryPathMap.entrySet()) {
        final Map<String, String> behaviorQueryElementMap = entry.getValue();
        // on SQL file
        final String behaviorName = behaviorQueryElementMap.get(KEY_BEHAVIOR_NAME);
        final String behaviorQueryPath = behaviorQueryElementMap.get(KEY_BEHAVIOR_QUERY_PATH);
        final String sqlApExp = behaviorQueryElementMap.get(KEY_SQLAP);
        if (reflectOnly && sqlApExp != null && "true".equalsIgnoreCase(sqlApExp)) {
            // out of target for ApplicationOutsideSql if reflect-only
            continue;
        }
        // relation point between SQL file and BsBhv
        File bsbhvFile = bsbhvFileMap.get(behaviorName);
        if (bsbhvFile == null) {
            if (isApplicationBehaviorProject()) {
                final String projectPrefixLib = getLibraryProjectPrefix();
                String retryName = behaviorName;
                if (retryName.startsWith(projectPrefixLib)) {
                    // e.g. LbFooBhv --> FooBhv
                    retryName = retryName.substring(projectPrefixLib.length());
                }
                final String projectPrefixAp = basicProp.getProjectPrefix();
                // e.g. FooBhv --> BpFooBhv
                retryName = projectPrefixAp + retryName;
                final String additionalSuffix = getApplicationBehaviorAdditionalSuffix();
                // e.g. BpFooBhv --> BpFooBhvAp
                retryName = retryName + additionalSuffix;
                bsbhvFile = bsbhvFileMap.get(retryName);
            }
            if (bsbhvFile == null) {
                throwBehaviorNotFoundException(bsbhvFileMap, behaviorQueryElementMap, bsbhvDir);
            }
        }
        Map<String, Map<String, String>> resourceElementMap = reflectResourceMap.get(bsbhvFile);
        if (resourceElementMap == null) {
            resourceElementMap = new LinkedHashMap<String, Map<String, String>>();
            reflectResourceMap.put(bsbhvFile, resourceElementMap);
        }
        if (!resourceElementMap.containsKey(behaviorQueryPath)) {
            resourceElementMap.put(behaviorQueryPath, behaviorQueryElementMap);
        }
    }
    return reflectResourceMap;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap) DfOutsideSqlFile(org.dbflute.logic.sql2entity.analyzer.DfOutsideSqlFile) File(java.io.File) DfBasicProperties(org.dbflute.properties.DfBasicProperties)

Aggregations

DfBasicProperties (org.dbflute.properties.DfBasicProperties)20 Properties (java.util.Properties)4 DfLanguageDependency (org.dbflute.logic.generate.language.DfLanguageDependency)3 DfSchemaXmlFacadeProp (org.dbflute.properties.facade.DfSchemaXmlFacadeProp)3 File (java.io.File)2 DfOutsideSqlFile (org.dbflute.logic.sql2entity.analyzer.DfOutsideSqlFile)2 DfDatabaseTypeFacadeProp (org.dbflute.properties.facade.DfDatabaseTypeFacadeProp)2 FileNotFoundException (java.io.FileNotFoundException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 DfBuildProperties (org.dbflute.DfBuildProperties)1 StringKeyMap (org.dbflute.helper.StringKeyMap)1 DfLanguageGrammar (org.dbflute.logic.generate.language.grammar.DfLanguageGrammar)1 DfLanguageClassPackage (org.dbflute.logic.generate.language.pkgstyle.DfLanguageClassPackage)1 DfDocumentProperties (org.dbflute.properties.DfDocumentProperties)1 DfLittleAdjustmentProperties (org.dbflute.properties.DfLittleAdjustmentProperties)1 DfSequenceIdentityProperties (org.dbflute.properties.DfSequenceIdentityProperties)1