Search in sources :

Example 1 with DfSchemaPolicyCheckUnknownVariableException

use of org.dbflute.exception.DfSchemaPolicyCheckUnknownVariableException in project dbflute-core by dbflute.

the class DfSPolicyLogicalSecretaryTest method test_isHitExp_basic.

// ===================================================================================
// isHitExp()
// ==========
public void test_isHitExp_basic() {
    // ## Arrange ##
    DfSPolicyLogicalSecretary secretary = new DfSPolicyLogicalSecretary();
    DfSPolicyStatement statement = createMockStatement();
    // ## Act ##
    // ## Assert ##
    assertTrue(secretary.isHitExp(statement, "SEA_MEMBER", "prefix:SEA_"));
    assertFalse(secretary.isHitExp(statement, "SEA_MEMBER", "prefix:LAND_"));
    assertTrue(secretary.isHitExp(statement, "SEA_MEMBER", "prefix:SEA_ and suffix:_MEMBER"));
    assertTrue(secretary.isHitExp(statement, "SEA_MEMBER", "prefix:SEA_ or prefix:LAND_"));
    assertTrue(secretary.isHitExp(statement, "LAND_MEMBER", "prefix:SEA_ or prefix:LAND_"));
    assertFalse(secretary.isHitExp(statement, "PIARI_MEMBER", "prefix:SEA_ or prefix:LAND_"));
    assertTrue(secretary.isHitExp(statement, "SEA_MEMBER", "$$ALL$$"));
    try {
        assertTrue(secretary.isHitExp(statement, "SEA_MEMBER", "$$sea$$_ID"));
        fail();
    } catch (DfSchemaPolicyCheckUnknownVariableException e) {
        log(e.getMessage());
    }
    try {
        assertTrue(secretary.isHitExp(statement, "SEA_MEMBER", "sea-mystic$$land-oneman$$piari-plaza"));
        fail();
    } catch (DfSchemaPolicyCheckUnknownVariableException e) {
        log(e.getMessage());
    }
}
Also used : DfSPolicyStatement(org.dbflute.logic.doc.spolicy.parsed.DfSPolicyStatement) DfSchemaPolicyCheckUnknownVariableException(org.dbflute.exception.DfSchemaPolicyCheckUnknownVariableException)

Example 2 with DfSchemaPolicyCheckUnknownVariableException

use of org.dbflute.exception.DfSchemaPolicyCheckUnknownVariableException in project dbflute-core by dbflute.

the class DfSPolicyLogicalSecretary method checkUnknownVariable.

protected void checkUnknownVariable(DfSPolicyStatement statement, String name, String hint) {
    if (Srl.count(hint, "$$") >= 2) {
        ExceptionMessageBuilder br = new ExceptionMessageBuilder();
        br.addNotice("Unknown variable in the SchemaPolicyCheck statement.");
        br.addItem("Advice");
        br.addElement("Confirm your statement in schemaPolicyMap.dfprop");
        br.addElement("and see the official document.");
        br.addElement("You can use only reserved variables.");
        br.addElement("For example:");
        br.addElement("  (o):");
        br.addElement("    columnName is $$ALL$$");
        br.addElement("    fkName is prefix:FK_$$table$$");
        br.addElement("    alias is not $$columnName$$");
        br.addElement("    alias is not $$comment$$");
        br.addElement("  (x):");
        br.addElement("    columnName is $$sea$$");
        br.addElement("    columnName is $$land$$");
        br.addElement("    columnName is $$piari$$");
        br.addElement("    columnName is $$bonvo$$");
        br.addElement("    columnName is $$dstore$$");
        br.addItem("Statement");
        br.addElement(statement.getNativeExp());
        br.addItem("Current Data");
        br.addElement(name);
        br.addItem("Unresolved Keyword");
        br.addElement(hint);
        final String msg = br.buildExceptionMessage();
        throw new DfSchemaPolicyCheckUnknownVariableException(msg);
    }
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfSchemaPolicyCheckUnknownVariableException(org.dbflute.exception.DfSchemaPolicyCheckUnknownVariableException)

Aggregations

DfSchemaPolicyCheckUnknownVariableException (org.dbflute.exception.DfSchemaPolicyCheckUnknownVariableException)2 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)1 DfSPolicyStatement (org.dbflute.logic.doc.spolicy.parsed.DfSPolicyStatement)1