public static void evaluateFetchQuery(KeyValueList keys, PrintableStringWriter out) {
    try {
      { Module temp000 = Stella.getStellaModule("EELD-EDB", false);

        { Module mdl000 = ((temp000 != null) ? temp000 : ((Module)(Stella.$MODULE$.get())));
          Context cxt000 = mdl000;

          if (mdl000 == null) {
            mdl000 = ((Module)(Stella.$MODULE$.get()));
            cxt000 = ((Context)(Stella.$CONTEXT$.get()));
          }
          { Object old$Module$000 = Stella.$MODULE$.get();
            Object old$Context$000 = Stella.$CONTEXT$.get();

            try {
              Native.setSpecial(Stella.$MODULE$, mdl000);
              Native.setSpecial(Stella.$CONTEXT$, cxt000);
              synchronized (Logic.$POWERLOOM_LOCK$) {
                { Stella_Object secondarydbname = keys.lookup(StringWrapper.wrapString("sdatabase"));
                  Stella_Object fetchdb = Stella_Object.get(((StringWrapper)(Stella_Object.copyConsTree(StringWrapper.wrapString("fetch-edb")))), Stella.NIL);
                  Stella_Object taskid = keys.lookup(StringWrapper.wrapString("task"));
                  Stella_Object subtaskid = keys.lookup(StringWrapper.wrapString("subtask"));
                  Stella_Object command = keys.lookup(StringWrapper.wrapString("command"));
                  Stella_Object result = null;

                  { OutputStream self000 = OutputStream.newOutputStream();

                    self000.nativeStream = out;
                    { OutputStream wrappedout = self000;

                      if (fetchdb != null) {
                        if (secondarydbname != null) {
                          edu.isi.powerloom.PLI.assertNaryProposition(Cons.cons(Logic.getRelation(RDBMS.SGT_RDBMS_DB_NAME), Cons.cons(fetchdb, Cons.cons(secondarydbname, Stella.NIL))), null, null);
                        }
                        if (taskid != null) {
                          edu.isi.powerloom.PLI.assertNaryProposition(Cons.cons(Logic.getRelation(RDBMS.SGT_RDBMS_TASK_ID), Cons.cons(fetchdb, Cons.cons(taskid, Stella.NIL))), null, null);
                        }
                        if (subtaskid != null) {
                          edu.isi.powerloom.PLI.assertNaryProposition(Cons.cons(Logic.getRelation(RDBMS.SGT_RDBMS_SUBTASK_ID), Cons.cons(fetchdb, Cons.cons(subtaskid, Stella.NIL))), null, null);
                        }
                      }
                      result = Logic.evaluateLogicCommand(Stella.readSExpressionFromString(((StringWrapper)(command)).wrapperValue), true);
                      if (Surrogate.subtypeOfP(Stella_Object.safePrimaryType(result), RDBMS.SGT_LOGIC_QUERY_ITERATOR)) {
                        { QueryIterator result000 = ((QueryIterator)(result));

                          { QuerySolution solution = null;
                            DictionaryIterator iter000 = ((DictionaryIterator)(result000.solutions.allocateIterator()));

                            while (iter000.nextP()) {
                              solution = ((QuerySolution)(iter000.value));
                              { Stella_Object elt = null;
                                Vector vector000 = solution.bindings;
                                int index000 = 0;
                                int length000 = vector000.length();
                                int i = Stella.NULL_INTEGER;
                                int iter001 = 0;

                                for (;index000 < length000; index000 = index000 + 1, iter001 = iter001 + 1) {
                                  elt = (vector000.theArray)[index000];
                                  i = iter001;
                                  if (i > 0) {
                                    out.print(" ");
                                  }
                                  Logic.printLogicalForm(elt, wrappedout);
                                }
                              }
                              out.print("<br>");
                            }
                          }
                        }
                      }
                      else {
                        Stella.writeHtmlQuotingSpecialCharacters(out, Native.stringify(result));
                      }
                    }
                  }
                }
              }

            } finally {
              Stella.$CONTEXT$.set(old$Context$000);
              Stella.$MODULE$.set(old$Module$000);
            }
          }
        }
      }
    } catch (java.lang.Exception e) {
      out.print("ERROR: " + Stella.exceptionMessage(e));
    }
  }