Example #1
0
  @SecurityControllIgnore
  public String getLocation() {
    HttpServletRequest request = ServletActionContext.getRequest();
    String reportId = request.getParameter("report");
    File targetJasperFile = getTargetJasperFile(reportId);
    File targetJrxmlFile =
        new File(
            getWebRootDir() + getRelativeJasperFilePath() + File.separator + reportId + ".jrxml");
    try {
      if (!targetJrxmlFile.exists()) {
        targetJrxmlFile.createNewFile();
      }
      logger.debug("Using jrxml file: {}", targetJrxmlFile.getAbsolutePath());
      logger.debug("Using jasper file: {}", targetJasperFile.getAbsolutePath());
      ReportDef reportDef = reportDefService.findByCode(reportId);
      AttachmentFile attachmentFile = null;
      if (reportDef != null) {
        attachmentFile = reportDef.getTemplateFile();
      }
      boolean needUpdateJasperFile = false;
      if (!targetJasperFile.exists()) {
        needUpdateJasperFile = true;
        if (!targetJasperFile.exists()) {
          targetJasperFile.createNewFile();
        }
      } else {

        if (attachmentFile != null) {
          // TODO
          //                    //数据对象判断处理
          //                    long compareTime = attachmentFile.getLastModifiedDate() != null ?
          // attachmentFile
          //                            .getLastModifiedDate().getTime() :
          // attachmentFile.getCreatedDate().getTime();
          //                    if (targetJasperFile.lastModified() < compareTime) {
          //                        needUpdateJasperFile = true;
          //                        FileCopyUtils.copy(attachmentFile.getFileContent(),
          // targetJrxmlFile);
          //                    }
        } else {
          if (targetJrxmlFile.lastModified() > targetJasperFile.lastModified()) {
            needUpdateJasperFile = true;
          }
        }
      }
      if (needUpdateJasperFile) {
        logger.info("Compiling jasper file: {}", targetJasperFile.getAbsolutePath());
        JasperCompileManager.compileReportToFile(
            targetJrxmlFile.getAbsolutePath(), targetJasperFile.getAbsolutePath());
      }
    } catch (Exception e) {
      logger.error(e.getMessage(), e);
      throw new WebException(e.getMessage(), e);
    }
    return getRelativeJasperFilePath() + File.separator + reportId + ".jasper";
  }
Example #2
0
 @MetaData(value = "计算显示角色关联数据")
 @SecurityControllIgnore
 public HttpHeaders findRelatedRoles() {
   GroupPropertyFilter groupFilter =
       GroupPropertyFilter.buildGroupFilterFromHttpRequest(Role.class, getRequest());
   List<Role> roles =
       roleService.findByFilters(groupFilter, new Sort(Direction.DESC, "aclType", "code"));
   List<ReportDefR2Role> r2s = reportDefService.findRelatedRoleR2s(this.getId());
   for (Role role : roles) {
     role.addExtraAttribute("related", false);
     for (ReportDefR2Role r2 : r2s) {
       if (r2.getRole().equals(role)) {
         role.addExtraAttribute("r2CreatedDate", r2.getCreatedDate());
         role.addExtraAttribute("related", true);
         break;
       }
     }
   }
   setModel(buildPageResultFromList(roles));
   return buildDefaultHttpHeaders();
 }
Example #3
0
 public List<String> getCategories() {
   return reportDefService.findCategories();
 }
Example #4
0
 @MetaData(value = "更新角色关联")
 public HttpHeaders doUpdateRelatedRoleR2s() {
   reportDefService.updateRelatedRoleR2s(getId(), getParameterIds("r2ids"));
   setModel(OperationResult.buildSuccessResult("角色关联操作完成"));
   return buildDefaultHttpHeaders();
 }
Example #5
0
 public void prepareShow() {
   String report = this.getRequiredParameter("report");
   ReportDef reportDef = reportDefService.findByCode(report);
   setModel(reportDef);
 }