Exemple #1
0
 public void readFromXml(Element config) throws FacetConfigurationFormatException {
   List<ModelRootDescriptor> descriptors = new ArrayList<ModelRootDescriptor>();
   for (Element ch : XmlUtil.children(config, "option")) {
     String optionName = ch.getAttributeValue("name");
     if ("UUID".equals(optionName)) {
       this.UUID = ch.getAttributeValue(OPT_VALUE);
     } else if ("generatorOutputPath".equals(optionName)) {
       this.generatorOutputPath = ch.getAttributeValue(OPT_VALUE);
     } else if ("modelRoots".equals(optionName)) {
       ModelRootDescriptor[] cache = new ModelRootDescriptor[2];
       for (ModelRoot root : SetSequence.fromSet(readModelRoots(XmlUtil.first(ch, "set")))) {
         Memento m = new MementoImpl();
         root.save(m);
         ModelRootDescriptor descr =
             ModuleDescriptorPersistence.createDescriptor(null, m, null, cache);
         if (descr != null) {
           descriptors.add(descr);
         }
       }
     } else if ("usedLanguages".equals(optionName)) {
       this.usedLanguages = readArray(XmlUtil.first(ch, "array"));
     } else if ("useModuleSourceFolder".equals(optionName)) {
       this.useModuleSourceFolder = "true".equals(ch.getAttributeValue(OPT_VALUE));
     } else if ("useTransientOutputFolder".equals(optionName)) {
       this.useTransientOutputFolder = "true".equals(ch.getAttributeValue(OPT_VALUE));
     }
   }
   for (Element modelRoot : XmlUtil.children(XmlUtil.first(config, "modelRoots"), "modelRoot")) {
     Element settings = XmlUtil.first(modelRoot, "settings");
     Memento m = new MementoImpl();
     if (settings != null) {
       MementoUtil.readMemento(m, settings);
     }
     descriptors.add(new ModelRootDescriptor(modelRoot.getAttributeValue("type"), m));
   }
   rootDescriptors = descriptors.toArray(new ModelRootDescriptor[descriptors.size()]);
 }
    private void load(File file, Element root) {
      FileMPSProject.ProjectDescriptor result_dkknya_a0a5o = this;
      final String result_dkknya_a0a0a5o = file.getName();
      result_dkknya_a0a5o.setName(result_dkknya_a0a0a5o);

      if (root == null) {
        return;
      }

      List<Element> moduleList = ListSequence.fromList(new ArrayList<Element>());
      ListSequence.fromList(moduleList)
          .addSequence(
              Sequence.fromIterable(
                  XmlUtil.children(XmlUtil.first(root, "projectSolutions"), "solutionPath")));
      ListSequence.fromList(moduleList)
          .addSequence(
              Sequence.fromIterable(
                  XmlUtil.children(XmlUtil.first(root, "projectLanguages"), "languagePath")));
      ListSequence.fromList(moduleList)
          .addSequence(
              Sequence.fromIterable(
                  XmlUtil.children(XmlUtil.first(root, "projectDevkits"), "devkitPath")));
      ListSequence.fromList(moduleList)
          .addSequence(
              Sequence.fromIterable(
                  XmlUtil.children(XmlUtil.first(root, "projectModules"), "modulePath")));
      for (Element moduleElement : ListSequence.fromList(moduleList)) {
        Path modulePath = new Path();
        Path result_dkknya_a1a9a0a5o = modulePath;
        final String result_dkknya_a0a1a9a0a5o =
            MacrosFactory.forProjectFile(FileSystem.getInstance().getFileByPath(file.getPath()))
                .expandPath(moduleElement.getAttributeValue("path"));
        result_dkknya_a1a9a0a5o.setPath(result_dkknya_a0a1a9a0a5o);
        final String result_dkknya_a1a1a9a0a5o = moduleElement.getAttributeValue("folder");
        result_dkknya_a1a9a0a5o.setMPSFolder(result_dkknya_a1a1a9a0a5o);
        result_dkknya_a0a5o.addModule(modulePath);
      }

      for (Element e :
          Sequence.fromIterable(
              XmlUtil.children(XmlUtil.first(root, "genConfs"), "genConfModels"))) {
        ModelsTestConfiguration tc = new ModelsTestConfiguration();
        tc.setName(e.getAttributeValue("name"));
        for (Element me :
            Sequence.fromIterable(XmlUtil.children(XmlUtil.first(e, "models"), "model"))) {
          tc.addModel(SModelReference.fromString(me.getAttributeValue("modelRef")));
        }
        result_dkknya_a0a5o.getTestConfigurations().add(tc);
      }

      for (Element e :
          Sequence.fromIterable(
              XmlUtil.children(XmlUtil.first(root, "genConfs"), "genConfModule"))) {
        ModuleTestConfiguration tc = new ModuleTestConfiguration();
        tc.setName(e.getAttributeValue("name"));
        String moduleRef = e.getAttributeValue("moduleRef");
        if (moduleRef != null) {
          tc.setModuleRef(ModuleReference.fromString(moduleRef));
          result_dkknya_a0a5o.getTestConfigurations().add(tc);
        }
      }
    }
  public static MappingConfig_AbstractRef loadGeneratorMappingConfigRef(
      final Element parentElement, final String genUID, boolean childOfGen) {
    if (Sequence.fromIterable(XmlUtil.children(parentElement, "all-mappings")).isNotEmpty()) {
      return new MappingConfig_RefAllGlobal();
    } else if (Sequence.fromIterable(XmlUtil.children(parentElement, "all-local-mappings"))
        .isNotEmpty()) {
      final MappingConfig_RefAllLocal local = new MappingConfig_RefAllLocal();
      if (childOfGen) {
        return local;
      }

      return new _FunctionTypes._return_P0_E0<MappingConfig_ExternalRef>() {
        public MappingConfig_ExternalRef invoke() {
          final MappingConfig_ExternalRef result_wk2vdq_a0a3a0a0e = new MappingConfig_ExternalRef();
          final SModuleReference result_wk2vdq_a0a0a3a0a0e =
              PersistenceFacade.getInstance().createModuleReference(genUID);
          result_wk2vdq_a0a3a0a0e.setGenerator(result_wk2vdq_a0a0a3a0a0e);
          final MappingConfig_AbstractRef result_wk2vdq_a1a0a3a0a0e = local;
          result_wk2vdq_a0a3a0a0e.setMappingConfig(result_wk2vdq_a1a0a3a0a0e);
          return result_wk2vdq_a0a3a0a0e;
        }
      }.invoke();
    } else if (XmlUtil.first(parentElement, "mapping-set") != null) {
      final MappingConfig_RefSet mappingSet = new MappingConfig_RefSet();
      for (Element mappingSetElement :
          Sequence.fromIterable(
              XmlUtil.children(
                  XmlUtil.first(parentElement, "mapping-set"), "mapping-set-element"))) {
        mappingSet
            .getMappingConfigs()
            .add(loadGeneratorMappingConfigRef(mappingSetElement, genUID, true));
      }

      if (childOfGen) {
        return mappingSet;
      }

      return new _FunctionTypes._return_P0_E0<MappingConfig_ExternalRef>() {
        public MappingConfig_ExternalRef invoke() {
          final MappingConfig_ExternalRef result_wk2vdq_a0a5a1a0e = new MappingConfig_ExternalRef();
          final SModuleReference result_wk2vdq_a0a0a5a1a0e =
              PersistenceFacade.getInstance().createModuleReference(genUID);
          result_wk2vdq_a0a5a1a0e.setGenerator(result_wk2vdq_a0a0a5a1a0e);
          final MappingConfig_AbstractRef result_wk2vdq_a1a0a5a1a0e = mappingSet;
          result_wk2vdq_a0a5a1a0e.setMappingConfig(result_wk2vdq_a1a0a5a1a0e);
          return result_wk2vdq_a0a5a1a0e;
        }
      }.invoke();
    } else if (XmlUtil.first(parentElement, "generator") != null) {
      // external reference
      final Element generator = XmlUtil.first(parentElement, "generator");
      return new _FunctionTypes._return_P0_E0<MappingConfig_ExternalRef>() {
        public MappingConfig_ExternalRef invoke() {
          final MappingConfig_ExternalRef result_wk2vdq_a0a2a2a0e = new MappingConfig_ExternalRef();
          final SModuleReference result_wk2vdq_a0a0a2a2a0e =
              PersistenceFacade.getInstance()
                  .createModuleReference(generator.getAttributeValue("generatorUID"));
          result_wk2vdq_a0a2a2a0e.setGenerator(result_wk2vdq_a0a0a2a2a0e);
          final MappingConfig_AbstractRef result_wk2vdq_a1a0a2a2a0e =
              loadGeneratorMappingConfigRef(
                  XmlUtil.first(parentElement, "external-mapping"),
                  generator.getAttributeValue("generatorUID"),
                  true);
          result_wk2vdq_a0a2a2a0e.setMappingConfig(result_wk2vdq_a1a0a2a2a0e);
          return result_wk2vdq_a0a2a2a0e;
        }
      }.invoke();
    } else if (XmlUtil.first(parentElement, "mapping-node") != null) {
      // simple reference
      Element mappingNode = XmlUtil.first(parentElement, "mapping-node");
      final MappingConfig_SimpleRef mapping_SimpleRef = new MappingConfig_SimpleRef();
      MappingConfig_SimpleRef result_wk2vdq_a3a3a0e = mapping_SimpleRef;
      final String result_wk2vdq_a0a3a3a0e = mappingNode.getAttributeValue("modelUID");
      result_wk2vdq_a3a3a0e.setModelUID(result_wk2vdq_a0a3a3a0e);
      final String result_wk2vdq_a1a3a3a0e = mappingNode.getAttributeValue("nodeID");
      result_wk2vdq_a3a3a0e.setNodeID(result_wk2vdq_a1a3a3a0e);

      if (childOfGen) {
        return mapping_SimpleRef;
      }

      return new _FunctionTypes._return_P0_E0<MappingConfig_ExternalRef>() {
        public MappingConfig_ExternalRef invoke() {
          final MappingConfig_ExternalRef result_wk2vdq_a0a7a3a0e = new MappingConfig_ExternalRef();
          final SModuleReference result_wk2vdq_a0a0a7a3a0e =
              PersistenceFacade.getInstance().createModuleReference(genUID);
          result_wk2vdq_a0a7a3a0e.setGenerator(result_wk2vdq_a0a0a7a3a0e);
          final MappingConfig_AbstractRef result_wk2vdq_a1a0a7a3a0e = mapping_SimpleRef;
          result_wk2vdq_a0a7a3a0e.setMappingConfig(result_wk2vdq_a1a0a7a3a0e);
          return result_wk2vdq_a0a7a3a0e;
        }
      }.invoke();
    }

    // empty?
    return new MappingConfig_AbstractRef();
  }