Exemplo n.º 1
0
  @Override
  public void addPortletBreadcrumbEntries(
      Folder folder, HttpServletRequest request, RenderResponse renderResponse) throws Exception {

    String strutsAction = ParamUtil.getString(request, "struts_action");

    long groupId = ParamUtil.getLong(request, "groupId");

    PortletURL portletURL = renderResponse.createRenderURL();

    if (strutsAction.equals("/document_library/select_file_entry")
        || strutsAction.equals("/document_library/select_folder")
        || strutsAction.equals("/document_library_display/select_folder")
        || strutsAction.equals("/dynamic_data_mapping/select_document_library")
        || strutsAction.equals("/image_gallery_display/select_folder")) {

      ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

      portletURL.setParameter("struts_action", strutsAction);
      portletURL.setParameter("groupId", String.valueOf(groupId));
      portletURL.setWindowState(LiferayWindowState.POP_UP);

      PortalUtil.addPortletBreadcrumbEntry(
          request, themeDisplay.translate("home"), portletURL.toString());
    } else {
      portletURL.setParameter("struts_action", "/document_library/view");
    }

    addPortletBreadcrumbEntries(folder, request, portletURL);
  }
Exemplo n.º 2
0
  public static PortletURL getCurrent(RenderRequest req, RenderResponse res) {
    PortletURL portletURL = res.createRenderURL();

    Enumeration enu = req.getParameterNames();

    while (enu.hasMoreElements()) {
      String param = (String) enu.nextElement();
      String[] values = req.getParameterValues(param);

      boolean addParam = true;

      // Don't set paramter values that are over 32 kb. See LEP-1755.

      for (int i = 0; i < values.length; i++) {
        if (values[i].length() > _CURRENT_URL_PARAMETER_THRESHOLD) {
          addParam = false;

          break;
        }
      }

      if (addParam) {
        portletURL.setParameter(param, values);
      }
    }

    return portletURL;
  }
Exemplo n.º 3
0
  @Override
  public void render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

    PortletURL portletURL = renderResponse.createRenderURL();

    portletURL.setParameter("mvcPath", "hello_soy_description");

    template.put("descriptionURL", portletURL.toString());

    String path = getPath(renderRequest, renderResponse);

    if (Validator.equals(path, "hello_soy_edit")) {
      portletURL.setParameter("mvcPath", "hello_soy_view");
    } else {
      portletURL.setParameter("mvcPath", "hello_soy_edit");
    }

    template.put("portletURL", portletURL.toString());

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    User user = themeDisplay.getUser();

    template.put("userName", user.getFirstName());

    super.render(renderRequest, renderResponse);
  }
Exemplo n.º 4
0
  public static PortletURL clone(
      LiferayPortletURL liferayPortletURL, boolean action, RenderResponse res)
      throws PortletException {

    LiferayPortletURL newURLImpl = null;

    if (action) {
      newURLImpl = (LiferayPortletURL) res.createActionURL();
    } else {
      newURLImpl = (LiferayPortletURL) res.createRenderURL();
    }

    newURLImpl.setPortletId(liferayPortletURL.getPortletId());

    WindowState windowState = liferayPortletURL.getWindowState();

    if (windowState != null) {
      newURLImpl.setWindowState(windowState);
    }

    PortletMode portletMode = liferayPortletURL.getPortletMode();

    if (portletMode != null) {
      newURLImpl.setPortletMode(portletMode);
    }

    newURLImpl.setParameters(liferayPortletURL.getParameterMap());

    return newURLImpl;
  }
  public static void addPortletBreadcrumbEntries(
      MBMessage message, HttpServletRequest request, RenderResponse renderResponse)
      throws Exception {

    if (message.getCategoryId() == MBCategoryConstants.DISCUSSION_CATEGORY_ID) {

      return;
    }

    MBCategory category = null;

    if (message.getCategoryId() != MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) {

      category = message.getCategory();
    }

    addPortletBreadcrumbEntries(category, request, renderResponse);

    PortletURL portletURL = renderResponse.createRenderURL();

    portletURL.setParameter("mvcRenderCommandName", "/message_boards/view_message");
    portletURL.setParameter("messageId", String.valueOf(message.getMessageId()));

    PortalUtil.addPortletBreadcrumbEntry(request, message.getSubject(), portletURL.toString());
  }
Exemplo n.º 6
0
  public static void addPortletBreadcrumbEntries(
      Folder folder, HttpServletRequest request, RenderResponse renderResponse) throws Exception {

    String mvcRenderCommandName = ParamUtil.getString(request, "mvcRenderCommandName");

    PortletURL portletURL = renderResponse.createRenderURL();

    if (mvcRenderCommandName.equals("/document_library/select_folder")) {
      ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

      portletURL.setParameter("mvcRenderCommandName", mvcRenderCommandName);
      portletURL.setWindowState(LiferayWindowState.POP_UP);

      PortalUtil.addPortletBreadcrumbEntry(
          request, themeDisplay.translate("home"), portletURL.toString());
    } else {
      portletURL.setParameter("mvcRenderCommandName", "/image_gallery_display/view");
    }

    long defaultFolderId = getDefaultFolderId(request);

    List<Folder> ancestorFolders = Collections.emptyList();

    if ((folder != null) && (folder.getFolderId() != defaultFolderId)) {
      ancestorFolders = folder.getAncestors();

      int indexOfRootFolder = -1;

      for (int i = 0; i < ancestorFolders.size(); i++) {
        Folder ancestorFolder = ancestorFolders.get(i);

        if (defaultFolderId == ancestorFolder.getFolderId()) {
          indexOfRootFolder = i;
        }
      }

      if (indexOfRootFolder > -1) {
        ancestorFolders = ancestorFolders.subList(0, indexOfRootFolder);
      }
    }

    Collections.reverse(ancestorFolders);

    for (Folder ancestorFolder : ancestorFolders) {
      portletURL.setParameter("folderId", String.valueOf(ancestorFolder.getFolderId()));

      PortalUtil.addPortletBreadcrumbEntry(
          request, ancestorFolder.getName(), portletURL.toString());
    }

    portletURL.setParameter("folderId", String.valueOf(folder.getFolderId()));

    PortalUtil.addPortletBreadcrumbEntry(request, folder.getName(), portletURL.toString());
  }
  public static void addPortletBreadcrumbEntries(
      MBCategory category, HttpServletRequest request, RenderResponse renderResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    String mvcRenderCommandName = ParamUtil.getString(request, "mvcRenderCommandName");

    PortletURL portletURL = renderResponse.createRenderURL();

    if (mvcRenderCommandName.equals("/message_boards/select_category")) {
      portletURL.setParameter("mvcRenderCommandName", "/message_boards/select_category");
      portletURL.setWindowState(LiferayWindowState.POP_UP);

      PortalUtil.addPortletBreadcrumbEntry(
          request, themeDisplay.translate("categories"), portletURL.toString());
    } else {
      portletURL.setParameter("mvcRenderCommandName", "/message_boards/view");
    }

    PortalUtil.addPortletBreadcrumbEntry(
        request, themeDisplay.translate("home"), portletURL.toString());

    if (category == null) {
      return;
    }

    if (!mvcRenderCommandName.equals("/message_boards/select_category")) {
      portletURL.setParameter("mvcRenderCommandName", "/message_boards/view_category");
    }

    List<MBCategory> ancestorCategories = category.getAncestors();

    Collections.reverse(ancestorCategories);

    for (MBCategory curCategory : ancestorCategories) {
      portletURL.setParameter("mbCategoryId", String.valueOf(curCategory.getCategoryId()));

      PortalUtil.addPortletBreadcrumbEntry(request, curCategory.getName(), portletURL.toString());
    }

    portletURL.setParameter("mbCategoryId", String.valueOf(category.getCategoryId()));

    PortalUtil.addPortletBreadcrumbEntry(request, category.getName(), portletURL.toString());
  }
Exemplo n.º 8
0
  public static void addPortletBreadcrumbEntries(
      BookmarksEntry entry, HttpServletRequest request, RenderResponse renderResponse)
      throws Exception {

    BookmarksFolder folder = entry.getFolder();

    if (folder.getFolderId() != BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

      addPortletBreadcrumbEntries(folder, request, renderResponse);
    }

    PortletURL portletURL = renderResponse.createRenderURL();

    portletURL.setParameter("struts_action", "/bookmarks/view_entry");
    portletURL.setParameter("entryId", String.valueOf(entry.getEntryId()));

    PortalUtil.addPortletBreadcrumbEntry(request, entry.getName(), portletURL.toString());
  }
  public static void addPortletBreadcrumbEntries(
      FileEntry fileEntry, HttpServletRequest request, RenderResponse renderResponse)
      throws Exception {

    Folder folder = fileEntry.getFolder();

    if (folder.getFolderId() != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

      addPortletBreadcrumbEntries(folder, request, renderResponse);
    }

    PortletURL portletURL = renderResponse.createRenderURL();

    portletURL.setParameter("struts_action", "/document_library/view_file_entry");
    portletURL.setParameter("fileEntryId", String.valueOf(fileEntry.getFileEntryId()));

    PortalUtil.addPortletBreadcrumbEntry(request, fileEntry.getTitle(), portletURL.toString());
  }
Exemplo n.º 10
0
  public static void addPortletBreadcrumbEntries(
      BookmarksFolder folder, HttpServletRequest request, RenderResponse renderResponse)
      throws Exception {

    String strutsAction = ParamUtil.getString(request, "struts_action");

    PortletURL portletURL = renderResponse.createRenderURL();

    if (strutsAction.equals("/bookmarks/select_folder")) {
      ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

      portletURL.setWindowState(LiferayWindowState.POP_UP);

      portletURL.setParameter("struts_action", "/bookmarks/select_folder");

      PortalUtil.addPortletBreadcrumbEntry(
          request, themeDisplay.translate("home"), portletURL.toString());
    } else {
      portletURL.setParameter("struts_action", "/bookmarks/view");
    }

    List<BookmarksFolder> ancestorFolders = folder.getAncestors();

    Collections.reverse(ancestorFolders);

    for (BookmarksFolder ancestorFolder : ancestorFolders) {
      portletURL.setParameter("folderId", String.valueOf(ancestorFolder.getFolderId()));

      PortalUtil.addPortletBreadcrumbEntry(
          request, ancestorFolder.getName(), portletURL.toString());
    }

    portletURL.setParameter("folderId", String.valueOf(folder.getFolderId()));

    if (folder.getFolderId() != BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

      PortalUtil.addPortletBreadcrumbEntry(request, folder.getName(), portletURL.toString());
    }
  }
Exemplo n.º 11
0
  @Override
  public void addPortletBreadcrumbEntries(
      DLFileShortcut dlFileShortcut, HttpServletRequest request, RenderResponse renderResponse)
      throws Exception {

    Folder folder = dlFileShortcut.getFolder();

    if (folder.getFolderId() != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

      addPortletBreadcrumbEntries(folder, request, renderResponse);
    }

    DLFileShortcut unescapedDLFileShortcut = dlFileShortcut.toUnescapedModel();

    PortletURL portletURL = renderResponse.createRenderURL();

    portletURL.setParameter("struts_action", "/document_library/view_file_entry");
    portletURL.setParameter("fileEntryId", String.valueOf(dlFileShortcut.getToFileEntryId()));

    PortalUtil.addPortletBreadcrumbEntry(
        request, unescapedDLFileShortcut.getToTitle(), portletURL.toString());
  }
Exemplo n.º 12
0
  public static void addPortletBreadcrumbEntries(
      Folder folder, HttpServletRequest request, RenderResponse renderResponse) throws Exception {

    String strutsAction = ParamUtil.getString(request, "struts_action");

    long groupId = ParamUtil.getLong(request, "groupId");

    PortletURL portletURL = renderResponse.createRenderURL();

    if (strutsAction.equals("/journal/select_document_library")
        || strutsAction.equals("/document_library/select_file_entry")
        || strutsAction.equals("/document_library/select_folder")
        || strutsAction.equals("/document_library_display/select_folder")
        || strutsAction.equals("/image_gallery_display/select_folder")) {

      ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

      portletURL.setWindowState(LiferayWindowState.POP_UP);

      portletURL.setParameter("struts_action", strutsAction);
      portletURL.setParameter("groupId", String.valueOf(groupId));

      Map<String, Object> data = new HashMap<String, Object>();

      data.put("folder-id", _getDefaultFolderId(request));
      data.put("view-entries", Boolean.TRUE.toString());
      data.put("view-folders", Boolean.TRUE.toString());

      PortalUtil.addPortletBreadcrumbEntry(
          request, themeDisplay.translate("home"), portletURL.toString(), data);
    } else {
      portletURL.setParameter("struts_action", "/document_library/view");
    }

    addPortletBreadcrumbEntries(folder, request, portletURL);
  }
Exemplo n.º 13
0
  public static String getSearchResultViewURL(
      RenderRequest renderRequest,
      RenderResponse renderResponse,
      String className,
      long classPK,
      boolean viewInContext,
      String currentURL)
      throws Exception {

    try {
      PortletURL viewContentURL = renderResponse.createRenderURL();

      viewContentURL.setParameter("mvcPath", "/view_content.jsp");
      viewContentURL.setParameter("redirect", currentURL);
      viewContentURL.setPortletMode(PortletMode.VIEW);
      viewContentURL.setWindowState(WindowState.MAXIMIZED);

      if (Validator.isNull(className) || (classPK <= 0)) {
        return viewContentURL.toString();
      }

      AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(className, classPK);

      AssetRendererFactory<?> assetRendererFactory =
          AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(className);

      if (assetRendererFactory == null) {
        return viewContentURL.toString();
      }

      viewContentURL.setParameter("assetEntryId", String.valueOf(assetEntry.getEntryId()));
      viewContentURL.setParameter("type", assetRendererFactory.getType());

      if (viewInContext) {
        String viewFullContentURLString = viewContentURL.toString();

        viewFullContentURLString =
            HttpUtil.setParameter(viewFullContentURLString, "redirect", currentURL);

        AssetRenderer<?> assetRenderer = assetRendererFactory.getAssetRenderer(classPK);

        String viewURL =
            assetRenderer.getURLViewInContext(
                (LiferayPortletRequest) renderRequest,
                (LiferayPortletResponse) renderResponse,
                viewFullContentURLString);

        ThemeDisplay themeDisplay =
            (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

        return AssetUtil.checkViewURL(assetEntry, viewInContext, viewURL, currentURL, themeDisplay);
      }

      return viewContentURL.toString();
    } catch (Exception e) {
      _log.error(
          "Unable to get search result  view URL for class "
              + className
              + " with primary key "
              + classPK,
          e);

      return "";
    }
  }
Exemplo n.º 14
0
  protected void compareVersions(RenderRequest renderRequest, RenderResponse renderResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long nodeId = ParamUtil.getLong(renderRequest, "nodeId");

    String title = ParamUtil.getString(renderRequest, "title");

    double sourceVersion = ParamUtil.getDouble(renderRequest, "sourceVersion");
    double targetVersion = ParamUtil.getDouble(renderRequest, "targetVersion");
    String type = ParamUtil.getString(renderRequest, "type", "escape");

    WikiPage sourcePage = WikiPageServiceUtil.getPage(nodeId, title, sourceVersion);
    WikiPage targetPage = WikiPageServiceUtil.getPage(nodeId, title, targetVersion);

    if (type.equals("html")) {
      WikiNode sourceNode = sourcePage.getNode();

      PortletURL viewPageURL = renderResponse.createRenderURL();

      viewPageURL.setParameter("struts_action", "/wiki/view");
      viewPageURL.setParameter("nodeName", sourceNode.getName());

      PortletURL editPageURL = renderResponse.createRenderURL();

      editPageURL.setParameter("struts_action", "/wiki/edit_page");
      editPageURL.setParameter("nodeId", String.valueOf(nodeId));
      editPageURL.setParameter("title", title);

      String attachmentURLPrefix =
          WikiUtil.getAttachmentURLPrefix(
              themeDisplay.getPathMain(), themeDisplay.getPlid(), nodeId, title);

      String htmlDiffResult =
          WikiUtil.diffHtml(sourcePage, targetPage, viewPageURL, editPageURL, attachmentURLPrefix);

      renderRequest.setAttribute(WebKeys.DIFF_HTML_RESULTS, htmlDiffResult);
    } else {
      String sourceContent = sourcePage.getContent();
      String targetContent = targetPage.getContent();

      sourceContent = WikiUtil.processContent(sourceContent);
      targetContent = WikiUtil.processContent(targetContent);

      if (type.equals("strip")) {
        sourceContent = HtmlUtil.extractText(sourceContent);
        targetContent = HtmlUtil.extractText(targetContent);
      } else {
        sourceContent = HtmlUtil.escape(sourceContent);
        targetContent = HtmlUtil.escape(targetContent);
      }

      List<DiffResult>[] diffResults =
          DiffUtil.diff(
              new UnsyncStringReader(sourceContent), new UnsyncStringReader(targetContent));

      renderRequest.setAttribute(WebKeys.DIFF_RESULTS, diffResults);
    }

    renderRequest.setAttribute(WebKeys.WIKI_NODE_ID, nodeId);
    renderRequest.setAttribute(WebKeys.TITLE, title);
    renderRequest.setAttribute(WebKeys.SOURCE_VERSION, sourceVersion);
    renderRequest.setAttribute(WebKeys.TARGET_VERSION, targetVersion);
  }
 public PortletURL createRenderURL() {
   return response.createRenderURL();
 }
  public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
    try {

      log.debug(":: VIEW STUDENT SEARCH " + this.viewJSP);

      PortletPreferences preferences = renderRequest.getPreferences();
      boolean showSearcher =
          GetterUtil.getBoolean(preferences.getValue("showSearcher", StringPool.TRUE));
      boolean showScreenName =
          GetterUtil.getBoolean(preferences.getValue("showScreenName", StringPool.TRUE));
      boolean showEmail =
          GetterUtil.getBoolean(preferences.getValue("showEmail", StringPool.FALSE));

      long teamId = ParamUtil.getLong(renderRequest, "team", 0);

      List<Team> teams = TeamLocalServiceUtil.getGroupTeams(themeDisplay.getScopeGroupId());

      renderRequest.setAttribute("showSearcher", showSearcher);
      renderRequest.setAttribute("showScreenName", showScreenName);
      renderRequest.setAttribute("showEmail", showEmail);

      PortletURL iteratorURL = renderResponse.createRenderURL();
      iteratorURL.setParameter("team", String.valueOf(teamId));

      /*iteratorURL.setParameter("showSearcher" ,  String.valueOf(showSearcher));
      iteratorURL.setParameter("showScreenName" , String.valueOf(showScreenName));
      iteratorURL.setParameter("showEmail" ,  String.valueOf(showEmail));*/

      UserSearchContainer userSearchContainer = new UserSearchContainer(renderRequest, iteratorURL);
      UserDisplayTerms displayTerms = (UserDisplayTerms) userSearchContainer.getDisplayTerms();
      LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>();
      params.put("usersGroups", new Long(themeDisplay.getScopeGroupId()));

      Course course = CourseLocalServiceUtil.fetchByGroupCreatedId(themeDisplay.getScopeGroupId());

      if (log.isDebugEnabled()) {
        log.debug("NAME " + displayTerms.getFirstName());
        log.debug("SURNAME " + displayTerms.getLastName());
        log.debug("SCREEN NAME " + displayTerms.getScreenName());
        log.debug("EMAIL ADDRESS " + displayTerms.getEmailAddress());
        log.debug("KEYWORDS " + displayTerms.getKeywords());
        log.debug("START " + userSearchContainer.getStart());
        log.debug("END  " + userSearchContainer.getEnd());

        log.debug("ADVANCED SEARCH " + displayTerms.isAdvancedSearch());
        log.debug("AND OPERATOR " + displayTerms.isAndOperator());
        log.debug("TEAM " + teamId);
      }

      if (log.isDebugEnabled()) {
        log.debug("NAME " + ParamUtil.getString(renderRequest, "firstName"));
      }

      if (course != null) {
        try {
          if (displayTerms.isAdvancedSearch()) {
            userSearchContainer.setResults(
                CourseLocalServiceUtil.getStudentsFromCourse(
                    themeDisplay.getCompanyId(),
                    themeDisplay.getScopeGroupId(),
                    userSearchContainer.getStart(),
                    userSearchContainer.getEnd(),
                    teamId,
                    displayTerms.getFirstName(),
                    displayTerms.getLastName(),
                    displayTerms.getScreenName(),
                    displayTerms.getEmailAddress(),
                    displayTerms.isAndOperator()));

            userSearchContainer.setTotal(
                CourseLocalServiceUtil.getStudentsFromCourseCount(
                    course.getCourseId(),
                    teamId,
                    displayTerms.getFirstName(),
                    displayTerms.getLastName(),
                    displayTerms.getScreenName(),
                    displayTerms.getEmailAddress(),
                    displayTerms.isAndOperator()));

          } else {
            userSearchContainer.setResults(
                CourseLocalServiceUtil.getStudentsFromCourse(
                    themeDisplay.getCompanyId(),
                    themeDisplay.getScopeGroupId(),
                    userSearchContainer.getStart(),
                    userSearchContainer.getEnd(),
                    teamId,
                    displayTerms.getKeywords(),
                    displayTerms.getKeywords(),
                    displayTerms.getKeywords(),
                    displayTerms.getKeywords(),
                    true));

            userSearchContainer.setTotal(
                CourseLocalServiceUtil.getStudentsFromCourseCount(
                    course.getCourseId(),
                    teamId,
                    displayTerms.getKeywords(),
                    displayTerms.getKeywords(),
                    displayTerms.getKeywords(),
                    displayTerms.getKeywords(),
                    true));
          }

        } catch (SystemException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
      if (log.isDebugEnabled()) {
        log.debug(" -- TOTAL: " + userSearchContainer.getTotal());
        log.debug(" -- SIZE: " + userSearchContainer.getResults().size());
      }

      renderRequest.setAttribute("searchContainer", userSearchContainer);
      renderRequest.setAttribute("team", teamId);
      renderRequest.setAttribute("teams", teams);

    } catch (SystemException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (PortalException e) {
      // TODO: handle exception
      e.printStackTrace();
    }

    this.include(this.viewJSP, renderRequest, renderResponse);
  }
  private void generateUrls(RenderRequest request, RenderResponse response)
      throws PortletModeException, WindowStateException {
    // Render URL for Print hyperlink
    PortletURL printModeUrl = response.createRenderURL();
    if (request.isPortletModeAllowed(new PortletMode("print"))) {
      printModeUrl.setPortletMode(new PortletMode("print"));
    }
    if (request.isWindowStateAllowed(new WindowState("pop_up"))) {
      printModeUrl.setWindowState(new WindowState("pop_up"));
    }
    request.setAttribute("printModeUrl", printModeUrl);

    // Action URL for upload Toc action
    PortletURL uploadTocActionUrl = response.createActionURL();
    uploadTocActionUrl.setParameter("myaction", "uploadTocAction");
    uploadTocActionUrl.setParameter(ActionRequest.ACTION_NAME, "uploadTocAction");
    request.setAttribute("uploadTocActionUrl", uploadTocActionUrl);

    // Render URL for Full Screen hyperlink
    PortletURL fullScreenUrl = response.createRenderURL();
    fullScreenUrl.setWindowState(WindowState.MAXIMIZED);
    request.setAttribute("fullScreenUrl", fullScreenUrl);

    // Render URL for Help hyperlink
    PortletURL helpUrl = response.createRenderURL();
    helpUrl.setPortletMode(PortletMode.HELP);
    request.setAttribute("helpUrl", helpUrl);

    // Render URL for Home hyperlink
    PortletURL homeUrl = response.createRenderURL();
    homeUrl.setPortletMode(PortletMode.VIEW);
    request.setAttribute("homeUrl", homeUrl);

    // Render URL for Preferences hyperlink
    PortletURL prefUrl = response.createRenderURL();
    prefUrl.setPortletMode(PortletMode.EDIT);
    request.setAttribute("prefUrl", prefUrl);

    // Render URL for form submission for Adding book
    PortletURL addBookFormUrl = response.createRenderURL();
    addBookFormUrl.setParameter("myaction", "addBookForm");
    request.setAttribute("addBookFormUrl", addBookFormUrl);

    // Action URL for Add Book Action
    PortletURL addBookActionUrl = response.createActionURL();
    addBookActionUrl.setParameter(ActionRequest.ACTION_NAME, "addBookAction");
    request.setAttribute("addBookActionUrl", addBookActionUrl);

    // Action URL for resetting search
    PortletURL resetActionUrl = response.createActionURL();
    resetActionUrl.setParameter(ActionRequest.ACTION_NAME, "resetAction");
    request.setAttribute("resetActionUrl", resetActionUrl);

    // Action URL for searching books
    PortletURL searchBookActionUrl = response.createActionURL();
    searchBookActionUrl.setParameter(ActionRequest.ACTION_NAME, "searchBookAction");
    request.setAttribute("searchBookActionUrl", searchBookActionUrl);

    // Render URL for Refresh Search Results link
    PortletURL refreshResultsUrl = response.createRenderURL();
    refreshResultsUrl.setParameter("myaction", "refreshResults");
    request.setAttribute("refreshResultsUrl", refreshResultsUrl);
  }
Exemplo n.º 18
0
  @RenderMapping(params = "action=elencoProgetti")
  public String elencoProgettiRenderRequest(
      RenderRequest renderRequest,
      RenderResponse renderResponse,
      Model model,
      @ModelAttribute("navigaProgetti") NavigaProgetti navigaProgetti) {
    // ,@RequestParam(required=false, value="jsonnavigaprogetti") String jsonnavigaprogetti){

    // if(!StringUtils.isEmpty(jsonnavigaprogetti)){
    //	navigaProgetti = createModelProgettiFromJsonString(jsonnavigaprogetti);
    // }

    if (StringUtils.isEmpty(navigaProgetti.getCurrentAction())) {
      navigaProgetti.setCurrentAction("elencoProgetti");
    }

    model.addAttribute("currentAction", navigaProgetti.getCurrentAction());
    model.addAttribute("paginate", "true");

    // LISTA PROGETTI //
    // orderByCol is the column name passed in the request while sorting
    String orderByCol = ParamUtil.getString(renderRequest, "orderByCol");
    if (Validator.isNull(orderByCol) || Validator.equals("", orderByCol)) {
      orderByCol = "impoCostoProgetto";
    }

    // orderByType is passed in the request while sorting. It can be either asc or desc
    String orderByType = ParamUtil.getString(renderRequest, "orderByType");
    if (Validator.isNull(orderByType) || Validator.equals("", orderByType)) {
      orderByType = "desc";
    }

    // delta
    String sDelta = ParamUtil.getString(renderRequest, "delta");
    int delta = maxResult;
    if (!(Validator.isNull(sDelta) || Validator.equals("", sDelta))) {
      delta = Integer.parseInt(sDelta);
    }

    SearchContainer<Progetto> searchContainerElenco =
        new SearchContainer<Progetto>(
            renderRequest,
            renderResponse.createRenderURL(),
            null,
            "Nessun dato trovato per la selezione fatta");
    searchContainerElenco.setDelta(delta);

    searchContainerElenco.setOrderByCol(orderByCol);
    searchContainerElenco.setOrderByType(orderByType);

    // int size =  progettoFacade.sizeElencoProgetti( navigaProgetti ).getSize();

    navigaProgetti.setOrderByCol(searchContainerElenco.getOrderByCol());
    navigaProgetti.setOrderByType(searchContainerElenco.getOrderByType());
    navigaProgetti.setStart(searchContainerElenco.getStart());
    navigaProgetti.setDelta(delta);

    List<Progetto> elencoProgetti4Pag = progettoFacade.findElencoProgetti(navigaProgetti);
    // int size =  elencoProgetti.size();
    /*
    searchContainerElenco.setTotal(size);
    int fromIndex = searchContainerElenco.getStart();
    int toIndex = (((searchContainerElenco.getStart() + delta) > size)?size:(searchContainerElenco.getStart() + delta)) - 1;

    System.out.println( fromIndex );
    System.out.println( toIndex );

    List<Progetto> elencoProgetti4Pag = new ArrayList<Progetto>();
    for( Progetto tmp : elencoProgetti.subList(fromIndex, toIndex) ){
    	if( tmp.getAnagraficaCup().getFkDcupDcupIdMaster() != null ){
    		tmp.getAnagraficaCup().setAnagraficaCup(
    				progettoFacade.findAnagraficaCupById( tmp.getAnagraficaCup().getFkDcupDcupIdMaster() ) );
    	}
    	elencoProgetti4Pag.add(tmp);
    }
    */
    searchContainerElenco.setResults(elencoProgetti4Pag);

    model.addAttribute("pagDettaglioProgetto", paginaDettaglioProgetto);
    // FINE LISTA PROGETTI //

    // MASCHERA RICERCA PROGETTI //
    initInModelMascheraRicerca(model, navigaProgetti);
    model.addAttribute("navigaProgetti", navigaProgetti);
    // FINE RICERCA PROGETTI //

    // RIEPILOGO //
    // DATI TOTALI

    NavigaAggregata navigaAggregata = new NavigaAggregata();
    String idNatura =
        (aggregataFacade.findNaturaByCod(codiNaturaOpenCUP) == null)
            ? "0"
            : aggregataFacade.findNaturaByCod(codiNaturaOpenCUP).getId().toString();
    navigaAggregata.setIdNatura(idNatura);
    List<AggregataDTO> listaAggregataDTO = aggregataFacade.findAggregataByNatura(navigaAggregata);
    NavigaProgetti navigaProgettitot = new NavigaProgetti();
    navigaProgettitot.setIdNatura(idNatura);

    Double impoCostoProgetti = 0.0;
    Double impoImportoFinanziato = 0.0;

    long sizetot = 0; // progettoFacade.sizeElencoProgetti( navigaProgettitot ).getSize();

    for (AggregataDTO aggregataDTO : listaAggregataDTO) {
      impoCostoProgetti = impoCostoProgetti + aggregataDTO.getImpoCostoProgetti();
      impoImportoFinanziato = impoImportoFinanziato + aggregataDTO.getImpoImportoFinanziato();
      sizetot = sizetot + aggregataDTO.getNumeProgetti();
    }

    model.addAttribute("volumeDeiProgetti", sizetot);
    model.addAttribute("costoDeiProgetti", impoCostoProgetti);
    model.addAttribute("importoFinanziamenti", impoImportoFinanziato);

    //		if( size > (delta*2)){
    //			navigaAggregata = new NavigaAggregata();
    //			navigaAggregata.setIdNatura(idNatura);
    //			navigaAggregata.importa( navigaProgetti );
    //			//Gestione ANNI
    //			if( navigaProgetti.getIdAnnoDecisiones() != null &&
    // navigaProgetti.getIdAnnoDecisiones().size() > 0){
    //				if( navigaProgetti.getIdAnnoDecisiones().contains("-1") ){
    //					List<String> idAnnoAggregatos = new ArrayList<String>();
    //					idAnnoAggregatos.add("0");
    //					navigaAggregata.setIdAnnoAggregatos( idAnnoAggregatos );
    //				}else{
    //					List<String> idAnnoAggregatos = new ArrayList<String>();
    //					for( String tmp : navigaProgetti.getIdAnnoDecisiones() ){
    //
    //	idAnnoAggregatos.add((aggregataFacade.findAnniDecisione(Integer.valueOf(tmp))).getAnnoAggregato().getId().toString());
    //					}
    //					navigaAggregata.setIdAnnoAggregatos( idAnnoAggregatos );
    //				}
    //			}
    //			//FINE Gestione ANNI
    //
    //			listaAggregataDTO = aggregataFacade.findAggregataByNatura(navigaAggregata);
    //
    //			Double impoCostoProgettiProg = 0.0;
    //			Double impoImportoFinanziatoProg = 0.0;
    //
    //			for(AggregataDTO aggregataDTO : listaAggregataDTO){
    //				impoCostoProgettiProg = impoCostoProgettiProg + aggregataDTO.getImpoCostoProgetti();
    //				impoImportoFinanziatoProg = impoImportoFinanziatoProg +
    // aggregataDTO.getImpoImportoFinanziato();
    //			}
    //			model.addAttribute("costoDeiProgettiProg", impoCostoProgettiProg);
    //			model.addAttribute("importoFinanziamentiProg", impoImportoFinanziatoProg);
    //		}else{
    TotaliDTO totali = progettoFacade.sommaImpElencoProgetti(navigaProgetti);
    model.addAttribute("costoDeiProgettiProg", totali.getImpoCostoProgetto());
    model.addAttribute("importoFinanziamentiProg", totali.getImpoImportoFinanziato());
    model.addAttribute("volumeDeiProgettiProg", totali.getContaProgetti().intValue());
    //		}

    searchContainerElenco.setTotal(totali.getContaProgetti().intValue());

    model.addAttribute("searchContainerElenco", searchContainerElenco);

    /*
    System.out.println("STEP 4");

    Double impoCostoProgettiProg = 0.0;
    Double impoImportoFinanziatoProg = 0.0;

    for( Progetto p : elencoProgetti ){
    	impoCostoProgettiProg = impoCostoProgettiProg + p.getImpoCostoProgetto();
    	impoImportoFinanziatoProg = impoImportoFinanziatoProg + p.getImpoImportoFinanziato();
    }

    model.addAttribute("volumeDeiProgettiProg", size);
    model.addAttribute("costoDeiProgettiProg", impoCostoProgettiProg);
    model.addAttribute("importoFinanziamentiProg", impoImportoFinanziatoProg);
    */
    // FINE RIEPILOGO //

    model.addAttribute("valoreRicercaValido", "SI");

    return "elenco-progetti-view";
  }
Exemplo n.º 19
0
  @RenderMapping(params = "action=ricercaLibera")
  public String effettuaRicerca(
      RenderRequest renderRequest,
      RenderResponse renderResponse,
      Model model,
      @ModelAttribute("navigaProgetti") NavigaProgetti navigaProgetti,
      @RequestParam("cercaPerKeyword") String cercaPerKeyword) {

    model.addAttribute("currentAction", "ricercaLibera");
    navigaProgetti.setCurrentAction("ricercaLibera");

    model.addAttribute("cercaPerKeyword", cercaPerKeyword);
    model.addAttribute("navigaProgetti", navigaProgetti);

    logger.info("effettuaRicerca.cercaPerKeyword: " + cercaPerKeyword);
    try {

      Document[] documents = null;
      List<DocumentoDTO> risultatiGenerici = new ArrayList<DocumentoDTO>();
      List<Progetto> risultatiProgetti = new ArrayList<Progetto>();

      if (cercaPerKeyword != null && cercaPerKeyword.length() > 3) {
        Query query =
            StringQueryFactoryUtil.create(
                Field.TITLE
                    + ":"
                    + cercaPerKeyword
                    + " or "
                    + Field.CONTENT
                    + ":"
                    + cercaPerKeyword
                    + " or "
                    + Constants.RICERCALIBERA_FIELD_SEARCH
                    + ":"
                    + cercaPerKeyword
                    + " or "
                    + Constants.RICERCALIBERA_FIELD_LOCALIZZAZIONE
                    + ":"
                    + cercaPerKeyword
                    + " or "
                    + Constants.RICERCALIBERA_FIELD_CODICE_CUP
                    + ":"
                    + cercaPerKeyword);

        logger.debug("query = " + query.toString());

        Hits hits =
            SearchEngineUtil.search(
                SearchEngineUtil.SYSTEM_ENGINE_ID, PortalUtil.getDefaultCompanyId(), query, -1, -1);

        logger.info("hits = " + hits.getLength());
        documents = hits.getDocs();
        model.addAttribute("valoreRicercaValido", "SI");
      } else {
        SessionMessages.add(renderRequest, "valore-ricerca-non-valido");
        model.addAttribute("valoreRicercaValido", "NO");
      }

      if (documents != null) {
        DocumentoDTO documento = null;
        Progetto progetto = null;
        int contaDoc = 0;
        for (Document document : documents) {
          logger.debug("Document: " + document.getUID());

          //					for (Map.Entry<String, Field> entry : document.getFields().entrySet() ) {
          //						logger.debug("-- " +  entry.getKey() + ": " + entry.getValue().getValue() );
          //					}

          if (document.get(Field.ENTRY_CLASS_NAME).equals(Progetto.class.getName())) {

            progetto = getProgettoFromDocument(document);
            risultatiProgetti.add(progetto);

          } else {

            documento = new DocumentoDTO();
            documento.setTitolo(document.getField(Field.TITLE).getValue());
            String testo = "non disponibile";
            if (document.getField(Field.CONTENT) != null) {
              testo = trunc(document.getField(Field.CONTENT).getValue(), 37);
            }
            documento.setTesto(testo);
            documento.setId(contaDoc++);

            AssetEntry assetEntry =
                AssetEntryLocalServiceUtil.getEntry(
                    document.get(Field.ENTRY_CLASS_NAME),
                    Long.parseLong(document.get(Field.ENTRY_CLASS_PK)));
            documento.setUrl(
                getAssetViewURL(renderRequest, renderResponse, assetEntry, cercaPerKeyword));

            risultatiGenerici.add(documento);
          }
        }
      }

      // model.addAttribute("risultatiGenerici", risultatiGenerici);
      model.addAttribute("risultatiGenericiSize", risultatiGenerici.size());

      SearchContainer<DocumentoDTO> searchContainerElencoDoc =
          new SearchContainer<DocumentoDTO>(
              renderRequest,
              renderResponse.createRenderURL(),
              null,
              "Nessun dato trovato per la selezione fatta");
      searchContainerElencoDoc.setDelta(risultatiGenerici.size());
      searchContainerElencoDoc.setTotal(risultatiGenerici.size());
      searchContainerElencoDoc.setResults(risultatiGenerici);
      model.addAttribute("searchContainerElencoDoc", searchContainerElencoDoc);

      // model.addAttribute("risultatiProgetti", risultatiProgetti);
      SearchContainer<Progetto> searchContainerElencoPro =
          new SearchContainer<Progetto>(
              renderRequest,
              renderResponse.createRenderURL(),
              null,
              "Nessun dato trovato per la selezione fatta");
      searchContainerElencoPro.setDelta(risultatiProgetti.size());
      searchContainerElencoPro.setTotal(risultatiProgetti.size());
      searchContainerElencoPro.setResults(risultatiProgetti);
      model.addAttribute("searchContainerElenco", searchContainerElencoPro);

    } catch (SearchException e) {
      logger.error("SearchException: ", e);
    } catch (NumberFormatException e) {
      logger.error("NumberFormatException: ", e);
    } catch (PortalException e) {
      logger.error("PortalException: ", e);
    } catch (SystemException e) {
      logger.error("SystemException: ", e);
    }

    return "elenco-progetti-view";
  }