Search in sources :

Example 6 with RuleParserException

use of org.smartdata.rule.exceptions.RuleParserException in project SSM by Intel-bigdata.

the class SmartRuleVisitTranslator method visitIdObjAtt.

@Override
public TreeNode visitIdObjAtt(SmartRuleParser.IdObjAttContext ctx) {
    SmartObject obj = createIfNotExist(ctx.OBJECTTYPE().toString());
    Property p = obj.getProperty(ctx.ID().getText());
    if (p == null) {
        throw new RuleParserException("Object " + obj.toString() + " does not have a attribute named '" + "'" + ctx.ID().getText());
    }
    if (p.getParamsTypes() != null) {
        throw new RuleParserException("Should have no parameter(s) for " + ctx.getText());
    }
    PropertyRealParas realParas = new PropertyRealParas(p, null);
    realParases.add(realParas);
    return new ValueNode(new VisitResult(p.getValueType(), null, realParas));
}
Also used : RuleParserException(org.smartdata.rule.exceptions.RuleParserException) PropertyRealParas(org.smartdata.rule.objects.PropertyRealParas) Property(org.smartdata.rule.objects.Property) SmartObject(org.smartdata.rule.objects.SmartObject)

Example 7 with RuleParserException

use of org.smartdata.rule.exceptions.RuleParserException in project SSM by Intel-bigdata.

the class SmartRuleVisitTranslator method visitIdObjAttPara.

@Override
public TreeNode visitIdObjAttPara(SmartRuleParser.IdObjAttParaContext ctx) {
    String objName = ctx.OBJECTTYPE().getText();
    String propertyName = ctx.ID().getText();
    Property p = createIfNotExist(objName).getProperty(propertyName);
    if (p == null) {
        throw new RuleParserException("Object " + ctx.OBJECTTYPE().toString() + " does not have a attribute named '" + "'" + ctx.ID().getText());
    }
    if (p.getParamsTypes() == null) {
        throw new RuleParserException(ctx.OBJECTTYPE().toString() + "." + ctx.ID().getText() + " does not need parameter(s)");
    }
    int numParameters = ctx.getChildCount() / 2 - 2;
    if (p.getParamsTypes().size() != numParameters) {
        throw new RuleParserException(ctx.OBJECTTYPE().toString() + "." + ctx.ID().getText() + " needs " + p.getParamsTypes().size() + " instead of " + numParameters);
    }
    return parseIdParams(ctx, p, 4);
}
Also used : RuleParserException(org.smartdata.rule.exceptions.RuleParserException) Property(org.smartdata.rule.objects.Property)

Example 8 with RuleParserException

use of org.smartdata.rule.exceptions.RuleParserException in project SSM by Intel-bigdata.

the class SmartRuleVisitTranslator method visitCmdlet.

@Override
public TreeNode visitCmdlet(SmartRuleParser.CmdletContext ctx) {
    Interval i = new Interval(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex());
    String cmd = ctx.getStart().getInputStream().getText(i);
    try {
        cmdDescriptor = CmdletDescriptor.fromCmdletString(cmd);
    } catch (ParseException e) {
        throw new RuleParserException(e.getMessage());
    }
    return null;
}
Also used : RuleParserException(org.smartdata.rule.exceptions.RuleParserException) ParseException(java.text.ParseException) Interval(org.antlr.v4.runtime.misc.Interval)

Aggregations

RuleParserException (org.smartdata.rule.exceptions.RuleParserException)8 Property (org.smartdata.rule.objects.Property)4 PropertyRealParas (org.smartdata.rule.objects.PropertyRealParas)3 SmartObject (org.smartdata.rule.objects.SmartObject)3 ParseException (java.text.ParseException)2 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Interval (org.antlr.v4.runtime.misc.Interval)1 TimeBasedScheduleInfo (org.smartdata.model.rule.TimeBasedScheduleInfo)1