/*
 * Copyright (c) 2017, University of Oslo
 *
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 * Neither the name of the HISP project nor the names of its contributors may
 * be used to endorse or promote products derived from this software without
 * specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package org.hisp.dhis.android.core.program;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import org.hisp.dhis.android.core.common.DeletableStore;

import java.util.Date;

public interface ProgramStageSectionStore extends DeletableStore {
    long insert(
            @NonNull String uid, @Nullable String code, @NonNull String name,
            @NonNull String displayName, @NonNull Date created, @NonNull Date lastUpdated,
            @Nullable Integer sortOrder, @Nullable String programStage,
            @Nullable ProgramStageSectionRenderingType desktopRenderType,
            @Nullable ProgramStageSectionRenderingType mobileRenderType
    );

    int update(@NonNull String uid, @Nullable String code, @NonNull String name,
               @NonNull String displayName, @NonNull Date created, @NonNull Date lastUpdated,
               @Nullable Integer sortOrder, @Nullable String programStage,
               @Nullable ProgramStageSectionRenderingType desktopRenderType,
               @Nullable ProgramStageSectionRenderingType mobileRenderType,
               @NonNull String whereProgramStageSectionUid);

    int delete(String uid);
}

@@ -1591,16 +1591,96 @@
 ogram;%0A%0A
+import android.database.Cursor;%0Aimport android.database.sqlite.SQLiteStatement;%0A
 import a
@@ -1718,132 +1718,471 @@
 ll;%0A
+%0A
 import 
-android.support.annotation.Nullable;%0A%0Aimport org.hisp.dhis.android.core.common.DeletableStore;%0A%0Aimport java.util.Date
+org.hisp.dhis.android.core.arch.db.binders.IdentifiableStatementBinder;%0Aimport org.hisp.dhis.android.core.arch.db.binders.StatementBinder;%0Aimport org.hisp.dhis.android.core.common.CursorModelFactory;%0Aimport org.hisp.dhis.android.core.common.IdentifiableObjectStore;%0Aimport org.hisp.dhis.android.core.common.StoreFactory;%0Aimport org.hisp.dhis.android.core.data.database.DatabaseAdapter;%0A%0Aimport static org.hisp.dhis.android.core.utils.StoreUtils.sqLiteBind
 ;%0A%0Ap
@@ -2191,312 +2191,502 @@
 lic 
+f
 in
-terface ProgramStageSectionStore extends DeletableStore
+al class ProgramStageSectionStore %7B%0A%0A    private ProgramStageSectionStore() %7B%7D%0A%0A    private static StatementBinder%3CProgramStageSection%3E BINDER = new IdentifiableStatementBinder%3CProgramStageSection%3E()
  %7B%0A    
-long insert(%0A            @NonNull String uid, @Nullable String code, @NonNull String name,%0A            @NonNull String displayName, @NonNull Date created, @NonNull Date lastUpdated,%0A            @Nullable Integer sortOrder, @Nullable String 
+    @Override%0A        public void bindToStatement(@NonNull ProgramStageSection o, @NonNull SQLiteStatement sqLiteStatement) %7B%0A            super.bindToStatement(o, sqLiteStatement);%0A            sqLiteBind(sqLiteStatement, 7, o.sortOrder());%0A            sqLiteBind(sqLiteStatement, 8, o.
 prog
@@ -2685,33 +2685,36 @@
 , o.programStage
-,
+());
 %0A            @Nu
@@ -2714,51 +2714,41 @@
     
-@Nullable ProgramStageSectionRenderingType 
+sqLiteBind(sqLiteStatement, 8, o.
 desk
@@ -2752,33 +2752,36 @@
 esktopRenderType
-,
+());
 %0A            @Nu
@@ -2781,51 +2781,41 @@
     
-@Nullable ProgramStageSectionRenderingType 
+sqLiteBind(sqLiteStatement, 8, o.
 mobi
@@ -2830,270 +2830,235 @@
 Type
+());
 %0A    
-);%0A%0A    int update(@NonNull String uid, @Nullable String code, @NonNull String name,%0A               @NonNull String displayName, @NonNull Date created, @NonNull Date lastUpdated,%0A               @Nullable Integer sortOrder, @Nullable String programStage,%0A   
+    %7D%0A    %7D;%0A%0A    private static final CursorModelFactory%3CProgramStageSection%3E FACTORY = new CursorModelFactory%3CProgramStageSection%3E() %7B%0A        @Override%0A        public ProgramStageSection fromCursor(Cursor cursor) %7B%0A
     
@@ -3061,33 +3061,30 @@
             
-@Nullable
+return
  ProgramStag
@@ -3095,40 +3095,24 @@
 tion
-RenderingType desktopRenderType,
+.create(cursor);
 %0A   
@@ -3120,164 +3120,265 @@
     
+%7D%0A
     
-   @Nullable ProgramStageSectionRenderingType mobileRenderType,%0A               @NonNull String whereProgramStageSectionUid);%0A%0A    int delete(String uid);%0A
+%7D;%0A%0A    public static IdentifiableObjectStore%3CProgramStageSection%3E create(DatabaseAdapter databaseAdapter) %7B%0A        return StoreFactory.objectWithUidStore(databaseAdapter, ProgramStageSectionTableInfo.TABLE_INFO,%0A                BINDER, FACTORY);%0A    
 %7D%0A
+%7D

Unify ProgramStageSectionStore