예제 #1
0
 private String getModelName(Model existingModel, InstanceSpecification node) {
   String modelName = existingModel.getName() + "_" + node.getName(); // $NON-NLS-1$
   if (configuration != null) {
     modelName += "_" + configuration.getBase_Class().getName(); // $NON-NLS-1$
   } else {
     modelName += "_" + srcModelComponentDeploymentPlan.getName(); // $NON-NLS-1$
   }
   return modelName;
 }
 @Override
 public Value evaluate() {
   // If the instance specification is for an enumeration, then return the
   // identified enumeration literal.
   // If the instance specification is for a data type (but not a primitive
   // value or an enumeration), then create a data value of the given data
   // type.
   // If the instance specification is for an object, then create an object
   // at the current locus with the specified types.
   // Set each feature of the created value to the result of evaluating the
   // value specifications for the specified slot for the feature.
   // Debug.println("[evaluate] InstanceValueEvaluation...");
   InstanceSpecification instance = ((InstanceValue) this.specification).getInstance();
   // List<Classifier> types = instance.getClassifiers();
   // Classifier myType = types.get(0);
   // Debug.println("[evaluate] type = " + myType.getName());
   Value value;
   if (instance instanceof EnumerationLiteral) {
     // Debug.println("[evaluate] Type is an enumeration.");
     EnumerationValue enumerationValue = new EnumerationValue();
     // enumerationValue.type = (Enumeration)myType;
     enumerationValue.type = ((EnumerationLiteral) instance).getEnumeration(); // ADDED
     enumerationValue.literal = (EnumerationLiteral) instance;
     value = enumerationValue;
     Debug.println("[evaluate] type = " + enumerationValue.type.getName()); // ADDED
   } else {
     // ADDED:
     List<Classifier> types = instance.getClassifiers();
     Classifier myType = types.get(0);
     Debug.println("[evaluate] type = " + myType.getName());
     //
     StructuredValue structuredValue = null;
     if (myType instanceof DataType) {
       // Debug.println("[evaluate] Type is a data type.");
       DataValue dataValue = new DataValue();
       dataValue.type = (DataType) myType;
       structuredValue = dataValue;
     } else {
       Object_ object = null;
       if (myType instanceof Behavior) {
         // Debug.println("[evaluate] Type is a behavior.");
         object = this.locus.factory.createExecution((Behavior) myType, null);
       } else {
         // Debug.println("[evaluate] Type is a class.");
         object = new Object_();
         for (int i = 0; i < types.size(); i++) {
           Classifier type = types.get(i);
           object.types.add((Class) type);
         }
       }
       this.locus.add(object);
       Reference reference = new Reference();
       reference.referent = object;
       structuredValue = reference;
     }
     structuredValue.createFeatureValues();
     // Debug.println("[evaluate] " + instance.slot.size() +
     // " slot(s).");
     List<Slot> instanceSlots = instance.getSlots();
     for (int i = 0; i < instanceSlots.size(); i++) {
       Slot slot = instanceSlots.get(i);
       List<Value> values = new ArrayList<Value>();
       // Debug.println("[evaluate] feature = " +
       // slot.definingFeature.getName() + ", " + slot.value.size() +
       // " value(s).");
       List<ValueSpecification> slotValues = slot.getValues();
       for (int j = 0; j < slotValues.size(); j++) {
         ValueSpecification slotValue = slotValues.get(j);
         // Debug.println("[evaluate] Value = " +
         // slotValue.getClass().getName());
         values.add(this.locus.executor.evaluate(slotValue));
       }
       structuredValue.setFeatureValue(slot.getDefiningFeature(), values, 0);
     }
     value = structuredValue;
   }
   return value;
 }
예제 #3
0
  private void deployNode(
      InstanceSpecification mainInstance,
      Model existingModel,
      Model tmpModel,
      InstanceSpecification newRootIS,
      EList<InstanceSpecification> nodes,
      int nodeIndex,
      InstanceSpecification node)
      throws TransformationException, InterruptedException {
    ModelManagement genModelManagement =
        createTargetModel(existingModel, MapUtil.rootModelName, false);
    Model generatedModel = genModelManagement.getModel();

    // --------------------------------------------------------------------
    checkProgressStatus();
    // --------------------------------------------------------------------

    // new model has name "root" and contains a package with the
    // existing model
    // Package originalRoot = genModel.createNestedPackage
    // (existingModel.getName ());
    LazyCopier targetCopy = new LazyCopier(tmpModel, generatedModel, true, true);
    // TODO: distribution to nodes is currently not done. How
    // can it be realized with a copy filter ?
    targetCopy.preCopyListeners.add(FilterStateMachines.getInstance());
    targetCopy.preCopyListeners.add(FilterRuleApplication.getInstance());

    monitor.setTaskName(
        String.format(Messages.InstantiateDepPlan_InfoDeployingForNode, node.getName()));

    ILangSupport langSupport = configureLanguageSupport(mainInstance, existingModel, node);
    if (langSupport == null) {
      return;
    }

    Deploy deployment = new Deploy(targetCopy, langSupport, node, nodeIndex, nodes.size());
    InstanceSpecification nodeRootIS = deployment.distributeToNode(newRootIS);
    TransformationUtil.updateDerivedInterfaces(nodeRootIS);

    // --------------------------------------------------------------------
    checkProgressStatus();
    // --------------------------------------------------------------------

    removeDerivedInterfacesInRoot(generatedModel);

    CompImplTrafos.transform(
        deployment.getBootloader(), targetCopy, generatedModel, modelIsObjectOriented);

    // --------------------------------------------------------------------
    checkProgressStatus();
    // --------------------------------------------------------------------

    destroyDeploymentPlanFolder(generatedModel);

    if (generateCode) {
      GenerateCode codeGenerator =
          new GenerateCode(langSupport.getProject(), langSupport, genModelManagement, monitor);
      boolean option = (generationOptions & GenerationOptions.ONLY_CHANGED) != 0;
      codeGenerator.generate(node, getTargetLanguage(mainInstance), option);
    }

    genModelManagement.dispose();
  }