ruper2/src/java/core/org/krysalis/ruper/query ResourceResultHelper.java,NONE,1.1 ResourceResult.java,1.5,1.6 ResourceQuery.java,1.4,1.5

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

Modified Files:
	ResourceResult.java ResourceQuery.java 
Added Files:
	ResourceResultHelper.java 
Log Message:
Renamced <update to <synchronize

--- NEW FILE: ResourceResultHelper.java ---
/*
 * Created on Aug 23, 2003
 */
package org.krysalis.ruper.query;

import java.util.Comparator;
import java.util.List;

import org.krysalis.ruper.resource.Resource;

/**
 * @author arb_jack
 *
 * A ResourceResultHelper.
 *  
 */
public class ResourceResultHelper {

	public static boolean noResult(ResourceResult result) {
		return (
			(null != result)
				&& !result.isEmpty()
				&& !getResourceList(result).isEmpty());
	}

	public static List getResourceList(ResourceResult result) {
		List list = null;

		if (!result.isEmpty())
			list = (List) result.get(0);

		return list;
	}

	// Two results sets compare based off the comparison of their first
	// entry (of their first list)
	public static int compareTo(
		ResourceResult result1,
		ResourceResult result2,
		Comparator comp) {
		int comparison = 0;

		List list1 = ResourceResultHelper.getResourceList(result1);
		List list2 = ResourceResultHelper.getResourceList(result2);

		if (null != list1) {
			if (null != list2) {

				if (!list1.isEmpty()) {
					if (!list2.isEmpty()) {

						//:TODO: Hmm ... sort w/ comp?

						Resource resource1 = (Resource) list1.get(0);
						Resource resource2 = (Resource) list2.get(0);

						comparison = comp.compare(resource1, resource2);
					}
					else
						comparison = 1;
				}
				else if (!list2.isEmpty())
					comparison = -1;
			}
			else
				comparison = 1;
		}
		else if (null != list2)
			comparison = -1;

		return comparison;
	}
}

Index: ResourceResult.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper/query/ResourceResult.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ResourceResult.java	8 Sep 2003 23:21:40 -0000	1.5
--- ResourceResult.java	11 Sep 2003 23:34:39 -0000	1.6
***************
*** 5,8 ****
--- 5,11 ----
  
  import java.util.ArrayList;
+ import java.util.Collection;
+ 
+ import org.krysalis.version.util.note.AnnotationScratchpad;
  
  /**
***************
*** 13,15 ****
--- 16,78 ----
   */
  public class ResourceResult extends ArrayList {
+ 
+ 	public boolean m_successful = true;
+ 	public AnnotationScratchpad m_notes = null;
+ 
+ 	/**
+ 	 * 
+ 	 */
+ 	public ResourceResult() {
+ 		super();
+ 		classInit();
+ 	}
+ 
+ 	/**
+ 	 * @param arg0
+ 	 */
+ 	public ResourceResult(int arg0) {
+ 		super(arg0);
+ 		classInit();
+ 	}
+ 
+ 	/**
+ 	 * @param arg0
+ 	 */
+ 	public ResourceResult(Collection arg0) {
+ 		super(arg0);
+ 		classInit();
+ 	}
+ 
+ 	private void classInit() {
+ 		m_notes = new AnnotationScratchpad();
+ 	}
+ 
+ 	/**
+ 	 * @return
+ 	 */
+ 	public AnnotationScratchpad getNotes() {
+ 		return m_notes;
+ 	}
+ 
+ 	/**
+ 	 * @return
+ 	 */
+ 	public boolean isSuccessful() {
+ 		return m_successful;
+ 	}
+ 
+ 	/**
+ 	 * @param scratchpad
+ 	 */
+ 	public void setNotes(AnnotationScratchpad scratchpad) {
+ 		m_notes = scratchpad;
+ 	}
+ 
+ 	/**
+ 	 * @param b
+ 	 */
+ 	public void setSuccessful(boolean b) {
+ 		m_successful = b;
+ 	}
+ 
  }

Index: ResourceQuery.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper/query/ResourceQuery.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ResourceQuery.java	11 Sep 2003 17:03:31 -0000	1.4
--- ResourceQuery.java	11 Sep 2003 23:34:39 -0000	1.5
***************
*** 66,69 ****
--- 66,91 ----
  		m_orderBy = orderBy;
  	}
+ 	
+ 	//
+ 	// :TODO: Nice if we could make queries referenceable
+ 	// to allow re-use (especially for the more generic) 
+ 	//
+ 	public ResourceQuery(ResourceQuery other) {
+ 		m_groups = other.m_groups;
+ 
+ 		m_repositories = other.m_repositories;
+ 		m_where = other.m_where;
+ 		m_groupBy = other.m_groupBy;
+ 		m_orderBy = other.m_orderBy;
+ 	}
+ 
+ 	//
+ 	// Same query, different repositories 
+ 	//
+ 	public ResourceQuery(ResourceQuery other, RepositorySet repositories) {
+ 		this(other);
+ 
+ 		m_repositories = repositories;
+ 	}
  
  	/**




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
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.