Package org.molgenis.model.elements

Examples of org.molgenis.model.elements.Plugin


    for (UISchema screen : schema.getChildren())
    {
      if (screen.getClass() == Plugin.class)
      {

        Plugin plugin = (Plugin) screen;

        String fullKlazzName = plugin.getPluginType();
        String packageName = fullKlazzName;
        if (fullKlazzName.contains(".")) packageName = fullKlazzName.substring(0,
            fullKlazzName.lastIndexOf("."));

        String shortKlazzName = fullKlazzName;
        if (fullKlazzName.contains(".")) shortKlazzName = fullKlazzName.substring(fullKlazzName
            .lastIndexOf(".") + 1);

        File targetFile = new File(this.getHandWrittenPath(options) + "/" + fullKlazzName.replace(".", "/")
            + ".java");

        File targetFtl = new File(fullKlazzName.replace(".", "/") + ".ftl");
        // only generate if the file doesn't exist AND is not on
        // classpath
        Class<?> c = null;
        try
        {
          c = Class.forName(fullKlazzName);
          // return;
        }
        catch (ClassNotFoundException e)
        {
          logger.debug("skipped plugin " + plugin.getName() + " as it is on the classpath");
        }
        logger.debug("tested classforname on " + fullKlazzName + ": " + c);

        if (!targetFile.exists() && c == null)
        {
          File targetDir = new File(this.getHandWrittenPath(options) + "/" + packageName.replace(".", "/"));
          boolean created = targetDir.mkdirs();
          if (!created && !targetDir.exists())
          {
            throw new IOException("could not create " + targetDir);
          }

          templateArgs.put("screen", plugin);
          templateArgs.put("template", template.getName());
          templateArgs.put("clazzName", shortKlazzName);
          templateArgs.put("macroName", fullKlazzName.replace(".", "_"));
          templateArgs.put("templatePath", targetFtl.toString().replace("\\", "/"));
          templateArgs.put("package", packageName);
          templateArgs.put("flavor", plugin.getFlavor().toString().toLowerCase());

          OutputStream targetOut = new FileOutputStream(targetFile);
          template.process(templateArgs, new OutputStreamWriter(targetOut, Charset.forName("UTF-8")));
          targetOut.close();
View Full Code Here


    for (UISchema screen : schema.getChildren())
    {
      if (screen.getClass() == Plugin.class)
      {

        Plugin plugin = (Plugin) screen;

        String fullKlazzName = plugin.getPluginType();
        String packageName = fullKlazzName;
        if (fullKlazzName.contains(".")) packageName = fullKlazzName.substring(0,
            fullKlazzName.lastIndexOf("."));

        String shortKlazzName = fullKlazzName;
        if (fullKlazzName.contains(".")) shortKlazzName = fullKlazzName.substring(fullKlazzName
            .lastIndexOf(".") + 1);

        File targetFile = new File(this.getHandWrittenPath(options) + "/" + fullKlazzName.replace(".", "/")
            + ".java");

        File targetFtl = new File(fullKlazzName.replace(".", "/") + ".ftl");
        // only generate if the file doesn't exist AND is not on
        // classpath
        Class<?> c = null;
        try
        {
          c = Class.forName(fullKlazzName);
          // return;
        }
        catch (ClassNotFoundException e)
        {
          logger.error("skipped plugin " + plugin.getName() + " as it is on the classpath");
        }
        logger.error("tested classforname on " + fullKlazzName + ": " + c);

        if (!targetFile.exists() && c == null)
        {
View Full Code Here

    for (UISchema screen : schema.getChildren())
    {
      if (screen.getClass() == Plugin.class)
      {

        Plugin plugin = (Plugin) screen;

        String fullKlazzName = plugin.getPluginType();
        String packageName = fullKlazzName;
        if (fullKlazzName.contains(".")) packageName = fullKlazzName.substring(0,
            fullKlazzName.lastIndexOf("."));

        String shortKlazzName = fullKlazzName;
        if (fullKlazzName.contains(".")) shortKlazzName = fullKlazzName.substring(fullKlazzName
            .lastIndexOf(".") + 1);

        File targetFile = new File(this.getHandWrittenPath(options) + "/" + fullKlazzName.replace(".", "/")
            + "Model.java");

        File targetFtl = new File(fullKlazzName.replace(".", "/") + ".ftl");
        // only generate if the file doesn't exist AND is not on
        // classpath
        Class<?> c = null;
        try
        {
          // check if plugin controller exist, then assume user is
          // already happy and don't need templates.
          c = Class.forName(fullKlazzName);
          // return;
        }
        catch (ClassNotFoundException e)
        {
          logger.debug("skipped plugin " + plugin.getName() + " as it is on the classpath");
        }
        catch (NoClassDefFoundError e)
        {
          logger.debug("skipped plugin " + plugin.getName() + " as it is on the classpath");
        }
        logger.debug("tested classforname on " + fullKlazzName + ": " + c);

        if (!targetFile.exists() && c == null)
        {
View Full Code Here

    for (UISchema screen : schema.getChildren())
    {
      if (screen.getClass() == Plugin.class)
      {

        Plugin plugin = (Plugin) screen;

        String fullKlazzName = plugin.getPluginType();
        String packageName = fullKlazzName;
        if (fullKlazzName.contains(".")) packageName = fullKlazzName.substring(0,
            fullKlazzName.lastIndexOf("."));

        String shortKlazzName = fullKlazzName;
        if (fullKlazzName.contains(".")) shortKlazzName = fullKlazzName.substring(fullKlazzName
            .lastIndexOf(".") + 1);

        File targetFile = new File(this.getHandWrittenPath(options) + "/" + fullKlazzName.replace(".", "/")
            + ".ftl");
        // only generate if the file doesn't exist AND plugin not
        // already on classpath
        Class<?> c = null;
        try
        {
          c = Class.forName(fullKlazzName);
          // return;
        }
        catch (ClassNotFoundException e)
        {
          logger.error("skipped plugin " + plugin.getName() + " as it is on the classpath");
        }
        logger.error("tested classforname on " + fullKlazzName + ": " + c);

        if (!targetFile.exists() && c == null)
        {
View Full Code Here

    {
      if (screen.getClass() == Plugin.class)
      {
        File targetFile = null;

        Plugin plugin = (Plugin) screen;

        String fullKlazzName = plugin.getPluginType();
        String packageName = fullKlazzName;
        if (fullKlazzName.contains(".")) packageName = fullKlazzName.substring(0,
            fullKlazzName.lastIndexOf("."));

        String shortKlazzName = fullKlazzName;
        if (fullKlazzName.contains(".")) shortKlazzName = fullKlazzName.substring(fullKlazzName
            .lastIndexOf(".") + 1);

        switch (plugin.getFlavor())
        {
          case FREEMARKER:
            targetFile = new File(this.getHandWrittenPath(options) + "/" + fullKlazzName.replace(".", "/")
                + "View.ftl");
            template = createTemplate("/" + getClass().getSimpleName() + "_FreemarkerFlavor.ftl.ftl");
            break;
          case EASY:
            targetFile = new File(this.getHandWrittenPath(options) + "/" + fullKlazzName.replace(".", "/")
                + "View.java");
            template = createTemplate("/" + getClass().getSimpleName() + "_EasyFlavor.ftl.ftl");
            break;
          default:
            throw new UnsupportedOperationException("Plugin flavor " + plugin.getFlavor()
                + " not (yet) supported");
        }

        // only generate if the file doesn't exist AND plugin not
        // already on classpath
        Class<?> c = null;
        try
        {
          // check if plugin controller exist, then assume user is
          // already happy and don't need templates.
          c = Class.forName(fullKlazzName);
          // return;
        }
        catch (Exception e)
        {
          logger.debug("skipped plugin " + plugin.getName() + " as it is on the classpath");
        }
        logger.debug("tested classforname on " + fullKlazzName + ": " + c);

        if (!targetFile.exists() && c == null)
        {
View Full Code Here

      {
        if (element.getAttribute("type") != null && element.getAttribute("type").isEmpty())
        {
          throw new MolgenisModelException("plugin has no name");
        }
        Plugin plugin = new Plugin(name, parent, element.getAttribute("type"));
        plugin.setLabel(label);
        plugin.setGroup(group);
        plugin.setGroupRead(groupRead);

        if (group != null && groupRead != null && group.equals(groupRead))
        {
          throw new MolgenisModelException(
              "You cannot assign both read/write and read rights on a single plugin");
        }

        plugin.setNamespace(namespace);
        new_parent = plugin;

        // METHOD
        String method = element.getAttribute("flavor");
        if (!"".equals(method))
        {
          plugin.setPluginMethod(Flavor.getPluginMethod(method));
        }

        // READONLY
        plugin.setReadOnly(false);
        String readonly = element.getAttribute("readonly");
        if (readonly != null)
        {
          plugin.setReadOnly(Boolean.parseBoolean(readonly));
        }
      }
      /*
       * else { // this is the unexpected throw new Exception("Encountered
       * unknown element: " + element.getTagName()); }
View Full Code Here

TOP

Related Classes of org.molgenis.model.elements.Plugin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.