<commit_before>package by.istin.android.xcore.provider;

import android.content.ContentProvider;
import android.content.ContentProviderOperation;
import android.content.ContentProviderResult;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.OperationApplicationException;
import android.content.UriMatcher;
import android.database.Cursor;
import android.net.Uri;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import by.istin.android.xcore.db.DBHelper;
import by.istin.android.xcore.provider.ModelContract.ModelColumns;
import by.istin.android.xcore.source.DataSourceRequest;
import by.istin.android.xcore.source.DataSourceRequestEntity;
import by.istin.android.xcore.source.SyncDataSourceRequestEntity;
import by.istin.android.xcore.utils.Log;
import by.istin.android.xcore.utils.StringUtil;

public abstract class ModelContentProvider extends ContentProvider {

	private static UriMatcher sUriMatcher;

	private static final int MODELS = 1;

	private static final int MODELS_ID = 2;
	
	private static final int MODELS_ID_NEGOTIVE = 3;

	private static DBHelper sDbHelper;

    private volatile Boolean isLock = false;

    private volatile Object mLock = new Object();

    @Override
	public boolean onCreate() {
        initUriMatcher();
        if (sDbHelper != null) {
            //check for only one instance of helper
            //2.3 android issue, we can have 2 calls of this method
            return true;
        }
        synchronized (mLock) {
            sDbHelper = new DBHelper(getContext());
            Class<?>[] dbEntities = getDbEntities();
            sDbHelper.createTablesForModels(DataSourceRequestEntity.class);
            sDbHelper.createTablesForModels(SyncDataSourceRequestEntity.class);
            sDbHelper.createTablesForModels(dbEntities);
            return true;<commit_msg>added some todo's<commit_after>package by.istin.android.xcore.provider;

import android.content.ContentProvider;
import android.content.ContentProviderOperation;
import android.content.ContentProviderResult;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.OperationApplicationException;
import android.content.UriMatcher;
import android.database.Cursor;
import android.net.Uri;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import by.istin.android.xcore.db.DBHelper;
import by.istin.android.xcore.provider.ModelContract.ModelColumns;
import by.istin.android.xcore.source.DataSourceRequest;
import by.istin.android.xcore.source.DataSourceRequestEntity;
import by.istin.android.xcore.source.SyncDataSourceRequestEntity;
import by.istin.android.xcore.utils.Log;
import by.istin.android.xcore.utils.StringUtil;

public abstract class ModelContentProvider extends ContentProvider {

	private static UriMatcher sUriMatcher;

	private static final int MODELS = 1;

	private static final int MODELS_ID = 2;
	
	private static final int MODELS_ID_NEGOTIVE = 3;

    //TODO close db helper after long time without work
    //TODO create dbHelper factory for control dbHelper lifecycle
    //TODO create dbHelperWrapper like this contentProvider for using inside ptocessors without ContentResolver
    //it will helps to improve speed for inserting/update/delete operation(specially for sub entities)
	private static DBHelper sDbHelper;

    private volatile Boolean isLock = false;

    private volatile Object mLock = new Object();

    @Override
	public boolean onCreate() {
        initUriMatcher();
        if (sDbHelper != null) {
            //check for only one instance of helper
            //2.3 android issue, we can have 2 calls of this method
            return true;
        }
        synchronized (mLock) {
            sDbHelper = new DBHelper(getContext());
            Class<?>[] dbEntities = getDbEntities();
            sDbHelper.createTablesForModels(DataSourceRequestEntity.class);
            sDbHelper.createTablesForModels(SyncDataSourceRequestEntity.class);
            sDbHelper.createTablesForModels(dbEntities);
            return true;
{'fraction_non_alphanumeric': 0.07925242488762715, 'fraction_numerical': 0.0028388928317956, 'mean_word_length': 3.9858490566037736, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6744282', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1128, 'n_words': 298}