(QueryImpl) context.getRule() );
}
if ( rce == null ) {
// look up the query in the current package
RuleImpl rule = context.getPkg().getRule( patternDescr.getObjectType() );
if ( rule instanceof QueryImpl ) {
// it's a query so delegate to the QueryElementBuilder
QueryElementBuilder qeBuilder = QueryElementBuilder.getInstance();
rce = qeBuilder.build( context,
descr,
prefixPattern,
(QueryImpl) rule );
}
}
if ( rce == null ) {
// the query may have been imported, so try package imports
for ( String importName : context.getDialect().getTypeResolver().getImports() ) {
importName = importName.trim();
int pos = importName.indexOf( '*' );
if ( pos >= 0 ) {
String pkgName = importName.substring( 0,
pos - 1 );
PackageRegistry pkgReg = context.getKnowledgeBuilder().getPackageRegistry( pkgName );
if ( pkgReg != null ) {
RuleImpl rule = pkgReg.getPackage().getRule( patternDescr.getObjectType() );
if ( rule instanceof QueryImpl) {
// it's a query so delegate to the QueryElementBuilder
QueryElementBuilder qeBuilder = QueryElementBuilder.getInstance();
rce = qeBuilder.build( context,
descr,