db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/jdo ExtentImpl.java PersistenceManagerImpl.java QueryImpl.java
Date Sat, 03 Apr 2004 00:28:00 GMT
brianm      2004/04/02 16:28:00

  Modified:    src/java/org/apache/ojb/jdo ExtentImpl.java
                        PersistenceManagerImpl.java QueryImpl.java
  Log:
  More progress on JDO native =)
  
  Revision  Changes    Path
  1.3       +2 -0      db-ojb/src/java/org/apache/ojb/jdo/ExtentImpl.java
  
  Index: ExtentImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/jdo/ExtentImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExtentImpl.java	11 Mar 2004 18:16:16 -0000	1.2
  +++ ExtentImpl.java	3 Apr 2004 00:27:59 -0000	1.3
  @@ -78,6 +78,8 @@
   	public void close(Iterator iterator)
   	{
   		if (iterator instanceof RsIterator)
  +        {
   			((RsIterator) iterator).releaseDbResources();
  +        }
   	}
   }
  
  
  
  1.4       +803 -720  db-ojb/src/java/org/apache/ojb/jdo/PersistenceManagerImpl.java
  
  Index: PersistenceManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/jdo/PersistenceManagerImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PersistenceManagerImpl.java	11 Mar 2004 18:16:16 -0000	1.3
  +++ PersistenceManagerImpl.java	3 Apr 2004 00:27:59 -0000	1.4
  @@ -20,6 +20,7 @@
   import org.apache.ojb.otm.OTMConnection;
   import org.apache.ojb.otm.copy.ObjectCopyStrategy;
   import org.apache.ojb.otm.kit.SimpleKit;
  +import org.apache.ojb.otm.lock.LockType;
   import org.apache.ojb.otm.lock.LockingException;
   import org.apache.ojb.otm.states.State;
   
  @@ -34,724 +35,806 @@
   
   public class PersistenceManagerImpl implements PersistenceManager
   {
  -	private OTMConnection m_conn;
  -	private SimpleKit m_kit;
  -	private boolean m_multiThreaded = false;
  -	private boolean m_ignoreCache = false;
  -	private PersistenceManagerFactory m_factory;
  -	private String m_userID;
  -	private String m_password;
  -	private String m_alias;
  -	private Object m_usersObject;
  -	private Transaction m_tx;
  -	private StateManager m_stateManager;
  -
  -
  -	public PersistenceManagerImpl(PersistenceManagerFactory factory, String alias, String userid, String password)
  -	{
  -		m_factory = factory;
  -		m_userID = userid;
  -		m_password = password;
  -		m_alias = alias;
  -		m_kit = SimpleKit.getInstance();
  -		/**
  -		 * if the alias is null, use the default.
  -		 */
  -		if (null == m_alias)
  -		{
  -			m_conn = m_kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());
  -		}
  -		else
  -		{
  -			PBKey key = new PBKey(m_alias, m_userID, m_password);
  -			m_conn = m_kit.acquireConnection(key);
  -		}
  -		m_stateManager = new StateManagerImpl(this);
  -	}
  -
  -	public boolean isClosed()
  -	{
  -		return m_conn.isClosed();
  -	}
  -
  -	public void close()
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("close()"));
  -		}
  -		m_conn.close();
  -	}
  -
  -	public Transaction currentTransaction()
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("currentTransaction()"));
  -		}
  -		if (m_tx == null)
  -		{
  -			m_tx = new TransactionImpl(this, m_kit.getTransaction(m_conn));
  -		}
  -		return m_tx;
  -	}
  -
  -	/**
  -	 * evict all persistent-clean instances from the editing context cache
  -	 * @param o
  -	 */
  -	public void evict(Object o)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("evict(Object)"));
  -		}
  -		if (null != o)
  -		{
  -		try
  -		{
  -			Identity oid = m_conn.getIdentity(o);
  -			State state = m_conn.getEditingContext().lookupState(oid);
  -			/**
  -			 * if the object is PersistentClean or non transactional, evict it.
  -			 */
  -			if (State.PERSISTENT_CLEAN == state)
  -			{
  -				/**
  -				 * spec says call the jdoPreClear if it's InstanceCallbacks aware
  -				 */
  -				if (o instanceof InstanceCallbacks)
  -				{
  -					((InstanceCallbacks) o).jdoPreClear();
  -				}
  -				m_conn.invalidate(m_conn.getIdentity(o));
  -				/**
  -				 * set all fields to their default values
  -				 */
  -
  -				/**
  -				 * set state to hollow
  -				 */
  -			}
  -			if (null == state)
  -			{
  -				/**
  -				 * not in the editing context, evict it from the global cache
  -				 */
  -				m_conn.serviceObjectCache().remove(m_conn.getIdentity(o));
  -			}
  -		}
  -		catch (LockingException e)
  -		{
  -			/**
  -			 * shouldn't happen, we're only dealing with persistentClean and non transactional (aka non-locked)
  -			 * objects.
  -			 */
  -		}
  -		}
  -	}
  -
  -	public void evictAll(Object[] objects)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("evictAll(Object[])"));
  -		}
  -		if (null == objects)
  -		{
  -			throw new NullPointerException("evictAll(Object[]) was passed a null Array.");
  -		}
  -		int length = objects.length;
  -		for (int i = 0; i < length; i++)
  -		{
  -			evict(objects[i]);
  -		}
  -	}
  -
  -	public void evictAll(Collection collection)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("evictAll(Collection)"));
  -		}
  -		if (null == collection)
  -		{
  -			throw new NullPointerException("evictAll(Collection) was passed a null Collection.");
  -		}
  -		Iterator it = collection.iterator();
  -		while (it.hasNext())
  -		{
  -			evict(it.next());
  -		}
  -	}
  -
  -	public void evictAll()
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("evictAll()"));
  -		}
  -		Collection collection = m_conn.getEditingContext().getAllObjectsInContext();
  -		Iterator it = collection.iterator();
  -		while (it.hasNext())
  -		{
  -			evict(it.next());
  -		}
  -
  -		/**
  -		 * clear the rest of the global cache
  -		 */
  -		m_conn.serviceObjectCache().clear();
  -	}
  -
  -	public void refresh(Object o)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("refresh(Object)"));
  -		}
  -		Identity oid = m_conn.getIdentity(o);
  -		try
  -		{
  -			Object refreshFrom = m_conn.getObjectByIdentity(oid);
  -			ObjectCopyStrategy strat = m_kit.getCopyStrategy(oid);
  -			strat.copy(refreshFrom, o);
  -			if (o instanceof InstanceCallbacks)
  -			{
  -				((InstanceCallbacks) o).jdoPostLoad();
  -			}
  -			m_conn.getEditingContext().setState(oid, State.PERSISTENT_CLEAN);
  -		}
  -		catch (LockingException e)
  -		{
  -		}
  -	}
  -
  -	public void refreshAll(Object[] objects)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("refreshAll(Object[])"));
  -		}
  -		if (null == objects)
  -		{
  -			throw new NullPointerException("refreshAll(Object[]) was passed a null Array.");
  -		}
  -		int length = objects.length;
  -		for (int i = 0; i < length; i++)
  -		{
  -			refresh(objects[i]);
  -		}
  -	}
  -
  -	public void refreshAll(Collection collection)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("refreshAll(Collection)"));
  -		}
  -		if (null == collection)
  -		{
  -			throw new NullPointerException("refreshAll(Collection) was passed a null Collection.");
  -		}
  -		Iterator it = collection.iterator();
  -		while (it.hasNext())
  -		{
  -			refresh(it.next());
  -		}
  -	}
  -
  -	public void refreshAll()
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("refreshAll()"));
  -		}
  -		if (currentTransaction().isActive())
  -		{
  -			Collection collection = m_conn.getEditingContext().getAllObjectsInContext();
  -			Iterator it = collection.iterator();
  -			while (it.hasNext())
  -			{
  -				refresh(it.next());
  -			}
  -		}
  -	}
  -
  -	public Query newQuery()
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery()"));
  -		}
  -
  -		return null;
  -	}
  -
  -	public Query newQuery(Object o)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Object)"));
  -		}
  -		return null;
  -	}
  -
  -	public Query newQuery(String s, Object o)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(String, Object)"));
  -		}
  -
  -		return null;
  -	}
  -
  -	public Query newQuery(Class aClass)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Class)"));
  -		}
  -		return null;
  -	}
  -
  -	public Query newQuery(Extent extent)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Extent)"));
  -		}
  -
  -		return null;
  -	}
  -
  -	public Query newQuery(Class aClass, Collection collection)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Class, Collection)"));
  -		}
  -		return null;
  -	}
  -
  -	public Query newQuery(Class aClass, String s)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Class, String)"));
  -		}
  -		return null;
  -	}
  -
  -	public Query newQuery(Class aClass, Collection collection, String s)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Class, Collection, String)"));
  -		}
  -		return null;
  -	}
  -
  -	public Query newQuery(Extent extent, String s)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Extent, String)"));
  -		}
  -		return null;
  -	}
  -
  -	public Extent getExtent(Class aClass, boolean b)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("getExtent(Class, boolean)"));
  -		}
  -		return new ExtentImpl(aClass, m_conn, this);
  -	}
  -
  -	public Object getObjectById(Object o, boolean validate)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("getObjectById(Object, boolean)"));
  -		}
  -		Object retval = null;
  -		try
  -		{
  -			retval = m_conn.getObjectByIdentity((Identity)o);
  -		}
  -		catch (LockingException e)
  -		{
  -			e.printStackTrace();  //To change body of catch statement use Options | File Templates.
  -		}
  -		return retval;
  -	}
  -
  -	public Object getObjectId(Object o)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("getObjectId(Object)"));
  -		}
  -		return m_conn.getIdentity(o);
  -	}
  -
  -	public Object getTransactionalObjectId(Object o)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("getTransactionalObjectId(Object)"));
  -		}
  -		return m_conn.getIdentity(o);
  -	}
  -
  -	public Object newObjectIdInstance(Class aClass, String s)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("newObjectIdInstance(Class, String)"));
  -		}
  -		return null;
  -	}
  -
  -	public void makePersistent(Object o)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("makePersistent(Object)"));
  -		}
  -		try
  -		{
  -			m_conn.makePersistent(o);
  -		}
  -		catch (LockingException e)
  -		{
  -			// throw runtime exception
  -		}
  -	}
  -
  -	public void makePersistentAll(Object[] objects)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("makePersistentAll(Object[])"));
  -		}
  -		if (null == objects)
  -		{
  -			throw new NullPointerException("makePersistentAll(Object[]) was passed a null Array.");
  -		}
  -		int length = objects.length;
  -		for (int i = 0; i < length; i++)
  -		{
  -			makePersistent(objects[i]);
  -		}
  -	}
  -
  -	public void makePersistentAll(Collection collection)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("makePersistentAll(Collection)"));
  -		}
  -		if (null == collection)
  -		{
  -			throw new NullPointerException("makePersistentAll(Collection) was passed a null Collection.");
  -		}
  -		Iterator it = collection.iterator();
  -		while (it.hasNext())
  -		{
  -			makePersistent(it.next());
  -		}
  -	}
  -
  -	public void deletePersistent(Object o)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("deletePersistent(Object)"));
  -		}
  -		try
  -		{
  -			m_conn.deletePersistent(o);
  -		}
  -		catch (LockingException e)
  -		{
  -			//throw runtime exception.
  -		}
  -	}
  -
  -	public void deletePersistentAll(Object[] objects)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("deletePersistentAll(Object[])"));
  -		}
  -		if (null == objects)
  -		{
  -			throw new NullPointerException("deletePersistentAll(Object[]) was passed a null Array.");
  -		}
  -		int length = objects.length;
  -		for (int i = 0; i < length; i++)
  -		{
  -			deletePersistent(objects[i]);
  -		}
  -	}
  -
  -	public void deletePersistentAll(Collection collection)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("deletePersistentAll(Collection)"));
  -		}
  -		if (null == collection)
  -		{
  -			throw new NullPointerException("deletePersistentAll(Collection) was passed a null Collection.");
  -		}
  -		Iterator it = collection.iterator();
  -		while (it.hasNext())
  -		{
  -			deletePersistent(it.next());
  -		}
  -	}
  -
  -	public void makeTransient(Object o)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransient(Object)"));
  -		}
  -	}
  -
  -	public void makeTransientAll(Object[] objects)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransientAll(Object[])"));
  -		}
  -		if (null == objects)
  -		{
  -			throw new NullPointerException("makeTransientAll(Object[]) was passed a null Array.");
  -		}
  -	}
  -
  -	public void makeTransientAll(Collection collection)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransientAll(Collection)"));
  -		}
  -		if (null == collection)
  -		{
  -			throw new NullPointerException("makeTransientAll(Collection) was passed a null Collection.");
  -		}
  -	}
  -
  -	public void makeTransactional(Object o)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransactional(Object)"));
  -		}
  -	}
  -
  -	public void makeTransactionalAll(Object[] objects)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransactionalAll(Object[])"));
  -		}
  -		if (null == objects)
  -		{
  -			throw new NullPointerException("makeTransactionalAll(Object[]) was passed a null Array.");
  -		}
  -	}
  -
  -	public void makeTransactionalAll(Collection collection)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransactionalAll(Collection)"));
  -		}
  -		if (null == collection)
  -		{
  -			throw new NullPointerException("makeTransactionalAll(Collection) was passed a null Collection.");
  -		}
  -	}
  -
  -	public void makeNontransactional(Object o)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("makeNontransactional(Object)"));
  -		}
  -	}
  -
  -	public void makeNontransactionalAll(Object[] objects)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("makeNontransactionalAll(Object[])"));
  -		}
  -		if (null == objects)
  -		{
  -			throw new NullPointerException("makeNontransactionalAll(Object[]) was passed a null Array.");
  -		}
  -	}
  -
  -	public void makeNontransactionalAll(Collection collection)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("makeNontransactionalAll(Collection)"));
  -		}
  -		if (null == collection)
  -		{
  -			throw new NullPointerException("makeNontransactionalAll(Collection) was passed a null Collection.");
  -		}
  -	}
  -
  -	public void retrieve(Object o)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("retrieve(Object)"));
  -		}
  -	}
  -
  -	public void retrieveAll(Collection collection)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("retrieveAll(Collection)"));
  -		}
  -		if (null == collection)
  -		{
  -			throw new NullPointerException("retrieveAll(Collection) was passed a null Collection.");
  -		}
  -	}
  -
  -	public void retrieveAll(Object[] objects)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("retrieveAll(Object[])"));
  -		}
  -		if (null == objects)
  -		{
  -			throw new NullPointerException("retrieveAll(Object[]) was passed a null Array.");
  -		}
  -	}
  -
  -	public void setUserObject(Object o)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("setUserObject(Object)"));
  -		}
  -		m_usersObject = o;
  -	}
  -
  -	public Object getUserObject()
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("getUserObject()"));
  -		}
  -		return m_usersObject;
  -	}
  -
  -	public PersistenceManagerFactory getPersistenceManagerFactory()
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("getPersistenceManagerFactory()"));
  -		}
  -		return this.m_factory;
  -	}
  -
  -	public Class getObjectIdClass(Class aClass)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("getObjectIdClass(Class)"));
  -		}
  -		return null;
  -	}
  -
  -	public void setMultithreaded(boolean b)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("setMultithreaded(boolean)"));
  -		}
  -		m_multiThreaded = b;
  -	}
  -
  -	public boolean getMultithreaded()
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("getMultithreaded()"));
  -		}
  -		return m_multiThreaded;
  -	}
  -
  -	public void setIgnoreCache(boolean b)
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("setIgnoreCache(boolean)"));
  -		}
  -		m_ignoreCache = b;
  -	}
  -
  -	public boolean getIgnoreCache()
  -	{
  -		if (isClosed())
  -		{
  -			throw new JDOFatalUserException(generateIsClosedErrorMessage("getIgnoreCache()"));
  -		}
  -		return m_ignoreCache;
  -	}
  -
  -	/**
  -	 * TODO i18n these messages
  -	 * @param methodSignature
  -	 * @return
  -	 */
  -	private static final String generateIsClosedErrorMessage(String methodSignature)
  -	{
  -		return "PersistenceManager already closed, cannot call '" + methodSignature + "'. Obtain a new PersistenceBroker and retry.";
  -	}
  -
  -	/**
  -	 * TODO i18n these messages
  -	 * @param methodSignature
  -	 * @param type
  -	 * @return
  -	 */
  -	private static final String generateNullParameterErrorMessage(String methodSignature, String type)
  -	{
  -		return methodSignature + " was passed a null " + type + ".";
  -	}
  -	/* (non-Javadoc)
  -	 * @see javax.jdo.PersistenceManager#retrieveAll(java.util.Collection, boolean)
  -	 */
  -	public void retrieveAll(Collection arg0, boolean arg1)
  -	{
  -		// TODO Auto-generated method stub
  -
  -	}
  -
  -	/* (non-Javadoc)
  -	 * @see javax.jdo.PersistenceManager#retrieveAll(java.lang.Object[], boolean)
  -	 */
  -	public void retrieveAll(Object[] arg0, boolean arg1)
  -	{
  -		// TODO Auto-generated method stub
  -
  -	}
  -
  +    private OTMConnection m_conn;
  +    private SimpleKit m_kit;
  +    private boolean m_multiThreaded = false;
  +    private boolean m_ignoreCache = false;
  +    private PersistenceManagerFactory m_factory;
  +    private String m_userID;
  +    private String m_password;
  +    private String m_alias;
  +    private Object m_usersObject;
  +    private Transaction m_tx;
  +    private StateManager m_stateManager;
  +
  +
  +    public PersistenceManagerImpl(PersistenceManagerFactory factory, String alias, String userid, String password)
  +    {
  +        m_factory = factory;
  +        m_userID = userid;
  +        m_password = password;
  +        m_alias = alias;
  +        m_kit = SimpleKit.getInstance();
  +        /**
  +         * if the alias is null, use the default.
  +         */
  +        if (null == m_alias)
  +        {
  +            m_conn = m_kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());
  +        }
  +        else
  +        {
  +            PBKey key = new PBKey(m_alias, m_userID, m_password);
  +            m_conn = m_kit.acquireConnection(key);
  +        }
  +        m_stateManager = new StateManagerImpl(this);
  +    }
  +
  +    public boolean isClosed()
  +    {
  +        return m_conn.isClosed();
  +    }
  +
  +    public void close()
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("close()"));
  +        }
  +        m_conn.close();
  +    }
  +
  +    public Transaction currentTransaction()
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("currentTransaction()"));
  +        }
  +        if (m_tx == null)
  +        {
  +            m_tx = new TransactionImpl(this, m_kit.getTransaction(m_conn));
  +        }
  +        return m_tx;
  +    }
  +
  +    /**
  +     * evict all persistent-clean instances from the editing context cache
  +     *
  +     * @param o
  +     */
  +    public void evict(Object o)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("evict(Object)"));
  +        }
  +        if (null != o)
  +        {
  +            try
  +            {
  +                Identity oid = m_conn.getIdentity(o);
  +                State state = m_conn.getEditingContext().lookupState(oid);
  +                /**
  +                 * if the object is PersistentClean or non transactional, evict it.
  +                 */
  +                if (State.PERSISTENT_CLEAN == state)
  +                {
  +                    /**
  +                     * spec says call the jdoPreClear if it's InstanceCallbacks aware
  +                     */
  +                    if (o instanceof InstanceCallbacks)
  +                    {
  +                        ((InstanceCallbacks) o).jdoPreClear();
  +                    }
  +                    m_conn.invalidate(m_conn.getIdentity(o));
  +                    /**
  +                     * set all fields to their default values
  +                     */
  +
  +                    /**
  +                     * set state to hollow
  +                     */
  +                }
  +                if (null == state)
  +                {
  +                    /**
  +                     * not in the editing context, evict it from the global cache
  +                     */
  +                    m_conn.serviceObjectCache().remove(m_conn.getIdentity(o));
  +                }
  +            }
  +            catch (LockingException e)
  +            {
  +                /**
  +                 * shouldn't happen, we're only dealing with persistentClean and non transactional (aka non-locked)
  +                 * objects.
  +                 */
  +            }
  +        }
  +    }
  +
  +    public void evictAll(Object[] objects)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("evictAll(Object[])"));
  +        }
  +        if (null == objects)
  +        {
  +            throw new NullPointerException("evictAll(Object[]) was passed a null Array.");
  +        }
  +        int length = objects.length;
  +        for (int i = 0; i < length; i++)
  +        {
  +            evict(objects[i]);
  +        }
  +    }
  +
  +    public void evictAll(Collection collection)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("evictAll(Collection)"));
  +        }
  +        if (null == collection)
  +        {
  +            throw new NullPointerException("evictAll(Collection) was passed a null Collection.");
  +        }
  +        Iterator it = collection.iterator();
  +        while (it.hasNext())
  +        {
  +            evict(it.next());
  +        }
  +    }
  +
  +    public void evictAll()
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("evictAll()"));
  +        }
  +        Collection collection = m_conn.getEditingContext().getAllObjectsInContext();
  +        Iterator it = collection.iterator();
  +        while (it.hasNext())
  +        {
  +            evict(it.next());
  +        }
  +
  +        /**
  +         * clear the rest of the global cache
  +         */
  +        m_conn.serviceObjectCache().clear();
  +    }
  +
  +    public void refresh(Object o)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("refresh(Object)"));
  +        }
  +        Identity oid = m_conn.getIdentity(o);
  +        try
  +        {
  +            Object refreshFrom = m_conn.getObjectByIdentity(oid);
  +            ObjectCopyStrategy strat = m_kit.getCopyStrategy(oid);
  +            strat.copy(refreshFrom, o);
  +            if (o instanceof InstanceCallbacks)
  +            {
  +                ((InstanceCallbacks) o).jdoPostLoad();
  +            }
  +            m_conn.getEditingContext().setState(oid, State.PERSISTENT_CLEAN);
  +        }
  +        catch (LockingException e)
  +        {
  +        }
  +    }
  +
  +    public void refreshAll(Object[] objects)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("refreshAll(Object[])"));
  +        }
  +        if (null == objects)
  +        {
  +            throw new NullPointerException("refreshAll(Object[]) was passed a null Array.");
  +        }
  +        int length = objects.length;
  +        for (int i = 0; i < length; i++)
  +        {
  +            refresh(objects[i]);
  +        }
  +    }
  +
  +    public void refreshAll(Collection collection)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("refreshAll(Collection)"));
  +        }
  +        if (null == collection)
  +        {
  +            throw new NullPointerException("refreshAll(Collection) was passed a null Collection.");
  +        }
  +        Iterator it = collection.iterator();
  +        while (it.hasNext())
  +        {
  +            refresh(it.next());
  +        }
  +    }
  +
  +    public void refreshAll()
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("refreshAll()"));
  +        }
  +        if (currentTransaction().isActive())
  +        {
  +            Collection collection = m_conn.getEditingContext().getAllObjectsInContext();
  +            Iterator it = collection.iterator();
  +            while (it.hasNext())
  +            {
  +                refresh(it.next());
  +            }
  +        }
  +    }
  +
  +    public Query newQuery()
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery()"));
  +        }
  +
  +        return new QueryImpl(this, m_conn);
  +    }
  +
  +    public Query newQuery(Object o)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Object)"));
  +        }
  +        throw new UnsupportedOperationException("Not yet implemented!");
  +    }
  +
  +    public Query newQuery(String s, Object o)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(String, Object)"));
  +        }
  +
  +        throw new UnsupportedOperationException("Not yet implemented!");
  +    }
  +
  +    public Query newQuery(Class aClass)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Class)"));
  +        }
  +        Query query = new QueryImpl(this, m_conn);
  +        query.setClass(aClass);
  +        return query;
  +    }
  +
  +    public Query newQuery(Extent extent)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Extent)"));
  +        }
  +
  +        Query query = new QueryImpl(this, m_conn);
  +        query.setCandidates(extent);
  +        return query;
  +    }
  +
  +    public Query newQuery(Class aClass, Collection collection)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Class, Collection)"));
  +        }
  +        Query query = new QueryImpl(this, m_conn);
  +        query.setCandidates(collection);
  +        query.setClass(aClass);
  +        return query;
  +    }
  +
  +    public Query newQuery(Class aClass, String s)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Class, String)"));
  +        }
  +        Query query = new QueryImpl(this, m_conn);
  +        query.setClass(aClass);
  +        query.setFilter(s);
  +        return query;
  +    }
  +
  +    public Query newQuery(Class aClass, Collection collection, String s)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Class, Collection, String)"));
  +        }
  +        Query query = new QueryImpl(this, m_conn);
  +        query.setCandidates(collection);
  +        query.setClass(aClass);
  +        query.setFilter(s);
  +        return query;
  +    }
  +
  +    public Query newQuery(Extent extent, String s)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Extent, String)"));
  +        }
  +        Query query = new QueryImpl(this, m_conn);
  +        query.setCandidates(extent);
  +        query.setFilter(s);
  +        return query;
  +    }
  +
  +    public Extent getExtent(Class aClass, boolean b)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("getExtent(Class, boolean)"));
  +        }
  +        return new ExtentImpl(aClass, m_conn, this);
  +    }
  +
  +    public Object getObjectById(Object o, boolean validate)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("getObjectById(Object, boolean)"));
  +        }
  +        Object retval = null;
  +        try
  +        {
  +            retval = m_conn.getObjectByIdentity((Identity) o);
  +        }
  +        catch (LockingException e)
  +        {
  +            e.printStackTrace();  //To change body of catch statement use Options | File Templates.
  +        }
  +        return retval;
  +    }
  +
  +    public Object getObjectId(Object o)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("getObjectId(Object)"));
  +        }
  +        return m_conn.getIdentity(o);
  +    }
  +
  +    public Object getTransactionalObjectId(Object o)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("getTransactionalObjectId(Object)"));
  +        }
  +        return m_conn.getIdentity(o);
  +    }
  +
  +    public Object newObjectIdInstance(Class aClass, String s)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("newObjectIdInstance(Class, String)"));
  +        }
  +        return null;
  +    }
  +
  +    public void makePersistent(Object o)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("makePersistent(Object)"));
  +        }
  +        try
  +        {
  +            m_conn.makePersistent(o);
  +        }
  +        catch (LockingException e)
  +        {
  +            // throw runtime exception
  +        }
  +    }
  +
  +    public void makePersistentAll(Object[] objects)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("makePersistentAll(Object[])"));
  +        }
  +        if (null == objects)
  +        {
  +            throw new NullPointerException("makePersistentAll(Object[]) was passed a null Array.");
  +        }
  +        int length = objects.length;
  +        for (int i = 0; i < length; i++)
  +        {
  +            makePersistent(objects[i]);
  +        }
  +    }
  +
  +    public void makePersistentAll(Collection collection)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("makePersistentAll(Collection)"));
  +        }
  +        if (null == collection)
  +        {
  +            throw new NullPointerException("makePersistentAll(Collection) was passed a null Collection.");
  +        }
  +        Iterator it = collection.iterator();
  +        while (it.hasNext())
  +        {
  +            makePersistent(it.next());
  +        }
  +    }
  +
  +    public void deletePersistent(Object o)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("deletePersistent(Object)"));
  +        }
  +        try
  +        {
  +            m_conn.deletePersistent(o);
  +        }
  +        catch (LockingException e)
  +        {
  +            handleLockingException(e);
  +        }
  +    }
  +
  +    public void deletePersistentAll(Object[] objects)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("deletePersistentAll(Object[])"));
  +        }
  +        if (null == objects)
  +        {
  +            throw new NullPointerException("deletePersistentAll(Object[]) was passed a null Array.");
  +        }
  +        int length = objects.length;
  +        for (int i = 0; i < length; i++)
  +        {
  +            deletePersistent(objects[i]);
  +        }
  +    }
  +
  +    public void deletePersistentAll(Collection collection)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("deletePersistentAll(Collection)"));
  +        }
  +        if (null == collection)
  +        {
  +            throw new NullPointerException("deletePersistentAll(Collection) was passed a null Collection.");
  +        }
  +        Iterator it = collection.iterator();
  +        while (it.hasNext())
  +        {
  +            deletePersistent(it.next());
  +        }
  +    }
  +
  +    /**
  +     * Right now this makes the object non-transactional.
  +     * @todo figure out what this is supposed to really do
  +     */
  +    public void makeTransient(Object o)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransient(Object)"));
  +        }
  +        m_conn.getEditingContext().remove(m_conn.getIdentity(o));
  +        m_conn.serviceObjectCache().remove(m_conn.getIdentity(o));
  +    }
  +
  +    public void makeTransientAll(Object[] objects)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransientAll(Object[])"));
  +        }
  +        if (null == objects)
  +        {
  +            throw new NullPointerException("makeTransientAll(Object[]) was passed a null Array.");
  +        }
  +        for (int i = 0; i < objects.length; i++)
  +        {
  +            this.makeTransient(objects[i]);
  +        }
  +    }
  +
  +    public void makeTransientAll(Collection collection)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransientAll(Collection)"));
  +        }
  +        if (null == collection)
  +        {
  +            throw new NullPointerException("makeTransientAll(Collection) was passed a null Collection.");
  +        }
  +        for (Iterator iterator = collection.iterator(); iterator.hasNext();)
  +        {
  +            this.makeTransient(iterator.next());
  +        }
  +    }
  +
  +    public void makeTransactional(Object o)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransactional(Object)"));
  +        }
  +        try
  +        {
  +            m_conn.getEditingContext().insert(m_conn.getIdentity(o), o, LockType.READ_LOCK);
  +        }
  +        catch (LockingException e)
  +        {
  +            handleLockingException(e);
  +        }
  +    }
  +
  +    public void makeTransactionalAll(Object[] objects)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransactionalAll(Object[])"));
  +        }
  +        if (null == objects)
  +        {
  +            throw new NullPointerException("makeTransactionalAll(Object[]) was passed a null Array.");
  +        }
  +        for (int i = 0; i < objects.length; i++)
  +        {
  +            this.makeTransactional(objects[i]);
  +        }
  +    }
  +
  +    public void makeTransactionalAll(Collection collection)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransactionalAll(Collection)"));
  +        }
  +        if (null == collection)
  +        {
  +            throw new NullPointerException("makeTransactionalAll(Collection) was passed a null Collection.");
  +        }
  +        for (Iterator iterator = collection.iterator(); iterator.hasNext();)
  +        {
  +            this.makeTransactional(iterator.next());
  +        }
  +    }
  +
  +    /**
  +     * @todo What is the difference between this and makeTransient?
  +     */
  +    public void makeNontransactional(Object o)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeNontransactional(Object)"));
  +        }
  +        this.makeTransient(o);
  +    }
  +
  +    public void makeNontransactionalAll(Object[] objects)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeNontransactionalAll(Object[])"));
  +        }
  +        if (null == objects)
  +        {
  +            throw new NullPointerException("makeNontransactionalAll(Object[]) was passed a null Array.");
  +        }
  +        for (int i = 0; i < objects.length; i++)
  +        {
  +            this.makeNontransactional(objects[i]);
  +        }
  +    }
  +
  +    public void makeNontransactionalAll(Collection collection)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeNontransactionalAll(Collection)"));
  +        }
  +        if (null == collection)
  +        {
  +            throw new NullPointerException("makeNontransactionalAll(Collection) was passed a null Collection.");
  +        }
  +        for (Iterator iterator = collection.iterator(); iterator.hasNext();)
  +        {
  +            this.makeNontransactional(iterator.next());
  +        }
  +    }
  +
  +    /**
  +     * @todo What does this do?
  +     * @param o
  +     */
  +    public void retrieve(Object o)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("retrieve(Object)"));
  +        }
  +        throw new UnsupportedOperationException("Not yet implemented!");
  +    }
  +
  +    /**
  +     * @todo What does this do?
  +     * @param collection
  +     */
  +    public void retrieveAll(Collection collection)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("retrieveAll(Collection)"));
  +        }
  +        if (null == collection)
  +        {
  +            throw new NullPointerException("retrieveAll(Collection) was passed a null Collection.");
  +        }
  +        throw new UnsupportedOperationException("Not yet implemented!");
  +    }
  +
  +    public void retrieveAll(Object[] objects)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("retrieveAll(Object[])"));
  +        }
  +        if (null == objects)
  +        {
  +            throw new NullPointerException("retrieveAll(Object[]) was passed a null Array.");
  +        }
  +        throw new UnsupportedOperationException("Not yet implemented!");
  +    }
  +
  +    public void setUserObject(Object o)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("setUserObject(Object)"));
  +        }
  +        m_usersObject = o;
  +    }
  +
  +    public Object getUserObject()
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("getUserObject()"));
  +        }
  +        return m_usersObject;
  +    }
  +
  +    public PersistenceManagerFactory getPersistenceManagerFactory()
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("getPersistenceManagerFactory()"));
  +        }
  +        return this.m_factory;
  +    }
  +
  +    /**
  +     * @todo what does this do?
  +     */
  +    public Class getObjectIdClass(Class aClass)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("getObjectIdClass(Class)"));
  +        }
  +        throw new UnsupportedOperationException("Not yet implemented!");
  +    }
  +
  +    public void setMultithreaded(boolean b)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("setMultithreaded(boolean)"));
  +        }
  +        m_multiThreaded = b;
  +    }
  +
  +    public boolean getMultithreaded()
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("getMultithreaded()"));
  +        }
  +        return m_multiThreaded;
  +    }
  +
  +    public void setIgnoreCache(boolean b)
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("setIgnoreCache(boolean)"));
  +        }
  +        m_ignoreCache = b;
  +    }
  +
  +    public boolean getIgnoreCache()
  +    {
  +        if (isClosed())
  +        {
  +            throw new JDOFatalUserException(generateIsClosedErrorMessage("getIgnoreCache()"));
  +        }
  +        return m_ignoreCache;
  +    }
  +
  +    /**
  +     * TODO i18n these messages
  +     *
  +     * @param methodSignature
  +     * @return
  +     */
  +    private static final String generateIsClosedErrorMessage(String methodSignature)
  +    {
  +        return "PersistenceManager already closed, cannot call '" + methodSignature + "'. Obtain a new PersistenceBroker and retry.";
  +    }
  +
  +    private void handleLockingException(LockingException e)
  +    {
  +        throw new UnsupportedOperationException("Not yet implemented!");
  +    }
  +
  +    /**
  +     * TODO i18n these messages
  +     *
  +     * @param methodSignature
  +     * @param type
  +     * @return
  +     */
  +    private static final String generateNullParameterErrorMessage(String methodSignature, String type)
  +    {
  +        return methodSignature + " was passed a null " + type + ".";
  +    }
  +
  +    /**
  +     * @todo what does this do?
  +     * @see javax.jdo.PersistenceManager#retrieveAll(java.util.Collection, boolean)
  +     */
  +    public void retrieveAll(Collection arg0, boolean arg1)
  +    {
  +        // TODO Auto-generated method stub
  +
  +    }
  +
  +    /**
  +     * @todo what does this do?
  +     * @see javax.jdo.PersistenceManager#retrieveAll(java.lang.Object[], boolean)
  +     */
  +    public void retrieveAll(Object[] arg0, boolean arg1)
  +    {
  +        // TODO Auto-generated method stub
  +    }
   }
  
  
  
  1.3       +50 -8     db-ojb/src/java/org/apache/ojb/jdo/QueryImpl.java
  
  Index: QueryImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/jdo/QueryImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- QueryImpl.java	11 Mar 2004 18:16:16 -0000	1.2
  +++ QueryImpl.java	3 Apr 2004 00:27:59 -0000	1.3
  @@ -14,11 +14,20 @@
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
  +import org.apache.ojb.broker.query.Criteria;
  +import org.apache.ojb.broker.query.QueryFactory;
  +import org.apache.ojb.broker.query.QueryByCriteria;
  +import org.apache.ojb.otm.OTMConnection;
  +import org.apache.commons.collections.CollectionUtils;
  +import org.odmg.DList;
  +
   import javax.jdo.Query;
   import javax.jdo.Extent;
   import javax.jdo.PersistenceManager;
   import java.util.Collection;
   import java.util.Map;
  +import java.util.Iterator;
  +import java.util.HashSet;
   
   /**
    * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
  @@ -26,91 +35,124 @@
   
   public class QueryImpl implements Query
   {
  +
  +    private PersistenceManager m_pm;
  +    private OTMConnection m_conn;
  +    private Criteria m_criteria;
  +    private Class m_searchClass;
  +    private Collection m_candidates;
  +
  +    QueryImpl(PersistenceManager pm, OTMConnection conn)
  +    {
  +        this.m_pm = pm;
  +        this.m_conn = conn;
  +        this.m_criteria = new Criteria();
  +        this.m_candidates = new HashSet();
  +    }
  +
   	public void setClass(Class aClass)
   	{
  +        this.m_searchClass = aClass;
   	}
   
   	public void setCandidates(Extent extent)
   	{
  +        Iterator itty = extent.iterator();
  +        while (itty.hasNext())
  +        {
  +            m_candidates.add(itty.next());
  +        }
   	}
   
   	public void setCandidates(Collection collection)
   	{
  +        this.m_candidates.addAll(collection);
   	}
   
   	public void setFilter(String s)
   	{
  +        throw new UnsupportedOperationException("Not yet implemented!");
   	}
   
   	public void declareImports(String s)
   	{
  +        throw new UnsupportedOperationException("Not yet implemented!");
   	}
   
   	public void declareParameters(String s)
   	{
  +        throw new UnsupportedOperationException("Not yet implemented!");
   	}
   
   	public void declareVariables(String s)
   	{
  +        throw new UnsupportedOperationException("Not yet implemented!");
   	}
   
   	public void setOrdering(String s)
   	{
  +        throw new UnsupportedOperationException("Not yet implemented!");
   	}
   
   	public void setIgnoreCache(boolean b)
   	{
  +        throw new UnsupportedOperationException("Not yet implemented!");
   	}
   
   	public boolean getIgnoreCache()
   	{
  -		return false;
  +		throw new UnsupportedOperationException("Not yet implemented!");
   	}
   
   	public void compile()
   	{
  +        // Do Nothing
   	}
   
   	public Object execute()
   	{
  -		return null;
  +        QueryByCriteria query = QueryFactory.newQuery(m_searchClass, this.m_criteria);
  +		Collection results =  (Collection) m_conn.getCollectionByQuery(query);
  +        return CollectionUtils.intersection(results, this.m_candidates);
   	}
   
   	public Object execute(Object o)
   	{
  -		return null;
  +		throw new UnsupportedOperationException("Not yet implemented!");
   	}
   
   	public Object execute(Object o, Object o1)
   	{
  -		return null;
  +		throw new UnsupportedOperationException("Not yet implemented!");
   	}
   
   	public Object execute(Object o, Object o1, Object o2)
   	{
  -		return null;
  +		throw new UnsupportedOperationException("Not yet implemented!");
   	}
   
   	public Object executeWithMap(Map map)
   	{
  -		return null;
  +		throw new UnsupportedOperationException("Not yet implemented!");
   	}
   
   	public Object executeWithArray(Object[] objects)
   	{
  -		return null;
  +		throw new UnsupportedOperationException("Not yet implemented!");
   	}
   
   	public PersistenceManager getPersistenceManager()
   	{
  -		return null;
  +		return m_pm;
   	}
   
   	public void close(Object o)
   	{
  +        throw new UnsupportedOperationException("Not yet implemented!");
   	}
   
   	public void closeAll()
   	{
  +        throw new UnsupportedOperationException("Not yet implemented!");
   	}
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message