/* * Copyright (C) 2005-2009 Alfresco Software Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program 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 General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * As a special exception to the terms and conditions of version 2.0 of * the GPL, you may redistribute this Program in connection with Free/Libre * and Open Source Software ("FLOSS") applications as described in Alfresco's * FLOSS exception. You should have recieved a copy of the text describing * the FLOSS exception, and it is also available here: * http://www.alfresco.com/legal/licensing" */ package org.alfresco.repo.domain.propval; import java.io.Serializable; import java.util.Date; import java.util.List; import org.alfresco.repo.domain.CrcHelper; import org.alfresco.util.Pair; /** * DAO services for alf_prop_XXX tables. * * @author Derek Hulley * @since 3.2 */ public interface PropertyValueDAO { //================================ // 'alf_prop_class' accessors //================================ /** * alf_prop_class accessor * * @param id the ID (may not be null) */ Pair> getPropertyClassById(Long id); /** * alf_prop_class accessor * * @param value the value to find the ID for (may not be null) */ Pair> getPropertyClass(Class value); /** * alf_prop_class accessor * * @param value the value to find the ID for (may not be null) */ Pair> getOrCreatePropertyClass(Class value); //================================ // 'alf_prop_date_value' accessors //================================ /** * alf_prop_date_value accessor * * @param id the ID (may not be null) */ Pair getPropertyDateValueById(Long id); /** * alf_prop_date_value accessor * * @param value the value to find the ID for (may not be null) */ Pair getPropertyDateValue(Date value); /** * alf_prop_date_value accessor * * @param value the value to find the ID for (may not be null) */ Pair getOrCreatePropertyDateValue(Date value); //================================ // 'alf_prop_string_value' accessors //================================ /** * Utility method to get query parameters for case-sensitive string searching * @see CrcHelper */ Pair getPropertyStringCaseSensitiveSearchParameters(String value); /** * alf_prop_string_value accessor * * @param id the ID (may not be null) */ Pair getPropertyStringValueById(Long id); /** * alf_prop_string_value accessor * * @param value the value to find the ID for (may not be null) */ Pair getPropertyStringValue(String value); /** * alf_prop_string_value accessor * * @param value the value to find the ID for (may not be null) */ Pair getOrCreatePropertyStringValue(String value); //================================ // 'alf_prop_double_value' accessors //================================ /** * alf_prop_double_value accessor * * @param id the ID (may not be null) */ Pair getPropertyDoubleValueById(Long id); /** * alf_prop_double_value accessor * * @param value the value to find the ID for (may not be null) */ Pair getPropertyDoubleValue(Double value); /** * alf_prop_double_value accessor * * @param value the value to find the ID for (may not be null) */ Pair getOrCreatePropertyDoubleValue(Double value); //================================ // 'alf_prop_serializable_value' accessors //================================ /** * alf_prop_serializable_value accessor * * @param id the ID (may not be null) */ Pair getPropertySerializableValueById(Long id); /** * alf_prop_serializable_value accessor * * @param value the value to find the ID for (may not be null) */ Pair createPropertySerializableValue(Serializable value); //================================ // 'alf_prop_value' accessors //================================ /** * alf_prop_value accessor: get a property based on the database ID * * @param id the ID (may not be null) */ Pair getPropertyValueById(Long id); /** * alf_prop_value accessor: find a property based on the value * * @param value the value to find the ID for (may be null) */ Pair getPropertyValue(Serializable value); /** * alf_prop_value accessor: find or create a property based on the value. * Note: This method will not recurse into maps or collections. Use the * dedicated methods if you want recursion; otherwise maps and collections will * be serialized and probably stored as BLOB values. *

* All collections and maps will be opened up to any depth. To limit this behaviour, * use {@link #getOrCreatePropertyValue(Serializable, int)}. * * @param value the value to find the ID for (may be null) */ Pair getOrCreatePropertyValue(Serializable value); /** * alf_prop_value accessor: find or create a property based on the value. * Note: This method will not recurse into maps or collections. Use the * dedicated methods if you want recursion; otherwise maps and collections will * be serialized and probably stored as BLOB values. *

* Max depth examples (there is no upper limit): *

    *
  • 0: don't expand the value if it's a map or collection
  • *
  • 1: open the value up if it is a map or collection but don't do any more
  • *
  • ...
  • *
  • 10: open up 10 levels of maps or collections
  • *
* All collections that are not opened up will be serialized unless there is a * custom {@link PropertyTypeConverter converter} which can serialize it in an * alternative format. * * @param value the value to find the ID for (may be null) * @param maxDepth the maximum depth of collections and maps to iterate into */ Pair getOrCreatePropertyValue(Serializable value, int maxDepth); /** * Utility method to convert property query results into the original value. Note * that the rows must all share the same root property ID. *

* If the rows passed in don't constitute a valid, full property - they don't contain all * the link entities for the property - then the result may be null. * * @param rows the search results for a single root property * @return Returns the root property as originally persisted, or null * if the rows don't represent a complete property * @throws IllegalArgumentException if rows don't all share the same root property ID */ Serializable convertPropertyIdSearchRows(List rows); }