Package de.iritgo.aktera.hibernate

Examples of de.iritgo.aktera.hibernate.StandardDao


          value = MethodUtils.invokeExactStaticMethod(descriptor.getPropertyType(), "valueOf", value);
        }
        else if (descriptor != null
                && descriptor.getPropertyType().getAnnotation(javax.persistence.Entity.class) != null)
        {
          StandardDao standardDAO = (StandardDao) SpringTools.getBean(StandardDao.ID);
          value = standardDAO.get(descriptor.getPropertyType().getName(), NumberTools.toInt(value, - 1));
        }

        PropertyUtils.setNestedProperty(o, name, value);

        return;
View Full Code Here


            }
          }
        }
        else
        {
          StandardDao standardDao = (StandardDao) SpringTools.getBean(StandardDao.ID);
          String entityName = aPersistentConfig.getAttribute("entity");

          if (id.intValue() != - 1)
          {
            Object bean = standardDao.get(entityName, id);

            persistents.put(aPersistentConfig.getAttribute("id"), bean);
          }
          else
          {
            try
            {
              Object bean = standardDao.newEntity(entityName);

              try
              {
                MethodUtils.invokeMethod(bean, "init", new Object[0]);
              }
              catch (Exception ignored)
              {
              }

              persistents.put(aPersistentConfig.getAttribute("id"), bean);
            }
            catch (InstantiationException x)
            {
              log.error("Unable to create entity: " + entityName, x);
            }
            catch (IllegalAccessException x)
            {
              log.error("Unable to create entity: " + entityName, x);
            }
          }

          for (; persistentConfigIterator.hasNext();)
          {
            aPersistentConfig = (Configuration) persistentConfigIterator.next();

            if (aPersistentConfig.getAttribute("join", null) != null)
            {
              entityName = aPersistentConfig.getAttribute("entity");

              if (id.intValue() != - 1)
              {
                try
                {
                  Object joinBean = persistents.get(aPersistentConfig.getAttribute("join"));
                  Serializable foreignKey = (Serializable) PropertyUtils.getSimpleProperty(joinBean,
                          aPersistentConfig.getAttribute("key"));
                  Object bean = standardDao.get(entityName, foreignKey);

                  persistents.put(aPersistentConfig.getAttribute("id"), bean);
                }
                catch (IllegalAccessException x)
                {
                  log.error("Unable to load entity: " + entityName, x);
                }
                catch (InvocationTargetException x)
                {
                  log.error("Unable to load entity: " + entityName, x);
                }
                catch (NoSuchMethodException x)
                {
                  log.error("Unable to load entity: " + entityName, x);
                }
              }
              else
              {
                try
                {
                  Object bean = standardDao.newEntity(entityName);

                  try
                  {
                    MethodUtils.invokeMethod(bean, "init", new Object[0]);
                  }
View Full Code Here

          {
            persistents.getPersistent(aPersistentConfig.getAttribute("id")).update();
          }
          else
          {
            StandardDao standardDao = (StandardDao) SpringTools.getBean(StandardDao.ID);
            Object bean = persistents.get(aPersistentConfig.getAttribute("id"));

            standardDao.update(bean);
          }
        }
      }
    }
    catch (ConfigurationException x)
View Full Code Here

          persistent.add();
          id = persistent.getFieldInt(aPersistentConfig.getAttribute("key"));
        }
        else
        {
          StandardDao standardDao = (StandardDao) SpringTools.getBean(StandardDao.ID);
          Object bean = persistents.get(aPersistentConfig.getAttribute("id"));

          standardDao.create(bean);

          try
          {
            id = (Integer) PropertyUtils.getSimpleProperty(bean, "id");
          }
View Full Code Here

  @Override
  public void deletePersistent(ModelRequest request, ModelResponse response, Object id, Object entity,
          boolean systemDelete) throws ModelException, PersistenceException
  {
    StandardDao standardDao = (StandardDao) SpringTools.getBean(StandardDao.ID);

    standardDao.delete(entity);
  }
View Full Code Here

                    ids[i], - 1));
            persistent.find();
          }
          else
          {
            StandardDao standardDao = (StandardDao) SpringTools.getBean(StandardDao.ID);

            bean = standardDao.get(persistentConfig.get(0).getAttribute("entity"), NumberTools.toInt(
                    ids[i], - 1));
          }
        }

        ValidationResult result = new ValidationResult();
View Full Code Here

   * @throws ModelException
   */
  private static void createListingWithQuery(ModelRequest request, ModelResponse response, ListingDescriptor listing,
          ListingHandler handler, ListContext context) throws ModelException, PersistenceException
  {
    StandardDao standardDao = (StandardDao) SpringTools.getBean(StandardDao.ID);
    QueryDescriptor query = listing.getQuery();
    Properties queryParams = ExpressionLanguageContext.evalExpressionLanguageValue(context, request, query
            .getParams());
    int count = 0;

    if (query.getDaoName() != null)
    {
      try
      {
        java.util.List list = (java.util.List) MethodUtils.invokeExactMethod(SpringTools.getBean(query
                .getDaoName()), query.getDaoMethodName(), queryParams);

        count = list.size();
      }
      catch (NoSuchMethodException x)
      {
        throw new ModelException(x);
      }
      catch (IllegalAccessException x)
      {
        throw new ModelException(x);
      }
      catch (InvocationTargetException x)
      {
        throw new ModelException(x.getTargetException());
      }
    }
    else if (query.getCountName() != null)
    {
      count = (int) standardDao.countByNamedQuery(query.getCountName(), queryParams);
    }
    else if (query.getName() != null)
    {
      count = (int) standardDao.countByNamedFindQuery(query.getName(), queryParams);
    }
    else
    {
      if (query.getCountQuery() != null)
      {
        count = (int) standardDao.countByQuery(query.getCountQuery(), queryParams);
      }
      else
      {
        count = (int) standardDao.countByFindQuery(query.getQuery(), queryParams);
      }
    }

    int page = Math.max(listing.getPage(), 1);
    int maxPage = (Math.max(0, count - 1) / context.getResultsPerPage()) + 1;

    page = Math.min(page, maxPage);

    context.setPage(page);
    context.setFirstResult((page - 1) * context.getResultsPerPage());

    Output outList = createHeaderElements(request, response, listing, context);

    outList.setAttribute("pageCount", new Integer(maxPage));
    outList.setAttribute("page", String.valueOf(page));

    int firstResult = (page - 1) * context.getResultsPerPage();
    int maxResults = context.getResultsPerPage();
    java.util.List res = null;

    if (query.getDaoName() != null)
    {
      try
      {
        res = (java.util.List) MethodUtils.invokeExactMethod(SpringTools.getBean(query.getDaoName()), query
                .getDaoMethodName(), queryParams);
      }
      catch (NoSuchMethodException x)
      {
        throw new ModelException(x);
      }
      catch (IllegalAccessException x)
      {
        throw new ModelException(x);
      }
      catch (InvocationTargetException x)
      {
        throw new ModelException(x.getTargetException());
      }
    }
    else if (query.getName() != null)
    {
      res = standardDao.findByNamedQuery(query.getName(), queryParams, firstResult, maxResults, listing
              .getSortColumnName(), listing.getSortOrder());
    }
    else
    {
      res = standardDao.findByQuery(query.getQuery(), queryParams, firstResult, maxResults, listing
              .getSortColumnName(), listing.getSortOrder());
    }

    int rowNum = 1;

View Full Code Here

TOP

Related Classes of de.iritgo.aktera.hibernate.StandardDao

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.