Пример #1
0
  public RowSourceHandler(ContainerHandler parent, RowSource rowSource) throws ParserException {
    this.parent = parent;
    OCL ocl = OCL.newInstance(parent.getEnvironment());
    Helper helper = ocl.createOCLHelper();
    OCLExpression expression = helper.createQuery(rowSource.getExpression());
    query = ocl.createQuery(expression);

    environment = parent.getEnvironment().getFactory().createEnvironment(parent.getEnvironment());
    Variable variable = EcoreFactory.eINSTANCE.createVariable();
    variable.setType(((CollectionType) expression.getType()).getElementType());
    varName = rowSource.getVar();
    environment.addElement(varName, variable, true);
  }
Пример #2
0
  private static OCLExpression parse(String expression) {
    if (expression == null) return null;

    OCLExpression oclExpression = null;
    Helper helper = OCL_ENV.createOCLHelper();
    helper.setContext(FragmentPackage.Literals.FRAGMENT);

    try {
      oclExpression = helper.createQuery(expression);
    } catch (ParserException e) {
      System.err.println(e.getLocalizedMessage());
    }
    return oclExpression;
  }