view flys-aft/src/main/java/de/intevation/aft/Rivers.java @ 4329:c9dcce9448f2

Added a new control 'show legend' to the map's toolbar. This control opens a window that displays the legends of all activated layers. Currently, the row in that window has a fixed size of 400x150. The size is fixed, because there are problems with SmartGWT to build panels with auto height/width :-/
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 30 Oct 2012 12:16:26 +0100
parents b20b710aa86f
children a310aceb2e51
line wrap: on
line source
package de.intevation.aft;

import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;


import java.sql.SQLException;
import java.sql.ResultSet;

import de.intevation.db.ConnectedStatements;

import org.apache.log4j.Logger;

public class Rivers
{
    private static Logger log = Logger.getLogger(Rivers.class);

    public Rivers() {
    }

    public boolean sync(SyncContext context) throws SQLException {

        log.info("sync: rivers");

        ConnectedStatements flysStatements = context.getFlysStatements();
        ConnectedStatements aftStatements  = context.getAftStatements();

        Map<String, Integer> flysRivers = new HashMap<String, Integer>();

        ResultSet flysRs = flysStatements
            .getStatement("select.river").executeQuery();

        while (flysRs.next()) {
            Integer id   = flysRs.getInt("id");
            String  name = flysRs.getString("name").toLowerCase();
            flysRivers.put(name, id);
        }

        flysRs.close();

        List<River> commonRivers = new ArrayList<River>();

        ResultSet aftRs = aftStatements
            .getStatement("select.gewaesser").executeQuery();

        while (aftRs.next()) {
            String name = aftRs.getString("NAME");
            Integer id1 = flysRivers.get(name.toLowerCase());
            if (id1 != null) {
                int id2 = aftRs.getInt("GEWAESSER_NR");
                River river = new River(id1, id2, name);
                commonRivers.add(river);
            }
        }

        aftRs.close();

        boolean modified = false;

        for (River river: commonRivers) {
            modified |= river.sync(context);
        }

        return modified;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org