comparison backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java @ 7339:40e5ad76103c

WST Import: Added parse error exception to WST parser.
author Sascha L. Teichmann <teichmann@intevation.de>
date Tue, 15 Oct 2013 18:31:59 +0200
parents c894b7b45c4c
children 2ce7bacc940f
comparison
equal deleted inserted replaced
7338:f37c7e183b5e 7339:40e5ad76103c
354 String name = file.getName().toLowerCase(); 354 String name = file.getName().toLowerCase();
355 if (!(name.endsWith(".zus") || name.endsWith(".wst"))) { 355 if (!(name.endsWith(".zus") || name.endsWith(".wst"))) {
356 continue; 356 continue;
357 } 357 }
358 log.info("found file '" + file.getName() + "'"); 358 log.info("found file '" + file.getName() + "'");
359 WstParser wstParser = new WstParser(); 359 try {
360 wstParser.parse(file); 360 WstParser wstParser = new WstParser();
361 ImportWst iw = wstParser.getWst(); 361 wstParser.parse(file);
362 iw.setKind(5); 362 ImportWst iw = wstParser.getWst();
363 iw.setDescription(FLOOD_PROTECTION + "/" + iw.getDescription()); 363 iw.setKind(5);
364 floodProtection.add(iw); 364 iw.setDescription(FLOOD_PROTECTION + "/" + iw.getDescription());
365 floodProtection.add(iw);
366 }
367 catch (WstParser.ParseException e) {
368 log.error(e);
369 }
365 } 370 }
366 } 371 }
367 372
368 public void storeOfficialNumber() { 373 public void storeOfficialNumber() {
369 if (Config.INSTANCE.skipBWASTR()) { 374 if (Config.INSTANCE.skipBWASTR()) {
766 String name = file.getName().toLowerCase(); 771 String name = file.getName().toLowerCase();
767 if (!(name.endsWith(".zus") || name.endsWith(".wst"))) { 772 if (!(name.endsWith(".zus") || name.endsWith(".wst"))) {
768 continue; 773 continue;
769 } 774 }
770 log.info("found file '" + file.getName() + "'"); 775 log.info("found file '" + file.getName() + "'");
771 WstParser wstParser = new WstParser(); 776 try {
772 wstParser.parse(file); 777 WstParser wstParser = new WstParser();
773 ImportWst iw = wstParser.getWst(); 778 wstParser.parse(file);
774 iw.setKind(4); 779 ImportWst iw = wstParser.getWst();
775 iw.setDescription(FLOOD_WATER + "/" + iw.getDescription()); 780 iw.setKind(4);
776 floodWater.add(iw); 781 iw.setDescription(FLOOD_WATER + "/" + iw.getDescription());
782 floodWater.add(iw);
783 }
784 catch (WstParser.ParseException e) {
785 log.error(e);
786 }
777 } 787 }
778 } 788 }
779 789
780 public void parseOfficialLines() throws IOException { 790 public void parseOfficialLines() throws IOException {
781 if (Config.INSTANCE.skipOfficialLines()) { 791 if (Config.INSTANCE.skipOfficialLines()) {
803 log.debug("Found WST file: " + file); 813 log.debug("Found WST file: " + file);
804 814
805 ImportWst iw = new ImportWst(ImportOfficialWstColumn.COLUMN_FACTORY); 815 ImportWst iw = new ImportWst(ImportOfficialWstColumn.COLUMN_FACTORY);
806 816
807 WstParser wstParser = new WstParser(iw); 817 WstParser wstParser = new WstParser(iw);
808 wstParser.parse(file); 818 try {
819 wstParser.parse(file);
820 }
821 catch (WstParser.ParseException e) {
822 log.error(e);
823 continue;
824 }
825
809 iw.setKind(3); 826 iw.setKind(3);
810 iw.setDescription(folder + "/" + iw.getDescription()); 827 iw.setDescription(folder + "/" + iw.getDescription());
811 828
812 File configFile = FileTools.repair(new File(dir, OFFICIAL_LINES_CONFIG)); 829 File configFile = FileTools.repair(new File(dir, OFFICIAL_LINES_CONFIG));
813 if (!configFile.isFile() || !configFile.canRead()) { 830 if (!configFile.isFile() || !configFile.canRead()) {
876 if (!name.endsWith(".wst")) { 893 if (!name.endsWith(".wst")) {
877 continue; 894 continue;
878 } 895 }
879 log.debug("Found WST file: " + file); 896 log.debug("Found WST file: " + file);
880 897
881 WstParser wstParser = new WstParser(); 898 try {
882 wstParser.parse(file); 899 WstParser wstParser = new WstParser();
883 ImportWst iw = wstParser.getWst(); 900 wstParser.parse(file);
884 iw.setKind(2); 901 ImportWst iw = wstParser.getWst();
885 iw.setDescription(FIXATIONS+ "/" + iw.getDescription()); 902 iw.setKind(2);
886 fixations.add(iw); 903 iw.setDescription(FIXATIONS+ "/" + iw.getDescription());
904 fixations.add(iw);
905 }
906 catch (WstParser.ParseException e) {
907 log.error(e);
908 }
887 } 909 }
888 } 910 }
889 911
890 public void parseExtraWsts() throws IOException { 912 public void parseExtraWsts() throws IOException {
891 if (Config.INSTANCE.skipExtraWsts()) { 913 if (Config.INSTANCE.skipExtraWsts()) {
920 if (!(name.endsWith(".zus") || name.endsWith(".wst"))) { 942 if (!(name.endsWith(".zus") || name.endsWith(".wst"))) {
921 continue; 943 continue;
922 } 944 }
923 log.debug("Found WST file: " + file); 945 log.debug("Found WST file: " + file);
924 946
925 WstParser wstParser = new WstParser(); 947 try {
926 wstParser.parse(file); 948 WstParser wstParser = new WstParser();
927 ImportWst iw = wstParser.getWst(); 949 wstParser.parse(file);
928 iw.setKind(1); 950 ImportWst iw = wstParser.getWst();
929 iw.setDescription(EXTRA_LONGITUDINALS + "/" + iw.getDescription()); 951 iw.setKind(1);
930 extraWsts.add(iw); 952 iw.setDescription(EXTRA_LONGITUDINALS + "/" + iw.getDescription());
953 extraWsts.add(iw);
954 }
955 catch (WstParser.ParseException e) {
956 log.error(e);
957 }
931 } 958 }
932 959
933 } 960 }
934 961
935 public void parseWst() throws IOException { 962 public void parseWst() throws IOException {
937 log.info("skip parsing WST file"); 964 log.info("skip parsing WST file");
938 return; 965 return;
939 } 966 }
940 967
941 WstParser wstParser = new WstParser(); 968 WstParser wstParser = new WstParser();
942 wstParser.parse(wstFile); 969 try {
943 wst = wstParser.getWst(); 970 wstParser.parse(wstFile);
944 wst.setKmUp(wst.guessWaterLevelIncreasing()); 971 wst = wstParser.getWst();
972 wst.setKmUp(wst.guessWaterLevelIncreasing());
973 }
974 catch (WstParser.ParseException e) {
975 log.error(e);
976 }
945 } 977 }
946 978
947 public void parseGauges() throws IOException { 979 public void parseGauges() throws IOException {
948 if (Config.INSTANCE.skipGauges()) { 980 if (Config.INSTANCE.skipGauges()) {
949 log.info("skip parsing gauges"); 981 log.info("skip parsing gauges");

http://dive4elements.wald.intevation.org