public PsicquicSearchManager(
      ExecutorService executorService, IntactViewConfiguration intactViewConfiguration) {
    if (executorService == null) {
      throw new NullPointerException("The psicquicController needs an executorService.");
    }
    if (intactViewConfiguration == null) {
      throw new NullPointerException("The psicquicController needs an intactViewConfiguration.");
    }
    this.executorService = executorService;
    this.intactViewConfiguration = intactViewConfiguration;

    try {
      initializeServices();
    } catch (PsicquicRegistryClientException e) {
      FacesContext context = FacesContext.getCurrentInstance();
      if (context != null) {
        FacesMessage facesMessage =
            new FacesMessage(
                FacesMessage.SEVERITY_ERROR,
                "Problem counting results in other databases",
                "Registry not available");
        context.addMessage(null, facesMessage);
      }

      e.printStackTrace();
    }
  }
  public void countResultsInOtherDatabases(String query) {
    resetPsicquicCounts();

    if (query == null || query.length() == 0) {
      query = UserQuery.STAR_QUERY;
    }
    runningTasks.clear();

    try {
      if (services == null) {
        initializeServices();
      }
      final String psicquicQuery = query;

      for (final ServiceType service : services) {
        final PsicquicSimpleClient client =
            intactViewConfiguration.getPsicquicClient(service.getRestUrl());

        if (intactViewConfiguration.getWebappName().contains(service.getName())
            || intactViewConfiguration
                .getDatabaseNamesUsingSameSolr()
                .contains(service.getName())) {
          continue;
        }

        Callable<PsicquicCountResults> runnable =
            new Callable<PsicquicCountResults>() {
              public PsicquicCountResults call() {

                return processPsicquicQueries(service, psicquicQuery, client);
              }
            };

        Future<PsicquicCountResults> f = executorService.submit(runnable);
        runningTasks.add(f);
      }
    } catch (PsicquicRegistryClientException e) {
      FacesContext context = FacesContext.getCurrentInstance();
      if (context != null) {
        FacesMessage facesMessage =
            new FacesMessage(
                FacesMessage.SEVERITY_ERROR,
                "Problem counting results in other databases",
                "Registry not available");
        context.addMessage(null, facesMessage);
      }

      e.printStackTrace();
    }
  }
Exemplo n.º 3
0
 public void setQuerySourcesFromPsicquicRegistry() {
   PsicquicRegistryClient registryClient = new DefaultPsicquicRegistryClient();
   try {
     List<ServiceType> allServices = registryClient.listServices();
     for (final ServiceType service : allServices) {
       if (service.isActive()) {
         this.addQuerySource(service.getName());
       }
     }
   } catch (PsicquicRegistryClientException e) {
     logger.error(e);
     e.printStackTrace();
   }
 }
Exemplo n.º 4
0
 public void setImexSources() {
   PsicquicRegistryClient registryClient = new DefaultPsicquicRegistryClient();
   try {
     List<ServiceType> allServices = registryClient.listServices();
     for (final ServiceType service : allServices) {
       List<String> tags = service.getTags();
       if (service.isActive() && tags != null) {
         if (tags.contains("MI:0959")) {
           this.addQuerySource(service.getName());
         }
       }
     }
   } catch (PsicquicRegistryClientException e) {
     logger.error(e);
     e.printStackTrace();
   }
 }