public EventDrivenTransformationBuilder setScope(EMFScope scope) throws IncQueryException { this.engine = IncQueryEngine.on(scope); return this; }
/** * Initializes a pattern-specification mapping with the contents of an existing {@link IncQueryEngine}. </p> * <p> * <strong>Warning</strong> It is assumed that each query specification in the engine has a unique fqn - if the * assumption fails, the resulting map is unspecified. * * @param engine */ public NameToSpecificationMap(IncQueryEngine engine) { this(); for (IncQueryMatcher<?> matcher : engine.getCurrentMatchers()) { IQuerySpecification<?> specification = matcher.getSpecification(); map.put(specification.getFullyQualifiedName(), specification); } }
public void initializeIndexes() throws IncQueryException { GenericPatternGroup.of(Iterables.toArray(Iterables.transform(rules, new Function<BatchTransformationRule<?, ?>, IQuerySpecification<?>>() { @Override public IQuerySpecification<?> apply(BatchTransformationRule<?,?> rule){ return rule.getPrecondition(); } }), IQuerySpecification.class)).prepare(iqEngine); }
public BatchTransformationRule(final String rulename, final IQuerySpecification<Matcher> matcher, final ActivationLifeCycle lifecycle, final IMatchProcessor<Match> action) { this(rulename, matcher, lifecycle, action, IncQuerySinglePatternMatchEventFilter.<Match>createFilter(((Match) matcher.newEmptyMatch().toImmutable()))); }
public <Match extends IPatternMatch, Matcher extends IncQueryMatcher<Match>> Match toMatch(final Matcher matcher) { Match _xblockexpression = null; { final Match match = matcher.newEmptyMatch(); List<String> _parameterNames = matcher.getParameterNames(); final Procedure1<String> _function = new Procedure1<String>() { @Override public void apply(final String it) { boolean _containsKey = MatchParameterFilter.this.filterMap.containsKey(it); if (_containsKey) { Object _get = MatchParameterFilter.this.filterMap.get(it); match.set(it, _get); } } }; IterableExtensions.<String>forEach(_parameterNames, _function); _xblockexpression = match; } return _xblockexpression; } }
public static BatchTransformation forScope(EMFScope scope) throws IncQueryException { AdvancedIncQueryEngine engine = AdvancedIncQueryEngine.createUnmanagedEngine(scope); return new BatchTransformation(engine); }
public NameToSpecificationMap(Collection<? extends IQuerySpecification<?>> specifications) { this(); for (IQuerySpecification<?> specification : specifications) { map.put(specification.getFullyQualifiedName(), specification); } }
private void forgetSpecificationTransitively(IQuerySpecification<?> specification, Set<IQuerySpecification<?>> forgottenSpecifications) { forgetSpecification(specification); forgottenSpecifications.add(specification); for (IQuerySpecification<?> dependant : dependantQueries.get(specification.getInternalQueryRepresentation())) { if (!forgottenSpecifications.contains(dependant)) { forgetSpecificationTransitively(dependant, forgottenSpecifications); } } dependantQueries.removeAll(specification); }
/** * Extracts appeared elements from the given match * * @param match */ protected void registerAppear(IPatternMatch match) { IQuerySpecification<? extends IncQueryMatcher<? extends IPatternMatch>> specification = match.specification(); Collection<IPatternMatch> appearMatches = appearAccumulator .get((IQuerySpecification<? extends IncQueryMatcher<IPatternMatch>>) specification); appearMatches.add(match); }
@Override public void apply(final String it) { boolean _containsKey = MatchParameterFilter.this.filterMap.containsKey(it); if (_containsKey) { Object _get = MatchParameterFilter.this.filterMap.get(it); match.set(it, _get); } } };
public void dispose() { if (selfManagedEngines) { ruleEngine.dispose(); iqEngine.dispose(); } }
public static BatchTransformation forRuleEngine(RuleEngine ruleEngine, IncQueryEngine engine) { return new BatchTransformation(ruleEngine, AdvancedIncQueryEngine.from(engine), false); }
@Override public boolean isProcessable(final IPatternMatch eventAtom) { List<String> _parameterNames = eventAtom.parameterNames(); final Function1<String, Boolean> _function = new Function1<String, Boolean>() { @Override public Boolean apply(final String it) { boolean _and = false; boolean _containsKey = MatchParameterFilter.this.filterMap.containsKey(it); if (!_containsKey) { _and = false; } else { Object _get = MatchParameterFilter.this.filterMap.get(it); Object _get_1 = eventAtom.get(it); boolean _notEquals = (!Objects.equal(_get, _get_1)); _and = _notEquals; } return Boolean.valueOf(_and); } }; Iterable<String> _filter = IterableExtensions.<String>filter(_parameterNames, _function); return IterableExtensions.isEmpty(_filter); }
public void registerRules(final BatchTransformationRuleGroup rules) { try { Iterable<BatchTransformationRule<?, ?>> _filterNull = IterableExtensions.<BatchTransformationRule<?, ?>>filterNull(rules); final Function1<BatchTransformationRule<?, ?>, IQuerySpecification<? extends IncQueryMatcher<? extends IPatternMatch>>> _function = new Function1<BatchTransformationRule<?, ?>, IQuerySpecification<? extends IncQueryMatcher<? extends IPatternMatch>>>() { @Override public IQuerySpecification<? extends IncQueryMatcher<? extends IPatternMatch>> apply(final BatchTransformationRule<?, ?> it) { return it.getPrecondition(); } }; final Iterable<IQuerySpecification<? extends IncQueryMatcher<? extends IPatternMatch>>> notNullPreconditions = IterableExtensions.<BatchTransformationRule<?, ?>, IQuerySpecification<? extends IncQueryMatcher<? extends IPatternMatch>>>map(_filterNull, _function); HashSet<IQuerySpecification<?>> _newHashSet = Sets.<IQuerySpecification<?>>newHashSet(notNullPreconditions); IQueryGroup _of = GenericPatternGroup.of(_newHashSet); _of.prepare(this.iqEngine); Iterable<BatchTransformationRule<?, ?>> _filterNull_1 = IterableExtensions.<BatchTransformationRule<?, ?>>filterNull(rules); final Procedure1<BatchTransformationRule<?, ?>> _function_1 = new Procedure1<BatchTransformationRule<?, ?>>() { @Override public void apply(final BatchTransformationRule<?, ?> it) { RuleSpecification<? extends IPatternMatch> _ruleSpecification = it.getRuleSpecification(); EventFilter<?> _filter = it.getFilter(); BatchTransformationStatements.this.ruleEngine.addRule(_ruleSpecification, ((EventFilter<IPatternMatch>) _filter)); } }; IterableExtensions.<BatchTransformationRule<?, ?>>forEach(_filterNull_1, _function_1); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Deprecated public BatchTransformation(ResourceSet set) throws IncQueryException { this(AdvancedIncQueryEngine.createUnmanagedEngine(new EMFScope(set))); }
public static EventDrivenTransformationBuilder forScope(EMFScope scope) throws IncQueryException { return forEngine(IncQueryEngine.on(scope)); }
public NameToSpecificationMap(IQuerySpecification<?>... specifications) { this(); for (IQuerySpecification<?> specification : specifications) { map.put(specification.getFullyQualifiedName(), specification); } }
@Override public boolean apply(IQuerySpecification<?> specification) { return specification.getInternalQueryRepresentation().getStatus().equals(status); } });
/** * Extracts updated elements from the given match * * @param match */ protected void registerUpdate(IPatternMatch match) { IQuerySpecification<? extends IncQueryMatcher<? extends IPatternMatch>> specification = match.specification(); Collection<IPatternMatch> updateMatches = updateAccumulator .get((IQuerySpecification<? extends IncQueryMatcher<IPatternMatch>>) specification); updateMatches.add(match); }
@Deprecated public BatchTransformation(Resource resource) throws IncQueryException { this(AdvancedIncQueryEngine.createUnmanagedEngine(new EMFScope(resource))); }