<commit_before>/*
 * Copyright (C) 20011-2014 Scalable minds UG (haftungsbeschränkt) & Co. KG. <http://scm.io>
 */
package com.scalableminds.datastore.services

import com.scalableminds.braingames.binary.models.{DataSourceRepository => AbstractDataSourceRepository, UnusableDataSource, UsableDataSource, DataSourceLike, InMemoryInboxSourceRepository}
import com.scalableminds.util.tools.FoxImplicits
import com.scalableminds.datastore.models.DataSourceDAO
import play.api.Logger
import play.api.libs.concurrent.Execution.Implicits._
import akka.actor.ActorSystem
import com.scalableminds.datastore.DataStorePlugin

class DataSourceRepository(implicit val system: ActorSystem) extends AbstractDataSourceRepository with InMemoryInboxSourceRepository with FoxImplicits {

  def findDataSource(name: String) =
    DataSourceDAO.find(name)

  def findUsableDataSource(name: String) =
    DataSourceDAO.findUsableByName(name).map(_.dataSource)

  def updateDataSources(dataSources: List[DataSourceLike]): Unit = {
    Logger.debug("Available datasets: " + dataSources.map(d => d.id + s" (${if(d.isUsable) "active" else "inactive"}})").mkString(", "))
    Logger.trace("Datasets: " + dataSources.mkString("\n"))
    dataSources.map{
      case d: UsableDataSource =>
        DataSourceDAO.updateDataSource(d)
      case d: UnusableDataSource =>
        DataSourceDAO.removeByName(d.id)
        DataSourceDAO.insert(d)
    }
    DataStorePlugin.current.map(_.binaryDataService.oxalisServer.reportDataSources(dataSources))
  }
}
<commit_msg>added more methods to datasource interface<commit_after>/*
 * Copyright (C) 20011-2014 Scalable minds UG (haftungsbeschränkt) & Co. KG. <http://scm.io>
 */
package com.scalableminds.datastore.services

import com.scalableminds.braingames.binary.models.{DataSourceRepository => AbstractDataSourceRepository, UnusableDataSource, UsableDataSource, DataSourceLike, InMemoryInboxSourceRepository}
import com.scalableminds.util.tools.FoxImplicits
import com.scalableminds.datastore.models.DataSourceDAO
import play.api.Logger
import play.api.libs.concurrent.Execution.Implicits._
import akka.actor.ActorSystem
import com.scalableminds.datastore.DataStorePlugin

class DataSourceRepository(implicit val system: ActorSystem) extends AbstractDataSourceRepository with InMemoryInboxSourceRepository with FoxImplicits {

  def findDataSource(name: String) =
    DataSourceDAO.find(name)

  def findUsableDataSource(name: String) =
    DataSourceDAO.findUsableByName(name).map(_.dataSource)

  def updateDataSources(dataSources: List[DataSourceLike]): Unit = {
    Logger.debug("Available datasets: " + dataSources.map(d => d.id + s" (${if(d.isUsable) "active" else "inactive"})").mkString(", "))
    Logger.trace("Datasets: " + dataSources.mkString("\n"))
    dataSources.map{
      case d: UsableDataSource =>
        DataSourceDAO.updateDataSource(d)
      case d: UnusableDataSource =>
        DataSourceDAO.removeByName(d.id)
        DataSourceDAO.insert(d)
    }
    DataStorePlugin.current.map(_.binaryDataService.oxalisServer.reportDataSources(dataSources))
  }
}

{'fraction_non_alphanumeric': 0.10769728331177232, 'fraction_numerical': 0.005821474773609315, 'mean_word_length': 5.47071129707113, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5629172', 'n_tokens_mistral': 964, 'n_tokens_neox': 925, 'n_words': 159}