def _add_supervising_officer(_file_tag: str, row: Dict[str, str], extracted_objects: List[IngestObject], _cache: IngestObjectCache): """Adds the current supervising officer onto the extracted person.""" supervising_officer_id = row.get('AGENT') if not supervising_officer_id: return for extracted_object in extracted_objects: if isinstance(extracted_object, StatePerson): agent_to_create = StateAgent( state_agent_id=supervising_officer_id, agent_type=StateAgentType.SUPERVISION_OFFICER.value) create_if_not_exists(agent_to_create, extracted_object, 'supervising_officer')
def _add_supervising_officer( _file_tag: str, row: Dict[str, str], extracted_objects: List[IngestObject], _cache: IngestObjectCache): agent_id = row.get('agnt_id', '') agent_name = row.get('name', '') if not agent_id or not agent_name: return for obj in extracted_objects: if isinstance(obj, StatePerson): agent_to_create = StateAgent( state_agent_id=agent_id, full_name=agent_name, agent_type=StateAgentType.SUPERVISION_OFFICER.value) create_if_not_exists(agent_to_create, obj, 'supervising_officer')
def _add_supervising_officer(_file_tag: str, row: Dict[str, str], extracted_objects: List[IngestObject], _cache: IngestObjectCache): agent_id = row.get('empl_sdesc', '') agent_name = row.get('empl_ldesc', '') if not agent_id or not agent_name or agent_id == UNKNOWN_EMPLOYEE_SDESC: return for obj in extracted_objects: if isinstance(obj, StateSupervisionPeriod): agent_to_create = StateAgent( state_agent_id=agent_id, full_name=agent_name, agent_type=StateAgentType.SUPERVISION_OFFICER.value) create_if_not_exists(agent_to_create, obj, 'supervising_officer')
def _add_judge_to_court_cases(_file_tag: str, row: Dict[str, str], extracted_objects: List[IngestObject], _cache: IngestObjectCache): judge_id = row.get('judge_cd', '') judge_name = row.get('judge_name', '') if not judge_id or not judge_name: return judge_to_create = StateAgent(state_agent_id=judge_id, full_name=judge_name, agent_type=StateAgentType.JUDGE.value) for obj in extracted_objects: if isinstance(obj, StateCourtCase): create_if_not_exists(judge_to_create, obj, 'judge')
def _add_terminating_officer_to_supervision_periods( _file_tag: str, row: Dict[str, str], extracted_objects: List[IngestObject], _cache: IngestObjectCache): """When present, adds supervising officer to the extracted SupervisionPeriods.""" terminating_officer_id = row.get('TERMINATING_OFFICER', None) if not terminating_officer_id: return agent_to_create = StateAgent( state_agent_id=terminating_officer_id, agent_type=StateAgentType.SUPERVISION_OFFICER.value) for extracted_object in extracted_objects: if isinstance(extracted_object, StateSupervisionPeriod): create_if_not_exists(agent_to_create, extracted_object, 'supervising_officer')
def _add_supervision_contact_fields( _file_tag: str, row: Dict[str, str], extracted_objects: List[IngestObject], _cache: IngestObjectCache): """Adds all extra fields needed on SupervisionContact entities that cannot be automatically mapped via YAMLs.""" agent_id = row.get('usr_id', '') agent_name = row.get('name', '') for obj in extracted_objects: if isinstance(obj, StateSupervisionContact): if agent_id and agent_name: agent_to_create = StateAgent( state_agent_id=agent_id, full_name=agent_name, agent_type=StateAgentType.SUPERVISION_OFFICER.value) create_if_not_exists(agent_to_create, obj, 'contacted_agent') obj.resulted_in_arrest = str(obj.status == CONTACT_RESULT_ARREST) if obj.location in CONTACT_TYPES_TO_BECOME_LOCATIONS: obj.contact_type = obj.location obj.location = None