Example #1
0
 public static ArrayList<Configuration> findConfiguration(
     ThingMLModel model, String name, boolean fuzzy) {
   ArrayList<Configuration> result = new ArrayList<Configuration>();
   for (Configuration c : allConfigurations(model)) {
     if (c.getName().startsWith(name)) {
       if (fuzzy) result.add(c);
       else if (c.getName().equals(name)) result.add(c);
     }
   }
   return result;
 }
  public void resolve(
      String identifier,
      org.sintef.thingml.InstanceRef container,
      org.eclipse.emf.ecore.EReference reference,
      int position,
      boolean resolveFuzzy,
      final org.sintef.thingml.resource.thingml.IThingmlReferenceResolveResult<
              org.sintef.thingml.Instance>
          result) {

    // In which configuration should we look:
    Configuration cfg = ThingMLHelpers.findContainingConfiguration(container);
    if (cfg != null) {

      for (Instance ci : cfg.getInstances()) {
        if (ci.getName().startsWith(identifier)) {
          if (resolveFuzzy) result.addMapping(ci.getName(), ci);
          else if (ci.getName().equals(identifier)) result.addMapping(ci.getName(), ci);
        }
      }
      if (!result.wasResolved())
        result.setErrorMessage(
            "Cannot resolve instance " + identifier + " in configuration " + cfg.getName());
    }
    if (!result.wasResolved()) result.setErrorMessage("Cannot resolve instance " + identifier);
  }
Example #3
0
  @Override
  public void generateBuildScript(Configuration cfg, Context ctx) {
    try {
      final InputStream input =
          this.getClass().getClassLoader().getResourceAsStream("javascript/lib/package.json");
      final List<String> packLines = IOUtils.readLines(input);
      String pack = "";
      for (String line : packLines) {
        pack += line + "\n";
      }
      input.close();
      pack = pack.replace("<NAME>", cfg.getName());

      final JsonObject json = JsonObject.readFrom(pack);
      final JsonValue deps = json.get("dependencies");
      for (Thing t : cfg.allThings()) {
        for (String dep : t.annotation("js_dep")) {
          deps.asObject().add(dep.split(":")[0].trim(), dep.split(":")[1].trim());
        }
      }

      for (Thing t : cfg.allThings()) {
        if (t.getStreams().size() > 0) {
          deps.asObject().add("rx", "^2.5.3");
          deps.asObject().add("events", "^1.0.2");
          break;
        }
      }

      final File f = new File(ctx.getOutputDirectory() + "/" + cfg.getName() + "/package.json");
      f.setWritable(true);
      final PrintWriter w = new PrintWriter(new FileWriter(f));
      w.println(json.toString());
      w.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @Override
  public void do_call_compiler(Configuration cfg, String... options) {

    DebugGUICompilerContext ctx = new DebugGUICompilerContext(this);
    processDebug(cfg);
    ctx.setCurrentConfiguration(cfg);
    ctx.setOutputDirectory(new File(ctx.getOutputDirectory(), cfg.getName()));

    DebugGUICfgMainGenerator mainGen = (DebugGUICfgMainGenerator) getMainCompiler();
    ExternalConnector eco = mainGen.findExternalConnector(cfg);
    if (eco != null) mainGen.generateMockUp(eco, cfg, ctx);

    // WRITE THE GENERATED CODE
    ctx.writeGeneratedCodeToFiles();
  }
Example #5
0
 @Override
 public String getDockerCfgRunPath(Configuration cfg, Context ctx) {
   return "COPY ./target/" + cfg.getName() + "-1.0-SNAPSHOT-jar-with-dependencies.jar /work/\n";
 }
Example #6
0
 @Override
 public String getDockerCMD(Configuration cfg, Context ctx) {
   return "java\", \"-jar\", \"" + cfg.getName() + "-1.0-SNAPSHOT-jar-with-dependencies.jar";
 }