import java.util.Set;\r
import java.util.UUID;\r
\r
+import org.hibernate.LockMode;\r
import org.hibernate.Session;\r
-import org.springframework.transaction.annotation.Propagation;\r
-import org.springframework.transaction.annotation.Transactional;\r
+import org.springframework.security.core.Authentication;\r
\r
import eu.etaxonomy.cdm.api.service.pager.Pager;\r
-import eu.etaxonomy.cdm.model.common.CdmBase;\r
-import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
-import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
+import eu.etaxonomy.cdm.model.common.ICdmBase;\r
+import eu.etaxonomy.cdm.permission.CdmPermission;\r
import eu.etaxonomy.cdm.persistence.dao.BeanInitializer;\r
import eu.etaxonomy.cdm.persistence.query.Grouping;\r
import eu.etaxonomy.cdm.persistence.query.OrderHint;\r
*\r
* @param <T>\r
*/\r
-@Transactional(propagation=Propagation.SUPPORTS, readOnly=true)\r
-public interface IService<T extends CdmBase>{\r
+public interface IService<T extends ICdmBase>{\r
\r
// FIXME what does this method do?\r
-// @Transactional(readOnly=false)\r
public void clear();\r
-\r
+ \r
+ /**\r
+ * Obtain the specified lock mode on the given object t\r
+ */\r
+ public void lock(T t, LockMode lockMode);\r
+ \r
+ /**\r
+ * Refreshes a given object t using the specified lockmode\r
+ * \r
+ * All bean properties given in the <code>propertyPaths</code> parameter are recursively initialized.\r
+ * <p>\r
+ * For detailed description and examples <b>please refer to:</b> \r
+ * {@link BeanInitializer#initialize(Object, List)}\r
+ * \r
+ * NOTE: in the case of lockmodes that hit the database (e.g. LockMode.READ), you will need to re-initialize\r
+ * child propertiesto avoid a HibernateLazyInitializationException (even if the properties of the child \r
+ * were initialized prior to the refresh).\r
+ * \r
+ * @param t\r
+ * @param lockMode\r
+ */\r
+ public void refresh(T t, LockMode lockMode, List<String> propertyPaths);\r
\r
/**\r
* Returns a count of all entities of type <T> optionally restricted\r
* @param persistentObject the object to be deleted\r
* @return the unique identifier of the deleted entity\r
*/\r
- @Transactional(readOnly=false)\r
public UUID delete(T persistentObject);\r
\r
/**\r
* @param transientObject the entity to be merged\r
* @return The unique identifier of the persisted entity\r
*/\r
- @Transactional(readOnly=false)\r
public UUID merge(T transientObject);\r
\r
/**\r
* @param persistentObject the object to be refreshed\r
* @return the unique identifier\r
*/\r
- @Transactional(readOnly=false)\r
public UUID refresh(T persistentObject);\r
\r
public List<T> rows(String tableName, int limit, int start);\r
* @return A Map containing the new entities, keyed using the generated UUID's\r
* of those entities\r
*/\r
- @Transactional(readOnly=false)\r
public Map<UUID,T> save(Collection<T> newInstances); \r
\r
/**\r
* @param newInstance the new entity to be persisted\r
* @return A generated UUID for the new persistent entity\r
*/\r
- @Transactional(readOnly=false)\r
public UUID save(T newInstance);\r
\r
/**\r
* @param transientObject the entity to be persisted\r
* @return The unique identifier of the persisted entity\r
*/\r
- @Transactional(readOnly=false)\r
public UUID saveOrUpdate(T transientObject);\r
\r
+ /**\r
+ * Save new entities or update the persistent state of existing \r
+ * transient entities that have been persisted previously\r
+ * \r
+ * @param transientObjects the entities to be persisted\r
+ * @return The unique identifier of the persisted entity\r
+ */\r
+ public Map<UUID,T> saveOrUpdate(Collection<T> transientObjects);\r
+ \r
/**\r
* Update the persistent state of an existing transient entity \r
* that has been persisted previously\r
* @param transientObject the entity to be persisted\r
* @return The unique identifier of the persisted entity\r
*/\r
- @Transactional(readOnly=false)\r
public UUID update(T transientObject);\r
\r
/**\r
* @return a list of matching objects\r
*/\r
public List<T> list(T example, Set<String> includeProperties, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
+ \r
+ /**\r
+ * Evaluates whether the authenticated user has the rights to perform an specific action on the target object\r
+ * @param authentication\r
+ * @param target\r
+ * @param permission\r
+ * @return\r
+ */\r
+ public boolean hasPermission(Authentication authentication, T target, CdmPermission permission);\r
+\r
}
\ No newline at end of file