Ejemplo n.º 1
0
  public AlphaNodeFieldConstraint getLiteralConstraint(
      final Pattern pattern,
      final String fieldName,
      final String evaluatorString,
      final String value)
      throws IntrospectionException {
    final Class<?> clazz = ((ClassObjectType) pattern.getObjectType()).getClassType();

    final InternalReadAccessor extractor =
        store.getReader(clazz, fieldName, getClass().getClassLoader());

    FieldValue fieldValue =
        FieldFactory.getInstance().getFieldValue(value, extractor.getValueType(), null);

    return new MvelConstraintTestUtil(fieldName + evaluatorString + value, fieldValue, extractor);
  }
Ejemplo n.º 2
0
  protected void initDeclaredMask(BuildContext context, LeftTupleSource leftInput) {
    if (context == null || context.getLastBuiltPatterns() == null) {
      // only happens during unit tests
      leftDeclaredMask = AllSetBitMask.get();
      return;
    }

    if (leftInput.getType() != NodeTypeEnums.LeftInputAdapterNode) {
      // BetaNode's not after LIANode are not relevant for left mask property specific, so don't
      // block anything.
      leftDeclaredMask = AllSetBitMask.get();
      return;
    }

    Pattern pattern = context.getLastBuiltPatterns()[1]; // left input pattern

    ObjectType objectType =
        pattern == null || this.getType() == NodeTypeEnums.AccumulateNode
            ? ((LeftInputAdapterNode) leftInput)
                .getParentObjectSource()
                .getObjectTypeNode()
                .getObjectType()
            : pattern.getObjectType();

    if (!(objectType instanceof ClassObjectType)) {
      // Only ClassObjectType can use property specific
      leftDeclaredMask = AllSetBitMask.get();
      return;
    }

    Class objectClass = ((ClassWireable) objectType).getClassType();
    if (isPropertyReactive(context, objectClass)) {
      // TODO: at the moment if pattern is null (e.g. for eval node) we cannot calculate the mask,
      // so we leave it to 0
      if (pattern != null) {
        List<String> leftListenedProperties = pattern.getListenedProperties();
        List<String> settableProperties =
            getSettableProperties(context.getKnowledgeBase(), objectClass);
        leftDeclaredMask = calculatePositiveMask(leftListenedProperties, settableProperties);
        leftNegativeMask = calculateNegativeMask(leftListenedProperties, settableProperties);
        setLeftListenedProperties(leftListenedProperties);
      }
    } else {
      // if property specific is not on, then accept all modification propagations
      leftDeclaredMask = AllSetBitMask.get();
    }
  }