db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/query AbstractCriterion.java Criteria.java SelectionCriteria.java IdentityCriterion.java Criterion.java
Date Wed, 22 Sep 2004 20:18:55 GMT
brj         2004/09/22 13:18:54

  Modified:    src/java/org/apache/ojb/broker/query AbstractCriterion.java
                        Criteria.java SelectionCriteria.java
                        IdentityCriterion.java Criterion.java
  Log:
  minor refactorings in alias handling
  
  Revision  Changes    Path
  1.2       +1 -39     db-ojb/src/java/org/apache/ojb/broker/query/AbstractCriterion.java
  
  Index: AbstractCriterion.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/AbstractCriterion.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractCriterion.java	15 Sep 2004 17:18:44 -0000	1.1
  +++ AbstractCriterion.java	22 Sep 2004 20:18:53 -0000	1.2
  @@ -27,9 +27,6 @@
   	// holds the path segment(s) to which the alias applies
   	private UserAlias m_userAlias = null;
   
  -	// optional alias
  -	private String m_alias = null;
  -
   	private Criterion m_parentCriterion = null;
   
       /**
  @@ -64,31 +61,6 @@
           return m_userAlias;
       }
   
  -    /**
  -     * @see org.apache.ojb.broker.query.Criterion#getAlias()
  -     */
  -    public String getAlias()
  -    {
  -        return m_alias;
  -    }
  -
  -    /**
  -     * Sets the alias. an empty String is regarded as null.
  -     * @param alias
  -     */
  -    public Criterion setAlias(String alias)
  -    {
  -		if (alias == null || alias.trim().equals(""))
  -		{
  -			m_alias = null;
  -		}
  -		else
  -		{    
  -		    m_alias = alias;
  -		}    
  -		
  -		return this;
  -    }
   
       /**
        * Sets the alias using a userAlias object. 
  @@ -97,16 +69,6 @@
       public Criterion setAlias(UserAlias userAlias)
       {
       	m_userAlias = userAlias;
  -    	
  -    	if (userAlias != null)
  -    	{
  -    	    m_alias = userAlias.getName();
  -    	}
  -    	else
  -    	{
  -    	    m_alias = null;
  -    	}
  -    	
       	return this;
       }	
   
  
  
  
  1.50      +40 -9     db-ojb/src/java/org/apache/ojb/broker/query/Criteria.java
  
  Index: Criteria.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/Criteria.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- Criteria.java	15 Sep 2004 17:18:44 -0000	1.49
  +++ Criteria.java	22 Sep 2004 20:18:53 -0000	1.50
  @@ -71,6 +71,8 @@
       private List m_groupby = null;
       private List m_prefetchedRelationships = null;
   
  +	// optional alias
  +	private String m_alias = null;
   	// an aliasPath to be used for this criteria
   	private String m_aliasPath = null;
   
  @@ -1071,20 +1073,44 @@
   	}
   
   
  +    /**
  +     * @see org.apache.ojb.broker.query.Criterion#getAlias()
  +     */
  +    public String getAlias()
  +    {
  +        return m_alias;
  +    }
  +
  +    /**
  +     * Sets the alias. an empty String is regarded as null.
  +     * @param alias
  +     */
  +    private void _setAlias(String alias)
  +    {
  +		if (alias == null || alias.trim().equals(""))
  +		{
  +			m_alias = null;
  +		}
  +		else
  +		{    
  +		    m_alias = alias;
  +		}    
  +    }
  +	
   	/**
   	 * Sets the alias. Empty String is regarded as null.
   	 * @param alias The alias to set
   	 */
   	public Criterion setAlias(String alias)
   	{
  -	    super.setAlias(alias);
  +	    _setAlias(alias);
   
   		// propagate to SelectionCriteria,not to Criteria
   		for (int i = 0; i < m_criteria.size(); i++)
   		{
  -			if (!(m_criteria.get(i) instanceof Criteria))
  +			if ((m_criteria.get(i) instanceof SelectionCriteria))
   			{
  -				((SelectionCriteria) m_criteria.get(i)).setAlias(getAlias());
  +				((SelectionCriteria) m_criteria.get(i)).setAlias(alias);
   			}
   		}
   		
  @@ -1098,16 +1124,16 @@
   	 */
   	public Criterion setAlias(String alias, String aliasPath)
   	{
  -	    super.setAlias(alias);
  -
  +	    _setAlias(alias);
  +	    
   		m_aliasPath = aliasPath;
   
   		// propagate to SelectionCriteria,not to Criteria
   		for (int i = 0; i < m_criteria.size(); i++)
   		{
  -			if (!(m_criteria.get(i) instanceof Criteria))
  +			if ((m_criteria.get(i) instanceof SelectionCriteria))
   			{
  -				((SelectionCriteria) m_criteria.get(i)).setAlias(getAlias(), aliasPath);
  +				((SelectionCriteria) m_criteria.get(i)).setAlias(alias, aliasPath);
   			}
   		}
           return this;
  @@ -1120,11 +1146,16 @@
   	public Criterion setAlias(UserAlias userAlias)
   	{
   	    super.setAlias(userAlias);
  +	    
  +	    if (userAlias != null)
  +	    {
  +	        _setAlias(userAlias.getName());
  +	    }
   
   		// propagate to SelectionCriteria,not to Criteria
   		for (int i = 0; i < m_criteria.size(); i++)
   		{
  -			if (!(m_criteria.get(i) instanceof Criteria))
  +			if ((m_criteria.get(i) instanceof SelectionCriteria))
   			{
   				((SelectionCriteria) m_criteria.get(i)).setAlias(userAlias);
   			}
  
  
  
  1.20      +2 -3      db-ojb/src/java/org/apache/ojb/broker/query/SelectionCriteria.java
  
  Index: SelectionCriteria.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/SelectionCriteria.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- SelectionCriteria.java	15 Sep 2004 17:18:44 -0000	1.19
  +++ SelectionCriteria.java	22 Sep 2004 20:18:54 -0000	1.20
  @@ -265,9 +265,8 @@
       public Criterion setAlias(String alias)
       {
       	String attributePath = (String)getAttribute();
  -    	boolean allPathsAliased = true;
   
  -    	setAlias(new UserAlias(alias, attributePath, allPathsAliased));
  +    	setAlias(new UserAlias(alias, attributePath, true));
       	
       	return this;
       }
  
  
  
  1.2       +2 -2      db-ojb/src/java/org/apache/ojb/broker/query/IdentityCriterion.java
  
  Index: IdentityCriterion.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/IdentityCriterion.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IdentityCriterion.java	15 Sep 2004 17:18:44 -0000	1.1
  +++ IdentityCriterion.java	22 Sep 2004 20:18:54 -0000	1.2
  @@ -138,7 +138,7 @@
           for (int i = 0;i < pkFields.length; i++)
           {
               String pkAttribute = attribute + pkFields[i].getAttributeName();
  -    		ValueCriteria c = new ValueCriteria(pkAttribute, pkValues[i], getClause(), getAlias());
  +    		ValueCriteria c = new ValueCriteria(pkAttribute, pkValues[i], getClause(), getUserAlias());
       		
       		c.setParentCriterion(getParentCriterion()); // set the parent
       		crits.add(c);
  
  
  
  1.2       +1 -8      db-ojb/src/java/org/apache/ojb/broker/query/Criterion.java
  
  Index: Criterion.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/Criterion.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Criterion.java	15 Sep 2004 17:18:44 -0000	1.1
  +++ Criterion.java	22 Sep 2004 20:18:54 -0000	1.2
  @@ -75,13 +75,6 @@
   	public UserAlias getUserAlias();
   
   	/**
  -	 * Get the Alias for this Criterion.
  -	 * 
  -	 * @return String
  -	 */
  -	public String getAlias();
  -
  -	/**
   	 * Sets the alias. Empty String is regarded as null.
   	 * @param alias The alias to set
   	 */
  
  
  

---------------------------------------------------------------------
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