package performa.search;

import oneit.objstore.*;
import oneit.objstore.rdbms.filters.*;
import performa.orm.*;

public class SearchMessageTemplate extends BaseSearchMessageTemplate
{
    private static final long serialVersionUID = 0L;
    
    // This constructor should not be called
    public SearchMessageTemplate ()
    {
        // Do not add any code to this, always put it in initialiseNewObject
    }

    @Override
    public BaseBusinessClass[] doSearch()
    {
        BaseMessageTemplate.SearchAll searchByAll = MessageTemplate.SearchByAll();
        
        if (isTrue(getOnlyGlobalTemplate()))
        {
            return searchByAll.andIsGlobalTemplate(new EqualsFilter<>(Boolean.TRUE)).search(getTransaction());
        }
        
        return searchByAll.andIsGlobalTemplate(new IsNotNullFilter<>()).search(getTransaction());
    }
}