ruper2/src/java/core/org/krysalis/ruper2/query DefaultQueryEngine.java,1.7,1.8 ResourceQuery.java,1.3,1.4 ResourceResultHelper.java,1.2,1.3

[email protected]
Newsgroups gmane.comp.krysalis.metamorphosis.cvs
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/query
In directory sc8-pr-cvs1:/tmp/cvs-serv23201/src/java/core/org/krysalis/ruper2/query

Modified Files:
	DefaultQueryEngine.java ResourceQuery.java 
	ResourceResultHelper.java 
Log Message:
1) Moved IMonitor -> IFileMonitor (to allow others)
2) GroupBy now works (iterated unsorted list be accindent)
3) Started on 'clean' (remove old versions from a repo)

Index: DefaultQueryEngine.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/query/DefaultQueryEngine.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** DefaultQueryEngine.java	10 Oct 2003 21:26:24 -0000	1.7
--- DefaultQueryEngine.java	12 Oct 2003 18:12:05 -0000	1.8
***************
*** 9,14 ****
  import java.util.Iterator;
  import java.util.List;
- import java.util.SortedSet;
- import java.util.TreeSet;
  
  import org.krysalis.ruper2.RuperException;
--- 9,12 ----
***************
*** 35,42 ****
  		throws RuperException {
  
! //		if (Logger.getLog().isDebug()) {
! //			DebugUtils.printSeparator();
! //			DebugUtils.dump(query);
! //		}
  
  		//
--- 33,40 ----
  		throws RuperException {
  
! 		//		if (Logger.getLog().isDebug()) {
! 		//			DebugUtils.printSeparator();
! 		//			DebugUtils.dump(query);
! 		//		}
  
  		//
***************
*** 48,58 ****
  		// Extract query components
  		List resourceGroups = query.getGroups();
  		ISelector whereClause = query.getWhere();
- 		Comparator groupBy = query.getGroupBy();
- 		Comparator orderBy = query.getOrderBy();
  
  		if (null == whereClause)
  			whereClause = AllSelector.getInstance();
- 
  		//:TODO: Total Hack, just to allow something...
  		// Rework w/ correct configurable components
--- 46,109 ----
  		// Extract query components
  		List resourceGroups = query.getGroups();
+ 
+ 		//
+ 		// Trawl the repositories to gather resources
+ 		//
+ 		results = gatherResources(wrappers, resourceGroups, query);
+ 
+ 		//
+ 		// Package the results..
+ 		//
+ 
+ 		if (results.isEmpty())
+ 			Logger.getLog().warn(
+ 				Messages.getString(MessageConstants.NO_RESOURCES_FOUND));
+ 		else {
+ 			Logger.getLog().info(
+ 				Messages.getString(MessageConstants.RESOURCES_FOUND));
+ 
+ 			Comparator groupBy = query.getGroupBy();
+ 			Comparator orderBy = query.getOrderBy();
+ 
+ 			//			if (Logger.getLog().isDebug()) {
+ 			//				DebugUtils.printSeparator();
+ 			//				DebugUtils.dump("All Results", results);
+ 			//			}
+ 			groupBy(result, results, groupBy);
+ 
+ 			//			if (Logger.getLog().isDebug()) {
+ 			//				DebugUtils.printSeparator();
+ 			//				DebugUtils.dump("Grouped Results", result);
+ 			//			}
+ 
+ 			//
+ 			// Order the various groups
+ 			//
+ 			if (null == orderBy)
+ 				orderBy =
+ 					StandardResourceComparisons
+ 						.getNameTypeVersionComparatorSequence();
+ 			orderBy(result, orderBy);
+ 
+ 			if (Logger.getLog().isDebug()) {
+ 				DebugUtils.printSeparator();
+ 				DebugUtils.dump("Final (Grouped/Ordered) Results", result);
+ 			}
+ 
+ 		}
+ 
+ 		return result;
+ 	}
+ 
+ 	private List gatherResources(
+ 		RepositorySetWrapper wrappers,
+ 		List resourceGroups,
+ 		ResourceQuery query) {
+ 		List results = new ArrayList();
+ 
  		ISelector whereClause = query.getWhere();
  
  		if (null == whereClause)
  			whereClause = AllSelector.getInstance();
  		//:TODO: Total Hack, just to allow something...
  		// Rework w/ correct configurable components
***************
*** 109,155 ****
  				Logger.getLog().warn(message, e);
  
! 				result.getNotes().warning(message, e);
! 			}
! 		}
! 
! 		//
! 		// Package the results..
! 		//
! 
! 		if (results.isEmpty())
! 			Logger.getLog().warn(
! 				Messages.getString(MessageConstants.NO_RESOURCES_FOUND));
! 		else {
! 			Logger.getLog().info(
! 				Messages.getString(MessageConstants.RESOURCES_FOUND));
! 
! //			if (Logger.getLog().isDebug()) {
! //				DebugUtils.printSeparator();
! //				DebugUtils.dump("All Results", results);
! //			}
! 			groupBy(result, results, groupBy);
! 
! //			if (Logger.getLog().isDebug()) {
! //				DebugUtils.printSeparator();
! //				DebugUtils.dump("Grouped Results", result);
! //			}
! 
! 			//
! 			// Order the various groups
! 			//
! 			if (null == orderBy)
! 				orderBy =
! 					StandardResourceComparisons
! 						.getNameTypeVersionComparatorSequence();
! 			orderBy(result, orderBy);
! 
! 			if (Logger.getLog().isDebug()) {
! 				DebugUtils.printSeparator();
! 				DebugUtils.dump("Final (Grouped/Ordered) Results", result);
  			}
- 
  		}
  
! 		return result;
  	}
  
--- 160,168 ----
  				Logger.getLog().warn(message, e);
  
! 				//:TODO: result.getNotes().warning(message, e);
  			}
  		}
  
! 		return results;
  	}
  
***************
*** 166,171 ****
  
  		if (null != groupBy) {
! 			SortedSet set = new TreeSet(groupBy);
! 			set.addAll(allResults);
  
  			Resource currentResource = null;
--- 179,188 ----
  
  		if (null != groupBy) {
! 			
! 			// Sort by groupBy, to split into groups
! 			//:TODO: If we sorted by a CominbationComparator
! 			// of groupBy followed by orderBy we'd save a sort,
! 			// no?
! 			Collections.sort(allResults, groupBy);
  
  			Resource currentResource = null;

Index: ResourceQuery.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/query/ResourceQuery.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ResourceQuery.java	9 Oct 2003 14:05:35 -0000	1.3
--- ResourceQuery.java	12 Oct 2003 18:12:05 -0000	1.4
***************
*** 46,51 ****
  	private List m_groups = null;
  
! 	//repository
! 	private RepositorySet m_repositories = null;
  	private RepositorySetSortContext m_repositorySetSortContext = null;
  
--- 46,56 ----
  	private List m_groups = null;
  
! 	// Repository
! 	// :TODO: Hmm, ought repositories be on query at all?
! 	private RepositorySet m_repositorySet = null;
! 	
! 	// :TODO: I'm not sure this ought be on here, I don't think
! 	// how to pick the repositories ought be on the query over
! 	// repositories. I don't know, same w/ above I guess...
  	private RepositorySetSortContext m_repositorySetSortContext = null;
  
***************
*** 67,71 ****
  		m_groups.add(group);
  
! 		m_repositories = repositories;
  		m_where = where;
  		m_groupBy = groupBy;
--- 72,76 ----
  		m_groups.add(group);
  
! 		m_repositorySet = repositories;
  		m_where = where;
  		m_groupBy = groupBy;
***************
*** 98,102 ****
  		m_groups = other.m_groups;
  
! 		m_repositories = other.m_repositories;
  		m_where = other.m_where;
  		m_groupBy = other.m_groupBy;
--- 103,107 ----
  		m_groups = other.m_groups;
  
! 		m_repositorySet = other.m_repositorySet;
  		m_where = other.m_where;
  		m_groupBy = other.m_groupBy;
***************
*** 109,113 ****
  	public ResourceQuery(ResourceQuery other, RepositorySet repositories) {
  		this(other);
! 		m_repositories = repositories;
  	}
  
--- 114,118 ----
  	public ResourceQuery(ResourceQuery other, RepositorySet repositories) {
  		this(other);
! 		m_repositorySet = repositories;
  	}
  
***************
*** 130,134 ****
  	 */
  	public RepositorySet getRepositorySet() {
! 		return m_repositories;
  	}
  
--- 135,139 ----
  	 */
  	public RepositorySet getRepositorySet() {
! 		return m_repositorySet;
  	}
  
***************
*** 158,162 ****
  	 */
  	public void setRepositorySet(RepositorySet set) {
! 		m_repositories = set;
  	}
  
--- 163,167 ----
  	 */
  	public void setRepositorySet(RepositorySet set) {
! 		m_repositorySet = set;
  	}
  
***************
*** 193,197 ****
  			"Repositories: ",
  			verbose,
! 			m_repositories);
  
  		DebugUtils.printSeparator(out, depth + 1);
--- 198,202 ----
  			"Repositories: ",
  			verbose,
! 			m_repositorySet);
  
  		DebugUtils.printSeparator(out, depth + 1);
***************
*** 207,212 ****
  
  		buffer.append("SELECT * FROM ");
! 		if (null != m_repositories) {
! 			buffer.append(m_repositories.getIdentifier());
  		}
  		else {
--- 212,217 ----
  
  		buffer.append("SELECT * FROM ");
! 		if (null != m_repositorySet) {
! 			buffer.append(m_repositorySet.getIdentifier());
  		}
  		else {
***************
*** 235,254 ****
  	 * @return
  	 */
- 	public RepositorySet getRepositories() {
- 		return m_repositories;
- 	}
- 
- 	/**
- 	 * @return
- 	 */
  	public RepositorySetSortContext getRepositorySetSortContext() {
  		return m_repositorySetSortContext;
- 	}
- 
- 	/**
- 	 * @param set
- 	 */
- 	public void setRepositories(RepositorySet set) {
- 		m_repositories = set;
  	}
  
--- 240,245 ----

Index: ResourceResultHelper.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/query/ResourceResultHelper.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ResourceResultHelper.java	2 Oct 2003 23:56:50 -0000	1.2
--- ResourceResultHelper.java	12 Oct 2003 18:12:05 -0000	1.3
***************
*** 4,7 ****
--- 4,8 ----
  package org.krysalis.ruper2.query;
  
+ import java.util.ArrayList;
  import java.util.Comparator;
  import java.util.Iterator;
***************
*** 43,48 ****
  		List list = null;
  
! 		if (!result.isEmpty())
! 			list = (List) result.get(0);
  
  		return list;
--- 44,98 ----
  		List list = null;
  
! 		int size = result.size();
! 
! 		if (0 != size) {
! 			// Return the 'last' list, since the normal 
! 			// order sort will put 'best' last.
! 			list = (List) result.get(size - 1);
! 		}
! 
! 		return list;
! 	}
! 	
! 	/**
! 	 * Get contents of all lists but last one (the 'best')
! 	 *  
! 	 * @param result
! 	 * @return
! 	*/
! 	public static List getRemainderResources(ResourceResult result) {
! 		List list = new ArrayList();
! 
! 		// Return contents of all, but last..
! 		List lists = getRemainderResourceLists(result);
! 
! 		for (Iterator j = lists.iterator(); j.hasNext();) {
! 			List resources = (List) j.next();
! 
! 			for (Iterator i = resources.iterator(); i.hasNext();) {
! 				list.add(i.next());
! 			}
! 		}
! 
! 		return list;
! 	}
! 
! 	/**
! 	 * Get all lists but last one (the 'best')
! 	 *  
! 	 * @param result
! 	 * @return
! 	 */
! 	public static List getRemainderResourceLists(ResourceResult result) {
! 		List list = new ArrayList();
! 
! 		int size = result.size();
! 
! 		if (0 != size) {
! 			// Return contents of all, but last..
! 			for (int j = 0; j < (size - 1); ++j) {
! 				list.add(result.get(j));
! 			}
! 		}
  
  		return list;




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.