Coverage report

  %line %branch
org.apache.portals.graffito.jcr.query.impl.QueryManagerImpl
0% 
0% 

 1  
 /*
 2  
  * Copyright 2004-2005 The Apache Software Foundation or its licensors,
 3  
  *                     as applicable.
 4  
  *
 5  
  * Licensed under the Apache License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.portals.graffito.jcr.query.impl;
 18  
 
 19  
 import java.util.Map;
 20  
 
 21  
 import org.apache.portals.graffito.jcr.mapper.Mapper;
 22  
 import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
 23  
 import org.apache.portals.graffito.jcr.query.Filter;
 24  
 import org.apache.portals.graffito.jcr.query.Query;
 25  
 import org.apache.portals.graffito.jcr.query.QueryManager;
 26  
 
 27  
 public class QueryManagerImpl implements QueryManager
 28  
 {
 29  
 
 30  
 	private Mapper mapper;
 31  
 	private Map atomicTypeConverters;
 32  
 	public QueryManagerImpl(Mapper mapper,  Map atomicTypeConverters)
 33  0
 	{
 34  0
 		this.mapper = mapper;
 35  0
 		this.atomicTypeConverters = atomicTypeConverters;
 36  0
 	}
 37  
 	
 38  
 	public Filter createFilter(Class classQuery) 
 39  
 	{
 40  
 
 41  0
 		return new FilterImpl(mapper.getClassDescriptor(classQuery), atomicTypeConverters, classQuery);
 42  
 	}
 43  
 
 44  
 	public Query createQuery(Filter filter)
 45  
 	{
 46  
 
 47  0
 		return new QueryImpl(filter, mapper);
 48  
 	}
 49  
 
 50  
 	public String buildJCRExpression(Query query)
 51  
 	{
 52  
 
 53  0
 		Filter filter = query.getFilter();
 54  
 					
 55  0
 		String jcrExp = "";
 56  
 		
 57  
 		// Add scope
 58  0
 		if ((filter.getScope() != null && ( ! filter.getScope().equals(""))))
 59  
 		{
 60  0
 			jcrExp +=  "/jcr:root" + filter.getScope() + "element(*, ";
 61  
 		}
 62  
 		else
 63  
 		{
 64  0
 			jcrExp +=  "//element(*, ";
 65  
 		}
 66  
 		
 67  
 		// Add node type
 68  0
 		jcrExp +=  this.getNodeType(filter) + ") ";
 69  
 
 70  
         // Add filter criteria
 71  0
 		String filterExp = ((FilterImpl)filter).getJcrExpression();
 72  0
 		if ((filterExp != null) && ( ! filterExp.equals("")))
 73  
 		{
 74  0
 		    jcrExp += "[" + filterExp + "]";
 75  
 		}
 76  
 		
 77  
 		// Add order by
 78  0
 		jcrExp += ((QueryImpl)query).getOrderByExpression();
 79  
 		
 80  0
 		return jcrExp;
 81  
 		 
 82  
 	}
 83  
 	
 84  
 	private String getNodeType(Filter filter)
 85  
 	{
 86  0
 		ClassDescriptor classDescriptor = mapper.getClassDescriptor(filter.getFilterClass());
 87  0
 		return classDescriptor.getJcrNodeType();
 88  
 		
 89  
 	}
 90  
 
 91  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.