org.sakaiproject.entitybroker.dao.impl.EntityBrokerDaoImpl Maven / Gradle / Ivy
The newest version!
/**
* $Id$
* $URL$
* EntityBrokerDaoImpl.java - entity-broker - Apr 15, 2008 4:29:18 PM - azeckoski
**************************************************************************
* Copyright (c) 2007, 2008 The Sakai Foundation
*
* Licensed under the Educational Community License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.opensource.org/licenses/ECL-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sakaiproject.entitybroker.dao.impl;
import java.util.ArrayList;
import java.util.List;
import org.sakaiproject.entitybroker.dao.EntityBrokerDao;
import org.sakaiproject.entitybroker.dao.EntityProperty;
import org.sakaiproject.entitybroker.dao.EntityTagApplication;
import org.sakaiproject.genericdao.api.mappers.NamesRecord;
import org.sakaiproject.genericdao.api.mappers.StatementMapper;
import org.sakaiproject.genericdao.api.search.Restriction;
import org.sakaiproject.genericdao.api.search.Search;
import org.sakaiproject.genericdao.springjdbc.JdbcGeneralGenericDao;
import org.sakaiproject.genericdao.util.JDBCUtils.QueryData;
/**
* Internal dao for entity broker internal services
*
* @author Aaron Zeckoski ([email protected])
*/
public class EntityBrokerDaoImpl extends JdbcGeneralGenericDao implements EntityBrokerDao {
/**
* Get a list of unique entity references for a set of search params, all lists must be the same
* size
*
* @param properties
* the persistent object properties
* @param values
* the values to match against the properties
* @param comparisons
* the type of comparisons to make between property and value
* @param relations
* the relation to the previous search param (must be "and" or "or") - note that the
* first relation is basically thrown away
* @return a list of unique {@link String}s which represent entity references
*/
@SuppressWarnings("unchecked")
public List getEntityRefsForSearch(List properties, List values,
List comparisons, List relations) {
if (properties.size() != values.size() || values.size() != comparisons.size()
|| comparisons.size() != relations.size() || properties.isEmpty()) {
throw new IllegalArgumentException(
"properties and values and comparisons must be the same size and not empty");
}
NamesRecord nr = getNamesRecord(EntityProperty.class);
String entityRefColumn = nr.getColumnForProperty("entityRef");
List