Class JSONFlagDiffSubCommand

  • All Implemented Interfaces:
    org.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
    Direct Known Subclasses:
    AtlasChecksGeoJSONDiffSubCommand, AtlasChecksLogDiffSubCommand

    public abstract class JSONFlagDiffSubCommand
    extends java.lang.Object
    implements org.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
    An abstract sub-command for creating json and flag based diffing commands.
    • Constructor Summary

      Constructors 
      Constructor Description
      JSONFlagDiffSubCommand​(java.lang.String name, java.lang.String description, java.lang.String fileExtension)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      int execute​(org.openstreetmap.atlas.utilities.runtime.CommandMap command)  
      java.lang.String getDescription()  
      protected java.util.Map<java.lang.String,​java.util.Set<com.google.gson.JsonObject>> getDiff​(java.util.Map<java.lang.String,​java.util.Map<java.util.Set<java.lang.String>,​com.google.gson.JsonObject>> reference, java.util.Map<java.lang.String,​java.util.Map<java.util.Set<java.lang.String>,​com.google.gson.JsonObject>> input)
      Takes two 2d HashMaps containing atlas-checks flags mapped by id mapped by check.
      protected com.google.gson.Gson getGson()
      Getter for gson
      protected java.util.Map<java.lang.String,​java.util.Map<java.util.Set<java.lang.String>,​com.google.gson.JsonObject>> getInput()
      Getter for input
      java.lang.String getName()  
      protected java.util.Map<java.lang.String,​java.util.Map<java.util.Set<java.lang.String>,​com.google.gson.JsonObject>> getReference()
      Getter for reference
      protected int getReferenceSize()
      A getter for the number of flags in reference
      protected abstract java.util.Map<java.lang.String,​java.util.Map<java.util.Set<java.lang.String>,​com.google.gson.JsonObject>> mapFeatures​(org.openstreetmap.atlas.streaming.resource.File file)
      Parses an atlas-checks flag file and maps each flag to its id.
      org.openstreetmap.atlas.utilities.runtime.Command.SwitchList switches()  
      void usage​(java.io.PrintStream writer)  
      protected void writeSetToGeoJSON​(java.util.Map<java.lang.String,​java.util.Set<com.google.gson.JsonObject>> flags, org.openstreetmap.atlas.streaming.resource.File output)
      Writes a Set of geoJSON atlas-checks flags to a file.
      • Methods inherited from class java.lang.Object

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

      • JSONFlagDiffSubCommand

        public JSONFlagDiffSubCommand​(java.lang.String name,
                                      java.lang.String description,
                                      java.lang.String fileExtension)
    • Method Detail

      • execute

        public int execute​(org.openstreetmap.atlas.utilities.runtime.CommandMap command)
        Specified by:
        execute in interface org.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
      • getDescription

        public java.lang.String getDescription()
        Specified by:
        getDescription in interface org.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface org.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
      • switches

        public org.openstreetmap.atlas.utilities.runtime.Command.SwitchList switches()
        Specified by:
        switches in interface org.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
      • usage

        public void usage​(java.io.PrintStream writer)
        Specified by:
        usage in interface org.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
      • getDiff

        protected java.util.Map<java.lang.String,​java.util.Set<com.google.gson.JsonObject>> getDiff​(java.util.Map<java.lang.String,​java.util.Map<java.util.Set<java.lang.String>,​com.google.gson.JsonObject>> reference,
                                                                                                          java.util.Map<java.lang.String,​java.util.Map<java.util.Set<java.lang.String>,​com.google.gson.JsonObject>> input)
        Takes two 2d HashMaps containing atlas-checks flags mapped by id mapped by check. Finds missing elements in the input based on ids.
        Parameters:
        reference - HashMap of the flags to compare from
        input - HashMap of the flags to compare to
        Returns:
        a Map of JsonObject by check
      • getGson

        protected com.google.gson.Gson getGson()
        Getter for gson
        Returns:
        Gson
      • getInput

        protected java.util.Map<java.lang.String,​java.util.Map<java.util.Set<java.lang.String>,​com.google.gson.JsonObject>> getInput()
        Getter for input
        Returns:
        HashMap
      • getReference

        protected java.util.Map<java.lang.String,​java.util.Map<java.util.Set<java.lang.String>,​com.google.gson.JsonObject>> getReference()
        Getter for reference
        Returns:
        HashMap
      • getReferenceSize

        protected int getReferenceSize()
        A getter for the number of flags in reference
        Returns:
        int
      • mapFeatures

        protected abstract java.util.Map<java.lang.String,​java.util.Map<java.util.Set<java.lang.String>,​com.google.gson.JsonObject>> mapFeatures​(org.openstreetmap.atlas.streaming.resource.File file)
        Parses an atlas-checks flag file and maps each flag to its id.
        Parameters:
        file - File containing the flags
        Returns:
        a 2d HashMap containing a HashMap of JsonObjects mapped to String feature ids, mapped to String check names.
      • writeSetToGeoJSON

        protected void writeSetToGeoJSON​(java.util.Map<java.lang.String,​java.util.Set<com.google.gson.JsonObject>> flags,
                                         org.openstreetmap.atlas.streaming.resource.File output)
        Writes a Set of geoJSON atlas-checks flags to a file.
        Parameters:
        flags - Set of JsonObjects representing geoJSON flags
        output - File to output to