package gw.product uses gw.api.database.IQueryBeanResult uses gw.api.database.Query uses gw.api.effdate.EffDatedFinderUtil uses gw.search.EntitySearchCriteria uses java.util.Date @Export class IndustryCodeSearchCriteria extends EntitySearchCriteria { var _code : String as Code var _previousCode : String as PreviousCode var _classification : String as Classification var _effectiveOnDate : Date as EffectiveOnDate var _domain : IndustryCodeType as Domain construct(domain : IndustryCodeType, refDate : Date, prevIndCode : IndustryCode) { _domain = domain _effectiveOnDate = refDate _previousCode = prevIndCode.Code } override protected function doSearch() : IQueryBeanResult { var query = constructBaseQuery() if (Code != null) { query.startsWith("Code", Code, true) } if (EffectiveOnDate != null) { EffDatedFinderUtil.addRestrictionsForEffectiveOnDate(query, EffectiveOnDate) } // don't need to do union if it's searching for specific code and the code is not previous code if (PreviousCode != null and (Code == null || PreviousCode.startsWith(Code))) { return query.union(getPreviousSelectedIndustryCode()).select() } return query.select() } function constructBaseQuery() : Query { var q = Query.make(IndustryCode) if (Domain != null) { q.compare("Domain", Equals, Domain) } if (Classification != null) { q.contains("Classification", Classification, true) } return q } function getPreviousSelectedIndustryCode() : Query { var query = constructBaseQuery() if (PreviousCode != null) { query.compare("Code", Equals, PreviousCode) } return query } override protected property get InvalidSearchCriteriaMessage() : String { return null } override protected property get MinimumSearchCriteriaMessage() : String { return null } }