use of org.dbflute.logic.doc.spolicy.parsed.DfSPolicyStatement.DfSPolicyIfClause 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.DfSPolicyIfClause in project dbflute-core by dbflute.
the class DfSPolicyLogicalSecretary 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.logic.doc.spolicy.parsed.DfSPolicyStatement.DfSPolicyIfClause 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.DfSPolicyIfClause 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);
}
use of org.dbflute.logic.doc.spolicy.parsed.DfSPolicyStatement.DfSPolicyIfClause 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);
}
Aggregations