use of org.dbflute.helper.jprop.JavaPropertiesProperty in project dbflute-core by dbflute.
the class DfPropHtmlManager method doSetupFamilyProperty.
protected Map<String, DfPropHtmlFileAttribute> doSetupFamilyProperty(DfPropHtmlRequest request, Map<String, Object> requestMap, String propertiesFile, String envType, Map<String, DfPropHtmlFileAttribute> defaultEnvMap) {
final List<File> familyFileList = extractFamilyFileList(request.getRequestName(), requestMap, propertiesFile);
if (familyFileList.isEmpty()) {
return DfCollectionUtil.emptyMap();
}
final String specifiedPureFileName = Srl.substringLastRear(propertiesFile, "/");
final Map<String, DfPropHtmlFileAttribute> attributeMap = DfCollectionUtil.newLinkedHashMap();
DfPropHtmlFileAttribute rootAttribute = null;
if (defaultEnvMap != null) {
// when specified environment
for (DfPropHtmlFileAttribute attribute : defaultEnvMap.values()) {
if (attribute.isRootFile()) {
// always exists here
rootAttribute = attribute;
}
}
}
final DfPropHtmlRequest extendsRequest = getExtendsRequest(request);
for (final File familyFile : familyFileList) {
final String langType = extractLangType(familyFile.getName());
final String fileKey = buildFileKey(envType, familyFile);
final String title = fileKey + ":" + familyFile.getPath();
final JavaPropertiesReader reader = createReader(request, title, familyFile);
final DfPropHtmlFileAttribute extendsAttribute = findExtendsAttribute(extendsRequest, envType, langType);
if (extendsAttribute != null) {
prepareExtendsProperties(request, reader, extendsAttribute);
}
_log.info("...Reading properties family file: " + fileKey);
final JavaPropertiesResult jpropResult = reader.read();
// only base-point properties are target here
// extends properties are used only for override
final List<JavaPropertiesProperty> jpropList = jpropResult.getPropertyBasePointOnlyList();
final Set<String> propertyKeySet = DfCollectionUtil.newLinkedHashSet();
for (JavaPropertiesProperty jprop : jpropList) {
request.addProperty(envType, langType, jprop);
propertyKeySet.add(jprop.getPropertyKey());
}
final DfPropHtmlFileAttribute attribute = new DfPropHtmlFileAttribute(familyFile, envType, langType);
attribute.addPropertyKeyAll(propertyKeySet);
attribute.setKeyCount(jpropList.size());
attribute.setExtendsAttribute(extendsAttribute);
attribute.addDuplicateKeyAll(jpropResult.getDuplicateKeyList());
if (defaultEnvMap != null) {
// when specified environment
if (rootAttribute != null) {
// always true
// every files compare with root file here
attribute.setStandardAttribute(rootAttribute);
} else {
// no way but just in case
final DfPropHtmlFileAttribute standardAttribute = defaultEnvMap.get(langType);
if (standardAttribute != null) {
// same language on standard environment is my standard here
attribute.setStandardAttribute(standardAttribute);
}
// if standard not found, the file exists only in the environment
}
} else {
// when default environment
attribute.toBeDefaultEnv();
if (familyFile.getName().equals(specifiedPureFileName)) {
_log.info(" -> root file: " + specifiedPureFileName + " (" + envType + ")");
attribute.toBeRootFile();
// save for relation to root
rootAttribute = attribute;
}
}
request.addFileAttribute(attribute);
attributeMap.put(langType, attribute);
}
if (rootAttribute != null) {
for (DfPropHtmlFileAttribute attribute : attributeMap.values()) {
if (attribute.isDefaultEnv() && !attribute.isRootFile()) {
attribute.setStandardAttribute(rootAttribute);
}
}
}
return attributeMap;
}
use of org.dbflute.helper.jprop.JavaPropertiesProperty in project dbflute-core by dbflute.
the class DfPropTableLoader method doConvertToMapList.
protected List<Map<String, Object>> doConvertToMapList(final List<JavaPropertiesProperty> propertyList, Map<String, Object> tableMap) {
final List<String> exceptKeyList = extractExceptKeyList(tableMap);
final Map<String, String> groupingKeyMap = extractGroupingKeyMap(tableMap);
final DfDocumentProperties prop = getDocumentProperties();
final List<Map<String, Object>> mapList = DfCollectionUtil.newArrayList();
for (JavaPropertiesProperty property : propertyList) {
final Map<String, Object> columnMap = DfCollectionUtil.newLinkedHashMap();
final String propertyKey = property.getPropertyKey();
if (!isTargetKey(propertyKey, exceptKeyList)) {
continue;
}
columnMap.put("propertyKey", propertyKey);
// basically one line
final String propertyValue = property.getPropertyValue();
columnMap.put("propertyValue", propertyValue != null ? propertyValue : "");
setupPropertyValueDocument(prop, columnMap, propertyValue);
columnMap.put("propertyValueStringLiteral", preparePropertyValueStringLiteral(propertyValue));
columnMap.put("hasPropertyValue", Srl.is_NotNull_and_NotTrimmedEmpty(propertyValue));
final String defName = convertToDefName(propertyKey);
columnMap.put("defName", defName);
final String camelizedName = Srl.camelize(defName);
columnMap.put("camelizedName", camelizedName);
columnMap.put("capCamelName", Srl.initCap(camelizedName));
columnMap.put("uncapCamelName", Srl.initUncap(camelizedName));
final List<Integer> variableNumberList = property.getVariableNumberList();
// old style
columnMap.put("variableCount", variableNumberList.size());
columnMap.put("variableNumberCount", variableNumberList.size());
columnMap.put("variableNumberList", variableNumberList);
final List<String> variableStringList = property.getVariableStringList();
columnMap.put("variableStringCount", variableStringList.size());
columnMap.put("variableStringList", variableStringList);
columnMap.put("variableArgNameList", property.getVariableArgNameList());
columnMap.put("variableArgDef", property.getVariableArgDef());
columnMap.put("variableArgSet", property.getVariableArgSet());
columnMap.put("hasVariable", !variableStringList.isEmpty());
// can be multiple line
final String comment = property.getComment();
columnMap.put("comment", comment != null ? comment : "");
setupPropertyCommentDocument(prop, columnMap, comment);
{
final boolean hasComment = Srl.is_NotNull_and_NotTrimmedEmpty(comment);
columnMap.put("hasComment", hasComment);
columnMap.put("isMultipleLineComment", hasComment && Srl.contains(comment, "\n"));
}
columnMap.put("isExtends", property.isExtends());
columnMap.put("isOverride", property.isOverride());
columnMap.put("mayBeIntegerProperty", mayBeIntegerProperty(property, comment));
columnMap.put("mayBeLongProperty", mayBeLongProperty(property, comment));
columnMap.put("mayBeDecimalProperty", mayBeDecimalProperty(property, comment));
columnMap.put("mayBeDateProperty", mayBeDateProperty(property, comment));
columnMap.put("mayBeBooleanProperty", mayBeBooleanProperty(property, comment));
for (Entry<String, String> entry : groupingKeyMap.entrySet()) {
final String groupingName = entry.getKey();
final String keyHint = entry.getValue();
final String deternationKey = "is" + Srl.initCap(groupingName);
columnMap.put(deternationKey, isGroupingTarget(propertyKey, keyHint));
}
mapList.add(columnMap);
}
return mapList;
}
Aggregations