Пример #1
0
  // scan has been done, create FmrcInv
  private FmrcInv makeFmrcInv(Formatter debug) throws IOException {
    try {
      Map<CalendarDate, FmrInv> fmrMap =
          new HashMap<CalendarDate, FmrInv>(); // all files are grouped by run date in an FmrInv
      List<FmrInv> fmrList = new ArrayList<FmrInv>(); // an fmrc is a collection of fmr

      // get the inventory, sorted by path
      for (MFile f : manager.getFiles()) {
        if (logger.isDebugEnabled()) logger.debug("Fmrc: " + config.spec + ": file=" + f.getPath());

        GridDatasetInv inv = null;
        try {
          inv =
              GridDatasetInv.open(
                  manager, f, config.innerNcml); // inventory is discovered for each GDS
        } catch (IOException ioe) {
          logger.warn("Error opening " + f.getPath() + "(skipped)", ioe);
          continue; // skip
        }

        CalendarDate runDate = inv.getRunDate();
        if (debug != null)
          debug.format("  opened %s rundate = %s%n", f.getPath(), inv.getRunDateString());

        // add to fmr for that rundate
        FmrInv fmr = fmrMap.get(runDate);
        if (fmr == null) {
          fmr = new FmrInv(runDate);
          fmrMap.put(runDate, fmr);
          fmrList.add(fmr);
        }
        fmr.addDataset(inv, debug);
      }
      if (debug != null) debug.format("%n");

      // finish the FmrInv
      Collections.sort(fmrList);
      for (FmrInv fmr : fmrList) {
        fmr.finish();
        if (logger.isDebugEnabled())
          logger.debug(
              "Fmrc: spec="
                  + config.spec
                  + ": fmr rundate="
                  + fmr.getRunDate()
                  + " nfiles= "
                  + fmr.getFiles().size());
      }

      return new FmrcInv(
          "fmrc:" + manager.getCollectionName(), fmrList, config.fmrcConfig.regularize);

    } catch (Throwable t) {
      logger.error("makeFmrcInv", t);
      throw new RuntimeException(t);
    }
  }
Пример #2
0
  public void checkNeeded(boolean force) {
    synchronized (lock) {
      if (fmrcDataset == null) {
        try {
          manager.scan(true);
          update();
          return;
        } catch (Throwable t) {
          logger.error(config.spec + ": rescan failed");
          throw new RuntimeException(t);
        }
      }

      if (!force && !manager.isScanNeeded()) return;
      try {
        if (!manager.scan(true)) return;
        update();
      } catch (Throwable t) {
        logger.error(config.spec + ": rescan failed");
        throw new RuntimeException(t);
      }
    }
  }
Пример #3
0
  private static void copierFichiers2(final boolean copyFiles, final boolean langueChanged) {

    if (copyFiles || langueChanged) {
      afficherProgress();
      // attendreAffichageProgress();
    }

    try {
      if (copyFiles) CopyFiles();
      if (copyFiles || langueChanged) {
        CollectionManager.ImportArchive(AppData.current_activity, mProgressDialog);
      }

      AppData.current_activity.runOnUiThread(
          new Runnable() {
            public void run() {
              fermerProgress();
              delegate.onBootstrapInitialised();
            }
          });
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 public Object eval(CallStack callstack, Interpreter interpreter) throws EvalError {
   Class elementType = null;
   SimpleNode expression;
   SimpleNode statement = null;
   NameSpace enclosingNameSpace = callstack.top();
   SimpleNode firstNode = ((SimpleNode) jjtGetChild(0));
   int nodeCount = jjtGetNumChildren();
   if (firstNode instanceof BSHType) {
     elementType = ((BSHType) firstNode).getType(callstack, interpreter);
     expression = ((SimpleNode) jjtGetChild(1));
     if (nodeCount > 2) {
       statement = ((SimpleNode) jjtGetChild(2));
     }
   } else {
     expression = firstNode;
     if (nodeCount > 1) {
       statement = ((SimpleNode) jjtGetChild(1));
     }
   }
   BlockNameSpace eachNameSpace = new BlockNameSpace(enclosingNameSpace);
   callstack.swap(eachNameSpace);
   final Object iteratee = expression.eval(callstack, interpreter);
   if (iteratee == Primitive.NULL) {
     throw new EvalError(
         "The collection, array, map, iterator, or "
             + "enumeration portion of a for statement cannot be null.",
         this,
         callstack);
   }
   CollectionManager cm = CollectionManager.getCollectionManager();
   if (!cm.isBshIterable(iteratee)) {
     throw new EvalError("Can't iterate over type: " + iteratee.getClass(), this, callstack);
   }
   BshIterator iterator = cm.getBshIterator(iteratee);
   Object returnControl = Primitive.VOID;
   while (iterator.hasNext()) {
     try {
       Object value = iterator.next();
       if (value == null) {
         value = Primitive.NULL;
       }
       if (elementType != null) {
         eachNameSpace.setTypedVariable(
             varName /*name*/, elementType /*type*/, value /*value*/, new Modifiers() /*none*/);
       } else {
         eachNameSpace.setVariable(varName, value, false);
       }
     } catch (UtilEvalError e) {
       throw e.toEvalError("for loop iterator variable:" + varName, this, callstack);
     }
     boolean breakout = false; // switch eats a multi-level break here?
     if (statement != null) {
       // not empty statement
       Object ret = statement.eval(callstack, interpreter);
       if (ret instanceof ReturnControl) {
         switch (((ReturnControl) ret).kind) {
           case RETURN:
             returnControl = ret;
             breakout = true;
             break;
           case CONTINUE:
             break;
           case BREAK:
             breakout = true;
             break;
         }
       }
     }
     if (breakout) {
       break;
     }
   }
   callstack.swap(enclosingNameSpace);
   return returnControl;
 }
Пример #5
0
 public void close() {
   manager.close();
 }