use of org.dbflute.logic.doc.spolicy.parsed.DfSPolicyStatement.DfSPolicyIfPart in project dbflute-core by dbflute.
the class DfSPolicyLogicalSecretaryTest method createMockStatement.
protected DfSPolicyStatement createMockStatement() {
List<DfSPolicyIfPart> ifPartList = newArrayList(new DfSPolicyIfPart("columnName", "$$ALL$$", false));
DfSPolicyIfClause ifClause = new DfSPolicyIfClause(ifPartList, false);
DfSPolicyThenClause thenClause = new DfSPolicyThenClause("bad", false, DfCollectionUtil.emptyList(), false, null);
return new DfSPolicyStatement("if columnName is $$ALL$$ then bad", ifClause, thenClause);
}
use of org.dbflute.logic.doc.spolicy.parsed.DfSPolicyStatement.DfSPolicyIfPart in project dbflute-core by dbflute.
the class DfSPolicyLogicalSecretary method analyzeIfClause.
// -----------------------------------------------------
// If Clause
// ---------
protected DfSPolicyIfClause analyzeIfClause(String statement, ScopeInfo ifScope) {
final String ifWhole = ifScope.getContent().trim();
if (!ifWhole.contains(EQUALS_DELIMITER)) {
final String additional = "The if-clause should contain 'is': " + ifWhole;
throwSchemaPolicyCheckIllegalIfThenStatementException(statement, additional);
}
// e.g. if tableName is sea and alias is land and piari and tableName is bonvo then ...
boolean connectedByOr = false;
List<String> ifPartStrList = splitClauseByConnector(ifWhole, " and ");
if (ifPartStrList.size() == 1) {
ifPartStrList = splitClauseByConnector(ifWhole, " or ");
if (ifPartStrList.size() >= 2) {
connectedByOr = true;
}
}
final List<DfSPolicyIfPart> ifPartList = new ArrayList<DfSPolicyIfPart>();
for (String ifPartStr : ifPartStrList) {
final String ifItem = Srl.substringFirstFront(ifPartStr, EQUALS_DELIMITER).trim();
final String ifValueCandidate = Srl.substringFirstRear(ifPartStr, EQUALS_DELIMITER).trim();
final boolean notIfValue = ifValueCandidate.startsWith(NOT_PREFIX);
final String ifValue = notIfValue ? Srl.substringFirstRear(ifValueCandidate, NOT_PREFIX).trim() : ifValueCandidate;
final DfSPolicyIfPart part = new DfSPolicyIfPart(ifItem, ifValue, notIfValue);
ifPartList.add(part);
}
return new DfSPolicyIfClause(Collections.unmodifiableList(ifPartList), connectedByOr);
}
use of org.dbflute.logic.doc.spolicy.parsed.DfSPolicyStatement.DfSPolicyIfPart in project dbflute-core by dbflute.
the class DfSPolicyMiscSecretary method analyzeIfClause.
// -----------------------------------------------------
// If Clause
// ---------
protected DfSPolicyIfClause analyzeIfClause(String statement, ScopeInfo ifScope) {
final String ifWhole = ifScope.getContent().trim();
if (!ifWhole.contains(EQUALS_DELIMITER)) {
final String additional = "The if-clause should contain 'is': " + ifWhole;
throwSchemaPolicyCheckIllegalIfThenStatementException(statement, additional);
}
// e.g. if tableName is sea and alias is land and piari and tableName is bonvo then ...
boolean connectedByOr = false;
List<String> ifPartStrList = splitClauseByConnector(ifWhole, " and ");
if (ifPartStrList.size() == 1) {
ifPartStrList = splitClauseByConnector(ifWhole, " or ");
if (ifPartStrList.size() >= 2) {
connectedByOr = true;
}
}
final List<DfSPolicyIfPart> ifPartList = new ArrayList<DfSPolicyIfPart>();
for (String ifPartStr : ifPartStrList) {
final String ifItem = Srl.substringFirstFront(ifPartStr, EQUALS_DELIMITER).trim();
final String ifValueCandidate = Srl.substringFirstRear(ifPartStr, EQUALS_DELIMITER).trim();
final boolean notIfValue = ifValueCandidate.startsWith(NOT_PREFIX);
final String ifValue = notIfValue ? Srl.substringFirstRear(ifValueCandidate, NOT_PREFIX).trim() : ifValueCandidate;
final DfSPolicyIfPart part = new DfSPolicyIfPart(ifItem, ifValue, notIfValue);
ifPartList.add(part);
}
return new DfSPolicyIfClause(Collections.unmodifiableList(ifPartList), connectedByOr);
}
Aggregations