Search in sources :

Example 1 with SceneTable

use of org.storymaker.app.model.SceneTable in project storymaker by StoryMaker.

the class ProjectsProvider method update.

@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
    mCacheWordHandler.connectToService();
    setTimer(60000);
    SQLiteDatabase db = getDB();
    if (db != null) {
        int uriType = sURIMatcher.match(uri);
        switch(uriType) {
            case PROJECTS:
            case PROJECT_ID:
                return (new ProjectTable(db)).update(getContext(), uri, values, selection, selectionArgs);
            case SCENES:
            case SCENE_ID:
                return (new SceneTable(db)).update(getContext(), uri, values, selection, selectionArgs);
            case LESSONS:
            case LESSON_ID:
                return (new LessonTable(db)).update(getContext(), uri, values, selection, selectionArgs);
            case MEDIA:
            case MEDIA_ID:
                return (new MediaTable(db)).update(getContext(), uri, values, selection, selectionArgs);
            case AUTH:
            case AUTH_ID:
                return (new AuthTable(db)).update(getContext(), uri, values, selection, selectionArgs);
            case TAGS:
            case TAG_ID:
            case DISTINCT_TAGS:
            case DISTINCT_TAG_ID:
                return (new TagTable(db)).update(getContext(), uri, values, selection, selectionArgs);
            case JOBS:
            case JOB_ID:
                return (new JobTable(db)).update(getContext(), uri, values, selection, selectionArgs);
            case PUBLISH_JOBS:
            case PUBLISH_JOB_ID:
                return (new PublishJobTable(db)).update(getContext(), uri, values, selection, selectionArgs);
            case AUDIO_CLIPS:
            case AUDIO_CLIP_ID:
                return (new AudioClipTable(db)).update(getContext(), uri, values, selection, selectionArgs);
            default:
                throw new IllegalArgumentException("Unknown URI");
        }
    }
    return 0;
}
Also used : SceneTable(org.storymaker.app.model.SceneTable) PublishJobTable(org.storymaker.app.model.PublishJobTable) JobTable(org.storymaker.app.model.JobTable) PublishJobTable(org.storymaker.app.model.PublishJobTable) MediaTable(org.storymaker.app.model.MediaTable) SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase) AudioClipTable(org.storymaker.app.model.AudioClipTable) AuthTable(org.storymaker.app.model.AuthTable) TagTable(org.storymaker.app.model.TagTable) ProjectTable(org.storymaker.app.model.ProjectTable) LessonTable(org.storymaker.app.model.LessonTable)

Example 2 with SceneTable

use of org.storymaker.app.model.SceneTable in project storymaker by StoryMaker.

the class ProjectsProvider method query.

@Nullable
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    mCacheWordHandler.connectToService();
    setTimer(60000);
    SQLiteDatabase db = getDB();
    if (db != null) {
        int uriType = sURIMatcher.match(uri);
        switch(uriType) {
            case PROJECT_ID:
                return (new ProjectTable(db)).queryOne(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case PROJECTS:
                return (new ProjectTable(db)).queryAll(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case SCENE_ID:
                return (new SceneTable(db)).queryOne(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case SCENES:
                return (new SceneTable(db)).queryAll(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case LESSON_ID:
                return (new LessonTable(db)).queryOne(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case LESSONS:
                return (new LessonTable(db)).queryAll(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case MEDIA_ID:
                return (new MediaTable(db)).queryOne(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case MEDIA:
                return (new MediaTable(db)).queryAll(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case AUTH_ID:
                return (new AuthTable(db)).queryOne(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case AUTH:
                return (new AuthTable(db)).queryAll(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case TAG_ID:
                return (new TagTable(db)).queryOne(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case TAGS:
                return (new TagTable(db)).queryAll(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case DISTINCT_TAG_ID:
                return (new TagTable(db)).queryOneDistinct(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case DISTINCT_TAGS:
                return (new TagTable(db)).queryAllDistinct(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case JOB_ID:
                return (new JobTable(db)).queryOne(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case JOBS:
                return (new JobTable(db)).queryAll(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case PUBLISH_JOB_ID:
                return (new PublishJobTable(db)).queryOne(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case PUBLISH_JOBS:
                return (new PublishJobTable(db)).queryAll(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case AUDIO_CLIP_ID:
                return (new AudioClipTable(db)).queryOne(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            case AUDIO_CLIPS:
                return (new AudioClipTable(db)).queryAll(getContext(), uri, projection, selection, selectionArgs, sortOrder);
            default:
                throw new IllegalArgumentException("Unknown URI");
        }
    }
    return null;
}
Also used : SceneTable(org.storymaker.app.model.SceneTable) PublishJobTable(org.storymaker.app.model.PublishJobTable) JobTable(org.storymaker.app.model.JobTable) PublishJobTable(org.storymaker.app.model.PublishJobTable) MediaTable(org.storymaker.app.model.MediaTable) SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase) AudioClipTable(org.storymaker.app.model.AudioClipTable) AuthTable(org.storymaker.app.model.AuthTable) TagTable(org.storymaker.app.model.TagTable) ProjectTable(org.storymaker.app.model.ProjectTable) LessonTable(org.storymaker.app.model.LessonTable) Nullable(android.support.annotation.Nullable)

Example 3 with SceneTable

use of org.storymaker.app.model.SceneTable in project storymaker by StoryMaker.

the class ProjectsProvider method delete.

@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
    mCacheWordHandler.connectToService();
    setTimer(60000);
    SQLiteDatabase db = getDB();
    if (db != null) {
        int uriType = sURIMatcher.match(uri);
        switch(uriType) {
            case PROJECTS:
            case PROJECT_ID:
                return (new ProjectTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case SCENES:
            case SCENE_ID:
                return (new SceneTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case LESSONS:
            case LESSON_ID:
                return (new LessonTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case MEDIA:
            case MEDIA_ID:
                return (new MediaTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case AUTH:
            case AUTH_ID:
                return (new AuthTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case TAGS:
            case TAG_ID:
            case DISTINCT_TAGS:
            case DISTINCT_TAG_ID:
                return (new TagTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case JOBS:
            case JOB_ID:
                return (new JobTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case PUBLISH_JOBS:
            case PUBLISH_JOB_ID:
                return (new PublishJobTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case AUDIO_CLIPS:
            case AUDIO_CLIP_ID:
                return (new AudioClipTable(db)).delete(getContext(), uri, selection, selectionArgs);
            default:
                throw new IllegalArgumentException("Unknown URI");
        }
    }
    return 0;
}
Also used : SceneTable(org.storymaker.app.model.SceneTable) PublishJobTable(org.storymaker.app.model.PublishJobTable) JobTable(org.storymaker.app.model.JobTable) PublishJobTable(org.storymaker.app.model.PublishJobTable) MediaTable(org.storymaker.app.model.MediaTable) SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase) AudioClipTable(org.storymaker.app.model.AudioClipTable) AuthTable(org.storymaker.app.model.AuthTable) TagTable(org.storymaker.app.model.TagTable) ProjectTable(org.storymaker.app.model.ProjectTable) LessonTable(org.storymaker.app.model.LessonTable)

Example 4 with SceneTable

use of org.storymaker.app.model.SceneTable in project storymaker by StoryMaker.

the class ProjectsProvider method insert.

@Nullable
@Override
public Uri insert(Uri uri, ContentValues values) {
    mCacheWordHandler.connectToService();
    setTimer(60000);
    SQLiteDatabase db = getDB();
    if (db != null) {
        long newId;
        int uriType = sURIMatcher.match(uri);
        switch(uriType) {
            case PROJECTS:
                return (new ProjectTable(db)).insert(getContext(), uri, values);
            case SCENES:
                return (new SceneTable(db)).insert(getContext(), uri, values);
            case LESSONS:
                return (new LessonTable(db)).insert(getContext(), uri, values);
            case MEDIA:
                return (new MediaTable(db)).insert(getContext(), uri, values);
            case AUTH:
                return (new AuthTable(db)).insert(getContext(), uri, values);
            case TAGS:
            case DISTINCT_TAGS:
                return (new TagTable(db)).insert(getContext(), uri, values);
            case JOBS:
                return (new JobTable(db)).insert(getContext(), uri, values);
            case PUBLISH_JOBS:
                return (new PublishJobTable(db)).insert(getContext(), uri, values);
            case AUDIO_CLIPS:
                return (new AudioClipTable(db)).insert(getContext(), uri, values);
            default:
                throw new IllegalArgumentException("Unknown URI");
        }
    }
    return null;
}
Also used : PublishJobTable(org.storymaker.app.model.PublishJobTable) JobTable(org.storymaker.app.model.JobTable) MediaTable(org.storymaker.app.model.MediaTable) AuthTable(org.storymaker.app.model.AuthTable) LessonTable(org.storymaker.app.model.LessonTable) SceneTable(org.storymaker.app.model.SceneTable) PublishJobTable(org.storymaker.app.model.PublishJobTable) SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase) AudioClipTable(org.storymaker.app.model.AudioClipTable) TagTable(org.storymaker.app.model.TagTable) ProjectTable(org.storymaker.app.model.ProjectTable) Nullable(android.support.annotation.Nullable)

Example 5 with SceneTable

use of org.storymaker.app.model.SceneTable in project storymaker by StoryMaker.

the class StoryMakerDB method onUpgrade.

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    Timber.d("updating db from " + oldVersion + " to " + newVersion);
    if ((oldVersion < 2) && (newVersion == 2)) {
        db.execSQL(StoryMakerDB.Schema.Projects.UPDATE_TABLE_PROJECTS);
    }
    if ((oldVersion < 3) && (newVersion == 3)) {
        db.execSQL(StoryMakerDB.Schema.Media.UPDATE_TABLE_MEDIA_ADD_TRIM_START);
        db.execSQL(StoryMakerDB.Schema.Media.UPDATE_TABLE_MEDIA_ADD_TRIM_END);
        db.execSQL(StoryMakerDB.Schema.Media.UPDATE_TABLE_MEDIA_ADD_DURATION);
    }
    if ((oldVersion < 4) && (newVersion >= 4)) {
        db.execSQL(StoryMakerDB.Schema.Auth.UPDATE_TABLE_AUTH);
        // migrates storymaker login credentials
        Auth.migrate(mContext, db);
    }
    if ((oldVersion < 5) && (newVersion >= 5)) {
        db.execSQL(StoryMakerDB.Schema.Projects.UPDATE_TABLE_PROJECTS_ADD_CREATED_AT);
        db.execSQL(StoryMakerDB.Schema.Projects.UPDATE_TABLE_PROJECTS_ADD_UPDATED_AT);
        db.execSQL(StoryMakerDB.Schema.Scenes.UPDATE_TABLE_SCENES_ADD_CREATED_AT);
        db.execSQL(StoryMakerDB.Schema.Scenes.UPDATE_TABLE_SCENES_ADD_UPDATED_AT);
        db.execSQL(StoryMakerDB.Schema.Media.UPDATE_TABLE_MEDIA_ADD_CREATED_AT);
        db.execSQL(StoryMakerDB.Schema.Media.UPDATE_TABLE_MEDIA_ADD_UPDATED_AT);
        // migrates existing database records and associated files
        Project.migrate(mContext, db);
    }
    if ((oldVersion < 6) && (newVersion >= 6)) {
        db.execSQL(StoryMakerDB.Schema.Projects.UPDATE_TABLE_PROJECTS_ADD_SECTION);
        db.execSQL(StoryMakerDB.Schema.Projects.UPDATE_TABLE_PROJECTS_ADD_LOCATION);
        db.execSQL(StoryMakerDB.Schema.Tags.UPDATE_TABLE_TAGS);
    }
    if ((oldVersion < 7) && (newVersion >= 7)) {
        @SuppressWarnings("unchecked") ArrayList<Scene> scenes = (ArrayList<Scene>) (new SceneTable(db)).getAllAsList(mContext);
        for (Scene scene : scenes) {
            scene.migrateDeleteDupedMedia();
        }
    }
    if ((oldVersion < 8) && (newVersion >= 8)) {
        db.execSQL(StoryMakerDB.Schema.Projects.UPDATE_TABLE_PROJECTS_ADD_DESCRIPTION);
    }
    if ((oldVersion < 9) && (newVersion >= 9)) {
        db.execSQL(StoryMakerDB.Schema.Jobs.CREATE_TABLE_JOBS);
        db.execSQL(StoryMakerDB.Schema.PublishJobs.CREATE_TABLE_PUBLISH_JOBS);
    }
    if ((oldVersion < 10) && (newVersion >= 10)) {
        db.execSQL(StoryMakerDB.Schema.Media.UPDATE_TABLE_MEDIA_ADD_VOLUME);
        db.execSQL(Schema.AudioClip.CREATE_TABLE_AUDIO_CLIP);
    }
    if ((oldVersion < 11) && (newVersion >= 11)) {
        // we need to force the server url to .org since beta users have .cc in their sharedprefs and are missing the update
        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mContext.getApplicationContext());
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(StoryMakerApp.STORYMAKER_SERVER_URL_PREFS_KEY, StoryMakerApp.STORYMAKER_DEFAULT_SERVER_URL);
        editor.commit();
    }
}
Also used : SceneTable(org.storymaker.app.model.SceneTable) SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList) Scene(org.storymaker.app.model.Scene)

Aggregations

SceneTable (org.storymaker.app.model.SceneTable)5 SQLiteDatabase (net.sqlcipher.database.SQLiteDatabase)4 AudioClipTable (org.storymaker.app.model.AudioClipTable)4 AuthTable (org.storymaker.app.model.AuthTable)4 JobTable (org.storymaker.app.model.JobTable)4 LessonTable (org.storymaker.app.model.LessonTable)4 MediaTable (org.storymaker.app.model.MediaTable)4 ProjectTable (org.storymaker.app.model.ProjectTable)4 PublishJobTable (org.storymaker.app.model.PublishJobTable)4 TagTable (org.storymaker.app.model.TagTable)4 Nullable (android.support.annotation.Nullable)2 SharedPreferences (android.content.SharedPreferences)1 ArrayList (java.util.ArrayList)1 Scene (org.storymaker.app.model.Scene)1