diff options
Diffstat (limited to 'Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/execution/validation/MetamodelValidator.java')
-rw-r--r-- | Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/execution/validation/MetamodelValidator.java | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/execution/validation/MetamodelValidator.java b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/execution/validation/MetamodelValidator.java new file mode 100644 index 00000000..1e21f6ab --- /dev/null +++ b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/execution/validation/MetamodelValidator.java | |||
@@ -0,0 +1,167 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.execution.validation; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; | ||
4 | import java.util.Collections; | ||
5 | import java.util.LinkedList; | ||
6 | import java.util.List; | ||
7 | import org.eclipse.emf.common.util.EList; | ||
8 | import org.eclipse.emf.ecore.EAttribute; | ||
9 | import org.eclipse.emf.ecore.EClass; | ||
10 | import org.eclipse.emf.ecore.EDataType; | ||
11 | import org.eclipse.emf.ecore.EEnum; | ||
12 | import org.eclipse.emf.ecore.EEnumLiteral; | ||
13 | import org.eclipse.emf.ecore.EReference; | ||
14 | import org.eclipse.emf.ecore.EcorePackage; | ||
15 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
16 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
17 | import org.eclipse.xtext.xbase.lib.Extension; | ||
18 | |||
19 | @SuppressWarnings("all") | ||
20 | public class MetamodelValidator { | ||
21 | public LinkedList<String> validateMetamodel(final EcoreMetamodelDescriptor descriptor) { | ||
22 | final LinkedList<String> errors = new LinkedList<String>(); | ||
23 | List<EClass> _classes = descriptor.getClasses(); | ||
24 | this.allSupertypesAreIncluded(_classes, errors); | ||
25 | List<EEnum> _enums = descriptor.getEnums(); | ||
26 | List<EEnumLiteral> _literals = descriptor.getLiterals(); | ||
27 | this.allEnumTypesareIncluded(_enums, _literals, errors); | ||
28 | List<EClass> _classes_1 = descriptor.getClasses(); | ||
29 | List<EReference> _references = descriptor.getReferences(); | ||
30 | this.referenceEndpointsAreIncluded(_classes_1, _references, errors); | ||
31 | List<EClass> _classes_2 = descriptor.getClasses(); | ||
32 | List<EAttribute> _attributes = descriptor.getAttributes(); | ||
33 | this.attributeSourcePontIsIncluded(_classes_2, _attributes, errors); | ||
34 | List<EAttribute> _attributes_1 = descriptor.getAttributes(); | ||
35 | this.attributeTargetIsSupported(_attributes_1, errors); | ||
36 | return errors; | ||
37 | } | ||
38 | |||
39 | private boolean supportedEDataType(final EDataType dataType) { | ||
40 | @Extension | ||
41 | final EcorePackage l = EcorePackage.eINSTANCE; | ||
42 | EDataType _eInt = l.getEInt(); | ||
43 | EDataType _eBoolean = l.getEBoolean(); | ||
44 | EDataType _eString = l.getEString(); | ||
45 | EDataType _eDouble = l.getEDouble(); | ||
46 | EDataType _eFloat = l.getEFloat(); | ||
47 | return Collections.<EDataType>unmodifiableList(CollectionLiterals.<EDataType>newArrayList(_eInt, _eBoolean, _eString, _eDouble, _eFloat)).contains(dataType); | ||
48 | } | ||
49 | |||
50 | public void allSupertypesAreIncluded(final List<EClass> classes, final List<String> errors) { | ||
51 | for (final EClass c : classes) { | ||
52 | EList<EClass> _eSuperTypes = c.getESuperTypes(); | ||
53 | for (final EClass s : _eSuperTypes) { | ||
54 | boolean _contains = classes.contains(s); | ||
55 | boolean _not = (!_contains); | ||
56 | if (_not) { | ||
57 | StringConcatenation _builder = new StringConcatenation(); | ||
58 | _builder.append("Metamodel contains \""); | ||
59 | String _name = c.getName(); | ||
60 | _builder.append(_name, ""); | ||
61 | _builder.append("\" but not contains its supertype \""); | ||
62 | String _name_1 = s.getName(); | ||
63 | _builder.append(_name_1, ""); | ||
64 | _builder.append("\"!"); | ||
65 | errors.add(_builder.toString()); | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | |||
71 | public void allEnumTypesareIncluded(final List<EEnum> enums, final List<EEnumLiteral> literals, final List<String> errors) { | ||
72 | for (final EEnumLiteral l : literals) { | ||
73 | EEnum _eEnum = l.getEEnum(); | ||
74 | boolean _contains = enums.contains(_eEnum); | ||
75 | boolean _not = (!_contains); | ||
76 | if (_not) { | ||
77 | StringConcatenation _builder = new StringConcatenation(); | ||
78 | _builder.append("Metamodel contains literal \""); | ||
79 | String _name = l.getName(); | ||
80 | _builder.append(_name, ""); | ||
81 | _builder.append("\" but does not contains enum \""); | ||
82 | EEnum _eEnum_1 = l.getEEnum(); | ||
83 | String _name_1 = _eEnum_1.getName(); | ||
84 | _builder.append(_name_1, ""); | ||
85 | _builder.append("\"!"); | ||
86 | errors.add(_builder.toString()); | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | |||
91 | public void referenceEndpointsAreIncluded(final List<EClass> classes, final List<EReference> references, final List<String> errors) { | ||
92 | for (final EReference reference : references) { | ||
93 | { | ||
94 | final EClass src = reference.getEContainingClass(); | ||
95 | boolean _contains = classes.contains(src); | ||
96 | boolean _not = (!_contains); | ||
97 | if (_not) { | ||
98 | StringConcatenation _builder = new StringConcatenation(); | ||
99 | _builder.append("Metamodel contains reference \""); | ||
100 | String _name = reference.getName(); | ||
101 | _builder.append(_name, ""); | ||
102 | _builder.append("\" but does not contains its source type \""); | ||
103 | String _name_1 = src.getName(); | ||
104 | _builder.append(_name_1, ""); | ||
105 | _builder.append("\"!"); | ||
106 | errors.add(_builder.toString()); | ||
107 | } | ||
108 | final EClass trg = reference.getEReferenceType(); | ||
109 | boolean _contains_1 = classes.contains(trg); | ||
110 | boolean _not_1 = (!_contains_1); | ||
111 | if (_not_1) { | ||
112 | StringConcatenation _builder_1 = new StringConcatenation(); | ||
113 | _builder_1.append("Metamodel contains reference \""); | ||
114 | String _name_2 = reference.getName(); | ||
115 | _builder_1.append(_name_2, ""); | ||
116 | _builder_1.append("\" but does not contains its target type \""); | ||
117 | String _name_3 = trg.getName(); | ||
118 | _builder_1.append(_name_3, ""); | ||
119 | _builder_1.append("\"!"); | ||
120 | errors.add(_builder_1.toString()); | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | } | ||
125 | |||
126 | public void attributeSourcePontIsIncluded(final List<EClass> classes, final List<EAttribute> attributes, final List<String> errors) { | ||
127 | for (final EAttribute attribute : attributes) { | ||
128 | { | ||
129 | final Class<?> src = attribute.getContainerClass(); | ||
130 | boolean _contains = classes.contains(src); | ||
131 | boolean _not = (!_contains); | ||
132 | if (_not) { | ||
133 | StringConcatenation _builder = new StringConcatenation(); | ||
134 | _builder.append("Metamodel contains attribute \""); | ||
135 | String _name = attribute.getName(); | ||
136 | _builder.append(_name, ""); | ||
137 | _builder.append("\" but does not contains its source type \""); | ||
138 | String _name_1 = src.getName(); | ||
139 | _builder.append(_name_1, ""); | ||
140 | _builder.append("\"!"); | ||
141 | errors.add(_builder.toString()); | ||
142 | } | ||
143 | } | ||
144 | } | ||
145 | } | ||
146 | |||
147 | public void attributeTargetIsSupported(final List<EAttribute> attributes, final List<String> errors) { | ||
148 | for (final EAttribute attribute : attributes) { | ||
149 | { | ||
150 | final EDataType trg = attribute.getEAttributeType(); | ||
151 | boolean _supportedEDataType = this.supportedEDataType(trg); | ||
152 | boolean _not = (!_supportedEDataType); | ||
153 | if (_not) { | ||
154 | StringConcatenation _builder = new StringConcatenation(); | ||
155 | _builder.append("Metamodels contains attribute \""); | ||
156 | String _name = attribute.getName(); | ||
157 | _builder.append(_name, ""); | ||
158 | _builder.append("\" with unsupported type \""); | ||
159 | String _name_1 = trg.getName(); | ||
160 | _builder.append(_name_1, ""); | ||
161 | _builder.append("\"!"); | ||
162 | errors.add(_builder.toString()); | ||
163 | } | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | } | ||