public void serviceGetPerfilturnoDetallePdf(
      HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    utf8RequestService(request);
    String[] getMethodos =
        new String[] {
          PerfilturnoHelper.IDTP_GET_METHOD_NAME,
          PerfilturnoHelper.IDPERFIL_GET_METHOD_NAME + "PerfilturnoParsed",
          PerfilturnoHelper.IDTURNO_GET_METHOD_NAME + "PerfilturnoParsed",
          PerfilturnoHelper.VALORCOSTE_GET_METHOD_NAME + "PerfilturnoParsed"
        };

    PerfilturnoGroupBean tgb = new PerfilturnoGroupBean();
    try {
      tgb.setElemento(PerfilturnoHelper.getPerfilturno(request));
    } catch (TorqueException e) {
      logger.severe(e.getMessage());
    }

    byte[] content =
        PdfUtils.getBytes(
            replaceStringBuffer(tgb.buildXml(getMethodos, null, "ISO-8859-1"), "n/a", " "),
            perfilturno_transformer,
            "ISO-8859-1");
    response.addHeader("content-disposition", "attachment;filename=Perfilturno.pdf");
    response.setContentType("application/pdf");
    response.setHeader("Cache-Control", ""); // para que funcione en IE
    response.setContentLength(content.length);
    response.getOutputStream().write(content);
    response.getOutputStream().flush();
    response.getOutputStream().close();
  }
Example #2
0
 /**
  * Loads an attributeValueBean from the TAttributeValue table by field, parameter and workItem
  *
  * @param field
  * @param workItem
  * @param parameterCode
  * @return
  */
 @Override
 public TAttributeValueBean loadBeanByFieldAndWorkItemAndParameter(
     Integer field, Integer workItem, Integer parameterCode) {
   List<TAttributeValue> attributeValueList = null;
   Criteria criteria = new Criteria();
   criteria.add(FIELDKEY, field);
   criteria.add(WORKITEM, workItem);
   criteria.addDescendingOrderByColumn(LASTEDIT);
   if (parameterCode == null) {
     criteria.add(PARAMETERCODE, (Object) null, Criteria.ISNULL);
   } else {
     criteria.add(PARAMETERCODE, parameterCode);
   }
   try {
     attributeValueList = doSelect(criteria);
   } catch (TorqueException e) {
     LOGGER.error(
         "Loading the attributevaluebean by field by field "
             + field
             + " parameterCode "
             + parameterCode
             + " and workItem "
             + workItem
             + " failed with "
             + e.getMessage(),
         e);
   }
   if (attributeValueList == null || attributeValueList.isEmpty()) {
     LOGGER.debug(
         "No attributevaluebean found for field "
             + field
             + " parameterCode "
             + parameterCode
             + " and workItem"
             + workItem);
     return null;
   }
   if (attributeValueList.size() > 1) {
     LOGGER.warn(
         "More than one attributevaluebean found for field "
             + field
             + " parameterCode "
             + parameterCode
             + " and workItem "
             + workItem
             + ". Delete them...");
     boolean first = true;
     for (Iterator<TAttributeValue> iterator = attributeValueList.iterator();
         iterator.hasNext(); ) {
       if (!first) {
         TAttributeValue attributeValue = iterator.next();
         iterator.remove();
         deleteByObjectID(attributeValue.getObjectID());
       }
       first = false;
     }
   }
   return ((TAttributeValue) attributeValueList.get(0)).getBean();
 }
Example #3
0
 /**
  * Delete all private report categories of a person
  *
  * @param personID
  */
 @Override
 public void deletePrivateReportCategories(Integer personID) {
   Criteria criteria = new Criteria();
   criteria.add(CREATEDBY, personID);
   criteria.add(REPOSITORY, TQueryRepositoryBean.REPOSITORY_TYPE.PRIVATE);
   try {
     doDelete(criteria);
   } catch (TorqueException e) {
     LOGGER.error("Deleting the private filter categories failed with " + e.getMessage());
   }
 }
Example #4
0
 /**
  * Get the attribute values for a TQL expression
  *
  * @param tqlExpression
  * @param personBean
  * @param locale
  * @param errors
  * @return
  */
 @Override
 public List<TAttributeValueBean> loadTQLFilterAttributeValues(
     String tqlExpression, TPersonBean personBean, Locale locale, List<ErrorData> errors) {
   try {
     return getCustomAttributeValues(
         TqlBL.createCriteria(tqlExpression, personBean, locale, errors));
   } catch (TorqueException e) {
     LOGGER.error(
         "Loading the custom option attribute values for TQL report failed with "
             + e.getMessage());
     return new ArrayList<TAttributeValueBean>();
   }
 }
  public static boolean borraLineaFactura(int idBorrar) {

    Criteria c = new Criteria();
    c.add(LineaFacturaPeer.ID, idBorrar);
    boolean bRet = false;
    try {
      LineaFacturaPeer.doDelete(c);
      bRet = true;
    } catch (TorqueException e) {
      logger.info("No se ha podido borrar la LineaFactura");
      e.printStackTrace();
      bRet = false;
    }
    return bRet;
  }
  public String intercept(ActionInvocation actionInvocation) throws Exception {

    Map session = actionInvocation.getInvocationContext().getSession();

    User user = (User) session.get(Constants.USER_KEY);

    boolean isAuthenticated = (null != user);

    if (!isAuthenticated) {
      return Action.LOGIN;
    } else {
      boolean isPermit = false;
      if (user.getIsSuperUser() != 1) {
        Map<String, AuthPermission> permissionMap =
            (Map<String, AuthPermission>) session.get(Constants.PERMISSION_MAP_KEY);
        AuthPermission manageItemPermission = permissionMap.get(Constants.AUDIT_VIDOE);
        try {
          List<UserPermission> permissionsList =
              UserPermissionService.findPermissionsByUserId(user.getUserId());

          for (UserPermission userPermission : permissionsList) {
            if (manageItemPermission != null
                && userPermission.getPermissionId() == manageItemPermission.getId()) {
              isPermit = true;
              break;
            }
          }
        } catch (TorqueException e) {
          e.printStackTrace();
        } catch (Exception e) {
          e.printStackTrace();
        } finally {
        }
      } else {
        isPermit = true;
      }

      if (user.getIsActive() != 1) {
        isPermit = false;
      }

      if (isPermit) {
        return actionInvocation.invoke();
      } else {
        return Constants.DENIED;
      }
    }
  }
Example #7
0
 /**
  * Gets the custom attribute values filtered by filterSelectsTO and raciBean
  *
  * @param filterSelectsTO
  * @param raciBean
  * @param personID
  * @return
  */
 @Override
 public List<TAttributeValueBean> loadTreeFilterAttributes(
     FilterUpperTO filterSelectsTO, RACIBean raciBean, Integer personID) {
   Integer[] selectedProjects = filterSelectsTO.getSelectedProjects();
   if (selectedProjects == null || selectedProjects.length == 0) {
     // at least one selected project needed
     return new ArrayList<TAttributeValueBean>();
   }
   Criteria crit =
       TreeFilterCriteria.prepareTreeFilterCriteria(filterSelectsTO, raciBean, personID);
   try {
     return getCustomAttributeValues(crit);
   } catch (TorqueException e) {
     LOGGER.error("Loading the custom attributes for tree filter failed with " + e.getMessage());
     return new ArrayList<TAttributeValueBean>();
   }
 }
Example #8
0
 /**
  * Loads a list of attributeValueBeans from the TAttributeValue table by workItem
  *
  * @param workItem
  * @return
  */
 @Override
 public List<TAttributeValueBean> loadByWorkItem(Integer workItem) {
   Criteria criteria = new Criteria();
   criteria.add(WORKITEM, workItem);
   // just in case there are accidentally more entries in the database
   criteria.addDescendingOrderByColumn(LASTEDIT);
   try {
     return convertTorqueListToBeanList(doSelect(criteria));
   } catch (TorqueException e) {
     LOGGER.error(
         "Loading the attributevaluebeans by workItem "
             + workItem
             + " failed with "
             + e.getMessage());
     return null;
   }
 }
Example #9
0
 /**
  * Loads a list of user picker attributes by workItem
  *
  * @param workItem
  * @return
  */
 @Override
 public List<TAttributeValueBean> loadUserPickerByWorkItem(Integer workItemID) {
   Criteria criteria = new Criteria();
   criteria.add(WORKITEM, workItemID);
   criteria.add(VALIDVALUE, ValueType.SYSTEMOPTION);
   criteria.add(SYSTEMOPTIONTYPE, SystemFields.INTEGER_PERSON);
   criteria.addDescendingOrderByColumn(LASTEDIT);
   try {
     return convertTorqueListToBeanList(doSelect(criteria));
   } catch (TorqueException e) {
     LOGGER.error(
         "Loading the user picker attributevaluebeans by workItem "
             + workItemID
             + " failed with "
             + e.getMessage());
     return null;
   }
 }
Example #10
0
 /**
  * Deletes the reportCategoryBean satisfying a certain criteria together with the dependent
  * database entries
  *
  * @param crit
  * @throws TorqueException
  */
 public static void doDelete(Criteria crit) throws TorqueException {
   List list = null;
   try {
     list = doSelect(crit);
   } catch (TorqueException e) {
     LOGGER.error(
         "Getting the list of TReportCategoryBean to be deleted failed with " + e.getMessage());
     throw e;
   }
   if (list != null && !list.isEmpty()) {
     Iterator<TReportCategory> iter = list.iterator();
     TReportCategory filterCategory = null;
     while (iter.hasNext()) {
       filterCategory = iter.next();
       ReflectionHelper.delete(deletePeerClasses, deleteFields, filterCategory.getObjectID());
     }
   }
 }
  public void testFetch() {
    try {
      ContentSource source = ContentSourcePeer.retrieveByPK(109);
      FSTransport transport = new FSTransport();

      transport.setFetchLocation(source);
      List list = transport.fetch();
      assertNotNull(list);
      assertFalse(list.isEmpty());
      Document doc = (Document) list.get(0);
      assertNotNull(doc.getRawContent());

    } catch (TorqueException e) {
      e.printStackTrace();
    } catch (TransportConfigurationException e1) {
      e1.printStackTrace();
    } catch (TransportException e) {
      e.printStackTrace();
    }
  }
Example #12
0
 /**
  * Gets the user picker attributes by a list of workItemIDs
  *
  * @param allWorkItemIDs
  * @return
  */
 @Override
 public List<TAttributeValueBean> getUserPickerAttributesByWorkItems(List<Integer> workItemIDs) {
   List<TAttributeValueBean> attributeValueBeans = new LinkedList<TAttributeValueBean>();
   if (workItemIDs == null || workItemIDs.isEmpty()) {
     return attributeValueBeans;
   }
   List<int[]> workItemIDChunksList = GeneralUtils.getListOfChunks(workItemIDs);
   Iterator<int[]> chunkIterator = workItemIDChunksList.iterator();
   while (chunkIterator.hasNext()) {
     int[] workItemIDChunk = chunkIterator.next();
     Criteria crit = new Criteria();
     crit.addIn(WORKITEM, workItemIDChunk);
     crit.add(VALIDVALUE, ValueType.SYSTEMOPTION);
     crit.add(SYSTEMOPTIONTYPE, SystemFields.INTEGER_PERSON);
     try {
       attributeValueBeans.addAll(convertTorqueListToBeanList(doSelect(crit)));
     } catch (TorqueException e) {
       LOGGER.error(
           "Loading the user pickers by workItemIDs failed with failed with " + e.getMessage());
     }
   }
   return attributeValueBeans;
 }