2. Persistence Marshalling Code

Marshalling service persistence interfaces that are separated into read-only and persistent operations, similar to the service layer.

Example 1. PersistenceFindMarshallingService

The find persistence interface has constants for creating request paths and the basic find methods.

                
public interface PersistenceFindMarshallingService<R extends EntityResponseResult, FR extends EntityFindResponseResult> {

    public final static String PATH_DELIM = "/";
    
    public final static String ID_VAR = "id";
    public final static String PAGE_VAR = "page";
    public final static String PAGE_SIZE_VAR = "page-size";

    public final static String PAGE_PATH = PATH_DELIM + PAGE_VAR;
    public final static String PAGE_SIZE_PATH = PATH_DELIM + PAGE_SIZE_VAR;
    public final static String PAGINATED = PAGE_PATH + PATH_DELIM + "{" + PAGE_VAR + "}" + PAGE_SIZE_PATH + PATH_DELIM + "{" + PAGE_SIZE_VAR + "}";
    
    
    /**
     * Find by primary key.
     */
    public R findById(long id);

    /**
     * Find a paginated record set.
     */
    public FR find(int page, int pageSize);

    /**
     * Find all records.
     */
    public FR find();

}
                
            

Example 2. PersistenceMarshallingService

Save and delete are both overloaded so they would continue to work with existing backend tests, but also automatically work with Sencha stores.

                
public interface PersistenceMarshallingService<R extends EntityResponseResult, FR extends EntityFindResponseResult, S extends PkEntityBase> 
        extends PersistenceFindMarshallingService<R, FR> {

    /**
     * Save record.
     */
    public R save(S request);
    
    /**
     * Update record.
     */
    public R update(S request);

    /**
     * Delete record.
     */
    public ResponseResult delete(long id);

    /**
     * Delete record.
     */
    public ResponseResult delete(S request);
    
}