From d92f5032256eaab64ec527ac1efbc1f36db12bf7 Mon Sep 17 00:00:00 2001 From: Jon Hill Date: Fri, 16 Sep 2022 13:26:08 +0100 Subject: [PATCH] v1.5.1 public release --- .../transport/SocrataResponseData.java | 4 +-- .../nypd/rest/transport/ItemFactory.java | 12 +++++-- .../nypd-connector/helper/classes.py | 8 +++-- .../sample-solution/nypd-connector/setup.bat | 32 ++++++++++++++++--- .../python/stage1/nypd-connector/setup.bat | 32 ++++++++++++++++--- .../python/stage2/nypd-connector/setup.bat | 32 ++++++++++++++++--- .../python/stage3/nypd-connector/setup.bat | 32 ++++++++++++++++--- .../python/stage4/nypd-connector/setup.bat | 32 ++++++++++++++++--- .../python/stage5/nypd-connector/setup.bat | 32 ++++++++++++++++--- 9 files changed, 186 insertions(+), 30 deletions(-) diff --git a/connector/nypd/java/sample-solution/nypd-connector/src/main/java/com/i2group/nypd/rest/externalsource/transport/SocrataResponseData.java b/connector/nypd/java/sample-solution/nypd-connector/src/main/java/com/i2group/nypd/rest/externalsource/transport/SocrataResponseData.java index f1ce205..69a7e60 100644 --- a/connector/nypd/java/sample-solution/nypd-connector/src/main/java/com/i2group/nypd/rest/externalsource/transport/SocrataResponseData.java +++ b/connector/nypd/java/sample-solution/nypd-connector/src/main/java/com/i2group/nypd/rest/externalsource/transport/SocrataResponseData.java @@ -48,10 +48,10 @@ public class SocrataResponseData { public LocalDate complaintEndDate; @JsonProperty("cmplnt_fr_tm") - public LocalTime complaintStartTime; + public String complaintStartTime; @JsonProperty("cmplnt_to_tm") - public LocalTime complaintEndTime; + public String complaintEndTime; @JsonProperty("crm_atpt_cptd_cd") public String crimeStatus; diff --git a/connector/nypd/java/sample-solution/nypd-connector/src/main/java/com/i2group/nypd/rest/transport/ItemFactory.java b/connector/nypd/java/sample-solution/nypd-connector/src/main/java/com/i2group/nypd/rest/transport/ItemFactory.java index ec24061..52a8490 100644 --- a/connector/nypd/java/sample-solution/nypd-connector/src/main/java/com/i2group/nypd/rest/transport/ItemFactory.java +++ b/connector/nypd/java/sample-solution/nypd-connector/src/main/java/com/i2group/nypd/rest/transport/ItemFactory.java @@ -28,6 +28,7 @@ import org.springframework.core.io.Resource; import java.io.IOException; +import java.time.LocalTime; import java.util.HashMap; /** Used to generate entity and link objects */ @@ -52,8 +53,8 @@ public EntityData createComplaint(SocrataResponseData entry) { properties.put("PT1", entry.complaintNum); properties.put("PT2", entry.complaintStartDate); properties.put("PT3", entry.complaintEndDate); - properties.put("PT4", entry.complaintStartTime); - properties.put("PT5", entry.complaintEndTime); + properties.put("PT4", parseStringToTime(entry.complaintStartTime)); + properties.put("PT5", parseStringToTime(entry.complaintEndTime)); properties.put("PT6", entry.crimeStatus); properties.put("PT7", entry.jurisdictionCode); properties.put("PT8", entry.jurisdictionDesc); @@ -74,6 +75,13 @@ public EntityData createComplaint(SocrataResponseData entry) { return complaint; } + private LocalTime parseStringToTime(String time) { + if (time.equals("(null)")) { + return null; + } + return LocalTime.parse(time); + } + /** * Creates location from a single record of data. * diff --git a/connector/nypd/python/sample-solution/nypd-connector/helper/classes.py b/connector/nypd/python/sample-solution/nypd-connector/helper/classes.py index a4f799d..fdc2361 100644 --- a/connector/nypd/python/sample-solution/nypd-connector/helper/classes.py +++ b/connector/nypd/python/sample-solution/nypd-connector/helper/classes.py @@ -87,8 +87,8 @@ def __init__(self, entry): 'PT1': entry.get('cmplnt_num'), 'PT2': entry.get('cmplnt_fr_dt')[:10] if entry.get('cmplnt_fr_dt') else None, 'PT3': entry.get('cmplnt_to_dt')[:10] if entry.get('cmplnt_to_dt') else None, - 'PT4': entry.get('cmplnt_fr_tm'), - 'PT5': entry.get('cmplnt_to_tm') if entry.get('cmplnt_to_tm') else None, + 'PT4': sanitizeTime(entry.get('cmplnt_fr_tm')), + 'PT5': sanitizeTime(entry.get('cmplnt_to_tm')) if entry.get('cmplnt_to_tm') else None, 'PT6': entry.get('crm_atpt_cptd_cd'), 'PT7': int(float(entry.get('jurisdiction_code'))) if entry.get('jurisdiction_code') else None, 'PT8': entry.get('juris_desc'), @@ -183,6 +183,10 @@ def __init__(self, entry): id = get_id("SO", entry) super().__init__("SO" + id, type_ids['suspect_of'], None, generate_source_ref(entry.get('cmplnt_num'))) +def sanitizeTime(time): + if time.__eq__("(null)"): + return None + def get_id(base, entry): id = int(entry.get('cmplnt_num')) return base + str(id) diff --git a/connector/nypd/python/sample-solution/nypd-connector/setup.bat b/connector/nypd/python/sample-solution/nypd-connector/setup.bat index 55b586f..79b30dc 100644 --- a/connector/nypd/python/sample-solution/nypd-connector/setup.bat +++ b/connector/nypd/python/sample-solution/nypd-connector/setup.bat @@ -1,10 +1,34 @@ @echo off @REM i2, i2 Group, the i2 Group logo, and i2group.com are trademarks of N.Harris Computer Corporation. @REM © N.Harris Computer Corporation (2022) -setlocal -IF NOT DEFINED SHELL_PATH ( - SET SHELL_PATH=%PROGRAMFILES%\Git\bin\sh.exe +echo Checking if Python is installed... +python -V +if %errorlevel% neq 0 exit /b %errorlevel% + +for /f "tokens=2" %%a in ('python -V') do set version=%%a + +set VERSION=%version% +echo Detected Python v%VERSION%. + +set NUMBER=%VERSION%/Python + +echo Installing pipenv... +pip install pipenv + +echo Checking pipenv version... +pipenv --version +if %errorlevel% neq 0 ( + echo: + echo Update the PATH variable in your environment to include the locations of both the Python application and its scripts directory. + exit /b %errorlevel% ) -"%SHELL_PATH%" "%~dp0setup.sh" %* +echo Running Python... +pipenv --python %NUMBER% + +echo Creating Piplock.file... +pipenv lock + +echo Syncing dependencies... +pipenv sync diff --git a/connector/nypd/python/stage1/nypd-connector/setup.bat b/connector/nypd/python/stage1/nypd-connector/setup.bat index 55b586f..79b30dc 100644 --- a/connector/nypd/python/stage1/nypd-connector/setup.bat +++ b/connector/nypd/python/stage1/nypd-connector/setup.bat @@ -1,10 +1,34 @@ @echo off @REM i2, i2 Group, the i2 Group logo, and i2group.com are trademarks of N.Harris Computer Corporation. @REM © N.Harris Computer Corporation (2022) -setlocal -IF NOT DEFINED SHELL_PATH ( - SET SHELL_PATH=%PROGRAMFILES%\Git\bin\sh.exe +echo Checking if Python is installed... +python -V +if %errorlevel% neq 0 exit /b %errorlevel% + +for /f "tokens=2" %%a in ('python -V') do set version=%%a + +set VERSION=%version% +echo Detected Python v%VERSION%. + +set NUMBER=%VERSION%/Python + +echo Installing pipenv... +pip install pipenv + +echo Checking pipenv version... +pipenv --version +if %errorlevel% neq 0 ( + echo: + echo Update the PATH variable in your environment to include the locations of both the Python application and its scripts directory. + exit /b %errorlevel% ) -"%SHELL_PATH%" "%~dp0setup.sh" %* +echo Running Python... +pipenv --python %NUMBER% + +echo Creating Piplock.file... +pipenv lock + +echo Syncing dependencies... +pipenv sync diff --git a/connector/nypd/python/stage2/nypd-connector/setup.bat b/connector/nypd/python/stage2/nypd-connector/setup.bat index 55b586f..79b30dc 100644 --- a/connector/nypd/python/stage2/nypd-connector/setup.bat +++ b/connector/nypd/python/stage2/nypd-connector/setup.bat @@ -1,10 +1,34 @@ @echo off @REM i2, i2 Group, the i2 Group logo, and i2group.com are trademarks of N.Harris Computer Corporation. @REM © N.Harris Computer Corporation (2022) -setlocal -IF NOT DEFINED SHELL_PATH ( - SET SHELL_PATH=%PROGRAMFILES%\Git\bin\sh.exe +echo Checking if Python is installed... +python -V +if %errorlevel% neq 0 exit /b %errorlevel% + +for /f "tokens=2" %%a in ('python -V') do set version=%%a + +set VERSION=%version% +echo Detected Python v%VERSION%. + +set NUMBER=%VERSION%/Python + +echo Installing pipenv... +pip install pipenv + +echo Checking pipenv version... +pipenv --version +if %errorlevel% neq 0 ( + echo: + echo Update the PATH variable in your environment to include the locations of both the Python application and its scripts directory. + exit /b %errorlevel% ) -"%SHELL_PATH%" "%~dp0setup.sh" %* +echo Running Python... +pipenv --python %NUMBER% + +echo Creating Piplock.file... +pipenv lock + +echo Syncing dependencies... +pipenv sync diff --git a/connector/nypd/python/stage3/nypd-connector/setup.bat b/connector/nypd/python/stage3/nypd-connector/setup.bat index 55b586f..79b30dc 100644 --- a/connector/nypd/python/stage3/nypd-connector/setup.bat +++ b/connector/nypd/python/stage3/nypd-connector/setup.bat @@ -1,10 +1,34 @@ @echo off @REM i2, i2 Group, the i2 Group logo, and i2group.com are trademarks of N.Harris Computer Corporation. @REM © N.Harris Computer Corporation (2022) -setlocal -IF NOT DEFINED SHELL_PATH ( - SET SHELL_PATH=%PROGRAMFILES%\Git\bin\sh.exe +echo Checking if Python is installed... +python -V +if %errorlevel% neq 0 exit /b %errorlevel% + +for /f "tokens=2" %%a in ('python -V') do set version=%%a + +set VERSION=%version% +echo Detected Python v%VERSION%. + +set NUMBER=%VERSION%/Python + +echo Installing pipenv... +pip install pipenv + +echo Checking pipenv version... +pipenv --version +if %errorlevel% neq 0 ( + echo: + echo Update the PATH variable in your environment to include the locations of both the Python application and its scripts directory. + exit /b %errorlevel% ) -"%SHELL_PATH%" "%~dp0setup.sh" %* +echo Running Python... +pipenv --python %NUMBER% + +echo Creating Piplock.file... +pipenv lock + +echo Syncing dependencies... +pipenv sync diff --git a/connector/nypd/python/stage4/nypd-connector/setup.bat b/connector/nypd/python/stage4/nypd-connector/setup.bat index 55b586f..79b30dc 100644 --- a/connector/nypd/python/stage4/nypd-connector/setup.bat +++ b/connector/nypd/python/stage4/nypd-connector/setup.bat @@ -1,10 +1,34 @@ @echo off @REM i2, i2 Group, the i2 Group logo, and i2group.com are trademarks of N.Harris Computer Corporation. @REM © N.Harris Computer Corporation (2022) -setlocal -IF NOT DEFINED SHELL_PATH ( - SET SHELL_PATH=%PROGRAMFILES%\Git\bin\sh.exe +echo Checking if Python is installed... +python -V +if %errorlevel% neq 0 exit /b %errorlevel% + +for /f "tokens=2" %%a in ('python -V') do set version=%%a + +set VERSION=%version% +echo Detected Python v%VERSION%. + +set NUMBER=%VERSION%/Python + +echo Installing pipenv... +pip install pipenv + +echo Checking pipenv version... +pipenv --version +if %errorlevel% neq 0 ( + echo: + echo Update the PATH variable in your environment to include the locations of both the Python application and its scripts directory. + exit /b %errorlevel% ) -"%SHELL_PATH%" "%~dp0setup.sh" %* +echo Running Python... +pipenv --python %NUMBER% + +echo Creating Piplock.file... +pipenv lock + +echo Syncing dependencies... +pipenv sync diff --git a/connector/nypd/python/stage5/nypd-connector/setup.bat b/connector/nypd/python/stage5/nypd-connector/setup.bat index 55b586f..79b30dc 100644 --- a/connector/nypd/python/stage5/nypd-connector/setup.bat +++ b/connector/nypd/python/stage5/nypd-connector/setup.bat @@ -1,10 +1,34 @@ @echo off @REM i2, i2 Group, the i2 Group logo, and i2group.com are trademarks of N.Harris Computer Corporation. @REM © N.Harris Computer Corporation (2022) -setlocal -IF NOT DEFINED SHELL_PATH ( - SET SHELL_PATH=%PROGRAMFILES%\Git\bin\sh.exe +echo Checking if Python is installed... +python -V +if %errorlevel% neq 0 exit /b %errorlevel% + +for /f "tokens=2" %%a in ('python -V') do set version=%%a + +set VERSION=%version% +echo Detected Python v%VERSION%. + +set NUMBER=%VERSION%/Python + +echo Installing pipenv... +pip install pipenv + +echo Checking pipenv version... +pipenv --version +if %errorlevel% neq 0 ( + echo: + echo Update the PATH variable in your environment to include the locations of both the Python application and its scripts directory. + exit /b %errorlevel% ) -"%SHELL_PATH%" "%~dp0setup.sh" %* +echo Running Python... +pipenv --python %NUMBER% + +echo Creating Piplock.file... +pipenv lock + +echo Syncing dependencies... +pipenv sync