changeset 2647:4e29550f635a

Remove statement abstraction API review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-May/023058.html reviewed-by: ebaron
author Mario Torre <neugens.limasoftware@gmail.com>
date Thu, 11 May 2017 17:51:55 +0200
parents 91412a25d6ec
children e2fffc5709ad
files distribution/pom.xml plugins/pom.xml storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/BeanAdapter.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/BeanAdapterBuilder.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/Category.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/CategoryBuilder.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/Criterion.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/FieldDescriptor.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/Indexed.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/InsertEngine.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/LimitCriterion.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/Query.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/QueryEngine.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/QueryValues.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/ResultHandler.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/SortCriterion.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/Statement.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/StatementEngine.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/StatementUtils.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/TypeMapper.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/Value.java storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/WhereCriterion.java storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/BeanAdapterBuilderTest.java storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/BeanAdapterTest.java storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/CategoryBuilderTest.java storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/InsertEngineTest.java storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/InvalidSampleBean.java storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/QueryEngineTest.java storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/QueryValuesTest.java storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/SampleBean.java storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/StatementTest.java storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/StatementUtilsTest.java
diffstat 32 files changed, 7 insertions(+), 3080 deletions(-) [+]
line wrap: on
line diff
--- a/distribution/pom.xml	Thu May 11 11:40:48 2017 -0400
+++ b/distribution/pom.xml	Thu May 11 17:51:55 2017 +0200
@@ -536,12 +536,12 @@
       <version>${project.version}</version>
       <type>zip</type>
     </dependency>
-    <dependency>
-      <groupId>com.redhat.thermostat</groupId>
-      <artifactId>thermostat-thread-distribution</artifactId>
-      <version>${project.version}</version>
-      <type>zip</type>
-    </dependency>
+    <!--<dependency>-->
+      <!--<groupId>com.redhat.thermostat</groupId>-->
+      <!--<artifactId>thermostat-thread-distribution</artifactId>-->
+      <!--<version>${project.version}</version>-->
+      <!--<type>zip</type>-->
+    <!--</dependency>-->
     <dependency>
       <groupId>com.redhat.thermostat</groupId>
       <artifactId>thermostat-vm-classstat-distribution</artifactId>
--- a/plugins/pom.xml	Thu May 11 11:40:48 2017 -0400
+++ b/plugins/pom.xml	Thu May 11 17:51:55 2017 +0200
@@ -51,7 +51,7 @@
   <name>Thermostat Plugins</name>
 
   <modules>
-    <module>thread</module>
+    <!--<module>thread</module>-->
     <module>killvm</module>
     <module>com.redhat.thermostat.host.overview</module>
     <module>host-cpu</module>
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/BeanAdapter.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,185 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import com.redhat.thermostat.common.utils.LoggingUtils;
-import com.redhat.thermostat.storage.core.Category;
-import com.redhat.thermostat.storage.core.Cursor;
-import com.redhat.thermostat.storage.core.DescriptorParsingException;
-import com.redhat.thermostat.storage.core.Id;
-import com.redhat.thermostat.storage.core.PreparedStatement;
-import com.redhat.thermostat.storage.core.StatementDescriptor;
-import com.redhat.thermostat.storage.core.StatementExecutionException;
-import com.redhat.thermostat.storage.core.Storage;
-import com.redhat.thermostat.storage.model.Pojo;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- *
- */
-public class BeanAdapter<T extends Pojo> {
-    public static final Id INSERT = new Id("BeanAdapter_Insert");
-
-    private static final Logger logger = LoggingUtils.getLogger(BeanAdapter.class);
-
-    protected Category<T> category;
-
-    private Map<Id, Statement> describedQueries;
-    private Map<Id, Query<T>> queries;
-    private List<FieldDescriptor> fieldDescriptors;
-
-    public BeanAdapter() {
-        this.queries = new HashMap<>();
-        this.describedQueries = new HashMap<>();
-    }
-
-    protected void setCategory(Category<T> category) {
-        this.category = category;
-    }
-
-    public Category<T> getCategory() {
-        return category;
-    }
-
-    public Set<String> describeStatements() {
-        Set<String> descriptions = new HashSet<>();
-        for (Statement statement : describedQueries.values()) {
-            descriptions.add(statement.get());
-        }
-        return descriptions;
-    }
-
-    public void insert(T bean, Storage storage)
-            throws StatementExecutionException
-    {
-        Statement statement = describedQueries.get(INSERT);
-
-        StatementDescriptor<T> desc =
-                new StatementDescriptor<>(category, statement.get());
-        try {
-            PreparedStatement<T> prepared = storage.prepareStatement(desc);
-            int i = 0;
-            for (FieldDescriptor descriptor : fieldDescriptors) {
-                Value value = StatementUtils.getValue(bean, descriptor);
-                StatementUtils.setData(prepared, value, i++);
-            }
-
-            prepared.execute();
-
-        } catch (DescriptorParsingException e) {
-            logger.log(Level.SEVERE, "Preparing stmt '" + desc + "' failed!", e);
-        }
-    }
-
-    public Query<T> getQuery(Id id) {
-        return queries.get(id);
-    }
-
-    public void query(QueryValues values, ResultHandler<T> handler,
-                      Storage storage) throws StatementExecutionException
-    {
-        Objects.requireNonNull(handler, "ResultHandler cannot be null");
-        Objects.requireNonNull(values, "QueryValues cannot be null");
-        Objects.requireNonNull(storage, "Storage cannot be null");
-
-        Query query = values.getQuery();
-        if (!queries.containsKey(query.getId())) {
-            throw new IllegalArgumentException("This adapter does not know" +
-                                               "about the given query: " +
-                                               query.getId());
-        }
-
-        Statement statement = describedQueries.get(query.getId());
-        List<Criterion> criteria = query.describe();
-
-        StatementDescriptor<T> desc =
-                new StatementDescriptor<>(category, statement.get());
-        PreparedStatement<T> prepared = null;
-        try {
-            prepared = storage.prepareStatement(desc);
-            int i = 0;
-            for (Criterion criterion : criteria) {
-                // sort doesn't take values
-                if (criterion instanceof SortCriterion) {
-                    continue;
-                }
-
-                Value value = values.getValue(criterion);
-                StatementUtils.setData(prepared, value, i++);
-            }
-
-        } catch (DescriptorParsingException e) {
-            logger.log(Level.SEVERE, "Preparing stmt '" + desc +
-                                     "' failed!", e);
-
-            // this can't really happen, but if it does is serious
-            throw new AssertionError("Autogenerated statement failed to parse",
-                                     e);
-        }
-
-        Cursor<T> cursor = prepared.executeQuery();
-        boolean needMoreResults = true;
-        while (cursor.hasNext() && needMoreResults) {
-            T result = cursor.next();
-            try {
-                needMoreResults = handler.onResult(result);
-
-            } catch (Throwable t) {
-                logger.log(Level.SEVERE, "Exception executing results", t);
-            }
-        }
-    }
-
-    protected void addStatement(Id id, Statement statement) {
-        describedQueries.put(id, statement);
-    }
-
-    protected void addQuery(Id id, Query query) {
-        queries.put(id, query);
-    }
-
-    protected void setFieldDescriptors(List<FieldDescriptor> fieldDescriptors) {
-        this.fieldDescriptors = fieldDescriptors;
-    }
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/BeanAdapterBuilder.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import com.redhat.thermostat.storage.core.Category;
-import com.redhat.thermostat.storage.model.Pojo;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- */
-public class BeanAdapterBuilder<T extends Pojo> {
-
-    private Class<T> target;
-    private BeanAdapter<T> adapter;
-
-    private List<Query<T>> queries;
-
-    public BeanAdapterBuilder(Class<T> target, List<Query<T>> queries) {
-        this.target = target;
-        this.queries = queries;
-    }
-
-    public BeanAdapterBuilder(Class<T> target, Query<T> query) {
-        this(target, new ArrayList<Query<T>>());
-        queries.add(query);
-    }
-
-    public BeanAdapter<T> build() {
-        try {
-            Category<T> category = new CategoryBuilder<>(target).build();
-            List<FieldDescriptor> fieldDescriptors =
-                    StatementUtils.createDescriptors(target);
-
-            adapter = new BeanAdapter<>();
-            adapter.setCategory(category);
-            adapter.setFieldDescriptors(fieldDescriptors);
-
-            createInsert(fieldDescriptors);
-            createQueries();
-
-            return adapter;
-
-        } catch (Throwable t) {
-            throw new RuntimeException(t);
-        }
-    }
-
-    protected void createQueries() {
-        for (Query<T> query : queries) {
-            createQuery(query);
-        }
-    }
-
-    private void createQuery(Query<T> query) {
-        List<Criterion> queryDescriptors = query.describe();
-
-        QueryEngine engine = new QueryEngine();
-        engine.prologue(adapter.getCategory());
-        for (Criterion criterion : queryDescriptors) {
-            if (criterion instanceof WhereCriterion) {
-                WhereCriterion where = (WhereCriterion) criterion;
-                engine.add(where.getFieldDescriptor(), where.getCriteria());
-
-            } else if (criterion instanceof SortCriterion) {
-                SortCriterion sort = (SortCriterion) criterion;
-                engine.sort(sort.getFieldDescriptor(), sort.getCriteria());
-
-            } else if (criterion instanceof LimitCriterion) {
-                engine.limit();
-            }
-        }
-
-        adapter.addStatement(query.getId(), engine.build());
-        adapter.addQuery(query.getId(), query);
-    }
-
-    protected void createInsert(List<FieldDescriptor> descriptors) {
-
-        InsertEngine engine = new InsertEngine();
-        engine.prologue(adapter.getCategory());
-
-        for (FieldDescriptor descriptor : descriptors) {
-            engine.add(descriptor);
-        }
-
-        adapter.addStatement(BeanAdapter.INSERT, engine.build());
-    }
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/Category.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- *
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Category {
-    String value();
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/CategoryBuilder.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import com.redhat.thermostat.storage.core.Category;
-import com.redhat.thermostat.storage.core.Key;
-import com.redhat.thermostat.storage.model.Pojo;
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- *
- */
-public class CategoryBuilder<T extends Pojo> {
-
-    private static final String LOCK = new String("CategoryBuilder_lock");
-    private static final Map<String, Category> categories = new HashMap<>();
-
-    private Class<T> bean;
-
-    public CategoryBuilder(Class<T> bean) {
-        this.bean = bean;
-    }
-
-    public Category<T> build() {
-
-        synchronized (LOCK) {
-
-            String document = StatementUtils.getDocument(bean);
-
-            // This helps performance as well, but it's needed because Category
-            // doesn't allow us to create the same twice, even with all the
-            // same data; categories are in fact some kind of singleton
-            if (categories.containsKey(document)) {
-                return categories.get(document);
-            }
-
-            List<FieldDescriptor> descriptors =
-                    StatementUtils.createDescriptors(bean);
-
-            // we first build the keys and the indexed keys
-            List<Key> indexed = new ArrayList<>();
-            List<Key> keys = new ArrayList<>();
-
-            // key are easy, the arguments are in the form:
-            // new Key<Type>(String name), we don't need reflection
-
-            for (FieldDescriptor descriptor : descriptors) {
-
-                Key key = new Key(descriptor.getName());
-
-                keys.add(key);
-                if (descriptor.isIndexed()) {
-                    indexed.add(key);
-                }
-            }
-
-            List<Class<?>> argumentClasses = new ArrayList<>();
-            argumentClasses.add(String.class);
-            argumentClasses.add(Class.class);
-            argumentClasses.add(List.class);
-
-            List argumentObjects = new ArrayList();
-            argumentObjects.add(document);
-            argumentObjects.add(bean);
-            argumentObjects.add(keys);
-
-            // indexed keys are optional
-            if (!indexed.isEmpty()) {
-                argumentClasses.add(List.class);
-                argumentObjects.add(indexed);
-            }
-
-            Class<?>[] classes = argumentClasses.toArray(new Class[argumentClasses.size()]);
-            Object[] objects = argumentObjects.toArray();
-
-            Category<T> category = create(classes, objects);
-            categories.put(document, category);
-
-            return category;
-        }
-    }
-
-    private Category<T> create(Class[] classes, Object[] objects) {
-
-        // we are using this constructor:
-        // Category(String name, Class<T> dataClass,
-        //          List<Key<?>> keys, List<Key<?>> indexedKeys)
-
-        try {
-            Constructor<Category> constructor =
-                    Category.class.getConstructor(classes);
-            constructor.setAccessible(true);
-
-            return constructor.newInstance(objects);
-
-        } catch (ReflectiveOperationException e) {
-            throw new RuntimeException(e);
-        }
-    }
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/Criterion.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import com.redhat.thermostat.storage.core.Id;
-
-/**
- *
- */
-public interface Criterion {
-    Id getId();
-    Class<?> getType();
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/FieldDescriptor.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import java.util.Objects;
-
-/**
- *
- */
-public class FieldDescriptor {
-    private Class<?> type;
-    private String name;
-    private boolean indexed;
-
-    public void setType(Class<?> type) {
-        this.type = type;
-    }
-
-    public Class<?> getType() {
-        return type;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setIndexed(boolean indexed) {
-        this.indexed = indexed;
-    }
-
-    public boolean isIndexed() {
-        return indexed;
-    }
-
-    @Override
-    public String toString() {
-        return "[FieldDescriptor: " +
-                "type = " + type +
-                ", name = '" + name + '\'' +
-                ", indexed = " + indexed +
-                ']';
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        FieldDescriptor that = (FieldDescriptor) o;
-        return Objects.equals(name, that.name);
-    }
-
-    @Override
-    public int hashCode() {
-        return name != null ? name.hashCode() : 0;
-    }
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/Indexed.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- *
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Indexed {
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/InsertEngine.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-/**
- *
- */
-class InsertEngine extends StatementEngine {
-
-    public InsertEngine() {
-        super(TypeMapper.Statement.Insert);
-        delimiter = TypeMapper.Symbol.InsertSeparator.id();
-        tokens.add(TypeMapper.Clause.Add.id());
-    }
-
-    public InsertEngine add(FieldDescriptor descriptor) {
-        super.add(descriptor, TypeMapper.Criteria.Equal);
-        return this;
-    }
-
-    @Override
-    protected void addPrologueClause() {
-        tokens.add(TypeMapper.Clause.Set.id());
-    }
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/LimitCriterion.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import com.redhat.thermostat.storage.core.Id;
-
-/**
- *
- */
-public class LimitCriterion implements Criterion {
-
-    private Id id;
-
-    public LimitCriterion(Id id) {
-        this.id = id;
-    }
-
-    @Override
-    public Id getId() {
-        return id;
-    }
-
-    @Override
-    public Class<?> getType() {
-        return int.class;
-    }
-
-    @Override
-    public String toString() {
-        return "Limit";
-    }
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/Query.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import com.redhat.thermostat.storage.core.Id;
-import com.redhat.thermostat.storage.model.Pojo;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- *
- */
-public abstract class Query<T extends Pojo> {
-
-    protected final class Criteria {
-        private List<Criterion> criteria;
-        private Map<Id, Criterion> map;
-
-        Criteria() {
-            criteria = new ArrayList<>();
-            map = new HashMap<>();
-        }
-
-        public void add(Criterion criterion) {
-            Id id = criterion.getId();
-            if (map.containsKey(id)) {
-                throw new IllegalArgumentException("Already contains criteria" +
-                                                   " with this id." +
-                                                   " New: " + criterion +
-                                                   " (id = " + id + ")" +
-                                                   " Old: " + map.get(id) +
-                                                   " query id: " + getId());
-            }
-            map.put(id, criterion);
-            criteria.add(criterion);
-        }
-    }
-
-    private List<Criterion> describedQuery;
-    private Criteria criteria;
-
-    public Query() {
-        criteria = new Criteria();
-    }
-
-    public abstract Id getId();
-
-    public final List<Criterion> describe() {
-        if (describedQuery == null) {
-            describe(criteria);
-            describedQuery = Collections.unmodifiableList(criteria.criteria);
-        }
-        return describedQuery;
-    }
-
-    protected abstract void describe(Criteria criteria);
-
-    public final QueryValues createValues() {
-        if (describedQuery == null) {
-            throw new IllegalStateException("Query must be described first");
-        }
-
-        QueryValues setter = new QueryValues(this);
-        setter.addCriteria(describedQuery);
-
-        return setter;
-    }
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/QueryEngine.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import static com.redhat.thermostat.storage.core.experimental.statement.TypeMapper.Symbol;
-import static com.redhat.thermostat.storage.core.experimental.statement.TypeMapper.Clause;
-import static com.redhat.thermostat.storage.core.experimental.statement.TypeMapper.Symbol.Quote;
-import static com.redhat.thermostat.storage.core.experimental.statement.TypeMapper.Symbol.Sort;
-import static com.redhat.thermostat.storage.core.experimental.statement.TypeMapper.Symbol.Space;
-
-/**
- *
- */
-class QueryEngine extends StatementEngine {
-
-    private String limit;
-    private String sort;
-
-    public QueryEngine() {
-        super(TypeMapper.Statement.Query);
-        addDelimiter = false;
-        delimiter = TypeMapper.Symbol.InsertSeparator.id();
-        delimiter = Symbol.QuerySeparator.id();
-        tokens.add(Clause.Query.id());
-    }
-
-    public QueryEngine add(FieldDescriptor descriptor, TypeMapper.Criteria criteria) {
-
-        if (addDelimiter) {
-            tokens.add(delimiter);
-        }
-
-        addDelimiter = true;
-
-        StringBuilder field = new StringBuilder();
-
-        field.append(Quote.id());
-        field.append(descriptor.getName());
-        field.append(Quote.id());
-
-        tokens.add(field.toString());
-
-        tokens.add(criteria.id());
-        tokens.add(TypeMapper.get(descriptor.getType()));
-
-        return this;
-    }
-
-    public QueryEngine sort(FieldDescriptor descriptor, TypeMapper.Sort criteria) {
-
-        StringBuilder field = new StringBuilder();
-
-        field.append(Sort.id());
-        field.append(Space.id());
-
-        field.append(Quote.id());
-        field.append(descriptor.getName());
-        field.append(Quote.id());
-
-        field.append(Space.id());
-        field.append(criteria.id());
-
-        sort = field.toString();
-
-        return this;
-    }
-
-    public QueryEngine limit() {
-
-        StringBuilder field = new StringBuilder();
-
-        field.append(Symbol.Limit.id());
-        field.append(Space.id());
-        field.append(TypeMapper.get(int.class));
-
-        limit = field.toString();
-
-        return this;
-    }
-
-    @Override
-    protected void addPrologueClause() {
-        tokens.add(Clause.Where.id());
-    }
-
-    @Override
-    protected void buildImpl(StringBuilder builder) {
-        if (sort != null) {
-            builder.append(Space.id()).append(sort);
-        }
-
-        if (limit != null) {
-            builder.append(Space.id()).append(limit);
-        }
-    }
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/QueryValues.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.redhat.thermostat.storage.core.Id;
-
-/**
- *
- */
-public class QueryValues {
-
-    private static final Class<?> EMPTY_VALUE = QueryValues.class;
-
-    private Query query;
-    private Map<Id, Value> values;
-    private Map<Id, Class<?>> types;
-
-    protected QueryValues(Query query) {
-        this.query = query;
-        values = new HashMap<>();
-        types = new HashMap<>();
-    }
-
-    public Query getQuery() {
-        return query;
-    }
-
-    public void set(Id criteriaId, String value) {
-        setImpl(criteriaId, value);
-    }
-
-    public void set(Id criteriaId, long value) {
-        setImpl(criteriaId, value);
-    }
-
-    public void set(Id criteriaId, int value) {
-        setImpl(criteriaId, value);
-    }
-
-    public void set(Id criteriaId, boolean value) {
-        setImpl(criteriaId, value);
-    }
-
-    private void setImpl(Id criteriaId, Object value) {
-        if (!values.containsKey(criteriaId)) {
-            throw new IllegalArgumentException("Query does not contain this criteria");
-        }
-        check(criteriaId, value);
-    }
-
-    private void check(Id criteriaId, Object value) {
-
-        Class<?> type = value.getClass();
-        Class<?> targetType = types.get(criteriaId);
-
-        boolean match = false;
-        if (targetType.isAssignableFrom(int.class) ||
-            targetType.isAssignableFrom(Integer.class))
-        {
-            if (type.isAssignableFrom(int.class) ||
-                type.isAssignableFrom(Integer.class))
-            {
-                match = true;
-            }
-        } else if (targetType.isAssignableFrom(long.class) ||
-                   targetType.isAssignableFrom(Long.class))
-        {
-            if (type.isAssignableFrom(long.class) ||
-                type.isAssignableFrom(Long.class))
-            {
-                match = true;
-            }
-        } else if (targetType.isAssignableFrom(boolean.class) ||
-                   targetType.isAssignableFrom(Boolean.class))
-        {
-            if (type.isAssignableFrom(boolean.class) ||
-                type.isAssignableFrom(Boolean.class))
-            {
-                match = true;
-            }
-        } else if (targetType.isAssignableFrom(String.class)) {
-            if (type.isAssignableFrom(String.class))
-            {
-                match = true;
-            }
-        }
-
-        if (!match) {
-            throw new IllegalArgumentException("value type does not match " +
-                                               "target criteria with id: " +
-                                               criteriaId.get() +
-                                               " Wanted: "  +
-                                               targetType + ", received: "  +
-                                               type);
-        }
-
-        values.put(criteriaId, new Value(value));
-    }
-
-    public void set(Criterion criterion, Object value) {
-        setImpl(criterion.getId(), value);
-    }
-
-    Value getValue(Criterion criterion) {
-        return values.get(criterion.getId());
-    }
-
-    void addCriteria(List<Criterion> _criteria) {
-        for (Criterion criterion : _criteria) {
-
-            // sort doesn't take values
-            if (criterion instanceof SortCriterion) {
-                continue;
-            }
-
-            Id id = criterion.getId();
-            values.put(id, new Value(EMPTY_VALUE));
-            types.put(id, criterion.getType());
-        }
-    }
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/ResultHandler.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-/**
- *
- */
-public interface ResultHandler<T> {
-    /**
-     * The return value indicates whether or not the statement engine should
-     * continue returning results as long as they are available. If the handler
-     * return {@code false}, the engine will not invoke this method anymore;
-     * it is still possible that the statement engine has more results already
-     * loaded in memory as a result of caching or other optimisation, however
-     * no more interaction with this handler will be performed.
-     */
-    boolean onResult(T result);
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/SortCriterion.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import com.redhat.thermostat.storage.core.Id;
-
-/**
- *
- */
-public class SortCriterion implements Criterion {
-    private FieldDescriptor descriptor;
-    private TypeMapper.Sort criteria;
-
-    private Id id;
-
-    public SortCriterion(FieldDescriptor descriptor,
-                         TypeMapper.Sort criteria)
-    {
-        this(new Id(descriptor.getName() + ":" + criteria.name()), descriptor, criteria);
-    }
-
-    private SortCriterion(Id id,
-                          FieldDescriptor descriptor,
-                          TypeMapper.Sort criteria)
-    {
-        this.descriptor = descriptor;
-        this.criteria = criteria;
-    }
-
-    @Override
-    public Class<?> getType() {
-        return descriptor.getType();
-    }
-
-    public FieldDescriptor getFieldDescriptor() {
-        return descriptor;
-    }
-
-    public TypeMapper.Sort getCriteria() {
-        return criteria;
-    }
-
-    @Override
-    public Id getId() {
-        return id;
-    }
-
-    @Override
-    public String toString() {
-        return "[Sort: " + criteria.name() + " -: " + descriptor + "]";
-    }
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/Statement.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-/**
- *
- */
-class Statement {
-    private String statement;
-
-    public Statement(String statement) {
-        this.statement = statement;
-    }
-
-    public String get() {
-        return statement;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-
-        if (o == null) {
-            return false;
-        }
-
-        if (o instanceof String && statement != null) {
-            return o.equals(statement);
-        }
-
-        if (getClass() != o.getClass()) return false;
-
-        Statement statement1 = (Statement) o;
-
-        if (statement != null ? !statement.equals(statement1.statement) :
-                                 statement1.statement != null)
-        {
-            return false;
-        }
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        return statement != null ? statement.hashCode() : 0;
-    }
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/StatementEngine.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import com.redhat.thermostat.storage.model.Pojo;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- *
- */
-abstract class StatementEngine {
-
-    protected List<String> tokens;
-
-    private TypeMapper.Statement type;
-    protected String delimiter;
-
-    protected boolean addDelimiter;
-
-    protected StatementEngine(TypeMapper.Statement type) {
-        tokens = new LinkedList<>();
-        this.type = type;
-        addDelimiter = false;
-    }
-
-    protected StatementEngine add(FieldDescriptor descriptor, TypeMapper.Criteria criteria) {
-
-        if (addDelimiter) {
-            tokens.add(delimiter);
-        }
-
-        addDelimiter = true;
-
-        StringBuilder field = new StringBuilder();
-
-        field.append(TypeMapper.Symbol.Quote.id());
-        field.append(descriptor.getName());
-        field.append(TypeMapper.Symbol.Quote.id());
-
-        tokens.add(field.toString());
-
-        tokens.add(criteria.id());
-        tokens.add(TypeMapper.get(descriptor.getType()));
-
-        return this;
-    }
-
-    protected abstract void addPrologueClause();
-
-    public StatementEngine prologue(com.redhat.thermostat.storage.core.Category<? extends Pojo> category) {
-        tokens.add(category.getName());
-        addPrologueClause();
-        return this;
-    }
-
-    protected void buildImpl(StringBuilder builder) {}
-
-
-    public Statement build() {
-        StringBuilder builder = new StringBuilder();
-        for (String token : tokens) {
-            builder.append(token).append(TypeMapper.Symbol.Space.id());
-        }
-        int position = builder.length() - 1;
-        builder.deleteCharAt(position);
-
-        buildImpl(builder);
-
-        return new Statement(builder.toString());
-    }
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/StatementUtils.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,179 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import com.redhat.thermostat.storage.core.Persist;
-import com.redhat.thermostat.storage.core.PreparedStatement;
-import com.redhat.thermostat.storage.model.Pojo;
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- *
- */
-public class StatementUtils {
-
-    static boolean isPersistent(PropertyDescriptor desc) {
-        return hasAnnotation(desc, Persist.class);
-    }
-
-    static boolean isIndexed(PropertyDescriptor desc) {
-        return hasAnnotation(desc, Indexed.class);
-    }
-
-    static <T extends Pojo> String getDocument(Class<T> pojoClass) {
-        if (!pojoClass.isAnnotationPresent(Category.class)) {
-            return null;
-        }
-
-        return pojoClass.getAnnotation(Category.class).value();
-    }
-
-    static boolean hasAnnotation(PropertyDescriptor desc,
-                                 Class<? extends Annotation> annotation)
-    {
-        Method readMethod = desc.getReadMethod();
-        boolean hasRead = (readMethod != null &&
-                           readMethod.isAnnotationPresent(annotation));
-
-        Method writeMethod = desc.getWriteMethod();
-        boolean hasWrite = (writeMethod != null &&
-                            writeMethod.isAnnotationPresent(annotation));
-
-        return hasRead && hasWrite;
-    }
-
-    public static Map<String, FieldDescriptor> createDescriptorMap(List<FieldDescriptor> descriptors) {
-        Map<String, FieldDescriptor> map = new HashMap<>();
-        for (FieldDescriptor desc : descriptors) {
-            map.put(desc.getName(), desc);
-        }
-        return map;
-    }
-
-    public static <T extends Pojo> List<FieldDescriptor> createDescriptors(Class<T> pojoClass) {
-        try {
-            BeanInfo info = Introspector.getBeanInfo(pojoClass);
-            PropertyDescriptor[] props = info.getPropertyDescriptors();
-
-            List<FieldDescriptor> descriptors = new ArrayList<>();
-            for (PropertyDescriptor desc : props) {
-
-                if (StatementUtils.isPersistent(desc)) {
-                    FieldDescriptor descriptor = new FieldDescriptor();
-                    descriptor.setType(desc.getPropertyType());
-                    descriptor.setName(desc.getName());
-                    descriptor.setIndexed(StatementUtils.isIndexed(desc));
-
-                    descriptors.add(descriptor);
-                }
-            }
-
-            // Afaik it's not specified that methods are returned or listed in
-            // any particular order by Introspector.getBeanInfo, so if we don't
-            // sort, we may end up with two differently ordered lists in two
-            // different calls to this method.
-            // This is a problem because the prepated statement API doesn't
-            // check if two statements are the same if fields are sorted in
-            // random order, it only considers two statements the same if
-            // their string representation completely matches;
-            // it also make the code depending on FieldDescriptor easier to
-            // write if it can count on the ordering being always consistent
-            Collections.sort(descriptors, new Comparator<FieldDescriptor>() {
-                @Override
-                public int compare(FieldDescriptor o1, FieldDescriptor o2) {
-                    return o1.getName().compareTo(o2.getName());
-                }
-            });
-
-            return Collections.unmodifiableList(descriptors);
-
-        } catch (IntrospectionException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    static <T extends Pojo> Value getValue(T bean,  FieldDescriptor descriptor)
-    {
-        try {
-            PropertyDescriptor property =
-                    new PropertyDescriptor(descriptor.getName(),
-                                           bean.getClass());
-            Method method = property.getReadMethod();
-            method.setAccessible(true);
-
-            return new Value(method.invoke(bean, new Object[0]));
-
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    static <T extends Pojo> void setData(PreparedStatement<T> prepared,
-                                         Value value, int index)
-    {
-        Class<?> type = value.get().getClass();
-        if (type.isAssignableFrom(int.class) ||
-            type.isAssignableFrom(Integer.class))
-        {
-            prepared.setInt(index, ((Integer) value.get()).intValue());
-
-        } else if (type.isAssignableFrom(long.class) ||
-                   type.isAssignableFrom(Long.class))
-        {
-            prepared.setLong(index, ((Long) value.get()).longValue());
-
-        } else if (type.isAssignableFrom(boolean.class) ||
-                   type.isAssignableFrom(Boolean.class))
-        {
-            prepared.setBoolean(index, ((Boolean) value.get()).booleanValue());
-
-        } else if (type.isAssignableFrom(String.class)) {
-            prepared.setString(index, (String) value.get());
-        }
-    }
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/TypeMapper.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- */
-public class TypeMapper {
-
-    private static final Map<Class<?>, String> map = new HashMap<>();
-    static {
-        map.put(String.class, "?s");
-        map.put(int.class, "?i");
-        map.put(long.class, "?l");
-        map.put(boolean.class, "?b");
-    }
-
-    static String get(Class<?> type) {
-        return map.get(type);
-    }
-
-    static enum Symbol {
-
-        QuerySeparator("AND"),
-        InsertSeparator(","),
-
-        Quote("'"),
-        Space(" "),
-
-        Sort("SORT"),
-        Limit("LIMIT"),
-
-        ;
-
-        private final String definition;
-        Symbol(String definition) {
-            this.definition = definition;
-        }
-
-        public String id() {
-            return definition;
-        }
-    }
-
-    public static enum Criteria {
-        Less("<"),
-        LessEqual("<="),
-
-        Equal("="),
-
-        Greater(">"),
-        GreaterEqual(">="),
-
-        ;
-
-        private final String definition;
-        Criteria(String definition) {
-            this.definition = definition;
-        }
-
-        public String id() {
-            return definition;
-        }
-    }
-
-    public static enum Sort {
-        Ascending("ASC"),
-        Descending("DSC"),
-        ;
-
-        private final String definition;
-        Sort(String definition) {
-            this.definition = definition;
-        }
-
-        public String id() {
-            return definition;
-        }
-    }
-
-    static enum Statement {
-        Query,
-        Insert,
-    }
-
-    static enum Clause {
-
-        Add("ADD"),
-        Set("SET"),
-
-        Query("QUERY"),
-        Where("WHERE"),
-
-        ;
-
-        private final String definition;
-        Clause(String definition) {
-            this.definition = definition;
-        }
-
-        public String id() {
-            return definition;
-        }
-    }
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/Value.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-/**
- *
- */
-public class Value {
-    private Object value;
-
-    public Value(Object value) {
-        this.value = value;
-    }
-
-    public Object get() {
-        return value;
-    }
-}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/experimental/statement/WhereCriterion.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import java.util.Objects;
-
-import com.redhat.thermostat.storage.core.Id;
-
-/**
- *
- */
-public class WhereCriterion implements Criterion {
-
-    private Id id;
-
-    private FieldDescriptor descriptor;
-    private TypeMapper.Criteria criteria;
-
-    public WhereCriterion(Id id,
-                          FieldDescriptor descriptor,
-                          TypeMapper.Criteria criteria)
-    {
-        Objects.requireNonNull(id, "id must be not null");
-        Objects.requireNonNull(criteria, "criteria must be not null");
-        Objects.requireNonNull(descriptor, "descriptor must be not null");
-
-        this.descriptor = descriptor;
-        this.criteria = criteria;
-        this.id = id;
-    }
-
-    @Override
-    public Class<?> getType() {
-        return descriptor.getType();
-    }
-
-    @Override
-    public Id getId() {
-        return id;
-    }
-
-    public FieldDescriptor getFieldDescriptor() {
-        return descriptor;
-    }
-
-    public TypeMapper.Criteria getCriteria() {
-        return criteria;
-    }
-
-    @Override
-    public String toString() {
-        return "[" + criteria.name() + " -: " + descriptor + "]";
-    }
-}
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/BeanAdapterBuilderTest.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import com.redhat.thermostat.storage.core.DescriptorParsingException;
-import com.redhat.thermostat.storage.core.Id;
-import com.redhat.thermostat.storage.core.StatementDescriptor;
-import com.redhat.thermostat.storage.internal.statement.StatementDescriptorTester;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public class BeanAdapterBuilderTest {
-
-    private List<Query<SampleBean>> queries;
-
-    @Before
-    public void setUp() {
-        queries = new ArrayList<>();
-
-        List<FieldDescriptor> descriptors = StatementUtils.createDescriptors(SampleBean.class);
-        final Map<String, FieldDescriptor> map = StatementUtils.createDescriptorMap(descriptors);
-        Query query = new Query<SampleBean>() {
-            @Override
-            protected void describe(Criteria criterias) {
-                criterias.add(new WhereCriterion(new Id("name"), map.get("name"), TypeMapper.Criteria.Equal));
-                criterias.add(new WhereCriterion(new Id("vmId>="), map.get("vmId"), TypeMapper.Criteria.GreaterEqual));
-                criterias.add(new WhereCriterion(new Id("vmId<="), map.get("vmId"), TypeMapper.Criteria.LessEqual));
-                criterias.add(new SortCriterion(map.get("timeStamp"), TypeMapper.Sort.Ascending));
-                criterias.add(new LimitCriterion(new Id("limit")));
-            }
-
-            @Override
-            public Id getId() {
-                return new Id("SortByTimeStamp");
-            }
-        };
-        queries.add(query);
-
-        query = new Query<SampleBean>() {
-            @Override
-            protected void describe(Criteria criterias) {
-                criterias.add(new WhereCriterion(new Id("name"), map.get("name"), TypeMapper.Criteria.Equal));
-                criterias.add(new WhereCriterion(new Id("timeStamp>="), map.get("timeStamp"), TypeMapper.Criteria.GreaterEqual));
-                criterias.add(new WhereCriterion(new Id("timeStamp<="), map.get("timeStamp"), TypeMapper.Criteria.LessEqual));
-                criterias.add(new SortCriterion(map.get("timeStamp"), TypeMapper.Sort.Ascending));
-                criterias.add(new LimitCriterion(new Id("limit")));
-            }
-
-            @Override
-            public Id getId() {
-                return new Id("RangedQuery");
-            }
-        };
-        queries.add(query);
-    }
-
-    @Test
-    public void testBeanAdapterBuilder() throws Exception {
-
-        BeanAdapterBuilder<SampleBean> builder =
-                new BeanAdapterBuilder<>(SampleBean.class, queries);
-
-        BeanAdapter<SampleBean> adapter = builder.build();
-        assertNotNull(adapter);
-
-        com.redhat.thermostat.storage.core.Category<SampleBean> category =
-                adapter.getCategory();
-
-        assertNotNull(category);
-        assertEquals("testCategory", category.getName());
-
-        String expected = "ADD testCategory SET 'name' = ?s , 'timeStamp' = ?l , 'vmId' = ?i";
-        Set<String> statements = adapter.describeStatements();
-
-        assertEquals(3, statements.size());
-        assertTrue(statements.contains(expected));
-
-        expected = "QUERY testCategory WHERE 'name' = ?s AND 'vmId' >= ?i AND 'vmId' <= ?i SORT 'timeStamp' ASC LIMIT ?i";
-        assertTrue(statements.contains(expected));
-
-        expected = "QUERY testCategory WHERE 'name' = ?s AND 'timeStamp' >= ?l AND 'timeStamp' <= ?l SORT 'timeStamp' ASC LIMIT ?i";
-        assertTrue(statements.contains(expected));
-
-        for (String s : statements) {
-            testStatement(category, s);
-        }
-    }
-
-    private void testStatement(com.redhat.thermostat.storage.core.Category<SampleBean> category,
-                               String statement) throws DescriptorParsingException
-    {
-        StatementDescriptorTester<SampleBean> tester = new StatementDescriptorTester<>();
-        StatementDescriptor<SampleBean> desc = new StatementDescriptor<>(category, statement);
-        tester.testParseBasic(desc);
-        tester.testParseSemantic(desc);
-    }
-}
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/BeanAdapterTest.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,286 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import com.redhat.thermostat.storage.core.Cursor;
-import com.redhat.thermostat.storage.core.Id;
-import com.redhat.thermostat.storage.core.PreparedStatement;
-import com.redhat.thermostat.storage.core.StatementDescriptor;
-import com.redhat.thermostat.storage.core.Storage;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
-
-public class BeanAdapterTest {
-
-    private Storage storage;
-    private PreparedStatement<SampleBean> insert;
-    private PreparedStatement<SampleBean> query;
-
-    private List<Query<SampleBean>> queries;
-
-    private static final Id SORT = new Id("SortByTimeStamp");
-    private static final Id RANGE = new Id("RangedQuery");
-
-    @Before
-    public void setUp() throws Exception {
-        storage = mock(Storage.class);
-        insert = mock(PreparedStatement.class);
-        query = mock(PreparedStatement.class);
-
-        queries = new ArrayList<>();
-
-        List<FieldDescriptor> descriptors = StatementUtils.createDescriptors(SampleBean.class);
-        final Map<String, FieldDescriptor> map = StatementUtils.createDescriptorMap(descriptors);
-        Query query = new Query<SampleBean>() {
-            @Override
-            protected void describe(Criteria criterias) {
-                criterias.add(new WhereCriterion(new Id("0"), map.get("name"), TypeMapper.Criteria.Equal));
-                criterias.add(new WhereCriterion(new Id("1"), map.get("vmId"), TypeMapper.Criteria.GreaterEqual));
-                criterias.add(new WhereCriterion(new Id("2"), map.get("vmId"), TypeMapper.Criteria.LessEqual));
-                criterias.add(new SortCriterion(map.get("timeStamp"), TypeMapper.Sort.Ascending));
-                criterias.add(new LimitCriterion(new Id("3")));
-            }
-
-            @Override
-            public Id getId() {
-                return SORT;
-            }
-        };
-        queries.add(query);
-
-        query = new Query<SampleBean>() {
-            @Override
-            protected void describe(Criteria criterias) {
-                criterias.add(new WhereCriterion(new Id("0"), map.get("name"), TypeMapper.Criteria.Equal));
-                criterias.add(new WhereCriterion(new Id("1"), map.get("timeStamp"), TypeMapper.Criteria.GreaterEqual));
-                criterias.add(new WhereCriterion(new Id("2"), map.get("timeStamp"), TypeMapper.Criteria.LessEqual));
-                criterias.add(new SortCriterion(map.get("timeStamp"), TypeMapper.Sort.Descending));
-                criterias.add(new LimitCriterion(new Id("3")));
-            }
-
-            @Override
-            public Id getId() {
-                return RANGE;
-            }
-        };
-        queries.add(query);
-    }
-
-    @Test
-    public void testHasQueries() throws Exception {
-        BeanAdapterBuilder<SampleBean> builder =
-                new BeanAdapterBuilder<>(SampleBean.class, queries);
-
-        BeanAdapter<SampleBean> adapter = builder.build();
-
-        Query query = adapter.getQuery(SORT);
-        assertSame(queries.get(0), query);
-
-        query = adapter.getQuery(RANGE);
-        assertSame(queries.get(1), query);
-    }
-
-    @Test
-    public void testInsert() throws Exception {
-        when(storage.prepareStatement(any(StatementDescriptor.class))).thenReturn(insert);
-
-        BeanAdapterBuilder<SampleBean> builder =
-                new BeanAdapterBuilder<>(SampleBean.class, queries);
-
-        BeanAdapter<SampleBean> adapter = builder.build();
-
-        SampleBean bean = new SampleBean();
-        bean.setName("fluff");
-        bean.setTimeStamp(1000l);
-        bean.setVmId(0xcafe);
-
-        adapter.insert(bean, storage);
-
-        verify(storage).prepareStatement(any(StatementDescriptor.class));
-
-        // the order is given by the bean methods, they are sorted in
-        // alphabetical order, this is not really important though,
-        // since the order is based on the same FieldDescriptors used by
-        // both the builder and the adapter, so it's transparent to the user
-
-        verify(insert).setString(0, "fluff");
-        verify(insert).setLong(1, 1000l);
-        verify(insert).setInt(2, 0xcafe);
-
-        verify(insert).execute();
-        verifyNoMoreInteractions(insert);
-    }
-
-    @Test
-    public void testSortQuery() throws Exception {
-
-        when(storage.prepareStatement(any(StatementDescriptor.class))).thenReturn(query);
-        Cursor cursor = mock(Cursor.class);
-        SampleBean sample = mock(SampleBean.class);
-        when(query.executeQuery()).thenReturn(cursor);
-        when(cursor.hasNext()).thenReturn(true).thenReturn(false);
-        when(cursor.next()).thenReturn(sample);
-
-        BeanAdapterBuilder<SampleBean> builder =
-                new BeanAdapterBuilder<>(SampleBean.class, queries);
-
-        BeanAdapter<SampleBean> adapter = builder.build();
-        Query sort = adapter.getQuery(SORT);
-        assertNotNull(sort);
-        assertSame(sort, queries.get(0));
-
-        QueryValues values = sort.createValues();
-        values.set(new Id("0"), "fluff");
-        values.set(new Id("1"), 5);
-        values.set(new Id("2"), 5);
-        values.set(new Id("3"), 2);
-
-        final boolean [] called = new boolean[1];
-        ResultHandler<SampleBean> handler = new ResultHandler<SampleBean>() {
-            @Override
-            public boolean onResult(SampleBean result) {
-                called[0] = true;
-                return true;
-            }
-        };
-
-        adapter.query(values, handler, storage);
-
-        verify(query).setString(0, "fluff");
-        verify(query).setInt(1, 5);
-        verify(query).setInt(2, 5);
-        verify(query).setInt(3, 2);
-
-        assertTrue(called[0]);
-    }
-
-    @Test
-    public void testRangeQuery() throws Exception {
-
-        when(storage.prepareStatement(any(StatementDescriptor.class))).thenReturn(query);
-        Cursor cursor = mock(Cursor.class);
-        SampleBean sample = mock(SampleBean.class);
-        when(query.executeQuery()).thenReturn(cursor);
-        when(cursor.hasNext()).thenReturn(true).thenReturn(false);
-        when(cursor.next()).thenReturn(sample);
-
-        BeanAdapterBuilder<SampleBean> builder =
-                new BeanAdapterBuilder<>(SampleBean.class, queries);
-
-        BeanAdapter<SampleBean> adapter = builder.build();
-        Query range = adapter.getQuery(RANGE);
-        assertNotNull(range);
-        assertSame(range, queries.get(1));
-
-        QueryValues values = range.createValues();
-        values.set(new Id("0"), "fluff");
-        values.set(new Id("1"), 10l);
-        values.set(new Id("2"), 20l);
-        values.set(new Id("3"), 2);
-
-        final boolean [] called = new boolean[1];
-        ResultHandler<SampleBean> handler = new ResultHandler<SampleBean>() {
-            @Override
-            public boolean onResult(SampleBean result) {
-                called[0] = true;
-                return true;
-            }
-        };
-
-        adapter.query(values, handler, storage);
-
-        verify(query).setString(0, "fluff");
-        verify(query).setLong(1, 10);
-        verify(query).setLong(2, 20);
-        verify(query).setInt(3, 2);
-
-        assertTrue(called[0]);
-    }
-
-    @Test
-    public void testSkipResultsOnHandlerRequest() throws Exception {
-        when(storage.prepareStatement(any(StatementDescriptor.class))).thenReturn(query);
-        Cursor cursor = mock(Cursor.class);
-
-        final SampleBean sample0 = mock(SampleBean.class);
-        final SampleBean sample1 = mock(SampleBean.class);
-        final SampleBean sample2 = mock(SampleBean.class);
-
-        when(query.executeQuery()).thenReturn(cursor);
-        when(cursor.hasNext()).thenReturn(true).thenReturn(true).thenReturn(true);
-        when(cursor.next()).thenReturn(sample0).thenReturn(sample1).thenReturn(sample2);
-
-        BeanAdapterBuilder<SampleBean> builder =
-                new BeanAdapterBuilder<>(SampleBean.class, queries);
-
-        BeanAdapter<SampleBean> adapter = builder.build();
-        Query range = adapter.getQuery(RANGE);
-        QueryValues values = range.createValues();
-        values.set(new Id("0"), "fluff");
-        values.set(new Id("1"), 10l);
-        values.set(new Id("2"), 20l);
-        values.set(new Id("3"), 2);
-
-        ResultHandler<SampleBean> handler = new ResultHandler<SampleBean>() {
-            @Override
-            public boolean onResult(SampleBean result) {
-                if (result.equals(sample1)) {
-                    return false;
-                }
-                return true;
-            }
-        };
-        adapter.query(values, handler, storage);
-
-        verify(cursor, times(2)).next();
-    }
-}
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/CategoryBuilderTest.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import com.redhat.thermostat.storage.core.Key;
-import java.util.Collection;
-import java.util.List;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public class CategoryBuilderTest {
-
-    private static final String CATEGORY_NAME = "testCategory";
-    @Test
-    public void testBuild() throws Exception {
-        CategoryBuilder<SampleBean> builder =  new CategoryBuilder<>(SampleBean.class);
-        com.redhat.thermostat.storage.core.Category<SampleBean> category =
-                builder.build();
-
-        assertNotNull(category);
-        assertEquals(CATEGORY_NAME, category.getName());
-        assertEquals(SampleBean.class, category.getDataClass());
-
-        List<Key<?>> indexed = category.getIndexedKeys();
-        assertEquals(2, indexed.size());
-
-        Key key0 = new Key("vmId");
-        Key key1 = new Key("timeStamp");
-
-        assertTrue(indexed.contains(key0));
-        assertTrue(indexed.contains(key1));
-
-        Collection<Key<?>> keys = category.getKeys();
-        assertEquals(3, keys.size());
-
-        Key key2 = new Key("name");
-
-        assertTrue(keys.contains(key0));
-        assertTrue(keys.contains(key1));
-        assertTrue(keys.contains(key2));
-    }
-}
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/InsertEngineTest.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import com.redhat.thermostat.storage.core.experimental.statement.FieldDescriptor;
-import com.redhat.thermostat.storage.core.experimental.statement.InsertEngine;
-import com.redhat.thermostat.storage.core.experimental.statement.Statement;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class InsertEngineTest {
-    private com.redhat.thermostat.storage.core.Category category;
-    private FieldDescriptor descriptor0;
-    private FieldDescriptor descriptor1;
-    private FieldDescriptor descriptor2;
-
-    @Before
-    public void setup() {
-        category = mock(com.redhat.thermostat.storage.core.Category.class);
-        when(category.getName()).thenReturn("testCategory");
-
-        descriptor0 = mock(FieldDescriptor.class);
-        when(descriptor0.getName()).thenReturn("descriptor0");
-        Class type = String.class;
-        when(descriptor0.getType()).thenReturn(type);
-
-        descriptor1 = mock(FieldDescriptor.class);
-        when(descriptor1.getName()).thenReturn("descriptor1");
-        type = long.class;
-        when(descriptor1.getType()).thenReturn(type);
-
-        descriptor2 = mock(FieldDescriptor.class);
-        when(descriptor2.getName()).thenReturn("descriptor2");
-        type = int.class;
-        when(descriptor2.getType()).thenReturn(type);
-    }
-
-    @Test
-    public void testBuildInsert() throws Exception {
-        InsertEngine engine = new InsertEngine();
-
-        engine.prologue(category);
-        engine.add(descriptor0);
-        engine.add(descriptor1);
-        engine.add(descriptor2);
-
-        Statement statement = engine.build();
-
-        String expected = "ADD testCategory SET 'descriptor0' = ?s , 'descriptor1' = ?l , 'descriptor2' = ?i";
-        assertEquals(expected, statement.get());
-    }
-}
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/InvalidSampleBean.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import com.redhat.thermostat.storage.core.Persist;
-import com.redhat.thermostat.storage.model.TimeStampedPojo;
-
-@Category("testCategory2")
-public class InvalidSampleBean implements TimeStampedPojo {
-
-    private long timeStamp;
-    private int vmId;
-    private String name;
-
-    public int getVmId() {
-        return vmId;
-    }
-
-    @Indexed
-    @Persist
-    public void setVmId(int vmId) {
-        this.vmId = vmId;
-    }
-
-    @Persist
-    public String getName() {
-        return name;
-    }
-
-    @Persist
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public void setTimeStamp(long timeStamp) {
-        this.timeStamp = timeStamp;
-    }
-
-    @Indexed
-    @Persist
-    @Override
-    public long getTimeStamp() {
-        return timeStamp;
-    }
-}
\ No newline at end of file
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/QueryEngineTest.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class QueryEngineTest {
-    private com.redhat.thermostat.storage.core.Category category;
-    private FieldDescriptor descriptor0;
-    private FieldDescriptor descriptor1;
-    private FieldDescriptor descriptor2;
-
-    @Before
-    public void setup() {
-        category = mock(com.redhat.thermostat.storage.core.Category.class);
-        when(category.getName()).thenReturn("testCategory");
-
-        descriptor0 = mock(FieldDescriptor.class);
-        when(descriptor0.getName()).thenReturn("descriptor0");
-        Class type = String.class;
-        when(descriptor0.getType()).thenReturn(type);
-
-        descriptor1 = mock(FieldDescriptor.class);
-        when(descriptor1.getName()).thenReturn("descriptor1");
-        type = long.class;
-        when(descriptor1.getType()).thenReturn(type);
-
-        descriptor2 = mock(FieldDescriptor.class);
-        when(descriptor2.getName()).thenReturn("descriptor2");
-        type = int.class;
-        when(descriptor2.getType()).thenReturn(type);
-    }
-
-    @Test
-    public void testBuildQuery() throws Exception {
-        QueryEngine engine = new QueryEngine();
-
-        engine.prologue(category);
-        engine.add(descriptor0, TypeMapper.Criteria.Equal);
-        engine.add(descriptor1, TypeMapper.Criteria.GreaterEqual);
-        engine.add(descriptor2, TypeMapper.Criteria.LessEqual);
-
-        engine.limit();
-        engine.sort(descriptor1, TypeMapper.Sort.Ascending);
-
-        Statement statement = engine.build();
-
-        String expected = "QUERY testCategory WHERE 'descriptor0' = ?s AND 'descriptor1' >= ?l AND 'descriptor2' <= ?i SORT 'descriptor1' ASC LIMIT ?i";
-
-        assertEquals(expected, statement.get());
-    }
-}
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/QueryValuesTest.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import com.redhat.thermostat.storage.core.Id;
-
-public class QueryValuesTest {
-
-    private Query query;
-    private List<Criterion> criterias;
-
-    private Criterion criterion0;
-    private Criterion criterion1;
-    private Criterion criterion2;
-
-    @Before
-    public void setup() {
-        query = mock(Query.class);
-        criterias = new ArrayList<>();
-
-        criterion0 = mock(Criterion.class);
-        when(criterion0.getType()).thenReturn((Class)  int.class);
-        when(criterion0.getId()).thenReturn(new Id("0"));
-
-        criterion1 = mock(Criterion.class);
-        when(criterion1.getType()).thenReturn((Class) String.class);
-        when(criterion1.getId()).thenReturn(new Id("1"));
-
-        criterion2 = mock(Criterion.class);
-        when(criterion2.getType()).thenReturn((Class) long.class);
-        when(criterion2.getId()).thenReturn(new Id("2"));
-
-        criterias.add(criterion0);
-        criterias.add(criterion1);
-        criterias.add(criterion2);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testSetWithWrongArguments() throws Exception {
-
-        QueryValues values = new QueryValues(query);
-        values.addCriteria(criterias);
-
-        values.set(criterion0, "wrong type");
-    }
-
-    @Test
-    public void testSet() throws Exception {
-
-        QueryValues values = new QueryValues(query);
-        values.addCriteria(criterias);
-
-        values.set(criterion0, 10);
-        values.set(criterion1, "test");
-        values.set(criterion2, 42l);
-    }
-}
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/SampleBean.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import com.redhat.thermostat.storage.core.Persist;
-import com.redhat.thermostat.storage.model.TimeStampedPojo;
-
-@Category("testCategory")
-public class SampleBean implements TimeStampedPojo {
-
-    private long timeStamp;
-    private int vmId;
-    private String name;
-
-    @Indexed
-    @Persist
-    public int getVmId() {
-        return vmId;
-    }
-
-    @Indexed
-    @Persist
-    public void setVmId(int vmId) {
-        this.vmId = vmId;
-    }
-
-    @Persist
-    public String getName() {
-        return name;
-    }
-
-    @Persist
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    @Indexed
-    @Persist
-    public void setTimeStamp(long timeStamp) {
-        this.timeStamp = timeStamp;
-    }
-
-    @Indexed
-    @Persist
-    @Override
-    public long getTimeStamp() {
-        return timeStamp;
-    }
-}
\ No newline at end of file
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/StatementTest.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class StatementTest {
-
-    @Test
-    public void testEquals() throws Exception {
-        Statement statement = new Statement("test");
-        Statement statement2 = new Statement("test");
-
-        assertTrue(statement.equals("test"));
-        assertTrue(statement.equals(statement2));
-
-        statement2 = new Statement("fluff");
-        assertFalse(statement.equals("fluff"));
-        assertFalse(statement.equals(statement2));
-    }
-
-    @Test
-    public void testHashCode() throws Exception {
-        Statement statement = new Statement("test");
-        Statement statement2 = new Statement("test");
-
-        assertEquals(statement.hashCode(), statement2.hashCode());
-
-        statement2 = new Statement("fluff");
-        assertFalse(statement.hashCode() == statement2.hashCode());
-    }
-}
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/StatementUtilsTest.java	Thu May 11 11:40:48 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.core.experimental.statement;
-
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class StatementUtilsTest {
-
-    @Test
-    public void testAnnotationSupport() {
-        List<FieldDescriptor> descriptors =
-                StatementUtils.createDescriptors(SampleBean.class);
-        Map<String, FieldDescriptor> map =
-                StatementUtils.createDescriptorMap(descriptors);
-
-        assertTrue(map.containsKey("timeStamp"));
-
-        descriptors =  StatementUtils.createDescriptors(InvalidSampleBean.class);
-        map = StatementUtils.createDescriptorMap(descriptors);
-
-        assertFalse(map.containsKey("timeStamp"));
-    }
-}