private void checkNames(String dsName, String secondName) throws DriverLoadException, NoSuchTableException, DataSourceCreationException, DriverException, AlreadyClosedException { assertEquals(sm.getSource(dsName), sm.getSource(secondName)); DataSource ds1 = dsf.getDataSource(dsName); DataSource ds2 = dsf.getDataSource(secondName); ds1.open(); Value[][] ds1c = getDataSourceContents(ds1); ds1.close(); ds2.open(); Value[][] ds2c = getDataSourceContents(ds2); ds2.close(); assertTrue(equals(ds1c, ds2c)); }
@Test public void testSetters() throws Exception { DataSource d = dsf.getDataSource("alltypes"); d.open(); d.setBinary(0, 0, d.getFieldValue(1, 0).getAsBinary()); d.setBinary(0, "binary", d.getFieldValue(1, 0).getAsBinary()); d.setBoolean(0, 1, d.getFieldValue(1, 1).getAsBoolean()); d.setBoolean(0, "boolean", d.getFieldValue(1, 1).getAsBoolean()); d.setByte(0, 2, d.getFieldValue(1, 2).getAsByte()); d.setByte(0, "byte", d.getFieldValue(1, 2).getAsByte()); d.setDate(0, 3, d.getFieldValue(1, 3).getAsDate()); d.setDate(0, "date", d.getFieldValue(1, 3).getAsDate()); d.setDouble(0, 4, d.getFieldValue(1, 4).getAsDouble()); d.setDouble(0, "double", d.getFieldValue(1, 4).getAsDouble()); d.setFloat(0, 5, d.getFieldValue(1, 5).getAsFloat()); d.setFloat(0, "float", d.getFieldValue(1, 5).getAsFloat()); d.setInt(0, 6, d.getFieldValue(1, 6).getAsInt()); d.setInt(0, "int", d.getFieldValue(1, 6).getAsInt()); d.setLong(0, 7, d.getFieldValue(1, 7).getAsLong()); d.setLong(0, "long", d.getFieldValue(1, 7).getAsLong()); d.setShort(0, 8, d.getFieldValue(1, 8).getAsShort()); d.setShort(0, "short", d.getFieldValue(1, 8).getAsShort()); d.setString(0, 9, d.getFieldValue(1, 9).getAsString()); d.setString(0, "string", d.getFieldValue(1, 9).getAsString()); d.setTimestamp(0, "timestamp", d.getFieldValue(1, 10).getAsTimestamp()); d.setTime(0, 11, d.getFieldValue(1, 11).getAsTime()); d.setTime(0, "time", d.getFieldValue(1, 11).getAsTime()); for (int i = 0; i < d.getMetadata().getFieldCount(); i++) { assertEquals(d.getFieldValue(0, i), d.getFieldValue(1, i)); } d.close(); }
@Override public DataReader open() { if (source == null) throw new IllegalStateException("property source not set"); DataReader srcDR = source.open(); ExtendMetaData extMeta = ExtendMetaData.create(getExtendColumns(), srcDR.getMetaData(), false, isIgnoreCase(), true); ExtendDataReader extRD = new ExtendDataReader(extMeta); extRD.setBaseDataReader(srcDR); return extRD; }
/** Creates the view, sets up the layout. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_categories); changed = false; press = false; intentGlob = getIntent(); if (intentGlob != null) { Bundle extras = intentGlob.getExtras(); if (extras != null) { press = extras.getBoolean("FROMDIALOG", false); } } lastClicked = 0; sp = PreferenceManager.getDefaultSharedPreferences(this); edit = sp.edit(); chFont = Typeface.createFromAsset(this.getAssets(), getString(R.string.exo2)); chFontBold = Typeface.createFromAsset(this.getAssets(), getString(R.string.exo2Bold)); catLabel = (TextView) findViewById(R.id.catLabel2); catLabel.setTypeface(chFontBold); addNewCat = (Button) findViewById(R.id.addCatBtn); addNewCat.setTypeface(chFont); addNewCat.setOnClickListener(this); lv = (ListView) findViewById(android.R.id.list); lv.setOnItemClickListener(this); datasource = new DataSource(this); datasource.open(); values = datasource.getAllCategories(); Collections.reverse(values); // to show latest added categories first exps = datasource.getAllExpenses(); adapter = new CustomListAdapter(this, R.layout.cust_list_cats, values, chFont); setListAdapter(adapter); if (press) { addNewCat.performClick(); // bring up dialog } }
private void initSettings() { DisplayImageOptions options = new DisplayImageOptions.Builder().cacheOnDisk(true).cacheInMemory(true).build(); File cacheDir = StorageUtils.getCacheDirectory(this); ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this) .defaultDisplayImageOptions(options) .diskCache(new UnlimitedDiscCache(cacheDir)) .threadPoolSize(5) .build(); ImageLoader.getInstance().init(configuration); m_adView = (AdView) findViewById(R.id.adview); m_adView.loadAd(new AdRequest()); m_dataSource = new DataSource(this); m_dataSource.open(); }
@Test public void testSecondNameWorksWithIndexes() throws Exception { String dsName = "test8"; sm.register(dsName, super.getAnySpatialResource()); String secondName = "secondName"; DataSource ds = dsf.getDataSource(dsName); ds.open(); String spatialFieldName = ds.getMetadata().getFieldName(MetadataUtilities.getSpatialFieldIndex(ds.getMetadata())); ds.close(); sm.addName(dsName, secondName); dsf.getIndexManager() .buildIndex(dsName, spatialFieldName, IndexManager.RTREE_SPATIAL_INDEX, null); SpatialIndexQuery query = new DefaultSpatialIndexQuery(spatialFieldName, new Envelope(0, 0, 0, 0)); assertNotNull(dsf.getIndexManager().getIndex(dsName, spatialFieldName)); assertNotNull(dsf.getIndexManager().getIndexedFieldNames(dsName)); assertNotNull(dsf.getIndexManager().queryIndex(dsName, query)); assertNotNull(dsf.getIndexManager().getIndex(secondName, spatialFieldName)); assertNotNull(dsf.getIndexManager().getIndexedFieldNames(secondName)); assertNotNull(dsf.getIndexManager().queryIndex(secondName, query)); }
@Test public void testAllGeters() throws Exception { AllTypesObjectDriver testD = new AllTypesObjectDriver(); DataSet test = testD.getTable("main"); DataSource d = dsf.getDataSource("alltypes"); d.open(); assertTrue( ValueFactory.createValue(d.getBinary(0, 0)) .equals(test.getFieldValue(0, 0)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getBinary(0, "binary")) .equals(test.getFieldValue(0, 0)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getBoolean(0, 1)) .equals(test.getFieldValue(0, 1)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getBoolean(0, "boolean")) .equals(test.getFieldValue(0, 1)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getByte(0, 2)).equals(test.getFieldValue(0, 2)).getAsBoolean()); assertTrue( ValueFactory.createValue(d.getByte(0, "byte")) .equals(test.getFieldValue(0, 2)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getDate(0, 3)).equals(test.getFieldValue(0, 3)).getAsBoolean()); assertTrue( ValueFactory.createValue(d.getDate(0, "date")) .equals(test.getFieldValue(0, 3)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getDouble(0, 4)) .equals(test.getFieldValue(0, 4)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getDouble(0, "double")) .equals(test.getFieldValue(0, 4)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getFloat(0, 5)).equals(test.getFieldValue(0, 5)).getAsBoolean()); assertTrue( ValueFactory.createValue(d.getFloat(0, "float")) .equals(test.getFieldValue(0, 5)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getInt(0, 6)).equals(test.getFieldValue(0, 6)).getAsBoolean()); assertTrue( ValueFactory.createValue(d.getInt(0, "int")) .equals(test.getFieldValue(0, 6)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getLong(0, 7)).equals(test.getFieldValue(0, 7)).getAsBoolean()); assertTrue( ValueFactory.createValue(d.getLong(0, "long")) .equals(test.getFieldValue(0, 7)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getShort(0, 8)).equals(test.getFieldValue(0, 8)).getAsBoolean()); assertTrue( ValueFactory.createValue(d.getShort(0, "short")) .equals(test.getFieldValue(0, 8)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getString(0, 9)) .equals(test.getFieldValue(0, 9)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getString(0, "string")) .equals(test.getFieldValue(0, 9)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getTimestamp(0, 10)) .equals(test.getFieldValue(0, 10)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getTimestamp(0, "timestamp")) .equals(test.getFieldValue(0, 10)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getTime(0, 11)) .equals(test.getFieldValue(0, 11)) .getAsBoolean()); assertTrue( ValueFactory.createValue(d.getTime(0, "time")) .equals(test.getFieldValue(0, 11)) .getAsBoolean()); d.close(); }