Class FlagDatabaseSubCommand

  • All Implemented Interfaces:
    org.openstreetmap.atlas.utilities.command.abstractcommand.AtlasShellToolsMarkerInterface

    public class FlagDatabaseSubCommand
    extends org.openstreetmap.atlas.utilities.command.abstractcommand.AbstractAtlasShellToolsCommand
    Upload Atlas Checks flags into a Postgres database.
    • Field Summary

      • Fields inherited from class org.openstreetmap.atlas.utilities.command.abstractcommand.AbstractAtlasShellToolsCommand

        DEFAULT_CONTEXT, DESCRIPTION, EXAMPLES
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void batchFlagFeatureStatement​(java.sql.PreparedStatement sql, CheckFlag flag, int flagIdentifier, com.google.gson.JsonObject feature)
      Add CheckFlag feature values to parameterized sql INSERT statement
      void createDatabaseSchema​(java.sql.Connection connection, java.lang.String schemaName)
      Create database schema from schema.sql resource file.
      int execute()  
      void executeFlagStatement​(java.sql.PreparedStatement sql, CheckFlag flag)
      Add CheckFlag values to parameterized sql INSERT statement
      java.lang.String getCommandName()  
      long getOsmIdentifier​(com.google.gson.JsonObject properties)
      Returns the OSM identifier for a given JsonObject.
      java.lang.String getSimpleDescription()  
      java.util.Map<java.lang.String,​java.lang.String> getTags​(com.google.gson.JsonObject properties)
      Filters non OSM tag in CheckFlag properties and converts into Map object for PostgreSQL hstore
      static void main​(java.lang.String[] args)  
      void processCheckFlags​(java.util.List<java.lang.String> lines, java.sql.PreparedStatement flagSqlStatement, java.sql.PreparedStatement featureSqlStatement)
      This function handles parsing each CheckFlag, and batching flag features into the database
      void registerManualPageSections()  
      void registerOptionsAndArguments()  
      • Methods inherited from class org.openstreetmap.atlas.utilities.command.abstractcommand.AbstractAtlasShellToolsCommand

        addCodeLineToSection, addManualPageSection, addManualPageSection, addParagraphToSection, getCommandOutputDelegate, getOptionAndArgumentDelegate, registerArgument, registerEmptyContext, registerOption, registerOption, registerOptionWithOptionalArgument, registerOptionWithOptionalArgument, registerOptionWithRequiredArgument, registerOptionWithRequiredArgument, runSubcommand, runSubcommandAndExit, setNewErrStream, setNewOutStream, setVersion, throwIfInvalidNameOrDescription
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FlagDatabaseSubCommand

        public FlagDatabaseSubCommand()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
      • batchFlagFeatureStatement

        public void batchFlagFeatureStatement​(java.sql.PreparedStatement sql,
                                              CheckFlag flag,
                                              int flagIdentifier,
                                              com.google.gson.JsonObject feature)
        Add CheckFlag feature values to parameterized sql INSERT statement
        Parameters:
        sql - PreparedStatement to add parameterized values to
        flag - CheckFlag to associate with feature
        flagIdentifier - Flag table record unique identifier
        feature - - Flagged AtlasItem
      • createDatabaseSchema

        public void createDatabaseSchema​(java.sql.Connection connection,
                                         java.lang.String schemaName)
        Create database schema from schema.sql resource file.
        Parameters:
        connection - jdbc Connection object
        schemaName - Name of database schema
      • execute

        public int execute()
        Specified by:
        execute in class org.openstreetmap.atlas.utilities.command.abstractcommand.AbstractAtlasShellToolsCommand
      • executeFlagStatement

        public void executeFlagStatement​(java.sql.PreparedStatement sql,
                                         CheckFlag flag)
        Add CheckFlag values to parameterized sql INSERT statement
        Parameters:
        sql - - PreparedStatement to add parameterized values to
        flag - - CheckFlag to insert into flag table
      • getCommandName

        public java.lang.String getCommandName()
        Specified by:
        getCommandName in class org.openstreetmap.atlas.utilities.command.abstractcommand.AbstractAtlasShellToolsCommand
      • getOsmIdentifier

        public long getOsmIdentifier​(com.google.gson.JsonObject properties)
        Returns the OSM identifier for a given JsonObject. Atlas Checks OSM identifier changed from "osmid" to "osmIdentifier"
        Parameters:
        properties - CheckFlag properties
        Returns:
        OSM identifier
        See Also:
        here
      • getSimpleDescription

        public java.lang.String getSimpleDescription()
        Specified by:
        getSimpleDescription in class org.openstreetmap.atlas.utilities.command.abstractcommand.AbstractAtlasShellToolsCommand
      • getTags

        public java.util.Map<java.lang.String,​java.lang.String> getTags​(com.google.gson.JsonObject properties)
        Filters non OSM tag in CheckFlag properties and converts into Map object for PostgreSQL hstore
        Parameters:
        properties - CheckFlag properties
        Returns:
        hstore Map object
      • processCheckFlags

        public void processCheckFlags​(java.util.List<java.lang.String> lines,
                                      java.sql.PreparedStatement flagSqlStatement,
                                      java.sql.PreparedStatement featureSqlStatement)
        This function handles parsing each CheckFlag, and batching flag features into the database
        Parameters:
        lines - a List of stringified CheckFlags read in from line-delimited json
        flagSqlStatement - Flag PreparedStatement
        featureSqlStatement - Feature PreparedStatement
      • registerManualPageSections

        public void registerManualPageSections()
        Specified by:
        registerManualPageSections in class org.openstreetmap.atlas.utilities.command.abstractcommand.AbstractAtlasShellToolsCommand
      • registerOptionsAndArguments

        public void registerOptionsAndArguments()
        Overrides:
        registerOptionsAndArguments in class org.openstreetmap.atlas.utilities.command.abstractcommand.AbstractAtlasShellToolsCommand