Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/mapserver/MapfileGenerator.java @ 5023:1da61095040c mapgenfix
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Tue, 19 Feb 2013 14:25:38 +0100 |
parents | a9243df307b1 |
children | cc50e1b9fc60 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/mapserver/MapfileGenerator.java Tue Feb 19 13:41:20 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/mapserver/MapfileGenerator.java Tue Feb 19 14:25:38 2013 +0100 @@ -39,12 +39,12 @@ public static final String DB_LAYER_TEMPLATE = "db_layer.vm"; public static final String RIVERAXIS_LAYER_TEMPLATE = "riveraxis-layer.vm"; - public static final String MS_WSPLGEN_PREFIX = "wsplgen-"; - public static final String MS_BARRIERS_PREFIX = "barriers-"; - public static final String MS_LINE_PREFIX = "lines-"; - public static final String MS_POLYGONS_PREFIX = "polygons-"; - public static final String MS_LAYER_PREFIX = "ms_layer-"; - public static final String MS_USERSHAPE_PREFIX = "user-"; + public static final String MS_PREFIX_WSPLGEN = "wsplgen-"; + public static final String MS_PREFIX_BARRIERS = "barriers-"; + // public static final String MS_LINE_PREFIX = "lines-"; + // public static final String MS_POLYGONS_PREFIX = "polygons-"; +// public static final String MS_LAYER_PREFIX = "ms_layer-"; + public static final String MS_PREFIX_USER = "user-"; private static Logger logger = Logger.getLogger(MapfileGenerator.class); @@ -63,12 +63,18 @@ * @param templateID The name of a template. * @return true, of the template exists - otherwise false. */ - public boolean templateExists(String templateID){ + protected boolean templateExists(String templateID){ Template template = getTemplateByName(templateID); return template != null; } + /** + * Starts the mapfile generation. This is the main entry point for + * the mapfile generation, all other methods of this class/package + * *should* be non-public. + * @throws Exception + */ public abstract void generate() throws Exception; @@ -228,40 +234,41 @@ } - protected File[] getUserDirs() + protected File[] getProjectDirs() throws FileNotFoundException, IOException { File baseDir = getShapefileBaseDir(); File[] artifactDirs = baseDir.listFiles(); - // TODO ONLY RETURN DIRECTORIES OF THE SPECIFIED USER - return artifactDirs; } - protected List<String> parseLayers(File[] dirs) { - List<String> layers = new ArrayList<String>(); + /** + * Search in all given directories for shapefiles that can be used + * as barrier, user oder wsplgen layers. + * @param dirs + * @return + */ + protected List<File> searchForLayerShapes(File[] dirs) { + List<File> shapes = new ArrayList<File>(); for (File dir: dirs) { File[] layerFiles = dir.listFiles(new FilenameFilter() { @Override public boolean accept(File directory, String name) { - return name.startsWith(MS_LAYER_PREFIX); + return name.startsWith(MS_PREFIX_BARRIERS) || + name.startsWith(MS_PREFIX_USER) || + name.startsWith(MS_PREFIX_WSPLGEN); } }); for (File layer: layerFiles) { - try { - layers.add(layer.getCanonicalPath()); - } - catch (IOException ioe) { - logger.warn(ioe, ioe); - } + shapes.add(layer); } } - return layers; + return shapes; }