Package com.clarkparsia.empire.ds

Examples of com.clarkparsia.empire.ds.ResultSet


      if (isConstruct()) {
        Graph aGraph = getSource().graphQuery(query());
        aList.add(aGraph);
      }
      else {
        ResultSet aResults = getSource().selectQuery(query());

                try {
                    if (getBeanClass() != null) {
                        // for now, by convention, for this to work like the JPQL stuff where you do something like
                        // "from Product pr join pr.poc as p where p.id = ?" and expect to get a list of Product instances
                        // back as the result set, you *MUST* have a var in the projection called 'result' which is
                        // the URI of the things you want to get back; when you don't do this, we prefix your partial query
                        // with this string
                        while (aResults.hasNext()) {
              BindingSet aBS = aResults.next();

                            Object aObj;

                            String aVarName = getProjectionVarName();

                            if (aBS.getValue(aVarName) instanceof URI && AnnotationChecker.isValid(getBeanClass())) {
                                if (EmpireOptions.ENABLE_QUERY_RESULT_PROXY) {
                                    aObj = new Proxy(getBeanClass(), asPrimaryKey(aBS.getValue(aVarName)), getSource());
                                }
                                else {
                                    aObj = RdfGenerator.fromRdf(getBeanClass(),
                                                                asPrimaryKey(aBS.getValue(aVarName)),
                                                                getSource());
                                }
                            }
                            else {
                                aObj = new RdfGenerator.ValueToObject(getSource(), null,
                                                                      getBeanClass(), null).apply(aBS.getValue(aVarName));
                            }

                            // if the object could not be created, or it was and its not the bean class type, or not a proxy
                            // for something of the bean class type, then we could not bind the value in the result set
                            // which is an error.
                            if (aObj == null
                                || !(getBeanClass().isInstance(aObj) || (aObj instanceof Proxy && getBeanClass().isAssignableFrom(((Proxy)aObj).getProxyClass())))) {
                                throw new PersistenceException("Cannot bind query result to bean: " + getBeanClass());
                            }
                            else {
                                aList.add(aObj);
                            }
                        }
                    }
                    else {
                        aList.addAll(Lists.newArrayList(aResults));
                    }
                }
                finally {
                    aResults.close();
                }
      }
    }
    catch (Exception e) {
      throw new PersistenceException(e);
View Full Code Here

TOP

Related Classes of com.clarkparsia.empire.ds.ResultSet

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