<commit_before>package edu.duke.oit.vw.models

import org.apache.solr.client.solrj.SolrServer
import edu.duke.oit.vw.utils._

import java.util.Date

import org.slf4j.{Logger, LoggerFactory}

object Person extends SolrModel 
  with AttributeParams {

  def find(uri: String, solr: SolrServer): Option[Person] = {
    getDocumentByIdOrAlternateId(uri,solr) match {
      case Some(sd) => Option(PersonExtraction(sd.get("json").toString))
      case _ => None
    }
  }

  // NOTE: person and organization have Option[Date] instead of Date for updatedAt because some people exist
  // in the index preceding the existence of that field.  If it is not Option[], it returns an error
  def build(uri:String,
            active:Boolean,
            updatedAt:Option[Date],
            personData:Map[Symbol,String],
            pubs:List[Publication],
            awards:List[Award],
            artisticWorks:List[ArtisticWork],
            artisticEvents:List[ArtisticEvent],
            grants:List[Grant],
            courses:List[Course],
            professionalActivities:List[ProfessionalActivity],
            positions:List[Position],
            addresses:List[Address],
            educations:List[Education],
            researchAreas:List[ResearchArea],
            webpages:List[Webpage],
            geographicalFocus:List[GeographicFocus],
            newsfeeds:List[Newsfeed],
            cvInfo:Option[PersonCVInfo]): Person = {
    new Person(uri,
               active,
               updatedAt,
               vivoType           = personData('type).stripBrackets(),
               label              = personData('label),
               title              = personData('title),
               publications       = pubs,
               awards             = awards,
               artisticWorks      = artisticWorks,
               artisticEvents     = artisticEvents,
               grants             = grants,
               courses            = courses,
               professionalActivities = professionalActivities,
               positions              = positions,
               addresses              = addresses,
               educations             = educations,
               researchAreas          = researchAreas,
               webpages               = webpages,
               geographicalFocus      = geographicalFocus,
               newsfeeds              = newsfeeds,
               cvInfo                 = cvInfo,
               attributes             = parseAttributes(personData, List('type,'label,'title)))
  }

}


case class PersonCVInfo(gifts:List[Gift],
                        academicPositions:List[AcademicPosition],
                        licenses:List[License],
                        pastAppointments:List[PastAppointment]) {

}


case class Person(uri:String,
                  active:Boolean,
                  updatedAt:Option[Date],
                  vivoType:String,
                  label:String,
                  title:String,
                  publications:List[Publication],
                  awards:List[Award],
                  artisticWorks:List[ArtisticWork],
                  artisticEvents:List[ArtisticEvent],
                  grants:List[Grant],
                  courses:List[Course],
                  professionalActivities:List[ProfessionalActivity],
                  positions:List[Position],
                  addresses:List[Address],
                  educations:List[Education],
                  researchAreas:List[ResearchArea],
                  webpages:List[Webpage],
                  geographicalFocus:List[GeographicFocus],
                  newsfeeds:List[Newsfeed],
                  cvInfo: Option[PersonCVInfo],<commit_msg>added active flag in Widgets JSON<commit_after>package edu.duke.oit.vw.models

import org.apache.solr.client.solrj.SolrServer
import edu.duke.oit.vw.utils._

import java.util.Date

import org.slf4j.{Logger, LoggerFactory}

object Person extends SolrModel 
  with AttributeParams {

  def find(uri: String, solr: SolrServer): Option[Person] = {
    getDocumentByIdOrAlternateId(uri,solr) match {
      case Some(sd) => Option(PersonExtraction(sd.get("json").toString))
      case _ => None
    }
  }

  // NOTE: person and organization have Option[Date] instead of Date for updatedAt because some people exist
  // in the index preceding the existence of that field.  If it is not Option[], it returns an error
  def build(uri:String,
            active:Option[Boolean],
            updatedAt:Option[Date],
            personData:Map[Symbol,String],
            pubs:List[Publication],
            awards:List[Award],
            artisticWorks:List[ArtisticWork],
            artisticEvents:List[ArtisticEvent],
            grants:List[Grant],
            courses:List[Course],
            professionalActivities:List[ProfessionalActivity],
            positions:List[Position],
            addresses:List[Address],
            educations:List[Education],
            researchAreas:List[ResearchArea],
            webpages:List[Webpage],
            geographicalFocus:List[GeographicFocus],
            newsfeeds:List[Newsfeed],
            cvInfo:Option[PersonCVInfo]): Person = {
    new Person(uri,
               active_b,
               updatedAt,
               vivoType           = personData('type).stripBrackets(),
               label              = personData('label),
               title              = personData('title),
               publications       = pubs,
               awards             = awards,
               artisticWorks      = artisticWorks,
               artisticEvents     = artisticEvents,
               grants             = grants,
               courses            = courses,
               professionalActivities = professionalActivities,
               positions              = positions,
               addresses              = addresses,
               educations             = educations,
               researchAreas          = researchAreas,
               webpages               = webpages,
               geographicalFocus      = geographicalFocus,
               newsfeeds              = newsfeeds,
               cvInfo                 = cvInfo,
               attributes             = parseAttributes(personData, List('type,'label,'title)))
  }

}


case class PersonCVInfo(gifts:List[Gift],
                        academicPositions:List[AcademicPosition],
                        licenses:List[License],
                        pastAppointments:List[PastAppointment]) {

}


case class Person(uri:String,
                  active_b:Option[Boolean],
                  updatedAt:Option[Date],
                  vivoType:String,
                  label:String,
                  title:String,
                  publications:List[Publication],
                  awards:List[Award],
                  artisticWorks:List[ArtisticWork],
                  artisticEvents:List[ArtisticEvent],
                  grants:List[Grant],
                  courses:List[Course],
                  professionalActivities:List[ProfessionalActivity],
                  positions:List[Position],
                  addresses:List[Address],
                  educations:List[Education],
                  researchAreas:List[ResearchArea],
                  webpages:List[Webpage],
                  geographicalFocus:List[GeographicFocus],
                  newsfeeds:List[Newsfeed],
                  cvInfo: Option[PersonCVInfo],
{'fraction_non_alphanumeric': 0.08210751537844344, 'fraction_numerical': 0.0002674511901577962, 'mean_word_length': 1.6168649405178446, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6182427', 'n_tokens_mistral': 1837, 'n_tokens_neox': 1765, 'n_words': 318}