public void process(JSONRequestContext jsonRequestContext) {
    ResourceDAO resourceDAO = DAOFactory.getInstance().getResourceDAO();
    ResourceCategoryDAO resourceCategoryDAO = DAOFactory.getInstance().getResourceCategoryDAO();
    WorkResourceDAO workResourceDAO = DAOFactory.getInstance().getWorkResourceDAO();
    TagDAO tagDAO = DAOFactory.getInstance().getTagDAO();

    String name = jsonRequestContext.getRequest().getParameter("name");
    Long resourceId =
        NumberUtils.createLong(jsonRequestContext.getRequest().getParameter("resource"));
    Double hourlyCost =
        NumberUtils.createDouble(jsonRequestContext.getRequest().getParameter("hourlyCost"));
    Double costPerUse =
        NumberUtils.createDouble(jsonRequestContext.getRequest().getParameter("costPerUse"));
    Long version = NumberUtils.createLong(jsonRequestContext.getRequest().getParameter("version"));
    String tagsText = jsonRequestContext.getString("tags");

    Set<Tag> tagEntities = new HashSet<Tag>();
    if (!StringUtils.isBlank(tagsText)) {
      List<String> tags = Arrays.asList(tagsText.split("[\\ ,]"));
      for (String tag : tags) {
        if (!StringUtils.isBlank(tag)) {
          Tag tagEntity = tagDAO.findByText(tag.trim());
          if (tagEntity == null) tagEntity = tagDAO.create(tag);
          tagEntities.add(tagEntity);
        }
      }
    }

    WorkResource workResource = workResourceDAO.findById(resourceId);
    if (!version.equals(workResource.getVersion()))
      throw new SmvcRuntimeException(
          PyramusStatusCode.CONCURRENT_MODIFICATION,
          Messages.getInstance()
              .getText(
                  jsonRequestContext.getRequest().getLocale(),
                  "generic.errors.concurrentModification"));

    ResourceCategory resourceCategory =
        resourceCategoryDAO.findById(
            NumberUtils.createLong(jsonRequestContext.getRequest().getParameter("category")));

    workResourceDAO.update(workResource, name, resourceCategory, costPerUse, hourlyCost);
    resourceDAO.setResourceTags(workResource, tagEntities);

    jsonRequestContext.setRedirectURL(jsonRequestContext.getReferer(true));
  }
 /**
  * Returns the localized name of this page. Used e.g. for breadcrumb navigation.
  *
  * @param locale The locale to be used for the name
  * @return The localized name of this page
  */
 public String getName(Locale locale) {
   return Messages.getInstance().getText(locale, "projects.editStudentProject.breadcrumb");
 }
 /**
  * Returns the localized name of this page. Used e.g. for breadcrumb navigation.
  *
  * @param locale The locale to be used for the name
  * @return The localized name of this page
  */
 public String getName(Locale locale) {
   return Messages.getInstance()
       .getText(locale, "settings.createTransferCreditTemplate.pageTitle");
 }
 /**
  * Returns the localized name of this page. Used e.g. for breadcrumb navigation.
  *
  * @param locale The locale to be used for the name
  * @return The localized name of this page
  */
 public String getName(Locale locale) {
   return Messages.getInstance().getText(locale, "reports.listReports.pageTitle");
 }
 /**
  * Returns the localized name of this page. Used e.g. for breadcrumb navigation.
  *
  * @param locale The locale to be used for the name
  * @return The localized name of this page
  */
 public String getName(Locale locale) {
   return Messages.getInstance()
       .getText(locale, "students.manageStudentGroupContactEntries.pageTitle");
 }
Пример #6
0
 /**
  * Returns the localized name of this page. Used e.g. for breadcrumb navigation.
  *
  * @param locale The locale to be used for the name
  * @return The localized name of this page
  */
 public String getName(Locale locale) {
   return Messages.getInstance().getText(locale, "settings.subjects.pageTitle");
 }
Пример #7
0
  @Override
  public void processForm(PageRequestContext requestContext) {
    PluginRepositoryDAO pluginRepositoryDAO = DAOFactory.getInstance().getPluginRepositoryDAO();
    PluginDAO pluginDAO = DAOFactory.getInstance().getPluginDAO();

    PluginManager pluginManager = PluginManager.getInstance();

    List<PluginRepository> pluginRepositories = pluginRepositoryDAO.listAll();
    List<Plugin> plugins = pluginDAO.listAll();
    List<PluginBean> pluginBeans = new ArrayList<PluginsViewController.PluginBean>(plugins.size());
    for (Plugin plugin : plugins) {
      String status = "";
      boolean loaded =
          pluginManager.isLoaded(plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion());
      boolean deletable = false;

      if (loaded) {
        if (plugin.getEnabled())
          status =
              Messages.getInstance()
                  .getText(
                      requestContext.getRequest().getLocale(),
                      "system.plugins.pluginsTableStatusLoaded");
        else
          status =
              Messages.getInstance()
                  .getText(
                      requestContext.getRequest().getLocale(),
                      "system.plugins.pluginsTableStatusUnloadOnRestart");
      } else {
        if (plugin.getEnabled())
          status =
              Messages.getInstance()
                  .getText(
                      requestContext.getRequest().getLocale(),
                      "system.plugins.pluginsTableStatusLoadOnRestart");
        else
          status =
              Messages.getInstance()
                  .getText(
                      requestContext.getRequest().getLocale(),
                      "system.plugins.pluginsTableStatusNotLoaded");
        deletable = true;
      }

      PluginBean pluginBean =
          new PluginBean(
              plugin.getId(),
              plugin.getGroupId(),
              plugin.getArtifactId(),
              plugin.getVersion(),
              plugin.getEnabled(),
              deletable,
              status);
      pluginBeans.add(pluginBean);
    }

    requestContext.getRequest().setAttribute("repositories", pluginRepositories);
    requestContext.getRequest().setAttribute("plugins", pluginBeans);
    /**
     * Messages.getInstance().getText(requestContext.getRequest().getLocale(),
     * "system.plugins.pluginsTableStatusNotLoaded");
     * Messages.getInstance().getText(requestContext.getRequest().getLocale(),
     * "system.plugins.pluginsTableStatusUnloadOnRestart");
     * Messages.getInstance().getText(requestContext.getRequest().getLocale(),
     * "system.plugins.pluginsTableStatusLoaded");
     */
    requestContext.setIncludeJSP("/templates/system/plugins.jsp");
  }