Search in sources :

Example 1 with SmartObject

use of org.smartdata.rule.objects.SmartObject in project SSM by Intel-bigdata.

the class SmartRuleVisitTranslator method visitObjTypeWith.

@Override
public TreeNode visitObjTypeWith(SmartRuleParser.ObjTypeWithContext ctx) {
    String objName = ctx.OBJECTTYPE().getText();
    SmartObject obj = SmartObject.getInstance(objName);
    objects.put(objName, obj);
    objects.put("Default", obj);
    objFilter = visit(ctx.objfilter());
    return null;
}
Also used : SmartObject(org.smartdata.rule.objects.SmartObject)

Example 2 with SmartObject

use of org.smartdata.rule.objects.SmartObject in project SSM by Intel-bigdata.

the class SmartRuleVisitTranslator method visitObjTypeOnly.

@Override
public TreeNode visitObjTypeOnly(SmartRuleParser.ObjTypeOnlyContext ctx) {
    String objName = ctx.OBJECTTYPE().getText();
    SmartObject obj = SmartObject.getInstance(objName);
    objects.put(objName, obj);
    objects.put("Default", obj);
    return null;
}
Also used : SmartObject(org.smartdata.rule.objects.SmartObject)

Example 3 with SmartObject

use of org.smartdata.rule.objects.SmartObject in project SSM by Intel-bigdata.

the class SmartRuleVisitTranslator method visitIdAttPara.

@Override
public TreeNode visitIdAttPara(SmartRuleParser.IdAttParaContext ctx) {
    SmartObject obj = createIfNotExist("Default");
    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(obj.toString() + "." + ctx.ID().getText() + " does not need parameter(s)");
    }
    int numParameters = ctx.getChildCount() / 2 - 1;
    if (p.getParamsTypes().size() != numParameters) {
        throw new RuleParserException(obj.toString() + "." + ctx.ID().getText() + " needs " + p.getParamsTypes().size() + " instead of " + numParameters);
    }
    return parseIdParams(ctx, p, 2);
}
Also used : RuleParserException(org.smartdata.rule.exceptions.RuleParserException) Property(org.smartdata.rule.objects.Property) SmartObject(org.smartdata.rule.objects.SmartObject)

Example 4 with SmartObject

use of org.smartdata.rule.objects.SmartObject 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 5 with SmartObject

use of org.smartdata.rule.objects.SmartObject in project SSM by Intel-bigdata.

the class SmartRuleVisitTranslator method createIfNotExist.

private SmartObject createIfNotExist(String objName) {
    SmartObject obj = objects.get(objName);
    if (obj == null) {
        obj = SmartObject.getInstance(objName);
        objects.put(objName, obj);
    }
    return obj;
}
Also used : SmartObject(org.smartdata.rule.objects.SmartObject)

Aggregations

SmartObject (org.smartdata.rule.objects.SmartObject)5 RuleParserException (org.smartdata.rule.exceptions.RuleParserException)2 Property (org.smartdata.rule.objects.Property)2 PropertyRealParas (org.smartdata.rule.objects.PropertyRealParas)1