use of me.himanshusoni.quantumflux.model.generate.TableDetails in project QuantumFlux by himanshu-soni.
the class QuantumFlux method insertAndReturn.
public static <T> T insertAndReturn(T dataModelObject) {
TableDetails tableDetails = findTableDetails(dataModelObject.getClass());
ContentValues contentValues = ModelInflater.deflate(tableDetails, dataModelObject);
Uri insertUri = UriMatcherHelper.generateItemUriBuilder(tableDetails).build();
ContentResolver contentResolver = mApplicationContext.getContentResolver();
Uri itemUri = contentResolver.insert(insertUri, contentValues);
return findSingleItem(itemUri, tableDetails);
}
use of me.himanshusoni.quantumflux.model.generate.TableDetails in project QuantumFlux by himanshu-soni.
the class QuantumFlux method updateColumnsExcluding.
public static <T> void updateColumnsExcluding(T dataModelObject, String... columnsToExclude) {
TableDetails tableDetails = findTableDetails(dataModelObject.getClass());
ContentValues contentValues = ModelInflater.deflate(tableDetails, dataModelObject);
Object columnValue = ModelInflater.deflateColumn(tableDetails, tableDetails.findPrimaryKeyColumn(), dataModelObject);
Uri itemUri = UriMatcherHelper.generateItemUriBuilder(tableDetails, String.valueOf(columnValue)).build();
for (String columnToExclude : columnsToExclude) {
contentValues.remove(columnToExclude);
}
ContentResolver contentResolver = mApplicationContext.getContentResolver();
contentResolver.update(itemUri, contentValues, null, null);
}
use of me.himanshusoni.quantumflux.model.generate.TableDetails in project QuantumFlux by himanshu-soni.
the class QuantumFlux method prepareDelete.
public static <T> ContentProviderOperation prepareDelete(T dataModelObject) {
TableDetails tableDetails = findTableDetails(dataModelObject.getClass());
Object columnValue = ModelInflater.deflateColumn(tableDetails, tableDetails.findPrimaryKeyColumn(), dataModelObject);
Uri itemUri = UriMatcherHelper.generateItemUriBuilder(tableDetails, String.valueOf(columnValue)).build();
return ContentProviderOperation.newDelete(itemUri).withExpectedCount(1).build();
}
use of me.himanshusoni.quantumflux.model.generate.TableDetails in project QuantumFlux by himanshu-soni.
the class QuantumFlux method prepareUpdate.
public static <T> ContentProviderOperation prepareUpdate(T dataModelObject) {
TableDetails tableDetails = findTableDetails(dataModelObject.getClass());
ContentValues contentValues = ModelInflater.deflate(tableDetails, dataModelObject);
Object columnValue = ModelInflater.deflateColumn(tableDetails, tableDetails.findPrimaryKeyColumn(), dataModelObject);
Uri itemUri = UriMatcherHelper.generateItemUriBuilder(tableDetails, String.valueOf(columnValue)).build();
return ContentProviderOperation.newUpdate(itemUri).withExpectedCount(1).withValues(contentValues).build();
}
use of me.himanshusoni.quantumflux.model.generate.TableDetails in project QuantumFlux by himanshu-soni.
the class QuantumFlux method findAll.
public static <T> Iterator<T> findAll(Class<T> dataModel) {
TableDetails tableDetails = findTableDetails(dataModel);
Uri itemUri = UriMatcherHelper.generateItemUriBuilder(tableDetails).build();
ContentResolver contentResolver = mApplicationContext.getContentResolver();
Cursor cursor = contentResolver.query(itemUri, null, null, null, null);
return new CursorIterator<T>(tableDetails, cursor);
}
Aggregations