Package

Source Code of QueryManagerBean

/**
- $Header: $
- $Author: $
- $Revision: $
- $Date: $

- $Log: $
**/

/***************************************************************************
*  Copyright (c) 2004 - 2008  Fabrizio Boco fabboco@users.sourceforge.net *
*                                                                         *
*   This file is generated with SeamWebAppGen.                            *
*                                                                         *
*   This is free software; you can redistribute it and/or                 *
*   modify it under the terms of the GNU Library General Public           *
*   License as published by the Free Software Foundation; either          *
*   version 2 of the License, or (at your option) any later version.      *
*                                                                         *
*   This library  is distributed in the hope that it will be useful,      *
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
*   GNU Library General Public License for more details.                  *
*                                                                         *
*   You should have received a copy of the GNU Library General Public     *
*   License along with this library; see the file COPYING.LIB. If not,    *
*   write to the Free Software Foundation, Inc., 59 Temple Place,         *
*   Suite 330, Boston, MA  02111-1307, USA                                *
*                                                                         *
***************************************************************************/

package @basePackage.manager;

import java.io.Serializable;
import java.util.Vector;

import javax.ejb.Remove;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import javax.persistence.Query;

import org.apache.commons.collections.set.ListOrderedSet;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.Destroy;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Transactional;
import org.jboss.seam.core.Conversation;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.log.Log;

import @basePackage.manager.managerInterface.QueryManager;

@Stateful
@Name("QueryManager")
@Scope(ScopeType.CONVERSATION)
public class QueryManagerBean implements Serializable, QueryManager
{

  private static final long      serialVersionUID  = 1L;

  @PersistenceContext(type = PersistenceContextType.EXTENDED)
  private EntityManager        entityManager;

  @Logger
  private Log                log;

  @In(create = true)
  private transient FacesMessages  facesMessages;

  /** Gestione ordinamento colonne **/
  private int                order          = 0;

  private String              query;
  private String              result;

  @In
  private Conversation          conversation;

  /** Gestione Bean derivati **/

  /** Variabili per codice custom **/
  // YOUR CODE GOES HERE
  // END OF YOUR CODE
  public QueryManagerBean()
  {
  }

  public String findAll()
  {
    log.info("findAll");

    facesMessages.clear();

    entityManager.clear();

    Vector tmp1 = new Vector();

    try
    {
      Query q = entityManager.createQuery(query);

      ListOrderedSet tmp = new ListOrderedSet();
      tmp.addAll(q.getResultList());
      tmp1 = new Vector(tmp.asList());
    }
    catch (Exception ex)
    {
      facesMessages.add(ex.fillInStackTrace().toString());
      return ".";
    }

    result = "";

    for (Object object : tmp1)
    {
      result += object.toString() + "\r\n";
    }

    return ".";
  }

  public String getQuery()
  {
    return query;
  }

  public void setQuery(String query)
  {
    this.query = query;
  }

  public String getResult()
  {
    return result;
  }

  public void setResult(String result)
  {
    this.result = result;
  }

  @Remove
  @Destroy
  public void destroy()
  {
    log.debug("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
    log.debug("Rilasciato bean per Conversation id " + conversation.getId());
    log.debug("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
  }

}
TOP

Related Classes of QueryManagerBean

TOP
Copyright © 2018 www.massapi.com. 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.