Package com.onpositive.gae.baseviewer.requests

Examples of com.onpositive.gae.baseviewer.requests.IComplexQueryRequest


      ArrayList<IComplexQueryRequest> s = new ArrayList<IComplexQueryRequest>();
      SimpleRequest simpleRequest = new SimpleRequest(kind, simpleQuery,
          limit);
      s.add(simpleRequest);
      for (Filter f : otherFilters) {
        IComplexQueryRequest m = toRequest(f);
        if (m == null) {
          Display.getDefault().syncExec(new Runnable() {

            public void run() {
              MessageDialog.openError(Display.getCurrent()
                  .getActiveShell(), "Error",
                  "Unable to parse reification request");
            }
          });
          return;
        }
        s.add(m);
      }
      ThreadPoolExecutor px = new ThreadPoolExecutor(5, 5, 10000,
          TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(
              1000));

      HashSet<OrRunnable> l = new HashSet<OrRunnable>();
      for (final IComplexQueryRequest z : s) {
        OrRunnable runnable = new OrRunnable(z);
        l.add(runnable);
        px.execute(runnable);
      }
      l2: while ((!monitor.isCanceled())
          && (px.getCompletedTaskCount() != l.size())) {
        {
          try {
            px.awaitTermination(100, TimeUnit.MILLISECONDS);
            for (OrRunnable m : l) {
              if (m.completed != null && m.completed == true) {
                break l2;
              } else {

              }
            }
          } catch (InterruptedException e) {
          }
        }
      }
      monitor.beginTask("Analyzing results", 10);
      px.shutdownNow();

      HashSet<OrRunnable> incompleted = new HashSet<OrRunnable>();
      HashSet<OrRunnable> completed = new HashSet<OrRunnable>();
      for (OrRunnable m : l) {
        if (m.completed != null && m.completed == true) {
          completed.add(m);
        } else {
          incompleted.add(m);
        }
      }

      if (completed.size() != 0) {
        OrRunnable z = completed.iterator().next();
        HashSet<Object> r = z.results;
        for (OrRunnable q : completed) {
          if (q != z) {
            r.retainAll(q.results);
          }
        }
        if (incompleted.size() != 0) {
          for (OrRunnable q : incompleted) {
            q.z.filter(r);
          }
        }
        ArrayList<Object> results = new ArrayList<Object>(r);
        if (query.sort.property != null
            && query.sort.property.length() > 0) {
          Collections.sort(results, new BaseViewer.SortComparator(
              query.sort.property, query.sort.ascending));
        }

        boolean b = results.size() > limit;
        if (b) {
          ArrayList<Object> m = new ArrayList<Object>(limit);
          for (int a = 0; a < limit; a++) {
            m.add(results.get(a));
          }
          results = m;
        }
        Field[] determineFields = determineFields(results, fieldsMap);
        callback.fieldsFetched(determineFields);
View Full Code Here

TOP

Related Classes of com.onpositive.gae.baseviewer.requests.IComplexQueryRequest

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.