@Parameters({"target"})
 @BeforeClass
 public void setUp(String target) throws Exception {
   log.info("METADATA VALIDATOR TARGET: " + target);
   sf = new TestServiceFactory().proxy();
   config = new ImportConfig();
   // Let the user know at what level we're logging
   ch.qos.logback.classic.Logger lociLogger =
       (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("loci");
   ch.qos.logback.classic.Logger omeLogger =
       (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("ome.formats");
   log.info(
       String.format(
           "Log levels -- Bio-Formats: %s OMERO.importer: %s",
           lociLogger.getLevel(), omeLogger.getLevel()));
   store = new OMEROMetadataStoreClient();
   store.initialize(sf);
   store.setEnumerationProvider(new TestEnumerationProvider());
   store.setInstanceProvider(new BlitzInstanceProvider(store.getEnumerationProvider()));
   minimalStore = new OMEROMetadataStoreClient();
   minimalStore.initialize(sf);
   minimalStore.setEnumerationProvider(new TestEnumerationProvider());
   minimalStore.setInstanceProvider(
       new BlitzInstanceProvider(minimalStore.getEnumerationProvider()));
   wrapper = new OMEROWrapper(config);
   wrapper.setMetadataOptions(new DefaultMetadataOptions(MetadataLevel.ALL));
   minimalWrapper = new OMEROWrapper(config);
   minimalWrapper.setMetadataOptions(new DefaultMetadataOptions(MetadataLevel.MINIMUM));
   wrapper.setMetadataStore(store);
   store.setReader(wrapper.getImageReader());
   minimalStore.setReader(minimalWrapper.getImageReader());
 }
Exemplo n.º 2
0
  public TestEngine(TestEngineConfig config)
      throws CannotCreateSessionException, PermissionDeniedException, ServerError {
    this.config = config;
    ProxyFactory pf = new ProxyFactory(new OMEROMetadataStoreClient());
    pf.addAdvice(interceptor);
    pf.setProxyTargetClass(true);
    store = (OMEROMetadataStoreClient) pf.getProxy();
    wrapper = new OMEROWrapper(new ImportConfig());

    login_url = config.getFeedbackLoginUrl();
    login_username = config.getFeedbackLoginUsername();
    login_password = config.getFeedbackLoginPassword();
    message_url = config.getFeedbackMessageUrl();
    comment_url = config.getCommentUrl();

    // Login
    if (config.getSessionKey() != null) {
      store.initialize(config.getHostname(), config.getPort(), config.getSessionKey());
    } else {
      store.initialize(
          config.getUsername(), config.getPassword(), config.getHostname(), config.getPort());
    }
    importLibrary = new ImportLibrary(store, wrapper);
  }
  public void init(Helper helper) {
    this.helper = helper;
    helper.setSteps(5);

    final ImportConfig config = new ImportConfig();
    final String sessionUuid = helper.getEventContext().getCurrentSessionUuid();

    if (!(location instanceof ManagedImportLocationI)) {
      throw helper.cancel(
          new ERR(), null, "bad-location", "location-type", location.getClass().getName());
    }

    ManagedImportLocationI managedLocation = (ManagedImportLocationI) location;
    logPath = managedLocation.getLogFile();
    logFilename = logPath.getFullFsPath();
    MDC.put("fileset", logFilename);

    file = ((ManagedImportLocationI) location).getTarget();

    try {
      sf = reg.getInternalServiceFactory(sessionUuid, "unused", 3, 1, clientUuid);
      store = new OMEROMetadataStoreClient();
      store.setCurrentLogFile(logFilename, token);
      store.initialize(sf);
      registerKeepAlive();

      fileName = file.getFullFsPath();
      shortName = file.getName();
      format = null;
      usedFiles = new String[] {fileName};

      open(reader, store, file);
      format = reader.getFormat();
      if (reader.getUsedFiles() != null) {
        usedFiles = reader.getUsedFiles();
      }
      if (usedFiles == null) {
        throw new NullPointerException("usedFiles must be non-null");
      }

      // Process all information which has been passed in as annotations
      detectKnownAnnotations();

      // Now that we've possibly updated the settings object, copy out
      // all the values needed by import.
      userSpecifiedTarget = settings.userSpecifiedTarget;
      userSpecifiedName =
          settings.userSpecifiedName == null ? null : settings.userSpecifiedName.getValue();
      userSpecifiedDescription =
          settings.userSpecifiedDescription == null
              ? null
              : settings.userSpecifiedDescription.getValue();
      userPixels = settings.userSpecifiedPixels;
      annotationList = settings.userSpecifiedAnnotationList;
      doThumbnails = settings.doThumbnails == null ? true : settings.doThumbnails.getValue();
      noStatsInfo = settings.noStatsInfo == null ? false : settings.noStatsInfo.getValue();

      IFormatReader baseReader = reader.getImageReader().getReader();
      if (log.isInfoEnabled()) {
        log.info("File format: " + format);
        log.info("Base reader: " + baseReader.getClass().getName());
      }
      notifyObservers(new ImportEvent.LOADED_IMAGE(shortName, 0, 0, 0));

      formatString = baseReader.getClass().getSimpleName();
      formatString = formatString.replace("Reader", "");

    } catch (Cancel c) {
      throw c;
    } catch (Throwable t) {
      throw helper.cancel(new ERR(), t, "error-on-init");
    } finally {
      MDC.clear();
    }
  }