) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
+ *
+ * This workaround is required e.g. to support recursion.
+ *
+ */
+ private static class LazyHolder {
+ private static final Allocate INSTANCE = new Allocate();
+
+ /**
+ * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
+ * This initialization order is required to support indirect recursion.
+ *
+ *
The static initializer is defined using a helper field to work around limitations of the code generator.
+ *
+ */
+ private static final Object STATIC_INITIALIZER = ensureInitialized();
+
+ public static Object ensureInitialized() {
+ INSTANCE.ensureInitializedInternal();
+ return null;
+ }
+ }
+
+ private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
+ private static final Allocate.GeneratedPQuery INSTANCE = new GeneratedPQuery();
+
+ private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT);
+
+ private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT);
+
+ private final List parameters = Arrays.asList(parameter_App, parameter_Host);
+
+ private class Embedded_1_ApplicationInstance_requirement_instances_allocatedTo extends BaseGeneratedEMFPQuery {
+ private final PParameter parameter_p0 = new PParameter("p0", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT);
+
+ private final PParameter parameter_p1 = new PParameter("p1", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT);
+
+ private final List embeddedParameters = Arrays.asList(parameter_p0, parameter_p1);
+
+ public Embedded_1_ApplicationInstance_requirement_instances_allocatedTo() {
+ super(PVisibility.EMBEDDED);
+ }
+
+ @Override
+ public String getFullyQualifiedName() {
+ return GeneratedPQuery.this.getFullyQualifiedName() + "$Embedded_1_ApplicationInstance_requirement_instances_allocatedTo";
+ }
+
+ @Override
+ public List getParameters() {
+ return embeddedParameters;
+ }
+
+ @Override
+ public Set doGetContainedBodies() {
+ PBody body = new PBody(this);
+ PVariable var_p0 = body.getOrCreateVariableByName("p0");
+ PVariable var_p1 = body.getOrCreateVariableByName("p1");
+ body.setSymbolicParameters(Arrays.asList(
+ new ExportedParameter(body, var_p0, parameter_p0),
+ new ExportedParameter(body, var_p1, parameter_p1)
+ ));
+ // ApplicationInstance.requirement.instances.allocatedTo(App, Host)
+ new TypeConstraint(body, Tuples.flatTupleOf(var_p0), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
+ PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
+ new TypeConstraint(body, Tuples.flatTupleOf(var_p0, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "requirement")));
+ new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement")));
+ PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
+ new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "instances")));
+ new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
+ PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
+ new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo")));
+ new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
+ new Equality(body, var__virtual_2_, var_p1);
+ return Collections.singleton(body);
+ }
+ }
+
+ private GeneratedPQuery() {
+ super(PVisibility.PUBLIC);
+ }
+
+ @Override
+ public String getFullyQualifiedName() {
+ return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocate";
+ }
+
+ @Override
+ public List getParameterNames() {
+ return Arrays.asList("App","Host");
+ }
+
+ @Override
+ public List getParameters() {
+ return parameters;
+ }
+
+ @Override
+ public Set doGetContainedBodies() {
+ setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
+ Set bodies = new LinkedHashSet<>();
+ {
+ PBody body = new PBody(this);
+ PVariable var_App = body.getOrCreateVariableByName("App");
+ PVariable var_Host = body.getOrCreateVariableByName("Host");
+ PVariable var_Req = body.getOrCreateVariableByName("Req");
+ PVariable var_AvailableMem = body.getOrCreateVariableByName("AvailableMem");
+ PVariable var_AvailableHdd = body.getOrCreateVariableByName("AvailableHdd");
+ PVariable var_RequiredMem = body.getOrCreateVariableByName("RequiredMem");
+ PVariable var_RequiredHdd = body.getOrCreateVariableByName("RequiredHdd");
+ new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
+ new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
+ body.setSymbolicParameters(Arrays.asList(
+ new ExportedParameter(body, var_App, parameter_App),
+ new ExportedParameter(body, var_Host, parameter_Host)
+ ));
+ // ApplicationInstance.type.requirements(App, Req)
+ new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
+ PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
+ new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type")));
+ new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType")));
+ PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
+ new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "requirements")));
+ new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement")));
+ new Equality(body, var__virtual_1_, var_Req);
+ // ResourceRequirement.hostType.instances(Req, Host)
+ new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement")));
+ PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
+ new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "hostType")));
+ new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType")));
+ PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}");
+ new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "instances")));
+ new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
+ new Equality(body, var__virtual_3_, var_Host);
+ // find unallocatedAppInstance(App)
+ new PositivePatternCall(body, Tuples.flatTupleOf(var_App), UnallocatedAppInstance.instance().getInternalQueryRepresentation());
+ // find availableMemory(Host, AvailableMem)
+ new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_AvailableMem), AvailableMemory.instance().getInternalQueryRepresentation());
+ // find availableHdd(Host, AvailableHdd)
+ new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_AvailableHdd), AvailableHdd.instance().getInternalQueryRepresentation());
+ // ResourceRequirement.requiredMemory(Req, RequiredMem)
+ new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement")));
+ PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}");
+ new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "requiredMemory")));
+ new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt")));
+ new Equality(body, var__virtual_4_, var_RequiredMem);
+ // ResourceRequirement.requiredHdd(Req, RequiredHdd)
+ new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement")));
+ PVariable var__virtual_5_ = body.getOrCreateVariableByName(".virtual{5}");
+ new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_5_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "requiredHdd")));
+ new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_5_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt")));
+ new Equality(body, var__virtual_5_, var_RequiredHdd);
+ // check(AvailableMem >= RequiredMem)
+ new ExpressionEvaluation(body, new IExpressionEvaluator() {
+
+ @Override
+ public String getShortDescription() {
+ return "Expression evaluation from pattern allocate";
+ }
+
+ @Override
+ public Iterable getInputParameterNames() {
+ return Arrays.asList("AvailableMem", "RequiredMem");}
+
+ @Override
+ public Object evaluateExpression(IValueProvider provider) throws Exception {
+ Integer AvailableMem = (Integer) provider.getValue("AvailableMem");
+ Integer RequiredMem = (Integer) provider.getValue("RequiredMem");
+ return evaluateExpression_1_1(AvailableMem, RequiredMem);
+ }
+ }, null);
+ // check(AvailableHdd >= RequiredHdd)
+ new ExpressionEvaluation(body, new IExpressionEvaluator() {
+
+ @Override
+ public String getShortDescription() {
+ return "Expression evaluation from pattern allocate";
+ }
+
+ @Override
+ public Iterable getInputParameterNames() {
+ return Arrays.asList("AvailableHdd", "RequiredHdd");}
+
+ @Override
+ public Object evaluateExpression(IValueProvider provider) throws Exception {
+ Integer AvailableHdd = (Integer) provider.getValue("AvailableHdd");
+ Integer RequiredHdd = (Integer) provider.getValue("RequiredHdd");
+ return evaluateExpression_1_2(AvailableHdd, RequiredHdd);
+ }
+ }, null);
+ // neg ApplicationInstance.requirement.instances.allocatedTo(App, Host)
+ new NegativePatternCall(body, Tuples.flatTupleOf(var_App, var_Host), new Allocate.GeneratedPQuery.Embedded_1_ApplicationInstance_requirement_instances_allocatedTo());
+ bodies.add(body);
+ }
+ return bodies;
+ }
+ }
+
+ private static boolean evaluateExpression_1_1(final Integer AvailableMem, final Integer RequiredMem) {
+ boolean _greaterEqualsThan = (AvailableMem.compareTo(RequiredMem) >= 0);
+ return _greaterEqualsThan;
+ }
+
+ private static boolean evaluateExpression_1_2(final Integer AvailableHdd, final Integer RequiredHdd) {
+ boolean _greaterEqualsThan = (AvailableHdd.compareTo(RequiredHdd) >= 0);
+ return _greaterEqualsThan;
+ }
+}
--
cgit v1.2.3-70-g09d2