Ejemplo n.º 1
0
  private void deployOnNodes(
      InstanceSpecification mainInstance,
      Model existingModel,
      Model tmpModel,
      InstanceSpecification newRootIS)
      throws TransformationException, InterruptedException {

    // not deploy on each node
    DepCreation.initAutoValues(newRootIS);

    EList<InstanceSpecification> nodes = AllocUtils.getAllNodes(newRootIS);
    if (nodes.size() > 0) {
      InstanceConfigurator.onNodeModel = true;
      for (int nodeIndex = 0; nodeIndex < nodes.size(); nodeIndex++) {
        InstanceSpecification node = nodes.get(nodeIndex);

        deployNode(mainInstance, existingModel, tmpModel, newRootIS, nodes, nodeIndex, node);
      }
    } else {
      throw new TransformationException(Messages.InstantiateDepPlan_InfoNoneAllocated);
    }
  }
Ejemplo n.º 2
0
  protected void executeTransformation() throws Exception {
    modelIsObjectOriented = true;
    ModelManagement intermediateModelManagement = null;

    InstanceSpecification mainInstance = DepUtils.getMainInstance(srcModelComponentDeploymentPlan);
    EList<InstanceSpecification> nodes = AllocUtils.getAllNodes(mainInstance);

    initiateProgressMonitor(generateCode, nodes);

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

    // 1a: create a new model (and applies same profiles / imports)
    Model existingModel = srcModelComponentDeploymentPlan.getModel();
    TransformationContext.sourceRoot = existingModel;

    intermediateModelManagement = createTargetModel(existingModel, existingModel.getName(), true);

    // Declare that the new model is a derivedElement (kind of hack,
    // since the source element (attribute of derive element) remains
    // undefined). This is used to deactivate automatic transformations
    // that should not be applied to the generated model.

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

    // get the temporary model
    Model intermediateModel = intermediateModelManagement.getModel();

    // create a package for global enumerations that are used by Acceleo code
    EnumService.createEnumPackage(intermediateModel);

    // create a lazy copier towards the intermediate model
    LazyCopier intermediateModelCopier =
        new LazyCopier(existingModel, intermediateModel, false, true);
    // add pre-copy and post-copy listeners to the copier
    intermediateModelCopier.preCopyListeners.add(FilterTemplate.getInstance());

    // 1b: reify the connectors "into" the new model
    monitor.subTask(Messages.InstantiateDepPlan_InfoExpandingConnectors);

    // obtain the component deployment plan in target model
    Package intermediateModelComponentDeploymentPlan =
        (Package) intermediateModelCopier.shallowCopy(srcModelComponentDeploymentPlan);
    intermediateModelCopier.createShallowContainer(srcModelComponentDeploymentPlan);

    AbstractContainerTrafo.init();
    InstanceConfigurator.onNodeModel = false;
    MainModelTrafo mainModelTrafo =
        new MainModelTrafo(intermediateModelCopier, intermediateModelComponentDeploymentPlan);
    InstanceSpecification newMainInstance = mainModelTrafo.transformInstance(mainInstance, null);

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

    TransformationUtil.applyInstanceConfigurators(newMainInstance);

    FlattenInteractionComponents.getInstance().flattenAssembly(newMainInstance, null);

    TransformationUtil.propagateAllocation(newMainInstance);

    intermediateModelManagement.saveModel(project, TEMP_MODEL_FOLDER, TEMP_MODEL_POSTFIX);

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

    if (!generateCACOnly) {
      deployOnNodes(mainInstance, existingModel, intermediateModel, newMainInstance);
    }

    intermediateModelManagement.dispose();

    if (AcceleoDriver.hasErrors()) {
      throw new AcceleoException();
    }
  }