All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jgrasstools.dbs.spatialite.SpatialiteTableNames Maven / Gradle / Ivy

The newest version!
/*
 * This file is part of JGrasstools (http://www.jgrasstools.org)
 * (C) HydroloGIS - www.hydrologis.com 
 * 
 * JGrasstools is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */
package org.jgrasstools.dbs.spatialite;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * Spatialite table namse and groups.
 * 
 * @author Andrea Antonello (www.hydrologis.com)
 *
 */
public class SpatialiteTableNames {
    public static final String USERDATA = "User Data";

    public static final String SPATIALINDEX = "Spatial Index";
    public static final String startsWithIndexTables = "idx_";
    public static final List spatialindexTables = Arrays.asList("SpatialIndex", //
            "KNN" //
    );

    // STYLE
    public static final String STYLE = "Styling (SLD/SE)";
    public static final String startsWithStyleTables = "SE_";

    // METADATA
    public static final String METADATA = "Metadata";
    public static final List metadataTables = Arrays.asList("geom_cols_ref_sys", //
            "geometry_columns", //
            "geometry_columns_time", //
            "raster_coverages", //
            "raster_coverages_keyword", //
            "raster_coverages_ref_sys", //
            "raster_coverages_srid", //
            "spatial_ref_sys", //
            "spatial_ref_sys_all", //
            "spatial_ref_sys_aux", //
            "spatialite_history", //
            "vector_coverages", //
            "vector_coverages_keyword", //
            "vector_coverages_ref_sys", //
            "vector_coverages_srid", //
            "vector_layers", //
            "views_geometry_columns", //
            "virts_geometry_columns"//
    );

    // INTERNAL DATA
    public static final String INTERNALDATA = "Internal Data";
    public static final List internalDataTables = Arrays.asList(//
            "sqlite_stat1", //
            "sqlite_stat3", //
            "ElementaryGeometries", //
            "geometry_columns_auth", //
            "geometry_columns_field_infos", //
            "geometry_columns_statistics", //
            "sql_statements_log", //
            "sqlite_sequence", //
            "vector_layers_auth", //
            "vector_layers_field_infos", //
            "vector_layers_statistics", //
            "views_geometry_columns_auth", //
            "views_geometry_columns_field_infos", //
            "views_geometry_columns_statistics", //
            "virts_geometry_columns_auth", //
            "virts_geometry_columns_field_infos", //
            "virts_geometry_columns_statistics");

    public static final List ALL_TYPES_LIST = Arrays.asList(//
            USERDATA, SPATIALINDEX, STYLE, METADATA, INTERNALDATA);

    /**
     * Sorts all supplied table names by type.
     * 
     * 

* Supported types are: *

    *
  • {@value SpatialiteTableNames#INTERNALDATA}
  • *
  • {@value SpatialiteTableNames#METADATA}
  • *
  • {@value SpatialiteTableNames#SPATIALINDEX}
  • *
  • {@value SpatialiteTableNames#STYLE}
  • *
  • {@value SpatialiteTableNames#USERDATA}
  • *
  • *
  • *
  • *
* * @param allTableNames list of all tables. * @param doSort if true, table names are alphabetically sorted. * @return the {@link LinkedHashMap}. */ public static LinkedHashMap> getTablesSorted( List allTableNames, boolean doSort ) { LinkedHashMap> tablesMap = new LinkedHashMap<>(); tablesMap.put(USERDATA, new ArrayList()); tablesMap.put(STYLE, new ArrayList()); tablesMap.put(METADATA, new ArrayList()); tablesMap.put(INTERNALDATA, new ArrayList()); tablesMap.put(SPATIALINDEX, new ArrayList()); for( String tableName : allTableNames ) { if (spatialindexTables.contains(tableName) || tableName.startsWith(startsWithIndexTables)) { List list = tablesMap.get(SPATIALINDEX); list.add(tableName); continue; } if (tableName.startsWith(startsWithStyleTables)) { List list = tablesMap.get(STYLE); list.add(tableName); continue; } if (metadataTables.contains(tableName)) { List list = tablesMap.get(METADATA); list.add(tableName); continue; } if (internalDataTables.contains(tableName)) { List list = tablesMap.get(INTERNALDATA); list.add(tableName); continue; } List list = tablesMap.get(USERDATA); list.add(tableName); } if (doSort) { for( List values : tablesMap.values() ) { Collections.sort(values); } } return tablesMap; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy