package org.flymine.tutorial;

/*
 * Copyright (C) 2002-2003 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */

import java.util.Iterator;

import org.flymine.objectstore.ObjectStore;
import org.flymine.objectstore.ObjectStoreFactory;
import org.flymine.objectstore.query.Query;
import org.flymine.objectstore.query.Results;
import org.flymine.objectstore.query.ResultsRow;

import org.flymine.model.tutorial.Company;

/**
 * Simple demonstration of query and results handling
 *
 * @author Mark Woodbridge
 */
public class SimpleQuery
{
    /**
     * main method
     * @param args command line parameters
     * @throws Exception if an error occurs
     */
    public static void main(String[] args) throws Exception {

        ObjectStore os = ObjectStoreFactory.getObjectStore("os.tutorial");

        Query q = new Query("select c from Company as c", "org.flymine.model.tutorial");

        Results r = os.execute(q);
        Iterator rrIter = r.iterator();
        while (rrIter.hasNext()) {
            ResultsRow rr = (ResultsRow) rrIter.next();
            Company c = (Company) rr.get(0);
            System
                .out.println(c.getName() + " has " + c.getDepartments().size() + " departments");
        }
    }
}

@@ -482,16 +482,23 @@
 e.query.
+fql.Fql
 Query;%0Ai
@@ -1024,16 +1024,19 @@
         
+Fql
 Query q 
@@ -1041,16 +1041,19 @@
 q = new 
+Fql
 Query(%22s
@@ -1144,16 +1144,26 @@
 xecute(q
+.toQuery()
 );%0A     

change Query object to and FqlQuery, now runs again.