package de.jpaw.bonaparte.refs;

import java.util.List;

import de.jpaw.bonaparte.core.BonaPortable;
import de.jpaw.bonaparte.pojos.api.DataWithTracking;
import de.jpaw.bonaparte.pojos.api.SearchFilter;
import de.jpaw.bonaparte.pojos.api.SortColumn;
import de.jpaw.bonaparte.pojos.api.TrackingBase;
import de.jpaw.util.ApplicationException;

/** Common superinterface for refsp.RefResolver, refsw.RefResolver and refsc.RefResolver.
 * Defines common (not key type specific) methods. */ 
public interface BaseRefResolver<REF extends BonaPortable, DTO extends REF, TRACKING extends TrackingBase> {
    /**
     * Returns the DTO for a given unique index. Null-safe, returns null for a null index value. Throws an exception if the key does not exist.
     */
    DTO getDTO(REF refObject) throws ApplicationException;

    /**
     * Creates the DTO as provided in the database. Throws an exception if the key does already exist or the key is invalid (<= 0).
     */
    void create(DTO obj) throws ApplicationException;

    /**
     * Updates the DTO as provided in the database. Throws an exception if no record with the provided key exists or the key is invalid (<= 0).
     */
    void update(DTO obj) throws ApplicationException;

    /**
     * Clears the cache (should be called at end of a transaction).
     */
    void clear();

    /**
     * Flushes all modified but not yet written data to the database.
     */
    void flush();
    
    /**
     * Creates a key object from a ref. Returns null for ref <= 0.
     */
    REF createKey(long ref);

    /**
     * Creates a key object from a ref. Returns null for ref = null.
     * Similar method to previous, in order to avoid object allocation overhead.
     */
    REF createKey(Long ref);

    /** Returns a number of (technical) keys for a query.
     * In case of objects where no technical key of type Long can be determined, throws UnsupportedOperationException.
     * In this case, refsc will define an alternate query returning List<KEY>
     */
    List<Long> queryKeys(int limit, int offset, List<SearchFilter> filters, List<SortColumn> sortColumns) throws ApplicationException;
    
    /** Returns a number of records for a query.
     * Throws UnsupportedOperationException in case the persistence provider does not support searches.
     */
    List<DataWithTracking<DTO,TRACKING>> query(int limit, int offset, List<SearchFilter> filters, List<SortColumn> sortColumns) throws ApplicationException;
}

@@ -30,32 +30,8 @@
 s;%0A%0A
-import java.util.List;%0A%0A
 impo
@@ -74,157 +74,8 @@
 le;%0A
-import de.jpaw.bonaparte.pojos.api.DataWithTracking;%0Aimport de.jpaw.bonaparte.pojos.api.SearchFilter;%0Aimport de.jpaw.bonaparte.pojos.api.SortColumn;%0A
 impo
@@ -1571,24 +1571,26 @@
 Long ref);%0A%0A
+//
     /** Retu
@@ -1631,24 +1631,26 @@
 or a query.%0A
+//
      * In ca
@@ -1756,16 +1756,18 @@
 eption.%0A
+//
      * I
@@ -1836,24 +1836,26 @@
 st%3CKEY%3E%0A
+//
      */%0A
     List
@@ -1838,32 +1838,34 @@
 %3CKEY%3E%0A//     */%0A
+//
     List%3CLong%3E q
@@ -1983,21 +1983,25 @@
 eption;%0A
+//
     %0A
+//
     /** 
@@ -2041,16 +2041,18 @@
  query.%0A
+//
      * T
@@ -2147,24 +2147,26 @@
 arches.%0A
+//
      */%0A
     List
@@ -2153,24 +2153,26 @@
 .%0A//     */%0A
+//
     List%3CDat

undo unified search