Package org.nightlabs.jfire.trade.dao

Source Code of org.nightlabs.jfire.trade.dao.ArticleEndCustomerHistoryItemDAO

package org.nightlabs.jfire.trade.dao;

import java.util.Collection;
import java.util.List;
import java.util.Set;

import org.nightlabs.jfire.base.JFireEjb3Factory;
import org.nightlabs.jfire.base.jdo.BaseJDOObjectDAO;
import org.nightlabs.jfire.security.SecurityReflector;
import org.nightlabs.jfire.trade.ArticleEndCustomerHistoryItem;
import org.nightlabs.jfire.trade.TradeManagerRemote;
import org.nightlabs.jfire.trade.id.ArticleEndCustomerHistoryItemID;
import org.nightlabs.jfire.trade.id.ArticleID;
import org.nightlabs.progress.ProgressMonitor;

public class ArticleEndCustomerHistoryItemDAO
extends BaseJDOObjectDAO<ArticleEndCustomerHistoryItemID, ArticleEndCustomerHistoryItem>
{
  private static volatile ArticleEndCustomerHistoryItemDAO _sharedInstance;

  public static ArticleEndCustomerHistoryItemDAO sharedInstance()
  {
    if (_sharedInstance == null) {
      synchronized (ArticleEndCustomerHistoryItemDAO.class) {
        if (_sharedInstance == null)
          _sharedInstance = new ArticleEndCustomerHistoryItemDAO();
      }
    }
    return _sharedInstance;
  }

  @Override
  protected Collection<ArticleEndCustomerHistoryItem> retrieveJDOObjects(
      Set<ArticleEndCustomerHistoryItemID> articleEndCustomerHistoryItemIDs, String[] fetchGroups,
      int maxFetchDepth, ProgressMonitor monitor) throws Exception
  {
    TradeManagerRemote tm = tradeManager;
    if (tm == null)
      tm = JFireEjb3Factory.getRemoteBean(TradeManagerRemote.class, SecurityReflector.getInitialContextProperties());

    return tm.getArticleEndCustomerHistoryItems(articleEndCustomerHistoryItemIDs, fetchGroups, maxFetchDepth);
  }

  public ArticleEndCustomerHistoryItem getArticleEndCustomerHistoryItem(
      ArticleEndCustomerHistoryItemID articleEndCustomerHistoryItemID, String[] fetchGroups,
      int maxFetchDepth, ProgressMonitor monitor
  )
  {
    return getJDOObject(null, articleEndCustomerHistoryItemID, fetchGroups, maxFetchDepth, monitor);
  }

  public List<ArticleEndCustomerHistoryItem> getArticleEndCustomerHistoryItems(
      Collection<ArticleEndCustomerHistoryItemID> articleEndCustomerHistoryItemIDs, String[] fetchGroups,
      int maxFetchDepth, ProgressMonitor monitor
  )
  {
    return getJDOObjects(null, articleEndCustomerHistoryItemIDs, fetchGroups, maxFetchDepth, monitor);
  }

  private TradeManagerRemote tradeManager = null;

  public synchronized List<ArticleEndCustomerHistoryItem> getArticleEndCustomerHistoryItems(
      ArticleID articleID,
      String[] fetchGroups, int maxFetchDepth, ProgressMonitor monitor
  )
  {
    tradeManager = JFireEjb3Factory.getRemoteBean(TradeManagerRemote.class, SecurityReflector.getInitialContextProperties());
    try {
      Collection<ArticleEndCustomerHistoryItemID> articleEndCustomerHistoryItemIDs = tradeManager.getArticleEndCustomerHistoryItemIDs(articleID);
      return getJDOObjects(null, articleEndCustomerHistoryItemIDs, fetchGroups, maxFetchDepth, monitor);
    } finally {
      tradeManager = null;
    }
  }
}
TOP

Related Classes of org.nightlabs.jfire.trade.dao.ArticleEndCustomerHistoryItemDAO

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.