use of org.dbflute.util.Srl.ScopeInfo in project dbflute-core by dbflute.
the class DfSPolicyMiscSecretary method parseStatement.
// ===================================================================================
// Statement
// =========
public DfSPolicyStatement parseStatement(String statement) {
if (!statement.startsWith("if ")) {
String msg = "The element of statementList should start with 'if' for SchemaPolicyCheck: " + statement;
throw new IllegalStateException(msg);
}
final ScopeInfo ifScope = Srl.extractScopeFirst(statement, "if ", " then ");
if (ifScope == null) {
final String additional = "The statement should start with 'if' and contain 'then'.";
throwSchemaPolicyCheckIllegalIfThenStatementException(statement, additional);
}
final DfSPolicyIfClause ifClause = analyzeIfClause(statement, ifScope);
final DfSPolicyThenClause thenClause = analyzeThenClause(statement, ifScope);
return new DfSPolicyStatement(statement, ifClause, thenClause);
}
use of org.dbflute.util.Srl.ScopeInfo in project lastaflute by lastaflute.
the class HookedXADataSource method resolveClassesUrl.
protected String resolveClassesUrl(String url) {
// for e.g. H2 local file
final String beginMark = CLASSES_BEGIN_MARK;
final String endMark = CLASSES_END_MARK;
final ScopeInfo classesScope = Srl.extractScopeFirst(url, beginMark, endMark);
if (classesScope == null) {
return url;
}
final String className = classesScope.getContent().trim();
final String front = Srl.substringFirstFront(url, beginMark);
final String rear = Srl.substringFirstRear(url, endMark);
final Class<?> lardmarkType = LdiClassUtil.forName(className);
final File buildDir = DfResourceUtil.getBuildDir(lardmarkType);
try {
final String canonicalPath = buildDir.getCanonicalPath();
return front + canonicalPath.replace('\\', '/') + rear;
} catch (IOException e) {
throw new IllegalStateException("Failed to get canonical path: " + buildDir, e);
}
}
use of org.dbflute.util.Srl.ScopeInfo in project dbflute-core by dbflute.
the class DfSql2EntityMarkAnalyzer method getTitle.
// ===================================================================================
// Title/Description
// =================
public String getTitle(String sql) {
// should be first not to conflict
final String oldStyleTitle = findOldStyleTitle(sql);
if (oldStyleTitle != null) {
return oldStyleTitle;
}
if (sql.startsWith("/*") && sql.contains("*/")) {
// new style
final ScopeInfo commentScope = Srl.extractScopeFirst(sql, "/*", "*/");
final String comment = commentScope.getContent();
final ScopeInfo titleScope = Srl.extractScopeFirst(comment, "[", "]");
if (titleScope != null) {
final String title = titleScope.getContent().trim();
if (!title.isEmpty()) {
return title;
}
}
}
return null;
}
use of org.dbflute.util.Srl.ScopeInfo in project dbflute-core by dbflute.
the class DfIncludeQueryProperties method extractColumnDrivenInterfaceMap.
protected Map<String, Map<String, List<String>>> extractColumnDrivenInterfaceMap(Map<String, Object> targetMap) {
// ; $MEMBER = map:{
// ; BIRTHDATE(Date) = list:{ !GreaterThan ; !LessThan }
// ; MEMBER_NAME(String) = list:{}
// }
final Map<String, Map<String, List<String>>> interfaceMap = newLinkedHashMap();
for (Entry<String, Object> propEntry : targetMap.entrySet()) {
final String propType = propEntry.getKey();
final Object value = propEntry.getValue();
if (!(value instanceof Map)) {
String msg = "The key '" + KEY_conditionBeanMap + "' should have map value:";
msg = msg + " key=" + propType + " value=" + value + " targetMap=" + targetMap;
throw new DfIllegalPropertyTypeException(msg);
}
if (!propType.startsWith("$")) {
continue;
}
final String tableName = Srl.substringFirstRear(propType, "$");
@SuppressWarnings("unchecked") final Map<String, List<String>> columnCKeyMap = (Map<String, List<String>>) value;
Set<Entry<String, List<String>>> entrySet = columnCKeyMap.entrySet();
for (Entry<String, List<String>> entry : entrySet) {
final String columnExp = entry.getKey();
final List<String> ckeyList = entry.getValue();
if (!ckeyList.isEmpty()) {
columnCKeyMap.put(columnExp, ckeyList);
} else {
final ScopeInfo scopeFirst = Srl.extractScopeFirst(columnExp, "(", ")");
if (scopeFirst == null) {
String msg = "The column expression should be e.g. Member(Date) but: " + columnExp;
throw new DfIllegalPropertySettingException(msg);
}
final String currentPropType = scopeFirst.getContent().trim();
final Set<String> ckeySet = _ckeySetMap.get(currentPropType);
if (ckeySet == null) {
String msg = "Unknown condition-key: " + currentPropType + ", expected=" + _ckeySetMap.keySet();
throw new DfIllegalPropertySettingException(msg);
}
final List<String> allCKeyList = new ArrayList<String>();
for (String ckey : ckeySet) {
allCKeyList.add("!" + ckey);
}
columnCKeyMap.put(columnExp, allCKeyList);
}
}
interfaceMap.put(tableName, columnCKeyMap);
}
return interfaceMap;
}
use of org.dbflute.util.Srl.ScopeInfo in project dbflute-core by dbflute.
the class DfClassificationResourceFileAnalyzer method extractRelatedColumnNameFronTitleLine.
protected AnalyzedTitleLine extractRelatedColumnNameFronTitleLine(String line) {
if (!isTitleLine(line)) {
String msg = "The line should be title line: line=" + line;
throw new IllegalArgumentException(msg);
}
final String connectBeginMark = "[";
final String connectEndMark = "]:";
final String wildCard = "*";
final String prefixMark = DfNameHintUtil.PREFIX_MARK;
final String suffixMark = DfNameHintUtil.SUFFIX_MARK;
if (!Srl.containsAll(line, connectBeginMark, connectEndMark)) {
return null;
}
line = line.trim();
line = removeRearXmlEndIfNeeds(line);
final AnalyzedTitleLine titleLine = new AnalyzedTitleLine();
final ScopeInfo scopeFirst = Srl.extractScopeFirst(line, connectBeginMark, connectEndMark);
if (scopeFirst == null) {
// basically no way
return null;
}
titleLine.setTitle(scopeFirst.getContent().trim());
final String relatedColumnName;
final String option;
{
String pureValue = Srl.substringFirstRear(line, connectEndMark).trim();
if (pureValue.startsWith(wildCard)) {
// *_FLG
pureValue = suffixMark + pureValue.substring(wildCard.length());
} else if (pureValue.endsWith(wildCard)) {
// LD_*
pureValue = pureValue.substring(0, pureValue.lastIndexOf(wildCard));
pureValue = prefixMark + pureValue;
}
if (pureValue.contains("|")) {
relatedColumnName = Srl.substringFirstFront(pureValue, "|").trim();
option = Srl.substringFirstRear(pureValue, "|").trim();
} else {
relatedColumnName = pureValue;
option = null;
}
}
titleLine.setRelatedColumnName(relatedColumnName);
if (Srl.is_NotNull_and_NotTrimmedEmpty(option)) {
final String codeTypeNumber = DfClassificationTop.CODE_TYPE_NUMBER;
if (Srl.containsIgnoreCase(option, codeTypeNumber)) {
titleLine.setCodeType(codeTypeNumber);
}
titleLine.setCheckImplicitSet(Srl.containsIgnoreCase(option, "check"));
}
return titleLine;
}
Aggregations