Beispiel #1
0
  @Test
  public void testGenerateMultipleStateMultipleActionCommands() throws Exception {
    DomainModel domainModel = parseHelper.parse(MULTIPLE_STATES_MULTIPLE_ACTION_COMMANDS_RIM);
    ResourceInteractionModel model = (ResourceInteractionModel) domainModel.getRims().get(0);
    InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
    underTest.doGenerate(model.eResource(), fsa);

    String resouceAKey = IFileSystemAccess.DEFAULT_OUTPUT + "Test/AResourceState.java";
    assertTrue(fsa.getFiles().containsKey(resouceAKey));
    String resourceA = fsa.getFiles().get(resouceAKey).toString();
    int indexOfFirstNewProperties = resourceA.indexOf("actionViewProperties = new Properties()");
    assertTrue(indexOfFirstNewProperties > 0);
    assertTrue(resourceA.contains("actionViewProperties.put(\"key\", \"value\""));
    assertTrue(
        resourceA.contains("new Action(\"DoStuff\", Action.TYPE.ENTRY, actionViewProperties)"));

    String resouceBKey = IFileSystemAccess.DEFAULT_OUTPUT + "Test/BResourceState.java";
    assertTrue(fsa.getFiles().containsKey(resouceBKey));
    String resourceB = fsa.getFiles().get(resouceBKey).toString();
    int indexOfSecondNewProperties =
        resourceB.indexOf("actionViewProperties = new Properties()", indexOfFirstNewProperties);
    assertTrue(indexOfSecondNewProperties > 0);
    assertTrue(resourceB.contains("actionViewProperties.put(\"keyB\", \"valueB\""));
    assertTrue(
        resourceB.contains("new Action(\"DoSomeStuff\", Action.TYPE.ENTRY, actionViewProperties)"));
    assertTrue(resourceB.contains("actionViewProperties.put(\"keyB0\", \"valueB0\""));
    assertTrue(resourceB.contains("actionViewProperties.put(\"keyB1\", \"valueB1\""));
    assertTrue(
        resourceB.contains(
            "new Action(\"DoSomeMoreStuff\", Action.TYPE.ENTRY, actionViewProperties)"));
  }
Beispiel #2
0
 @Test
 public void testGenerateWithNull() throws Exception {
   boolean exceptionThrown = false;
   try {
     InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
     underTest.doGenerate(null, fsa);
   } catch (RuntimeException e) {
     exceptionThrown = true;
   }
   assertTrue(exceptionThrown);
 }
Beispiel #3
0
 @Xpect(liveExecution = LiveExecutionType.FAST)
 @ParameterParser(syntax = "('file' arg2=TEXT)?")
 public void generated(
     @StringExpectation IStringExpectation expectation,
     @ThisResource XtextResource resource,
     String arg2) {
   InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
   generator.doGenerate(resource, fsa);
   String files =
       createInMemoryFileSystemAccessFormatter().includeOnlyFileNamesEndingWith(arg2).apply(fsa);
   expectation.assertEquals(files);
 }
Beispiel #4
0
 @Test
 public void testGenerateFromIncompleteRIM() throws Exception {
   DomainModel model = parseHelper.parse(INCOMPLETE_RIM);
   InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
   boolean exceptionThrown = false;
   try {
     underTest.doGenerate(model.eResource(), fsa);
   } catch (RuntimeException e) {
     exceptionThrown = true;
   }
   assertFalse(exceptionThrown);
 }
Beispiel #5
0
  @Test
  public void testGenerateUpdateTransition() throws Exception {
    DomainModel domainModel = parseHelper.parse(TRANSITION_WITH_UPDATE_EVENT);
    ResourceInteractionModel model = (ResourceInteractionModel) domainModel.getRims().get(0);
    InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
    underTest.doGenerate(model.eResource(), fsa);

    String resourceAKey = IFileSystemAccess.DEFAULT_OUTPUT + "Test/AResourceState.java";
    assertTrue(fsa.getFiles().containsKey(resourceAKey));
    String resourceA = fsa.getFiles().get(resourceAKey).toString();
    assertTrue(resourceA.contains("sA.addTransition(new Transition.Builder()"));
    assertTrue(resourceA.contains(".flags(Transition.FOR_EACH)"));
    assertTrue(resourceA.contains(".method(\"GET\")"));
    assertTrue(resourceA.contains(".target(sB)"));
    assertTrue(resourceA.contains(".uriParameters(uriLinkageProperties)"));
    assertTrue(
        resourceA.contains(
            ".evaluation(conditionalLinkExpressions != null ? new SimpleLogicalExpressionEvaluator(conditionalLinkExpressions) : null)"));
    assertTrue(resourceA.contains(".label(\"B\")"));

    String resourceBKey = IFileSystemAccess.DEFAULT_OUTPUT + "Test/BResourceState.java";
    assertTrue(fsa.getFiles().containsKey(resourceBKey));
    String resourceB = fsa.getFiles().get(resourceBKey).toString();
    assertTrue(resourceB.contains("sB.addTransition(new Transition.Builder()"));
    assertTrue(resourceB.contains(".method(\"PUT\")"));
    assertTrue(resourceB.contains(".target(sB_pseudo)"));
    assertTrue(resourceB.contains(".uriParameters(uriLinkageProperties)"));
    assertTrue(
        resourceB.contains(
            ".evaluation(conditionalLinkExpressions != null ? new SimpleLogicalExpressionEvaluator(conditionalLinkExpressions) : null)"));
    assertTrue(resourceB.contains(".label(\"B_pseudo\")"));

    String resourceB_pseudoKey =
        IFileSystemAccess.DEFAULT_OUTPUT + "Test/B_pseudoResourceState.java";
    assertTrue(fsa.getFiles().containsKey(resourceB_pseudoKey));
    String resourceB_pseudo = fsa.getFiles().get(resourceB_pseudoKey).toString();
    assertTrue(resourceB_pseudo.contains("sB_pseudo.addTransition(new Transition.Builder()"));
    assertTrue(resourceB_pseudo.contains(".flags(Transition.AUTO)"));
    assertTrue(resourceB_pseudo.contains(".target(sA)"));
    assertTrue(resourceB_pseudo.contains(".uriParameters(uriLinkageProperties)"));
    assertTrue(
        resourceB_pseudo.contains(
            ".evaluation(conditionalLinkExpressions != null ? new SimpleLogicalExpressionEvaluator(conditionalLinkExpressions) : null)"));

    assertTrue(resourceB_pseudo.contains("sB_pseudo.addTransition(new Transition.Builder()"));
    assertTrue(resourceB_pseudo.contains(".flags(Transition.AUTO)"));
    assertTrue(resourceB_pseudo.contains(".target(sB)"));
    assertTrue(resourceB_pseudo.contains(".uriParameters(uriLinkageProperties)"));
    assertTrue(
        resourceB_pseudo.contains(
            ".evaluation(conditionalLinkExpressions != null ? new SimpleLogicalExpressionEvaluator(conditionalLinkExpressions) : null)"));
  }
Beispiel #6
0
  /*
   * doGenerate should producer one file per resource
   */
  @Test
  public void testGenerateOneFile() throws Exception {
    DomainModel domainModel = parseHelper.parse(SINGLE_STATE_VIEW_COMMAND_ONLY_RIM);
    ResourceInteractionModel model = (ResourceInteractionModel) domainModel.getRims().get(0);
    InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
    underTest.doGenerate(model.eResource(), fsa);
    System.out.println(fsa.getFiles());
    assertEquals(2, fsa.getFiles().size());

    assertTrue(fsa.getFiles().containsKey(IFileSystemAccess.DEFAULT_OUTPUT + "TestBehaviour.java"));
    assertTrue(
        fsa.getFiles().containsKey(IFileSystemAccess.DEFAULT_OUTPUT + "Test/AResourceState.java"));
  }
Beispiel #7
0
  @Test
  public void testGenerateOnErrorResourceSeparateRIM() throws Exception {
    DomainModel domainModel = parseHelper.parse(RESOURCE_ON_ERROR_SEPARATE_RIM);
    InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
    underTest.doGenerate(domainModel.eResource(), fsa);

    // collection
    String expectedKey = IFileSystemAccess.DEFAULT_OUTPUT + "ErrorTest/Test/AResourceState.java";
    assertTrue(fsa.getFiles().containsKey(expectedKey));
    String output = fsa.getFiles().get(expectedKey).toString();
    assertTrue(
        output.contains(
            "super(\"ENTITY\", \"A\", createActions(), \"/A\", createLinkRelations(), null, factory.getResourceState(\"ErrorTest.Error.AE\"));"));
  }
Beispiel #8
0
  @Test
  public void testGenerateSingleStateViewCommandOnly() throws Exception {
    DomainModel domainModel = parseHelper.parse(SINGLE_STATE_VIEW_COMMAND_ONLY_RIM);
    InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
    underTest.doGenerate(domainModel.eResource(), fsa);

    String expectedKey = IFileSystemAccess.DEFAULT_OUTPUT + "Test/AResourceState.java";
    assertTrue(fsa.getFiles().containsKey(expectedKey));
    assertTrue(
        fsa.getFiles()
            .get(expectedKey)
            .toString()
            .contains("new Action(\"GetEntity\", Action.TYPE.VIEW, new Properties())"));
  }
Beispiel #9
0
  @Test
  public void testGenerateResourceWithBasepath() throws Exception {
    DomainModel domainModel = parseHelper.parse(RESOURCE_WITH_BASEPATH);
    ResourceInteractionModel model = (ResourceInteractionModel) domainModel.getRims().get(0);
    InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
    underTest.doGenerate(model.eResource(), fsa);

    // collection
    String expectedKey = IFileSystemAccess.DEFAULT_OUTPUT + "Test/AResourceState.java";
    assertTrue(fsa.getFiles().containsKey(expectedKey));
    String output = fsa.getFiles().get(expectedKey).toString();
    assertTrue(
        output.contains(
            "super(\"ENTITY\", \"A\", createActions(), \"/{companyid}/A\", createLinkRelations(), null, null);"));
  }
Beispiel #10
0
  @Test
  public void testGenerateAutoTransitionsWithUriLinkage() throws Exception {
    DomainModel domainModel = parseHelper.parse(AUTO_TRANSITION_WITH_URI_LINKAGE_RIM);
    ResourceInteractionModel model = (ResourceInteractionModel) domainModel.getRims().get(0);
    InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
    underTest.doGenerate(model.eResource(), fsa);

    String expectedKey =
        IFileSystemAccess.DEFAULT_OUTPUT + "Test/create_pseudo_stateResourceState.java";
    assertTrue(fsa.getFiles().containsKey(expectedKey));
    String output = fsa.getFiles().get(expectedKey).toString();

    assertTrue(output.contains("uriLinkageProperties.put(\"id\", \"{MyId}\");"));
    assertTrue(output.contains("screate_pseudo_state.addTransition(new Transition.Builder()"));
    assertTrue(output.contains(".target(screated)"));
  }
Beispiel #11
0
 protected void handleChangedContents(
     Delta delta, IBuildContext context, EclipseResourceFileSystemAccess2 fileSystemAccess)
     throws CoreException {
   // TODO: we will run out of memory here if the number of deltas is large enough
   Resource resource = context.getResourceSet().getResource(delta.getUri(), true);
   if (shouldGenerate(resource, context)) {
     try {
       generator.doGenerate(resource, fileSystemAccess);
     } catch (RuntimeException e) {
       if (e.getCause() instanceof CoreException) {
         throw (CoreException) e.getCause();
       }
       throw e;
     }
   }
 }
Beispiel #12
0
  private void compileResource(String fileName) {
    // get instances
    Injector injector = new DeltaJStandaloneSetup().createInjectorAndDoEMFRegistration();
    ResourceSet set = injector.getInstance(ResourceSet.class);
    validator = injector.getInstance(IResourceValidator.class);
    fileAccess = injector.getInstance(JavaIoFileSystemAccess.class);
    generator = injector.getInstance(IGenerator.class);

    Resource resource = set.getResource(URI.createURI(getUriPrefix() + fileName), true);

    // validate the resource for syntax errors
    issueList = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl);

    // generate
    fileAccess.setOutputPath(this.outputPath);
    generator.doGenerate(resource, fileAccess);
  }
Beispiel #13
0
  @Test
  public void testGenerateResourcesWithGlobalRelations() throws Exception {
    DomainModel domainModel = parseHelper.parse(GLOBAL_RESOURCE_RELATIONS_RIM);
    ResourceInteractionModel model = (ResourceInteractionModel) domainModel.getRims().get(0);
    InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
    underTest.doGenerate(model.eResource(), fsa);

    // collection
    String expectedKey =
        IFileSystemAccess.DEFAULT_OUTPUT + "Test/accTransactionsResourceState.java";
    assertTrue(fsa.getFiles().containsKey(expectedKey));
    String accTransactionsOutput = fsa.getFiles().get(expectedKey).toString();
    // the constructor part
    assertTrue(accTransactionsOutput.contains("\"/accTransactions\", createLinkRelations()"));
    // createLinkRelations method
    String expectedAccTransactionsRelArray =
        ""
            + "        String accTransactionsRelationsStr = \"\";"
            + LINE_SEP
            + "        accTransactionsRelationsStr += \"archive \";"
            + LINE_SEP
            + "        accTransactionsRelationsStr += \"http://www.temenos.com/statement-entries \";"
            + LINE_SEP
            + "        String[] accTransactionsRelations = accTransactionsRelationsStr.trim().split(\" \");"
            + LINE_SEP
            + "";
    assertTrue(accTransactionsOutput.contains(expectedAccTransactionsRelArray));

    // item
    expectedKey = IFileSystemAccess.DEFAULT_OUTPUT + "Test/accTransactionResourceState.java";
    assertTrue(fsa.getFiles().containsKey(expectedKey));
    String accTransactionOutput = fsa.getFiles().get(expectedKey).toString();
    // the constructor part
    assertTrue(accTransactionOutput.contains("\"/accTransaction\", createLinkRelations()"));
    // createLinkRelations method
    String expectedAccTransactionRelArray =
        ""
            + "        String accTransactionRelationsStr = \"\";"
            + LINE_SEP
            + "        accTransactionRelationsStr += \"edit \";"
            + LINE_SEP
            + "        String[] accTransactionRelations = accTransactionRelationsStr.trim().split(\" \");"
            + LINE_SEP
            + "";
    assertTrue(accTransactionOutput.contains(expectedAccTransactionRelArray));
  }
Beispiel #14
0
  @Test
  public void testGenerateEmbeddedTransitions() throws Exception {
    DomainModel domainModel = parseHelper.parse(EMBEDDED_TRANSITION_RIM);
    ResourceInteractionModel model = (ResourceInteractionModel) domainModel.getRims().get(0);
    InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
    underTest.doGenerate(model.eResource(), fsa);

    String expectedKey = IFileSystemAccess.DEFAULT_OUTPUT + "Test/AResourceState.java";
    assertTrue(fsa.getFiles().containsKey(expectedKey));
    String output = fsa.getFiles().get(expectedKey).toString();

    assertTrue(output.contains("sA.addTransition(new Transition.Builder()"));
    assertTrue(output.contains(".target(sB)"));
    assertTrue(output.contains(".flags(Transition.EMBEDDED)"));

    String expectedBKey = IFileSystemAccess.DEFAULT_OUTPUT + "Test/BResourceState.java";
    assertTrue(fsa.getFiles().containsKey(expectedBKey));
  }
Beispiel #15
0
  @Test
  public void testGenerateTransitionsWithExpressions() throws Exception {
    DomainModel domainModel = parseHelper.parse(TRANSITION_WITH_EXPRESSION_RIM);
    ResourceInteractionModel model = (ResourceInteractionModel) domainModel.getRims().get(0);
    InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
    underTest.doGenerate(model.eResource(), fsa);

    String expectedKey = IFileSystemAccess.DEFAULT_OUTPUT + "Test/AResourceState.java";
    assertTrue(fsa.getFiles().containsKey(expectedKey));
    String output = fsa.getFiles().get(expectedKey).toString();

    final String NEW_STATEMENT = "conditionalLinkExpressions = new ArrayList<Expression>();";
    final String ADD_TRANSITION =
        ".method(\"GET\").target(sB).uriParameters(uriLinkageProperties).evaluation(conditionalLinkExpressions != null ? new SimpleLogicalExpressionEvaluator(conditionalLinkExpressions) : null).label(\"B\")";

    int indexOfNewStatement = output.indexOf(NEW_STATEMENT);
    assertTrue(indexOfNewStatement > 0);
    assertTrue(
        output.contains(
            "conditionalLinkExpressions.add(new ResourceGETExpression(factory.getResourceState(\"Test.B\"), ResourceGETExpression.Function.OK))"));
    int indexOfAddTransition = output.indexOf(ADD_TRANSITION);
    assertTrue(indexOfAddTransition > 0);

    indexOfNewStatement = output.indexOf(NEW_STATEMENT, indexOfNewStatement);
    assertTrue(indexOfNewStatement > 0);
    assertTrue(
        output.contains(
            "conditionalLinkExpressions.add(new ResourceGETExpression(factory.getResourceState(\"Test.B\"), ResourceGETExpression.Function.NOT_FOUND))"));
    indexOfAddTransition = output.indexOf(ADD_TRANSITION, indexOfAddTransition);
    assertTrue(indexOfAddTransition > 0);

    indexOfNewStatement = output.indexOf(NEW_STATEMENT, indexOfNewStatement);
    assertTrue(indexOfNewStatement > 0);
    assertTrue(
        output.contains(
            "conditionalLinkExpressions.add(new ResourceGETExpression(factory.getResourceState(\"Test.C\"), ResourceGETExpression.Function.OK))"));
    assertTrue(
        output.contains(
            "conditionalLinkExpressions.add(new ResourceGETExpression(factory.getResourceState(\"Test.D\"), ResourceGETExpression.Function.NOT_FOUND))"));
    indexOfAddTransition = output.indexOf(ADD_TRANSITION, indexOfAddTransition);
    assertTrue(indexOfAddTransition > 0);
  }
Beispiel #16
0
  protected void runGenerator(String string) {
    // load the resource
    ResourceSet set = resourceSetProvider.get();
    Resource resource = set.getResource(URI.createURI(string), true);

    // validate the resource
    List<Issue> list = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl);
    if (!list.isEmpty()) {
      for (Issue issue : list) {
        System.err.println(issue);
      }
      return;
    }

    // configure and start the generator
    fileAccess.setOutputPath("src-gen/");
    generator.doGenerate(resource, fileAccess);

    System.out.println("Code generation finished.");
  }
Beispiel #17
0
  /*
   * doGenerate should producer one file per resource
   */
  @Test
  public void testGenerateFileInPackage() throws Exception {
    DomainModel domainModel = parseHelper.parse(SINGLE_STATE_WITH_PACKAGE_RIM);
    InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
    underTest.doGenerate(domainModel.eResource(), fsa);
    System.out.println(fsa.getFiles());
    assertEquals(2, fsa.getFiles().size());

    String expectedKey = IFileSystemAccess.DEFAULT_OUTPUT + "blah/TestBehaviour.java";
    assertTrue(fsa.getFiles().containsKey(expectedKey));
    String output = fsa.getFiles().get(expectedKey).toString();
    assertTrue(output.contains("package blah;"));
    assertTrue(output.contains("public class TestBehaviour {"));
    assertTrue(output.contains("getRIM"));
    assertTrue(output.contains("factory.getResourceState(\"blah.Test.A\");"));

    String expectedRSKey = IFileSystemAccess.DEFAULT_OUTPUT + "blah/Test/AResourceState.java";
    assertTrue(fsa.getFiles().containsKey(expectedRSKey));
    String outputRS = fsa.getFiles().get(expectedRSKey).toString();
    assertTrue(outputRS.contains("package blah.Test;"));
  }
Beispiel #18
0
  @Test
  public void testGenerateSimpleStates() throws Exception {
    DomainModel domainModel = parseHelper.parse(SIMPLE_STATES_RIM);
    ResourceInteractionModel model = (ResourceInteractionModel) domainModel.getRims().get(0);
    InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
    underTest.doGenerate(model.eResource(), fsa);
    System.out.println(fsa.getFiles());
    assertEquals(4, fsa.getFiles().size());

    // the behaviour class
    String expectedKey = IFileSystemAccess.DEFAULT_OUTPUT + "SimpleBehaviour.java";
    assertTrue(fsa.getFiles().containsKey(expectedKey));
    assertEquals(SIMPLE_STATES_BEHAVIOUR, fsa.getFiles().get(expectedKey).toString());

    // one class per resource
    assertTrue(
        fsa.getFiles()
            .containsKey(IFileSystemAccess.DEFAULT_OUTPUT + "Simple/AResourceState.java"));
    assertTrue(
        fsa.getFiles()
            .containsKey(IFileSystemAccess.DEFAULT_OUTPUT + "Simple/BResourceState.java"));
  }
Beispiel #19
0
  @Test
  public void testGenerateSingleStateActionCommands() throws Exception {
    DomainModel domainModel = parseHelper.parse(SINGLE_STATE_ACTION_COMMANDS_RIM);
    ResourceInteractionModel model = (ResourceInteractionModel) domainModel.getRims().get(0);
    InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
    underTest.doGenerate(model.eResource(), fsa);

    String expectedKey = IFileSystemAccess.DEFAULT_OUTPUT + "Test/AResourceState.java";
    assertTrue(fsa.getFiles().containsKey(expectedKey));

    String output = fsa.getFiles().get(expectedKey).toString();
    int indexOfFirstNewProperties = output.indexOf("actionViewProperties = new Properties()");
    assertTrue(indexOfFirstNewProperties > 0);
    assertTrue(output.contains("actionViewProperties.put(\"getkey\", \"getvalue\""));
    assertTrue(
        output.contains("new Action(\"GetEntity\", Action.TYPE.VIEW, actionViewProperties)"));

    // No onerror handler so should not define an error state
    assertTrue(
        output.contains(
            "super(\"ENTITY\", \"A\", createActions(), \"/A\", createLinkRelations(), null, null);"));
  }
Beispiel #20
0
  public boolean runGenerator(String inputPath, Metadata metadata, String outputPath) {

    // load the resource
    resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
    Resource resource = resourceSet.getResource(URI.createFileURI(inputPath), true);

    if (metadata != null) {
      Map<String, Object> entitiesMap = new HashMap<String, Object>();
      for (State key :
          Iterables.<State>filter(
              IteratorExtensions.<EObject>toIterable(resource.getAllContents()), State.class)) {
        String entity = key.getEntity().getName();
        if (StringUtils.isNotEmpty(entity)) {
          try {
            EntityMetadata em = metadata.getEntityMetadata(entity);
            if (null != em) {
              Map<String, Object> entityPropMap = new HashMap<String, Object>();
              for (String propertySimple : em.getTopLevelProperties()) {
                if (!em.isPropertyList(propertySimple)) {

                  ArrayList<String> obj = new ArrayList<String>();

                  String propertyName = em.getSimplePropertyName(propertySimple);

                  if (em.isPropertyNumber(propertySimple)) {
                    obj.add(0, "double");
                  } else if (em.isPropertyDate(propertySimple)) {
                    obj.add(0, "date");
                  } else if (em.isPropertyTime(propertySimple)) {
                    obj.add(0, "dateTime");
                  } else if (em.isPropertyBoolean(propertySimple)) {
                    obj.add(0, "boolean");
                  } else {
                    obj.add(0, "string");
                  }

                  String description = em.getTermValue(propertySimple, "TERM_DESCRIPTION");
                  description = (null != description) ? description : "";
                  obj.add(1, description);

                  entityPropMap.put(propertyName, obj);

                } else {
                  String propertyName = em.getSimplePropertyName(propertySimple);
                  entityPropMap.put(propertyName, complexTypeHandler(propertySimple, em));
                }
              }
              entitiesMap.put(entity, entityPropMap);
            }
          } catch (Exception e) {
            System.out.println("Entity Not found: " + entity);
          }
        }
      }
      resource.getResourceSet().getLoadOptions().put("Metadata", entitiesMap);
    }

    // validate the resource
    List<Issue> list = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl);
    if (!list.isEmpty()) {
      for (Issue issue : list) {
        listener.notify(issue.toString());
      }

      return false;
    }

    // configure and start the generator
    fileAccess.setOutputPath(outputPath);
    generator.doGenerate(resource, fileAccess);

    return true;
  }
  @Override
  public void launch(
      ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
      throws CoreException {

    IPath containerPath =
        new Path(
            configuration.getAttribute(
                "ContainerLocation",
                ResourcesPlugin.getWorkspace().getRoot().getRawLocation().toOSString()));
    IPath filePath = new Path(configuration.getAttribute("filePath", ""));
    IFile dudFile =
        ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(containerPath.append(filePath));
    boolean externState = configuration.getAttribute("isRunningExtern", true);
    boolean designState = configuration.getAttribute("isRunningDesign", false);
    Injector injector = HIPIEActivator.getInstance().getInjector("org.xtext.hipie.HIPIE");
    ResourceSet resourceSet = injector.getInstance(ResourceSet.class);
    IGenerator generator = injector.getInstance(IGenerator.class);
    InMemoryFileSystemAccess fsa = injector.getInstance(InMemoryFileSystemAccess.class);

    Resource r =
        resourceSet.getResource(URI.createPlatformResourceURI(filePath.toOSString(), false), true);
    try {
      r.load(null);
    } catch (IOException e1) {
      e1.printStackTrace();
    }
    generator.doGenerate(r, fsa);
    final IFile htmlFile =
        dudFile
            .getProject()
            .getFile(
                dudFile.getProjectRelativePath().removeFileExtension().addFileExtension("html"));

    if (htmlFile.exists()) {
      if (externState) {
        URL url;
        try {
          url = htmlFile.getRawLocationURI().toURL();
          PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(url);
        } catch (MalformedURLException e) {
          e.printStackTrace();
        } catch (PartInitException e) {
          e.printStackTrace();
        }
      }
      if (designState) {
        IFile corDdlFile =
            htmlFile
                .getProject()
                .getFile(
                    htmlFile
                        .getProjectRelativePath()
                        .removeFileExtension()
                        .addFileExtension("ddl"));
        IFile corDatabombFile =
            htmlFile
                .getProject()
                .getFile(
                    htmlFile
                        .getProjectRelativePath()
                        .removeFileExtension()
                        .addFileExtension("databomb"));
        IFile corPersistFile =
            htmlFile
                .getProject()
                .getFile(
                    htmlFile
                        .getProjectRelativePath()
                        .removeFileExtension()
                        .addFileExtension("persist"));

        if (corDdlFile.exists() && corDatabombFile.exists() && corPersistFile.exists()) {
          Display.getDefault()
              .syncExec(
                  new Runnable() {
                    public void run() {
                      DesignModeView view = null;
                      try {
                        view =
                            (DesignModeView)
                                PlatformUI.getWorkbench()
                                    .getActiveWorkbenchWindow()
                                    .getActivePage()
                                    .showView(DesignModeView.ID);
                      } catch (PartInitException e) {
                        e.printStackTrace();
                      }
                      view.updateView(htmlFile);
                    }
                  });
        }
      }
    }
  }