use of org.dbflute.properties.assistant.classification.DfClassificationElement in project dbflute-core by dbflute.
the class DfClassificationResourceAnalyzerTest method test_analyze_by_lineList.
public void test_analyze_by_lineList() {
// ## Arrange ##
final DfClassificationResourceFileAnalyzer analyzer = new DfClassificationResourceFileAnalyzer() {
@Override
protected void setupClassificationTopOption(DfClassificationTop classificationTop) {
// because of little adjustment properties
// super.setupClassificationTopOption(classificationTop);
}
};
final List<String> lineList = new ArrayList<String>();
lineList.add("<encoding=\"UTF-8\"/>");
lineList.add("AAAAAAAAAAAA");
lineList.add("BBBB");
lineList.add("[会員ステータス]: MEMBER_STATUS_CODE");
lineList.add("$ MemberStatus, 会員の状態を示す");
lineList.add("- FML, Formalized, 正式会員, 正式な会員を示す");
lineList.add("- PVS, Provisinal, 仮会員, 仮の会員を示す");
lineList.add("- WDL, Withdrawal, 退会会員, 退会した会員を示す");
lineList.add("CCCCCCCCCCCC");
lineList.add("[会員ステータス2]: *_FLG");
lineList.add("$ MemberStatus2, 会員の状態を示す");
lineList.add("- FML, Formalized, 正式会員, 正式な会員を示す");
lineList.add("- PVS, Provisinal, 仮会員, 仮の会員を示す");
lineList.add("DDDDDDDDDD");
lineList.add("- WDL, Withdrawal, 退会会員, 退会した会員を示す");
lineList.add("EEEEEEEEEEEEE");
lineList.add("[Dummy]");
lineList.add("FFFFFFFFFFFFFFFFFF");
lineList.add("[Dummy2]");
lineList.add("$ ABC, DEF");
lineList.add("HHHHHHHHHHHHHHHHHHHHHH");
lineList.add("[会員ステータス3]");
lineList.add("$ MemberStatus3");
lineList.add("- FML, Formalized");
lineList.add("- PVS, Provisinal");
lineList.add("IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII");
// ## Act ##
final List<DfClassificationTop> classificationTopList = analyzer.analyze(lineList);
// ## Assert ##
assertNotNull(classificationTopList);
assertFalse(classificationTopList.isEmpty());
assertEquals(3, classificationTopList.size());
{
final DfClassificationTop top = classificationTopList.get(0);
assertEquals("MemberStatus", top.getClassificationName());
assertEquals("会員ステータス: 会員の状態を示す", top.getTopComment());
assertEquals("MEMBER_STATUS_CODE", top.getRelatedColumnName());
assertEquals(3, top.getClassificationElementList().size());
final List<DfClassificationElement> classificationElementList = top.getClassificationElementList();
{
final DfClassificationElement element = classificationElementList.get(0);
assertEquals("FML", element.getCode());
assertEquals("Formalized", element.getName());
assertEquals("正式会員", element.getAlias());
assertEquals("正式な会員を示す", element.getComment());
}
{
final DfClassificationElement element = classificationElementList.get(1);
assertEquals("PVS", element.getCode());
assertEquals("Provisinal", element.getName());
assertEquals("仮会員", element.getAlias());
assertEquals("仮の会員を示す", element.getComment());
}
{
final DfClassificationElement element = classificationElementList.get(2);
assertEquals("WDL", element.getCode());
assertEquals("Withdrawal", element.getName());
assertEquals("退会会員", element.getAlias());
assertEquals("退会した会員を示す", element.getComment());
}
}
{
final DfClassificationTop top = classificationTopList.get(1);
assertEquals("MemberStatus2", top.getClassificationName());
assertEquals("会員ステータス2: 会員の状態を示す", top.getTopComment());
assertEquals("suffix:_FLG", top.getRelatedColumnName());
assertEquals(2, top.getClassificationElementList().size());
final List<DfClassificationElement> classificationElementList = top.getClassificationElementList();
{
final DfClassificationElement element = classificationElementList.get(0);
assertEquals("FML", element.getCode());
assertEquals("Formalized", element.getName());
assertEquals("正式会員", element.getAlias());
assertEquals("正式な会員を示す", element.getComment());
}
{
final DfClassificationElement element = classificationElementList.get(1);
assertEquals("PVS", element.getCode());
assertEquals("Provisinal", element.getName());
assertEquals("仮会員", element.getAlias());
assertEquals("仮の会員を示す", element.getComment());
}
}
{
final DfClassificationTop top = classificationTopList.get(2);
assertEquals("MemberStatus3", top.getClassificationName());
assertEquals(null, top.getTopComment());
assertNull(top.getRelatedColumnName());
assertEquals(2, top.getClassificationElementList().size());
final List<DfClassificationElement> classificationElementList = top.getClassificationElementList();
{
final DfClassificationElement element = classificationElementList.get(0);
assertEquals("FML", element.getCode());
assertEquals("Formalized", element.getName());
assertNull(element.getAlias());
assertNull(element.getComment());
}
{
final DfClassificationElement element = classificationElementList.get(1);
assertEquals("PVS", element.getCode());
assertEquals("Provisinal", element.getName());
assertNull(element.getAlias());
assertNull(element.getComment());
}
}
}
use of org.dbflute.properties.assistant.classification.DfClassificationElement in project dbflute-core by dbflute.
the class DfFixedConditionDynamicAnalyzer method doExtractEmbeddedCommentClassificationNormalCode.
protected String doExtractEmbeddedCommentClassificationNormalCode(DfClassificationTop classificationTop, String elementName) {
final List<DfClassificationElement> elementList = classificationTop.getClassificationElementList();
String code = null;
for (final DfClassificationElement element : elementList) {
final String name = element.getName();
if (elementName.equals(name)) {
code = quoteClassifiationElementIfNeeds(classificationTop, element.getCode());
break;
}
}
return code;
}
use of org.dbflute.properties.assistant.classification.DfClassificationElement in project dbflute-core by dbflute.
the class DfClsTopGroupElementHandling method toElementList.
// ===================================================================================
// Element Object Handling
// =======================
public List<DfClassificationElement> toElementList() {
if (_elementNameList == null) {
return new ArrayList<DfClassificationElement>();
}
final int size = _elementNameList.size();
final List<DfClassificationElement> elementList = new ArrayList<DfClassificationElement>(size);
for (String elementName : _elementNameList) {
final DfClassificationElement element = _classificationTop.findClassificationElementByName(elementName);
if (element == null) {
throwClassificationGroupingMapElementNotFoundException(elementName);
}
elementList.add(element);
}
return elementList;
}
use of org.dbflute.properties.assistant.classification.DfClassificationElement in project dbflute-core by dbflute.
the class DfClassificationResourceFileAnalyzer method analyze.
protected List<DfClassificationTop> analyze(final List<String> lineList) {
final List<DfClassificationTop> classificationList = new ArrayList<DfClassificationTop>();
AnalyzedTitleLine titleLine = null;
boolean inGroup = false;
final int size = lineList.size();
int index = -1;
for (String line : lineList) {
++index;
if (inGroup) {
if (isTopLine(line)) {
final DfClassificationTop classificationTop = extractClassificationTop(titleLine, line);
classificationList.add(classificationTop);
if (titleLine != null) {
classificationTop.setRelatedColumnName(titleLine.getRelatedColumnName());
final String codeType = titleLine.getCodeType();
if (codeType != null) {
classificationTop.setCodeType(codeType);
}
classificationTop.setCheckImplicitSet(titleLine.isCheckImplicitSet());
}
continue;
} else if (isElementLine(line)) {
final DfClassificationElement classificationElement = extractClassificationElement(line);
final DfClassificationTop classificationTop = classificationList.get(classificationList.size() - 1);
classificationTop.addClassificationElement(classificationElement);
continue;
} else {
inGroup = false;
continue;
}
}
if (!isTitleLine(line)) {
continue;
}
final int nextIndex = index + 1;
if (nextIndex >= size) {
break;
}
final String nextLine = lineList.get(nextIndex);
if (!isTopLine(nextLine)) {
continue;
}
final int nextNextIndex = nextIndex + 1;
if (nextNextIndex >= size) {
break;
}
final String nextNextLine = lineList.get(nextNextIndex);
if (!isElementLine(nextNextLine)) {
continue;
}
titleLine = extractRelatedColumnNameFronTitleLine(line);
inGroup = true;
}
return classificationList;
}
use of org.dbflute.properties.assistant.classification.DfClassificationElement in project dbflute-core by dbflute.
the class DfClsTopDeprecatedExistenceVerifier method throwDeprecatedClassificationElementNotFoundException.
protected void throwDeprecatedClassificationElementNotFoundException(String deprecated) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Not found the specified element in deprecated list.");
br.addItem("Classification");
br.addElement(_classificationTop.getClassificationName());
br.addItem("Existing Element");
final StringBuilder sb = new StringBuilder();
for (DfClassificationElement element : _classificationTop.getClassificationElementList()) {
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(element.getName());
}
br.addElement(sb.toString());
br.addItem("NotFound Element");
br.addElement(deprecated);
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg);
}
Aggregations