final Collection conditionValues = new HashSet();
final CannedQuery[] queries = queryFeature.getQueries();
for( int i = 0; i < queries.length; i++ )
{
final CannedQuery query = queries[ i ];
for( Iterator iterator = query.getMetaQueryFields().iterator(); iterator.hasNext(); )
{
final MetaQueryField queryField = (MetaQueryField)iterator.next();
final String fieldValue = queryField.getValue();
if( fieldValue.length() > 0 )
{
conditionValues.add( getCondition( normaliseQueryContext( query.getSchemaContext() ), queryField.getName(), null, fieldValue ) );
}
}
for( Iterator iterator = query.getQueryFields().iterator(); iterator.hasNext(); )
{
final QueryField queryField = (QueryField)iterator.next();
final DataFieldModel dataFieldModel = queryField.getEditFieldModel();
final String fieldValue = queryField.getValue();
if( fieldValue.length() > 0 )
{
conditionValues.add( getCondition( normaliseQueryContext( query.getSchemaContext() ), dataFieldModel.isAttribute() ? asAttribute( queryField.getName() ) : queryField.getName(), queryField.getOperator(), fieldValue ) );
}
}
}
final Collection returnValues = new HashSet();
final QueryResult[] queryResultTemplates = queryFeature.getQueryResultTemplates();
for( int i = 0; i < queryResultTemplates.length; i++ )
{
final QueryResult queryResult = queryResultTemplates[ i ];
RecordModel recordModel = queryResult.getRecordModel();
if( recordModel == null )
{
recordModel= recordModelFactory.createRecordModel( queryResult.getRecordClassName() );
}
final Collection editFields = recordModel.getEditFields();
for( Iterator iterator = editFields.iterator(); iterator.hasNext(); )
{
final DataFieldModel dataFieldModel = (DataFieldModel)iterator.next();
if( dataFieldModel.isAttribute() )
{
returnValues.add( stripAttribute( SEPARATOR + normaliseQueryContext( queryResult.getSchemaContext() ) + SEPARATOR + dataFieldModel.getName() ) );
}
else
{
returnValues.add( SEPARATOR + normaliseQueryContext( queryResult.getSchemaContext() ) + SEPARATOR + dataFieldModel.getName() );
}
}
}
final StringBuffer query = ( isTamino ) ? new StringBuffer( "declare namespace tf=\"http://namespaces.softwareag.com/tamino/TaminoFunction\" " ) : new StringBuffer(); //$NON-NLS-1$;
query.append( generateQuery( conditionValues, returnValues ) );
return query.toString();
}