Package org.dspace.app.webui.cris.dto

Examples of org.dspace.app.webui.cris.dto.ExportParametersDTO


  @Override
  protected ModelAndView onSubmit(HttpServletRequest request,
      HttpServletResponse response, Object command, BindException errors)
      throws Exception {
    ExportParametersDTO exportParameters = (ExportParametersDTO) command;

    List<String> f = new LinkedList<String>();
    List<String> q = new LinkedList<String>();
    addToTempQuery("names", exportParameters.getNames(), f, q,
        !exportParameters.getAdvancedSyntax());

    addToTempQuery("dept", exportParameters.getDept(), f, q,
        !exportParameters.getAdvancedSyntax());

    addToTempQuery("interests", exportParameters.getInterests(), f, q,
        !exportParameters.getAdvancedSyntax());

    addToTempQuery("media", exportParameters.getMedia(), f, q,
        !exportParameters.getAdvancedSyntax());

    String[] temp_query = new String[] {};
    temp_query = q.toArray(temp_query);
    String[] temp_fields = new String[] {};
    temp_fields = f.toArray(temp_fields);
    List<ResearcherPage> list = null;
    try {
      //TODO
//      list = searchService.search(temp_fields, temp_query,
//          exportParameters.getStatus(),
//          exportParameters.getCreationStart(),
//          exportParameters.getCreationEnd(),
//          exportParameters.getStaffNoStart(),
//          exportParameters.getStaffNoEnd(),
//          exportParameters.getRpIdStart(),
//          exportParameters.getRpIdEnd(),
//          exportParameters.getDefaultOperator(), ResearcherPage.class);
    } catch (Exception e) {
      errors.reject("jsp.layout.hku.export.validation.notvalid.query");
      return showForm(request, errors, getFormView());

    }

    // export all tab
    List<IContainable> containables = new LinkedList<IContainable>();
    if (exportParameters.getTabToExport() == null || exportParameters.getTabToExport().isEmpty()) {
      containables = applicationService
      .findAllContainables(RPPropertiesDefinition.class);
    } else {
      for(Integer tab : exportParameters.getTabToExport()) {
        for(BoxResearcherPage box : applicationService.<BoxResearcherPage, TabResearcherPage>findPropertyHolderInTab(TabResearcherPage.class, tab)) {
          containables.addAll(box.getMask());
          applicationService.findOtherContainablesInBoxByConfiguration(box.getShortName(), containables);
        }
      }
    }

    if (exportParameters.getMainMode() == null) {
      response.setContentType("application/excel");
      response.addHeader("Content-Disposition",
          "attachment; filename=rpdata.xls");
      ImportExportUtils.exportData(list, applicationService,
          response.getOutputStream(), containables);
View Full Code Here


        return clazz.isAssignableFrom(arg0);
    }

    public void validate(Object arg0, Errors arg1)
    {
        ExportParametersDTO param = (ExportParametersDTO) arg0;

        if (param.getRpIdStart() != null)
        {
            if (!param.getRpIdStart().toLowerCase().startsWith("rp")
                    && !StringUtils.isNumeric(param.getRpIdStart()))
            {
                // errore formato non valido
                arg1.rejectValue("rpIdStart", "jsp.layout.hku.export.validation.notvalid.rpIdStart");
            }
            else
            {
                // check sulla lunghezza e fix a rp00000
                if (param.getRpIdStart().toLowerCase().startsWith("rp"))
                {
                    param.setRpIdStart(ResearcherPageUtils.getPersistentIdentifier(Integer.parseInt(param.getRpIdStart().substring(2)),ResearcherPage.class));
                }
                else
                {
                    param.setRpIdStart(ResearcherPageUtils.getPersistentIdentifier(Integer.parseInt(param.getRpIdStart()),ResearcherPage.class));
                }
            }
        }

        if (param.getRpIdEnd() != null)
        {
            if (!param.getRpIdEnd().toLowerCase().startsWith("rp")
                    && !StringUtils.isNumeric(param.getRpIdEnd()))
            {
                // errore formato non valido
                arg1.rejectValue("rpIdStart", "jsp.layout.hku.export.validation.notvalid.rpIdEnd");
            }
            else
            {
                // check sulla lunghezza e fix a rp00000
                if (param.getRpIdEnd().toLowerCase().startsWith("rp"))
                {
                    param.setRpIdEnd(ResearcherPageUtils.getPersistentIdentifier(Integer.parseInt(param.getRpIdEnd().substring(2)),ResearcherPage.class));
                }
                else
                {
                    param.setRpIdEnd(ResearcherPageUtils.getPersistentIdentifier(Integer.parseInt(param.getRpIdEnd()),ResearcherPage.class));
                }
            }
        }
       
        if (param.getCreationStart() != null && param.getCreationEnd() != null && param.getCreationStart().after(param.getCreationEnd()))
        {
            arg1.rejectValue("creationStart", "jsp.layout.hku.export.validation.notvalid.creationStart");
        }
       
        // if only a rp id is entered use it for both limit
        if (param.getRpIdStart() != null && param.getRpIdEnd() == null)
        {
            param.setRpIdEnd(param.getRpIdStart());
        }
       
        if (param.getRpIdEnd() != null && param.getRpIdStart() == null)
        {
            param.setRpIdStart(param.getRpIdEnd());
        }
       
        // if only a staff no is entered use it for both limit       
        if (param.getStaffNoStart() != null && param.getStaffNoEnd() == null)
        {
            param.setStaffNoEnd(param.getStaffNoStart());
        }
       
        if (param.getStaffNoEnd() != null && param.getStaffNoStart() == null)
        {
            param.setStaffNoStart(param.getStaffNoEnd());
        }
    }
View Full Code Here

TOP

Related Classes of org.dspace.app.webui.cris.dto.ExportParametersDTO

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.