use of org.dbflute.helper.mapstring.MapListFile in project dbflute-core by dbflute.
the class DfWebClsTableLoader method loadTable.
// ===================================================================================
// Load Table
// ==========
// ; resourceMap = map:{
// ; baseDir = ../src/main
// ; resourceType = WEB_CLS
// ; resourceFile = ../../../dockside_webcls.properties
// }
// ; outputMap = map:{
// ; templateFile = LaAppCDef.vm
// ; outputDirectory = $$baseDir$$/java
// ; package = org.dbflute...
// ; className = unused
// }
// ; optionMap = map:{
// }
@Override
public DfFreeGenMetaData loadTable(String requestName, DfFreeGenResource resource, DfFreeGenMapProp mapProp) {
// _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
// very similar to AppCls but no recycle because of silent maintenance
// _/_/_/_/_/_/_/_/_/_/
final String resourceFile = resource.getResourceFile();
final Map<String, Object> webclsMap;
try {
webclsMap = new MapListFile().readMap(new FileInputStream(resourceFile));
} catch (FileNotFoundException e) {
throw new DfIllegalPropertySettingException("Not found the dfprop file: " + resourceFile, e);
} catch (IOException e) {
throw new DfIllegalPropertySettingException("Cannot read the the dfprop file: " + resourceFile, e);
}
// lazy load because it might be unused
Map<String, DfClassificationTop> dbClsMap = null;
boolean hasRefCls = false;
final DfClassificationProperties clsProp = getClassificationProperties();
final DfClassificationLiteralArranger literalArranger = new DfClassificationLiteralArranger();
final List<DfClassificationTop> topList = new ArrayList<DfClassificationTop>();
for (Entry<String, Object> entry : webclsMap.entrySet()) {
final String classificationName = entry.getKey();
final DfClassificationTop classificationTop = new DfClassificationTop();
topList.add(classificationTop);
classificationTop.setClassificationName(classificationName);
DfRefClsElement refClsElement = null;
@SuppressWarnings("unchecked") final List<Map<String, Object>> elementMapList = (List<Map<String, Object>>) entry.getValue();
for (Map<String, Object> elementMap : elementMapList) {
if (isElementMapClassificationTop(elementMap)) {
classificationTop.acceptClassificationTopBasicItemMap(elementMap);
// pickup from DfClassificationProperties@processClassificationTopFromLiteralIfNeeds()
classificationTop.putGroupingAll(clsProp.getElementMapGroupingMap(elementMap));
classificationTop.putDeprecatedAll(clsProp.getElementMapDeprecatedMap(elementMap));
} else {
if (isElementMapRefCls(elementMap)) {
assertRefClsOnlyOne(classificationName, refClsElement, elementMap, resource);
if (dbClsMap == null) {
dbClsMap = getClassificationProperties().getClassificationTopMap();
}
refClsElement = createRefClsElement(classificationName, elementMap, dbClsMap, resource);
handleRefCls(classificationTop, refClsElement);
} else {
literalArranger.arrange(classificationName, elementMap);
final DfClassificationElement element = new DfClassificationElement();
element.setClassificationName(classificationName);
element.acceptBasicItemMap(elementMap);
classificationTop.addClassificationElement(element);
}
}
}
if (refClsElement != null) {
refClsElement.checkRelationshipByRefTypeIfNeeds(classificationTop);
hasRefCls = true;
}
}
final Map<String, Object> optionMap = mapProp.getOptionMap();
final String clsTheme = "webcls";
optionMap.put("clsTheme", clsTheme);
optionMap.put("classificationTopList", topList);
optionMap.put("classificationNameList", topList.stream().map(top -> {
return top.getClassificationName();
}).collect(Collectors.toList()));
optionMap.put("hasRefCls", hasRefCls);
optionMap.put("allcommonPackage", getBasicProperties().getBaseCommonPackage());
return DfFreeGenMetaData.asOnlyOne(optionMap, clsTheme, Collections.emptyList());
}
use of org.dbflute.helper.mapstring.MapListFile in project dbflute-core by dbflute.
the class DfPropPublicMap method loadMap.
// ===================================================================================
// Load Meta
// =========
public void loadMap() {
final String siteUrl = getPublicMapUrl();
InputStream ins = null;
try {
final URL url = new URL(siteUrl);
ins = url.openStream();
final MapListFile mapListFile = new MapListFile();
_map = mapListFile.readMap(ins);
} catch (IOException e) {
throw new IllegalStateException("The url threw the IO exception: url=" + siteUrl, e);
} finally {
if (ins != null) {
try {
ins.close();
} catch (IOException ignored) {
}
}
}
}
Aggregations