1 23 package org.apache.slide.store.impl.rdbms.expression; 24 25 import java.util.Collection ; 26 import java.util.Iterator ; 27 28 import org.apache.slide.search.BadQueryException; 29 import org.apache.slide.search.SearchException; 30 import org.apache.slide.search.basic.IBasicExpression; 31 import org.apache.slide.search.basic.IBasicResultSet; 32 33 35 public class RDBMSMergeExpression extends RDBMSExpression { 36 37 private final String _name; 38 private final String _namespace; 39 private final Collection _rdbmsExpressions; 40 private final Collection _otherExpressions; 41 42 public RDBMSMergeExpression(String name, 43 String namespace, 44 RDBMSQueryContext context, 45 Collection rdbmsExpressions, 46 Collection otherExpressions) throws BadQueryException { 47 super(context); 48 _name = name; 49 _namespace = namespace; 50 _rdbmsExpressions = rdbmsExpressions; 51 _otherExpressions = otherExpressions; 52 } 53 54 public IBasicResultSet execute() throws SearchException { 55 return compile(null); 56 } 57 58 protected IBasicResultSet compile(RDBMSMergeExpression expression) throws SearchException { 59 if (_rdbmsExpressions != null && _rdbmsExpressions.size() > 0) { 60 _context.criteria().add(" ( "); 61 Iterator iter = _rdbmsExpressions.iterator(); 62 while (iter.hasNext()) { 63 ((RDBMSExpression) iter.next()).compile(this); 64 if (iter.hasNext()) { 65 _context.criteria().add(" " + _name + " "); 66 } 67 } 68 _context.criteria().add(" ) "); 69 } 70 if (_otherExpressions != null) { 71 IBasicExpression merger = _factory.createStandardMergeExpression( 72 _name, _namespace, _otherExpressions); 73 return merger.execute(); 74 } 75 return _context.results(); 76 } 77 78 protected String getName() { 79 return _name; 80 } 81 82 protected Collection getRDBMSExpressions() { 83 return _rdbmsExpressions; 84 } 85 86 } | Popular Tags |