/**
  * @see org.gbif.portal.service.DataResourceManager#getDataResourcesForProvider(java.lang.String)
  */
 @SuppressWarnings("unchecked")
 public List<DataResourceDTO> getDataResourcesForProvider(String dataProviderKey)
     throws ServiceException {
   Long dataProviderId = parseKey(dataProviderKey);
   List<DataResource> dataResources = dataResourceDAO.getDataResourcesForProvider(dataProviderId);
   return (List<DataResourceDTO>) dataResourceDTOFactory.createDTOList(dataResources);
 }
 /**
  * @see
  *     org.gbif.portal.service.DataResourceManager#getResourceNetworksForDataResource(java.lang.String)
  */
 @SuppressWarnings("unchecked")
 public List<ResourceNetworkDTO> getResourceNetworksForDataResource(String dataResourceKey)
     throws ServiceException {
   Long dataResourceId = parseKey(dataResourceKey);
   List<ResourceNetwork> resourceNetworks =
       resourceNetworkDAO.getResourceNetworksForDataResource(dataResourceId);
   return (List<ResourceNetworkDTO>) resourceNetworkDTOFactory.createDTOList(resourceNetworks);
 }
 /**
  * @see
  *     org.gbif.portal.service.DataResourceManager#getDataResourcesForResourceNetwork(java.lang.String)
  */
 @SuppressWarnings("unchecked")
 public List<DataResourceDTO> getDataResourcesForResourceNetwork(String resourceNetworkKey)
     throws ServiceException {
   Long resourceNetworkId = parseKey(resourceNetworkKey);
   List<DataResource> dataResources =
       dataResourceDAO.getDataResourcesForResourceNetwork(resourceNetworkId);
   return (List<DataResourceDTO>) dataResourceDTOFactory.createDTOList(dataResources);
 }
 /**
  * @see
  *     org.gbif.portal.service.DataResourceManager#getPropertyStoreNamespacesForResourceAccesspoint(java.lang.String)
  */
 @SuppressWarnings("unchecked")
 public List<PropertyStoreNamespaceDTO> getPropertyStoreNamespacesForResourceAccessPoint(
     String resourceAccessPointKey) throws ServiceException {
   Long resourceAccessPointId = parseKey(resourceAccessPointKey);
   List<PropertyStoreNamespace> propertyStoreNamespaces =
       propertyStoreNamespaceDAO.getPropertyStoreNamespacesForResourceAccessPoint(
           resourceAccessPointId);
   return (List<PropertyStoreNamespaceDTO>)
       propertyStoreNamespaceDTOFactory.createDTOList(propertyStoreNamespaces);
 }
  /** @see org.gbif.portal.service.DataResourceManager#findDataProvidersForUser(java.lang.String) */
  public List<DataProviderDTO> findDataProvidersForUser(String email) throws ServiceException {

    int indexOfAt = email.indexOf('@');
    if (indexOfAt < 0) {
      return new ArrayList<DataProviderDTO>();
    }

    // this could be dodgy - eg. [email protected] and [email protected]
    String username = email.substring(0, indexOfAt) + '%';
    String domain = '%' + email.substring(indexOfAt + 1);

    List<DataProvider> dps = dataProviderDAO.getDataProviderAssociatedWithUser(username, domain);
    return dataProviderDTOFactory.createDTOList(dps);
  }
 /** @see org.gbif.portal.service.DataResourceManager#getDataResourceList(java.lang.String) */
 @SuppressWarnings({"unchecked", "unchecked"})
 public List<KeyValueDTO> getDataResourceList(String resourceNetworkKey, String dataProviderKey) {
   Long resourceNetworkId = parseKey(resourceNetworkKey);
   Long dataProviderId = parseKey(dataProviderKey);
   List dataResourceKVs = null;
   if (resourceNetworkId != null) {
     List<DataResource> dataResources =
         dataResourceDAO.getDataResourcesForResourceNetwork(resourceNetworkId);
     List<KeyValueDTO> kvps = new ArrayList<KeyValueDTO>();
     for (DataResource dr : dataResources) {
       StringBuffer sb = new StringBuffer(dr.getName());
       if (dr.getDataProvider() != null) {
         sb.append(" - ");
         sb.append(dr.getDataProvider().getName());
       }
       kvps.add(new KeyValueDTO(dr.getId().toString(), sb.toString()));
     }
     return kvps;
   } else {
     dataResourceKVs = dataResourceDAO.getDataResourceList(dataProviderId);
     return keyValueDTOFactory.createDTOList(dataResourceKVs);
   }
 }
 /** @see org.gbif.portal.service.DataResourceManager#getInternationalDataProviders() */
 public List<DataProviderDTO> getInternationalDataProviders() {
   return dataProviderDTOFactory.createDTOList(
       dataProviderDAO.getInternationalDataProviders(true));
 }
 /** @see org.gbif.portal.service.DataResourceManager#getAgentsForDataResource(java.lang.String) */
 @SuppressWarnings("unchecked")
 public List<DataResourceAgentDTO> getAgentsForDataResource(String dataResourceKey) {
   List<DataResourceAgent> agents = agentDAO.getAgentsForDataResource(parseKey(dataResourceKey));
   return dataResourceAgentDTOFactory.createDTOList(agents);
 }
 /** @see org.gbif.portal.service.DataResourceManager#getResourceNetworkList() */
 @SuppressWarnings("unchecked")
 public List<KeyValueDTO> getResourceNetworkList() {
   List resourceNetworkKVs = resourceNetworkDAO.getResourceNetworkList();
   return keyValueDTOFactory.createDTOList(resourceNetworkKVs);
 }
 /** @see org.gbif.portal.service.DataResourceManager#getDataProviderList() */
 @SuppressWarnings("unchecked")
 public List<KeyValueDTO> getDataProviderList() {
   List dataProviderKVs = dataProviderDAO.getDataProviderList();
   return keyValueDTOFactory.createDTOList(dataProviderKVs);
 }
 /** @see org.gbif.portal.service.DataResourceManager#getDataResourcesWithInferredTaxonomies() */
 @SuppressWarnings("unchecked")
 public List<DataResourceDTO> getDataResourcesWithInferredTaxonomies() throws ServiceException {
   logger.debug("Retrieving Data Resource offering taxonomies");
   List<DataResource> dataResources = dataResourceDAO.getDataResourcesWithNonSharedTaxonomies();
   return (List<DataResourceDTO>) dataResourceDTOFactory.createDTOList(dataResources);
 }
 /** @see org.gbif.portal.service.DataResourceManager#getDataProvidersOfferingTaxonomies() */
 @SuppressWarnings("unchecked")
 public List<DataProviderDTO> getDataProvidersOfferingTaxonomies() throws ServiceException {
   logger.debug("Retrieving Data Providers offering taxonomies");
   List<DataProvider> dataProviders = dataProviderDAO.getDataProvidersOfferingTaxonomies();
   return (List<DataProviderDTO>) dataProviderDTOFactory.createDTOList(dataProviders);
 }
 /** @see org.gbif.portal.service.DataResourceManager#getAllDataResources() */
 public List<DataResourceDTO> getAllDataResources() throws ServiceException {
   List<DataResource> drs = dataResourceDAO.getAllDataResources();
   return dataResourceDTOFactory.createDTOList(drs);
 }
 /** @see org.gbif.portal.service.DataResourceManager#getAllDataProviders() */
 public List<DataProviderDTO> getAllDataProviders() throws ServiceException {
   List<DataProvider> dps = dataProviderDAO.getAllDataProviders();
   return dataProviderDTOFactory.createDTOList(dps);
 }