/**
   * Executes the sql sentence created by <code>getSql</code>.
   *
   * @param values the values
   * @return the list< map< string, object>>
   */
  protected List<Map<String, Object>> resolveLookups(Object[] values) {
    List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();

    try {
      IManagerBean bean = getForeignManagerBean();
      Criteria criteria = getCriteria(bean, values);
      List<ITransferObject> list = bean.getList(criteria);
      if (list.size() > 0) {
        List<String> alias = getAlias();
        for (ITransferObject to : list) {
          result.add(getToMap(to, alias));
        }
      }
    } catch (ManagerBeanException e) {
      LOGGER.severe(e.getMessage());
    } catch (IllegalAccessException e) {
      LOGGER.severe(e.getMessage());
    } catch (InvocationTargetException e) {
      LOGGER.severe(e.getMessage());
    } catch (NoSuchMethodException e) {
      LOGGER.severe(e.getMessage());
    } catch (ExpressionException e) {
      LOGGER.severe(e.getMessage());
    }

    return result;
  }
 private void saveTypes(EvaluateController ec) throws ManagerBeanException {
   Integer score = 0;
   List types = (List) ec.getTypes().getWrappedData();
   IManagerBean bean = BeanManager.getManagerBean(Evaluate.class);
   for (Iterator iter = types.iterator(); iter.hasNext(); ) {
     Evaluate e = (Evaluate) iter.next();
     if (e.getId() == null) bean.insert(e);
     else bean.update(e);
     score += e.getValue().ordinal();
   }
   ec.setScore(score);
 }
Example #3
0
 /**
  * Gets the detail list. Used in the reports
  *
  * @return the detail list
  */
 @Transient
 public List getDetailList() {
   try {
     IManagerBean offerDetailBean = BeanManager.getManagerBean(OfferDetail.class);
     Criteria criteria = new Criteria();
     criteria.addEqualExpression(
         offerDetailBean.getFieldName(ICommercialAlias.OFFER_DETAIL_OFFER_ID), getId());
     return offerDetailBean.getList(criteria);
   } catch (ManagerBeanException e) {
     LOGGER.log(Level.SEVERE, "Error obtaining offerDetail list", e);
   }
   return null;
 }
 @Override
 public void afterBeanRemoved(ControllerEvent event) throws ControllerListenerException {
   EvaluateController ec = (EvaluateController) event.getController();
   try {
     IManagerBean bean = BeanManager.getManagerBean(Evaluate.class);
     List types = (List) ec.getTypes().getWrappedData();
     for (Iterator iter = types.iterator(); iter.hasNext(); ) {
       Evaluate e = (Evaluate) iter.next();
       bean.remove(e);
     }
   } catch (ManagerBeanException e) {
     throw new ControllerListenerException(e);
   }
   ec.onReset(null);
 }
 /**
  * Gets the criteria.
  *
  * @param values the values
  * @param bean the bean
  * @return the criteria
  * @throws ManagerBeanException the manager bean exception
  * @throws ExpressionException the expression exception
  */
 private Criteria getCriteria(IManagerBean bean, Object[] values)
     throws ManagerBeanException, ExpressionException {
   Criteria criteria = null;
   if (values != null) {
     criteria = new Criteria();
     String prefix = ClassUtils.getShortClassName(bean.getPOJOClass()) + "_";
     for (int i = 0; i < values.length; i++) {
       String fieldName = bean.getFieldName(prefix + getForeignJoinProperties().get(i));
       if (values[i] != null) {
         criteria.addExpression(fieldName, values[i].toString());
       } else {
         criteria.addNullExpression(fieldName);
       }
     }
   }
   return criteria;
 }