Search in sources :

Example 1 with MapListString

use of org.dbflute.helper.mapstring.MapListString in project dbflute-core by dbflute.

the class DfPropertyUtil method mapProp.

public static Map<String, Object> mapProp(Properties prop, String key, String delimiter) {
    final MapListString mapListString = new MapListString();
    mapListString.setDelimiter(delimiter);
    return mapListString.generateMap(stringProp(prop, key));
}
Also used : MapListString(org.dbflute.helper.mapstring.MapListString)

Example 2 with MapListString

use of org.dbflute.helper.mapstring.MapListString in project dbflute-core by dbflute.

the class DfClassificationLiteralArranger method arrange.

public void arrange(String classificationName, Map<String, Object> elementMap) {
    final String codeKey = DfClassificationElement.KEY_CODE;
    final String code = (String) elementMap.get(codeKey);
    if (code == null) {
        // required check
        throwClassificationLiteralCodeNotFoundException(classificationName, elementMap);
    }
    final String nameKey = DfClassificationElement.KEY_NAME;
    final String name = (String) elementMap.get(nameKey);
    if (name == null) {
        // use code
        elementMap.put(nameKey, code);
    }
    final String aliasKey = DfClassificationElement.KEY_ALIAS;
    final String alias = (String) elementMap.get(aliasKey);
    if (alias == null) {
        // use name or code
        elementMap.put(aliasKey, name != null ? name : code);
    }
    final String subItemMapKey = DfClassificationElement.KEY_SUB_ITEM_MAP;
    @SuppressWarnings("unchecked") final Map<String, Object> subItemMap = (Map<String, Object>) elementMap.get(subItemMapKey);
    if (subItemMap != null) {
        final MapListString mapListString = new MapListString();
        for (Entry<String, Object> entry : subItemMap.entrySet()) {
            String key = entry.getKey();
            final Object value = entry.getValue();
            if (value != null && value instanceof List<?>) {
                // nested List is treated as string
                final List<?> listValue = (List<?>) value;
                final String listString = mapListString.buildListString(listValue);
                subItemMap.put(key, filterLineStringOnMapListString(listString));
            } else if (value != null && value instanceof Map<?, ?>) {
                // nested Map is treated as string
                @SuppressWarnings("unchecked") final Map<String, ?> mapValue = (Map<String, ?>) value;
                final String mapString = mapListString.buildMapString(mapValue);
                subItemMap.put(key, filterLineStringOnMapListString(mapString));
            } else if (value != null && value instanceof String) {
                subItemMap.put(key, filterLineStringOnMapListString((String) value));
            }
        }
    }
}
Also used : MapListString(org.dbflute.helper.mapstring.MapListString) List(java.util.List) MapListString(org.dbflute.helper.mapstring.MapListString) Map(java.util.Map)

Example 3 with MapListString

use of org.dbflute.helper.mapstring.MapListString in project dbflute-core by dbflute.

the class DfRefreshResourceProcess method handlePropsResult.

protected void handlePropsResult(String projectName, String body, Properties props) {
    try {
        final String refreshResult = props.getProperty("refresh.result");
        if (!Srl.equalsPlain(refreshResult, "allNotFound", "hasNotFound")) {
            // means success
            return;
        }
        final String ports = props.getProperty("retry.port");
        final List<Object> portList = new MapListString().generateList(ports);
        int refreshLevel = 2;
        boolean retrySuccess = false;
        for (Object portObj : portList) {
            final int port = Integer.parseInt(portObj.toString());
            if (retrySpecifiedPort(projectName, port, refreshLevel)) {
                retrySuccess = true;
                break;
            }
            ++refreshLevel;
        }
        if (!retrySuccess) {
            show("*Not found the projects in the Eclipse: " + projectName);
        }
    } catch (RuntimeException continued) {
        show("*Cannot retry by response port for the project: " + projectName + " " + continued.getMessage());
    }
}
Also used : MapListString(org.dbflute.helper.mapstring.MapListString) MapListString(org.dbflute.helper.mapstring.MapListString)

Example 4 with MapListString

use of org.dbflute.helper.mapstring.MapListString in project dbflute-core by dbflute.

the class DfPropertyUtil method listProp.

public static List<Object> listProp(Properties prop, String key, String delimiter) {
    final MapListString mapListString = new MapListString();
    mapListString.setDelimiter(delimiter);
    return mapListString.generateList(stringProp(prop, key));
}
Also used : MapListString(org.dbflute.helper.mapstring.MapListString)

Example 5 with MapListString

use of org.dbflute.helper.mapstring.MapListString in project dbflute-core by dbflute.

the class DfTableNameProp method outputTableNameMap.

public void outputTableNameMap(String baseDir, Map<String, Table> tableNameMap) {
    final Map<String, String> map = new LinkedHashMap<String, String>();
    for (Entry<String, Table> entry : tableNameMap.entrySet()) {
        final String sheetName = entry.getKey();
        final Table table = entry.getValue();
        map.put(sheetName, table.getTableSqlName());
    }
    final String mapString = new MapListString().buildMapString(map);
    final File dataPropFile = new File(baseDir + "/tableNameMap.dataprop");
    BufferedWriter bw = null;
    try {
        bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dataPropFile), "UTF-8"));
        bw.write(mapString);
        bw.flush();
    } catch (IOException e) {
        String msg = "Failed to write tableNameMap.dataprop: " + dataPropFile;
        throw new IllegalStateException(msg, e);
    } finally {
        if (bw != null) {
            try {
                bw.close();
            } catch (IOException ignored) {
            }
        }
    }
}
Also used : MapListString(org.dbflute.helper.mapstring.MapListString) Table(org.apache.torque.engine.database.model.Table) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) MapListString(org.dbflute.helper.mapstring.MapListString) IOException(java.io.IOException) File(java.io.File) LinkedHashMap(java.util.LinkedHashMap) BufferedWriter(java.io.BufferedWriter)

Aggregations

MapListString (org.dbflute.helper.mapstring.MapListString)6 List (java.util.List)2 Map (java.util.Map)2 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 LinkedHashMap (java.util.LinkedHashMap)1 Table (org.apache.torque.engine.database.model.Table)1