diff options
Diffstat (limited to 'Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/execution/validation/QueryAndMetamodelValidator.java')
-rw-r--r-- | Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/execution/validation/QueryAndMetamodelValidator.java | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/execution/validation/QueryAndMetamodelValidator.java b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/execution/validation/QueryAndMetamodelValidator.java deleted file mode 100644 index ee4567d8..00000000 --- a/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/execution/validation/QueryAndMetamodelValidator.java +++ /dev/null | |||
@@ -1,93 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.execution.validation; | ||
2 | |||
3 | import com.google.common.collect.Iterables; | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; | ||
5 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; | ||
6 | import java.util.Collections; | ||
7 | import java.util.LinkedList; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.common.util.EList; | ||
11 | import org.eclipse.emf.common.util.TreeIterator; | ||
12 | import org.eclipse.emf.ecore.EAttribute; | ||
13 | import org.eclipse.emf.ecore.EClass; | ||
14 | import org.eclipse.emf.ecore.EClassifier; | ||
15 | import org.eclipse.emf.ecore.EEnum; | ||
16 | import org.eclipse.emf.ecore.EEnumLiteral; | ||
17 | import org.eclipse.emf.ecore.ENamedElement; | ||
18 | import org.eclipse.emf.ecore.EObject; | ||
19 | import org.eclipse.emf.ecore.EReference; | ||
20 | import org.eclipse.viatra.query.patternlanguage.patternLanguage.Pattern; | ||
21 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
22 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
23 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
24 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
25 | import org.eclipse.xtext.xbase.lib.IteratorExtensions; | ||
26 | import org.eclipse.xtext.xbase.lib.ListExtensions; | ||
27 | import org.eclipse.xtext.xbase.lib.Pair; | ||
28 | |||
29 | @SuppressWarnings("all") | ||
30 | public class QueryAndMetamodelValidator { | ||
31 | public LinkedList<String> validateQueryAndMetamodel(final EcoreMetamodelDescriptor metamodel, final Pair<ViatraQuerySetDescriptor, Set<Pattern>> viatra) { | ||
32 | final Set<Pattern> patterns = viatra.getValue(); | ||
33 | List<EClass> _classes = metamodel.getClasses(); | ||
34 | List<EEnum> _enums = metamodel.getEnums(); | ||
35 | Iterable<EClassifier> _plus = Iterables.<EClassifier>concat(_classes, _enums); | ||
36 | List<EEnumLiteral> _literals = metamodel.getLiterals(); | ||
37 | Iterable<ENamedElement> _plus_1 = Iterables.<ENamedElement>concat(_plus, _literals); | ||
38 | List<EAttribute> _attributes = metamodel.getAttributes(); | ||
39 | Iterable<ENamedElement> _plus_2 = Iterables.<ENamedElement>concat(_plus_1, _attributes); | ||
40 | List<EReference> _references = metamodel.getReferences(); | ||
41 | Iterable<ENamedElement> _plus_3 = Iterables.<ENamedElement>concat(_plus_2, _references); | ||
42 | final Set<ENamedElement> elementsInMetamodel = IterableExtensions.<ENamedElement>toSet(_plus_3); | ||
43 | final LinkedList<String> errors = new LinkedList<String>(); | ||
44 | for (final Pattern pattern : patterns) { | ||
45 | { | ||
46 | final Iterable<ENamedElement> elements = this.getReferredNamedElements(pattern); | ||
47 | for (final ENamedElement element : elements) { | ||
48 | boolean _contains = elementsInMetamodel.contains(element); | ||
49 | boolean _not = (!_contains); | ||
50 | if (_not) { | ||
51 | StringConcatenation _builder = new StringConcatenation(); | ||
52 | _builder.append("Pattern \""); | ||
53 | String _name = pattern.getName(); | ||
54 | _builder.append(_name, ""); | ||
55 | _builder.append("\" refers to an element \""); | ||
56 | _builder.append(element, ""); | ||
57 | _builder.append("\" that is not included to the selected metamodel!"); | ||
58 | errors.add(_builder.toString()); | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | return errors; | ||
64 | } | ||
65 | |||
66 | public Iterable<ENamedElement> getReferredNamedElements(final Pattern pattern) { | ||
67 | TreeIterator<EObject> _eAllContents = pattern.eAllContents(); | ||
68 | final List<EObject> elements = IteratorExtensions.<EObject>toList(_eAllContents); | ||
69 | final Function1<EObject, Iterable<ENamedElement>> _function = (EObject element) -> { | ||
70 | EClass _eClass = element.eClass(); | ||
71 | final EList<EReference> references = _eClass.getEAllReferences(); | ||
72 | final Function1<EReference, Iterable<ENamedElement>> _function_1 = (EReference r) -> { | ||
73 | boolean _isMany = r.isMany(); | ||
74 | if (_isMany) { | ||
75 | Object _eGet = element.eGet(r); | ||
76 | return Iterables.<ENamedElement>filter(((List<?>) _eGet), ENamedElement.class); | ||
77 | } else { | ||
78 | final Object value = element.eGet(r); | ||
79 | if ((value instanceof ENamedElement)) { | ||
80 | return Collections.<ENamedElement>unmodifiableList(CollectionLiterals.<ENamedElement>newArrayList(((ENamedElement)value))); | ||
81 | } else { | ||
82 | return Collections.<ENamedElement>unmodifiableList(CollectionLiterals.<ENamedElement>newArrayList()); | ||
83 | } | ||
84 | } | ||
85 | }; | ||
86 | List<Iterable<ENamedElement>> _map = ListExtensions.<EReference, Iterable<ENamedElement>>map(references, _function_1); | ||
87 | Iterable<ENamedElement> _flatten = Iterables.<ENamedElement>concat(_map); | ||
88 | return Iterables.<ENamedElement>filter(_flatten, ENamedElement.class); | ||
89 | }; | ||
90 | List<Iterable<ENamedElement>> _map = ListExtensions.<EObject, Iterable<ENamedElement>>map(elements, _function); | ||
91 | return Iterables.<ENamedElement>concat(_map); | ||
92 | } | ||
93 | } | ||