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));
}
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));
}
}
}
}
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());
}
}
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));
}
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) {
}
}
}
}
Aggregations