Package com.db4o.query

Examples of com.db4o.query.Query


        storage.storeEntry(e);
        ServerBaseEntry e1 = createServerBaseEntry();
        storage.storeEntry(e1);

        storage = this.controller.getStorage();
        Query query = getContainer().query();
        query.constrain(BaseEntry.class);
        query.descend("id").constrain(e.getId());
        ObjectSet resultSet = query.execute();
        assertEquals(1, resultSet.size());
        BaseEntry storedEntry = (BaseEntry) resultSet.next();
        assertEquals("1", storedEntry.getVersionId());

        ServerBaseFeed bFeed = new ServerBaseFeed();
View Full Code Here


        storage.deleteEntry(e);

        container.close();
        container = getContainer();
        Query query = container.query();
        query.constrain(BaseEntry.class);
        query.descend("id").constrain(e.getId());
        ObjectSet resultSet = query.execute();
        assertEquals(0, resultSet.size());

        // #### test version matching
        ServerBaseEntry eVersion = createServerBaseEntry();
        storage.storeEntry(eVersion);
        eVersion.setVersion(33);
        try {
            storage.deleteEntry(eVersion);
            fail("version does not match");
        } catch (Exception ex) {
            // TODO: handle exception
        }
        try {
            storage.deleteEntry(null);
            fail("entry id is null");
        } catch (Exception ex) {
            // TODO: handle exception
        }
        storage = this.controller.getStorage();
        storage.deleteEntry(e1);
        container.close();
        container = getContainer();
        query = container.query();
        query.constrain(BaseEntry.class);
        query.descend("id").constrain(e1.getId());
        resultSet = query.execute();
        assertEquals(0, resultSet.size());

        // ############ test concurrency

        // ############ test concurrency
View Full Code Here

        e2.setId(e.getId());
        e2.setTitle(new PlainTextConstruct("new"));
        e2.setUpdated(DateTime.now());
        storage.updateEntry(e2);
        ObjectContainer container = getContainer();
        Query query = container.query();
        query.constrain(BaseEntry.class);
        query.descend("id").constrain(e.getId());
        ObjectSet resultSet = query.execute();
        assertEquals(1, resultSet.size());
        BaseEntry result = (BaseEntry) resultSet.next();
        assertEquals("new", result.getTitle().getPlainText());
        assertEquals("2", result.getVersionId());
View Full Code Here

        account.setName("simon");
        account.setPassword("somepass");
        Storage storage = this.controller.getStorage();
        storage.storeAccount(account);
        ObjectContainer container = getContainer();
        Query q = container.query();
        q.constrain(GDataAccount.class);
        q.descend("name").constrain(account.getName());
        ObjectSet set = q.execute();
        assertEquals(1, set.size());
        assertEquals(account.getPassword(), ((GDataAccount) set.next())
                .getPassword());
        try {
            storage.storeAccount(account);
View Full Code Here

        } catch (Exception e) {
            //
        }
        storage.storeAccount(account);
        ObjectContainer container = getContainer();
        Query q = container.query();
        q.constrain(GDataAccount.class);
        q.descend("name").constrain(account.getName());
        ObjectSet set = q.execute();
        assertEquals(1, set.size());
        assertEquals(account.getPassword(), ((GDataAccount) set.next())
                .getPassword());
        account = new GDataAccount();
        account.setName("simon");
        account.setPassword("newPass");
        storage.updateAccount(account);
        container.close();
        container = getContainer();
        q = container.query();
        q.constrain(GDataAccount.class);
        q.descend("name").constrain(account.getName());
        set = q.execute();
        assertEquals(1, set.size());
        assertEquals(account.getPassword(), ((GDataAccount) set.next())
                .getPassword());
        container.close();
    }
View Full Code Here

        account.setName("simon");
        account.setPassword("somepass");
        Storage storage = this.controller.getStorage();
        storage.storeAccount(account);
        ObjectContainer container = getContainer();
        Query q = container.query();
        q.constrain(GDataAccount.class);
        q.descend("name").constrain(account.getName());
        ObjectSet set = q.execute();
        assertEquals(1, set.size());

        storage.deleteAccount(account.getName());
        container.close();
        container = getContainer();
        q = container.query();
        q.constrain(GDataAccount.class);
        q.descend("name").constrain(account.getName());
        set = q.execute();
        assertEquals(0, set.size());
        try {
            storage.deleteAccount("notstored");
            fail("account not stored");
        } catch (Exception e) {
View Full Code Here

        container.commit();
        container.close();
        storage.storeFeed(feed, ACCOUNTNAME);

        container = getContainer();
        Query query = container.query();
        query.constrain(ServerBaseFeed.class);
        query.descend("feed").descend("id").constrain(FEEDID);
        ObjectSet set = query.execute();
        assertEquals(1, set.size());

        assertEquals(feed.getId(), ((ServerBaseFeed) set.next()).getId());
        container.close();
View Full Code Here

        feed.setServiceConfig(conf);
        storage.storeFeed(feed, ACCOUNTNAME);

        storage.deleteFeed(FEEDID);
        container = getContainer();
        Query query = container.query();
        query.constrain(ServerBaseFeed.class);
        query.descend("feed").descend("id").constrain(FEEDID);
        ObjectSet set = query.execute();
        assertEquals(0, set.size());

        query = getContainer().query();
        query.constrain(BaseFeed.class);
        query.descend("id").constrain(FEEDID);
        set = query.execute();
        assertEquals(0, set.size());
        container.close();
    }
View Full Code Here

        throw new ResourceNotFoundException("can not find feed for given feed id -- "
                + feedId);

    }
    private boolean checkService(String feedId,String serviceId){
        Query query = this.container.query();
        query.constrain(ServerBaseFeed.class);
        query.descend("feed").descend("id").constrain(feedId).equal();
        query.descend("serviceType").constrain(serviceId).equal();
        return query.execute().size() == 1;
    }
View Full Code Here

        query.descend("feed").descend("id").constrain(feedId).equal();
        query.descend("serviceType").constrain(serviceId).equal();
        return query.execute().size() == 1;
    }
    private ObjectSet getEnriesForFeedID(String feedId) {
        Query query = this.container.query();
        query.constrain(DB4oEntry.class);
        query.descend("feedId").constrain(feedId).equal();

        return query.execute();
    }
View Full Code Here

TOP

Related Classes of com.db4o.query.Query

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.