Example #1
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 #2
0
  /**
   * Find hot words on index page
   *
   * @param conn
   * @return
   * @throws TorqueException
   */
  public static List<Hotword> findIndexVideo() throws TorqueException {
    Criteria crit = new Criteria();
    crit.add(HotwordPeer.INDEX_TYPE, Constants.INDEX_DISPLAY);
    crit.addDescendingOrderByColumn(HotwordPeer.SORT);

    List<Hotword> hotwordList = HotwordPeer.doSelect(crit);
    return hotwordList;
  }
Example #3
0
  /** Find object list using pagination */
  public static void findHotwordPagination(PageInfo pageInfo, String searchWord, int itemId)
      throws Exception {

    Criteria crit = new Criteria();

    String whereSql = " Where 1 = 1 ";
    if (searchWord != null && !searchWord.equals("")) {
      crit.add(HotwordPeer.NAME, (Object) ("%" + searchWord + "%"), Criteria.LIKE);
      whereSql += "AND " + HotwordPeer.NAME + " LIKE " + ("'%" + searchWord + "%'");
    }

    if (itemId > 0) {
      crit.add(HotwordPeer.ITEM_ID, itemId);
      whereSql += "AND " + HotwordPeer.ITEM_ID + "=" + itemId;
    }

    int totalRecord =
        ((Record)
                HotwordPeer.executeQuery(
                        "SELECT count(*) FROM " + HotwordPeer.TABLE_NAME + whereSql,
                        HotwordPeer.DATABASE_NAME)
                    .get(0))
            .getValue(1)
            .asInt();

    int totalPageNumber = (int) Math.ceil((double) totalRecord / pageInfo.getPageSize());
    pageInfo.setTotalPageNumber(totalPageNumber);
    pageInfo.initCrit(crit);
    if (searchWord != null && !"".equals(searchWord)) {
      crit.add(HotwordPeer.NAME, (Object) ("%" + searchWord + "%"), Criteria.LIKE);
    }

    if (itemId > 0) {
      crit.add(HotwordPeer.ITEM_ID, itemId);
    }

    crit.addDescendingOrderByColumn(HotwordPeer.SORT);
    // crit.addDescendingOrderByColumn(HotwordPeer.INDEX_TYPE);
    crit.addDescendingOrderByColumn(HotwordPeer.CREATE_DATE);

    List result = HotwordPeer.doSelect(crit);

    pageInfo.setResults(result);

    // return 0;
  }
 private Criteria ordenacion(Criteria c, String CampoOrdenacion, String OrdenOrdenacion) {
   if ((OrdenOrdenacion != null) && (OrdenOrdenacion.compareTo("ASC") == 0))
     if ((CampoOrdenacion != null)) {
       c.addAscendingOrderByColumn(CampoOrdenacion.toString());
     }
   if ((OrdenOrdenacion != null) && (OrdenOrdenacion.compareTo("DESC") == 0))
     if ((CampoOrdenacion != null)) {
       c.addDescendingOrderByColumn(CampoOrdenacion.toString());
     }
   return c;
 }
Example #5
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;
   }
 }
 public List<InteresseVendaHistorico> searchInteresseVendaHistoricoByInteresseVendaId(int id) {
   try {
     Criteria c = new Criteria();
     c.add(BaseInteresseVendaHistoricoPeer.INTERESSE_VENDA_ID, id);
     c.addDescendingOrderByColumn(BaseInteresseVendaHistoricoPeer.DATA_OCORRENCIA);
     List<InteresseVendaHistorico> interesses = BaseInteresseVendaHistoricoPeer.doSelect(c);
     if (CollectionUtils.isNotEmpty(interesses)) {
       return interesses;
     }
   } catch (Exception e) {
     LOG.error(
         "Ocorreu um erro ao buscar interesse de venda historico com INTERESSE_VENDA_ID["
             + id
             + "]",
         e);
   }
   return null;
 }
Example #7
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;
   }
 }