コード例 #1
0
 /**
  * @see org.gbif.portal.service.DataResourceManager#findDatasets(java.lang.String, boolean,
  *     org.gbif.portal.dto.util.SearchConstraints)
  */
 @SuppressWarnings("unchecked")
 public SearchResultsDTO findDatasetsFromPlots(
     String nameStub,
     boolean fuzzy,
     boolean anyOccurrence,
     boolean includeCountrySearch,
     SearchConstraints searchConstraints) {
   List resources =
       dataResourceDAO.findDataResourcesAndProvidersAndNetworksFromPlots(
           nameStub,
           fuzzy,
           anyOccurrence,
           includeCountrySearch,
           searchConstraints.getStartIndex(),
           searchConstraints.getMaxResults() + 1);
   List resourceDTOList = new ArrayList();
   for (Object resource : resources) {
     if (resource instanceof DataResource)
       resourceDTOList.add(dataResourceDTOFactory.createDTO(resource));
     else if (resource instanceof DataProvider)
       resourceDTOList.add(dataProviderDTOFactory.createDTO(resource));
     else if (resource instanceof ResourceNetwork)
       resourceDTOList.add(resourceNetworkDTOFactory.createDTO(resource));
   }
   SearchResultsDTO searchResultsDTO = new SearchResultsDTO();
   searchResultsDTO.setResults(resourceDTOList, searchConstraints.getMaxResults());
   return searchResultsDTO;
 }
コード例 #2
0
 /**
  * @see org.gbif.portal.service.DataResourceManager#findResourceNetworks(java.lang.String,
  *     boolean, java.lang.String, java.util.Date, org.gbif.portal.dto.util.SearchConstraints)
  */
 public SearchResultsDTO findResourceNetworks(
     String networkName,
     boolean fuzzy,
     String code,
     Date modifiedSince,
     SearchConstraints searchConstraints) {
   List<ResourceNetwork> networks =
       resourceNetworkDAO.findResourceNetworks(
           networkName,
           fuzzy,
           code,
           modifiedSince,
           searchConstraints.getStartIndex(),
           searchConstraints.getMaxResults() + 1);
   return resourceNetworkDTOFactory.createResultsDTO(networks, searchConstraints.getMaxResults());
 }
コード例 #3
0
 /**
  * @see org.gbif.portal.service.DataResourceManager#findDataProviders(java.lang.String, boolean,
  *     java.lang.String, java.util.Date, org.gbif.portal.dto.util.SearchConstraints)
  */
 public SearchResultsDTO findDataProviders(
     String providerName,
     boolean fuzzy,
     String isoCountryCode,
     Date modifiedSince,
     SearchConstraints searchConstraints) {
   List<DataProvider> providers =
       dataProviderDAO.findDataProviders(
           providerName,
           fuzzy,
           isoCountryCode,
           modifiedSince,
           searchConstraints.getStartIndex(),
           searchConstraints.getMaxResults() + 1);
   return dataProviderDTOFactory.createResultsDTO(providers, searchConstraints.getMaxResults());
 }
コード例 #4
0
  /**
   * @see org.gbif.portal.service.DataResourceManager#findDataResources(java.lang.String, boolean,
   *     org.gbif.portal.dto.util.SearchConstraints)
   */
  public SearchResultsDTO findDataResources(
      String resourceName,
      boolean fuzzy,
      String providerKey,
      String basisOfRecordCode,
      Date modifiedSince,
      SearchConstraints searchConstraints)
      throws ServiceException {
    BasisOfRecord basisOfRecord = null;
    if (basisOfRecordCode != null) {
      basisOfRecord = BasisOfRecord.getBasisOfRecord(basisOfRecordCode);

      if (basisOfRecord == null) {
        throw new ServiceException("No basis of record found for code " + basisOfRecordCode);
      }
    }

    DataProvider dataProvider = null;
    if (providerKey != null) {
      Long dataProviderId = parseKey(providerKey);
      dataProvider = dataProviderDAO.getDataProviderFor(dataProviderId);

      if (dataProvider == null) {
        throw new ServiceException("No DataProvider found for key " + providerKey);
      }
    }

    List<DataResource> resources =
        dataResourceDAO.findDataResources(
            resourceName,
            fuzzy,
            dataProvider,
            basisOfRecord,
            modifiedSince,
            searchConstraints.getStartIndex(),
            searchConstraints.getMaxResults() + 1);
    return dataResourceDTOFactory.createResultsDTO(resources, searchConstraints.getMaxResults());
  }