org.ow2.dragon.service.uddi.query.FindBindingQueryHelper Maven / Gradle / Ivy
/**
* Dragon - SOA Governance Platform.
* Copyright (c) 2009 EBM Websourcing, http://www.ebmwebsourcing.com/
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* -------------------------------------------------------------------------
* FindBindingQueryHelper.java
* -------------------------------------------------------------------------
*/
package org.ow2.dragon.service.uddi.query;
import java.util.Set;
import org.ow2.dragon.persistence.bo.common.CategoryBag;
import org.ow2.dragon.persistence.bo.deployment.Endpoint;
import org.ow2.dragon.service.uddi.FindQualifiers;
import org.ow2.dragon.util.StringHelper;
import com.trg.search.Filter;
import com.trg.search.IMutableSearch;
import com.trg.search.Search;
/**
* @author ofabre - ebmwebsourcing
*
*/
public class FindBindingQueryHelper extends CommonQueryHelper {
public static IMutableSearch constructFindBindingSearch(FindQualifiers findQualifiers,
CategoryBag dragonCategoryBag, Set tModelKeys, String serviceKey, Paging paging) {
Class searchedType = Endpoint.class;
Search searchQuery = createDistinctSearch(searchedType);
// Add service key filter
if (!StringHelper.isNullOrEmpty(serviceKey)) {
searchQuery.addFilter(createServiceKeyFilter(serviceKey));
}
// Add category filters
if (dragonCategoryBag != null) {
searchQuery.addFilter(createCategoryBagFilter(findQualifiers, dragonCategoryBag));
}
// Add tmodel keys filters
if (tModelKeys != null) {
searchQuery.addFilter(createTModelKeysFilter(findQualifiers, tModelKeys, null,
new String[] { "binding.serviceSpecifications", "binding.protocols",
"binding.transports" }));
}
// Add sort options
addSortOptions(searchedType, searchQuery, findQualifiers);
// Add paging options
addPagingOptions(searchQuery, paging);
return searchQuery;
}
private static Filter createServiceKeyFilter(String serviceKey) {
return Filter.equal("technicalService.id", serviceKey);
}
}