Issue #1794 Consolidate common filename filters into FilenameFilters class
Change-Id: I29d7267d79164e005e3c202a23267767c853bf36 Former-commit-id:43a9f608ef
[formerlyecb0d2c826
[formerly 0e4c9f6ef22bf59f18ce3aab6539c52192539106]] Former-commit-id:ecb0d2c826
Former-commit-id:fff7e7983f
This commit is contained in:
parent
32ba1814f5
commit
65f87506b7
20 changed files with 521 additions and 164 deletions
|
@ -75,11 +75,12 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
import com.raytheon.uf.common.util.FileUtil;
|
import com.raytheon.uf.common.util.FileUtil;
|
||||||
|
import com.raytheon.uf.common.util.file.FilenameFilters;
|
||||||
import com.raytheon.uf.viz.core.RGBColors;
|
import com.raytheon.uf.viz.core.RGBColors;
|
||||||
import com.raytheon.uf.viz.core.VizApp;
|
import com.raytheon.uf.viz.core.VizApp;
|
||||||
import com.raytheon.uf.viz.core.exception.VizException;
|
import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
import com.raytheon.viz.gfe.Activator;
|
import com.raytheon.viz.gfe.Activator;
|
||||||
import com.raytheon.viz.gfe.core.DataManager;
|
import com.raytheon.viz.gfe.core.DataManagerUIFactory;
|
||||||
import com.raytheon.viz.gfe.textformatter.CombinationsFileGenerator;
|
import com.raytheon.viz.gfe.textformatter.CombinationsFileGenerator;
|
||||||
import com.raytheon.viz.gfe.textformatter.CombinationsFileUtil;
|
import com.raytheon.viz.gfe.textformatter.CombinationsFileUtil;
|
||||||
import com.raytheon.viz.gfe.textformatter.TextProductManager;
|
import com.raytheon.viz.gfe.textformatter.TextProductManager;
|
||||||
|
@ -99,6 +100,7 @@ import com.raytheon.viz.gfe.ui.zoneselector.ZoneSelector;
|
||||||
* Changes for non-blocking SaveDeleteComboDlg.
|
* Changes for non-blocking SaveDeleteComboDlg.
|
||||||
* Changes for non-blocking ShuffleZoneGroupsDialog.
|
* Changes for non-blocking ShuffleZoneGroupsDialog.
|
||||||
* Changes for non-blocking ZoneColorEditorDlg.
|
* Changes for non-blocking ZoneColorEditorDlg.
|
||||||
|
* Mar 14, 2013 1794 djohnson Consolidate common FilenameFilter implementations.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -114,7 +116,7 @@ public class ZoneCombinerComp extends Composite implements
|
||||||
/**
|
/**
|
||||||
* Parent composite.
|
* Parent composite.
|
||||||
*/
|
*/
|
||||||
private Composite parent;
|
private final Composite parent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tool bar that mimics a menu bar.
|
* Tool bar that mimics a menu bar.
|
||||||
|
@ -174,7 +176,7 @@ public class ZoneCombinerComp extends Composite implements
|
||||||
/**
|
/**
|
||||||
* Product name.
|
* Product name.
|
||||||
*/
|
*/
|
||||||
private String productName;
|
private final String productName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load sub menu. This gets generated when the program runs.
|
* Load sub menu. This gets generated when the program runs.
|
||||||
|
@ -186,7 +188,7 @@ public class ZoneCombinerComp extends Composite implements
|
||||||
*/
|
*/
|
||||||
private ZoneSelector zoneSelector;
|
private ZoneSelector zoneSelector;
|
||||||
|
|
||||||
private IProductTab callBack;
|
private final IProductTab callBack;
|
||||||
|
|
||||||
protected TextProductManager textProductMgr;
|
protected TextProductManager textProductMgr;
|
||||||
|
|
||||||
|
@ -201,7 +203,7 @@ public class ZoneCombinerComp extends Composite implements
|
||||||
|
|
||||||
Matcher matcher;
|
Matcher matcher;
|
||||||
|
|
||||||
private String theSaved = "";
|
private final String theSaved = "";
|
||||||
|
|
||||||
private Composite mapCompCtrl;
|
private Composite mapCompCtrl;
|
||||||
|
|
||||||
|
@ -217,7 +219,7 @@ public class ZoneCombinerComp extends Composite implements
|
||||||
|
|
||||||
private String currentComboFile = null;
|
private String currentComboFile = null;
|
||||||
|
|
||||||
private LocalizationFile comboDir;
|
private final LocalizationFile comboDir;
|
||||||
|
|
||||||
private boolean includeAllZones = false;
|
private boolean includeAllZones = false;
|
||||||
|
|
||||||
|
@ -802,8 +804,8 @@ public class ZoneCombinerComp extends Composite implements
|
||||||
.getProductDefinition(productName).get("subDomainUGCs");
|
.getProductDefinition(productName).get("subDomainUGCs");
|
||||||
|
|
||||||
// First thing, give the zone resource a bounding geometry.
|
// First thing, give the zone resource a bounding geometry.
|
||||||
GridLocation gloc = DataManager.getCurrentInstance().getParmManager()
|
GridLocation gloc = DataManagerUIFactory.getCurrentInstance()
|
||||||
.compositeGridLocation();
|
.getParmManager().compositeGridLocation();
|
||||||
|
|
||||||
zoneSelector = new ZoneSelector(controlComp, gloc, this);
|
zoneSelector = new ZoneSelector(controlComp, gloc, this);
|
||||||
|
|
||||||
|
@ -855,25 +857,8 @@ public class ZoneCombinerComp extends Composite implements
|
||||||
String comboDirName = "saved";
|
String comboDirName = "saved";
|
||||||
String[] combos;
|
String[] combos;
|
||||||
File localFile;
|
File localFile;
|
||||||
FilenameFilter filter = new FilenameFilter() {
|
// Accept any file whose name ends with ".py".
|
||||||
|
FilenameFilter filter = FilenameFilters.byFileExtension(".py");
|
||||||
/**
|
|
||||||
* Accept any file whose name ends with ".py".
|
|
||||||
*
|
|
||||||
* @param dir
|
|
||||||
* The directory in which the file exists
|
|
||||||
* @param name
|
|
||||||
* the file name
|
|
||||||
* @return true if name ends with ".py", false otherwise.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
if (name.endsWith(".py")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (level == null) {
|
if (level == null) {
|
||||||
// Aggregate the filenames for all levels.
|
// Aggregate the filenames for all levels.
|
||||||
|
@ -1083,10 +1068,12 @@ public class ZoneCombinerComp extends Composite implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setStatusText(String significance, String message) {
|
public void setStatusText(String significance, String message) {
|
||||||
callBack.updateStatus(significance, message);
|
callBack.updateStatus(significance, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void applyButtonState(final boolean enabled) {
|
public void applyButtonState(final boolean enabled) {
|
||||||
if (this.applyZoneComboBtn != null
|
if (this.applyZoneComboBtn != null
|
||||||
&& !this.applyZoneComboBtn.isDisposed()) {
|
&& !this.applyZoneComboBtn.isDisposed()) {
|
||||||
|
|
|
@ -111,6 +111,7 @@
|
||||||
<exclude>qpf-ingest.xml</exclude>
|
<exclude>qpf-ingest.xml</exclude>
|
||||||
<exclude>fssobs-ingest.xml</exclude>
|
<exclude>fssobs-ingest.xml</exclude>
|
||||||
<exclude>cpgsrv-spring.xml</exclude>
|
<exclude>cpgsrv-spring.xml</exclude>
|
||||||
|
<exclude>.*sbn-simulator.*</exclude>
|
||||||
</mode>
|
</mode>
|
||||||
<mode name="ingestGrib">
|
<mode name="ingestGrib">
|
||||||
<include>time-common.xml</include>
|
<include>time-common.xml</include>
|
||||||
|
@ -202,6 +203,9 @@
|
||||||
<include>ebxml.*\.xml</include>
|
<include>ebxml.*\.xml</include>
|
||||||
<includeMode>statsTemplate</includeMode>
|
<includeMode>statsTemplate</includeMode>
|
||||||
<includeMode>dataDeliveryTemplate</includeMode>
|
<includeMode>dataDeliveryTemplate</includeMode>
|
||||||
|
<!-- TODO: These patterns can be commented out when this mode is productionized -->
|
||||||
|
<include>.*sbn-simulator.*</include>
|
||||||
|
<!-- END TODO -->
|
||||||
<exclude>.*datadelivery-ncf.*</exclude>
|
<exclude>.*datadelivery-ncf.*</exclude>
|
||||||
<exclude>harvester-*</exclude>
|
<exclude>harvester-*</exclude>
|
||||||
<exclude>crawler-*</exclude>
|
<exclude>crawler-*</exclude>
|
||||||
|
@ -297,6 +301,7 @@
|
||||||
<exclude>pointDataRetrievel-spring.xml</exclude>
|
<exclude>pointDataRetrievel-spring.xml</exclude>
|
||||||
<exclude>q2FileProcessor-spring.xml</exclude>
|
<exclude>q2FileProcessor-spring.xml</exclude>
|
||||||
<exclude>satpre-spring.xml</exclude>
|
<exclude>satpre-spring.xml</exclude>
|
||||||
|
<exclude>.*sbn-simulator.*</exclude>
|
||||||
</mode>
|
</mode>
|
||||||
<mode name="localization">
|
<mode name="localization">
|
||||||
<include>auth-request.xml</include>
|
<include>auth-request.xml</include>
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.raytheon.edex.exception.ColorTableException;
|
import com.raytheon.edex.exception.ColorTableException;
|
||||||
import com.raytheon.uf.common.colormap.CMapFilenameFilter;
|
import com.raytheon.uf.common.colormap.CMapFilenameFilter;
|
||||||
|
@ -52,6 +53,7 @@ import com.raytheon.uf.common.util.FileUtil;
|
||||||
* Aug 20, 2008 dglazesk JiBX replaced with JaXB
|
* Aug 20, 2008 dglazesk JiBX replaced with JaXB
|
||||||
* Aug 20, 2008 dglazesk Updated for the new ColorMap interface
|
* Aug 20, 2008 dglazesk Updated for the new ColorMap interface
|
||||||
* Feb 15, 2013 1638 mschenke Moved IndexColorModel creation to common.colormap utility
|
* Feb 15, 2013 1638 mschenke Moved IndexColorModel creation to common.colormap utility
|
||||||
|
* Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -136,7 +138,7 @@ public class ColorMapManager {
|
||||||
*/
|
*/
|
||||||
public String[] listColorMaps() {
|
public String[] listColorMaps() {
|
||||||
File colormapsDir = new File(baseColormapDir);
|
File colormapsDir = new File(baseColormapDir);
|
||||||
ArrayList<File> files = FileUtil.listFiles(colormapsDir,
|
List<File> files = FileUtil.listFiles(colormapsDir,
|
||||||
new CMapFilenameFilter(), true);
|
new CMapFilenameFilter(), true);
|
||||||
ArrayList<String> colormaps = new ArrayList<String>();
|
ArrayList<String> colormaps = new ArrayList<String>();
|
||||||
for (int i = 0; i < files.size(); i++) {
|
for (int i = 0; i < files.size(); i++) {
|
||||||
|
|
|
@ -57,6 +57,7 @@ import com.raytheon.uf.edex.core.props.PropertiesFactory;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jul 11, 2008 1250 jelkins Initial creation
|
* Jul 11, 2008 1250 jelkins Initial creation
|
||||||
|
* Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author jelkins
|
* @author jelkins
|
||||||
|
@ -257,7 +258,7 @@ public class EDEXLocalizationAdapter implements ILocalizationAdapter {
|
||||||
|
|
||||||
for (LocalizationContext ctx : context) {
|
for (LocalizationContext ctx : context) {
|
||||||
|
|
||||||
ArrayList<File> fileList = com.raytheon.uf.common.util.FileUtil
|
List<File> fileList = com.raytheon.uf.common.util.FileUtil
|
||||||
.listFiles(getPath(ctx, path), null, recursive);
|
.listFiles(getPath(ctx, path), null, recursive);
|
||||||
|
|
||||||
for (File file : fileList) {
|
for (File file : fileList) {
|
||||||
|
|
|
@ -19,23 +19,26 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.edex.monitors;
|
package com.raytheon.edex.monitors;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.util.file.FilenameFilters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract base class for directory monitors.
|
* An abstract base class for directory monitors.
|
||||||
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
* SOFTWARE HISTORY
|
* SOFTWARE HISTORY
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 08May2008 1113 MW Fegan Initial creation.
|
* 08May2008 1113 MW Fegan Initial creation.
|
||||||
|
* Mar 14, 2013 1794 djohnson Consolidate common FilenameFilter implementations.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author mfegan
|
* @author mfegan
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class AEdexDirMonitor extends AEdexMonitor {
|
public abstract class AEdexDirMonitor extends AEdexMonitor {
|
||||||
|
@ -48,11 +51,7 @@ public abstract class AEdexDirMonitor extends AEdexMonitor {
|
||||||
protected String dirToCheck = ".";
|
protected String dirToCheck = ".";
|
||||||
|
|
||||||
/* file filter that screens out "dot" files */
|
/* file filter that screens out "dot" files */
|
||||||
protected FilenameFilter filter = new FilenameFilter() {
|
protected FilenameFilter filter = FilenameFilters.NO_LINUX_HIDDEN_FILES;
|
||||||
public boolean accept(final File dir, final String name) {
|
|
||||||
return !name.startsWith(".");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Takes no action.
|
* Constructor. Takes no action.
|
||||||
|
|
|
@ -59,6 +59,7 @@ import com.raytheon.uf.common.util.FileUtil;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 07/14/09 1995 bphillip Initial creation
|
* 07/14/09 1995 bphillip Initial creation
|
||||||
|
* Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -72,13 +73,13 @@ public class GfeIRT extends Thread {
|
||||||
.getHandler(GfeIRT.class);
|
.getHandler(GfeIRT.class);
|
||||||
|
|
||||||
/** The site ID associated with this IRT thread */
|
/** The site ID associated with this IRT thread */
|
||||||
private String siteID;
|
private final String siteID;
|
||||||
|
|
||||||
/** The MHS ID associated with this IRT thread */
|
/** The MHS ID associated with this IRT thread */
|
||||||
private String mhsID;
|
private final String mhsID;
|
||||||
|
|
||||||
/** The script file name */
|
/** The script file name */
|
||||||
private String scriptFile;
|
private final String scriptFile;
|
||||||
|
|
||||||
/** The Python script object */
|
/** The Python script object */
|
||||||
private PythonScript script;
|
private PythonScript script;
|
||||||
|
@ -186,7 +187,7 @@ public class GfeIRT extends Thread {
|
||||||
return name.trim().matches("ISC_\\p{Alnum}{3}\\.xml");
|
return name.trim().matches("ISC_\\p{Alnum}{3}\\.xml");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ArrayList<File> editAreas = FileUtil.listFiles(editAreaDir,
|
List<File> editAreas = FileUtil.listFiles(editAreaDir,
|
||||||
filter, false);
|
filter, false);
|
||||||
|
|
||||||
String name = "";
|
String name = "";
|
||||||
|
|
|
@ -43,6 +43,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
import com.raytheon.uf.common.util.FileUtil;
|
import com.raytheon.uf.common.util.FileUtil;
|
||||||
|
import com.raytheon.uf.common.util.file.FilenameFilters;
|
||||||
import com.raytheon.uf.edex.site.SiteAwareRegistry;
|
import com.raytheon.uf.edex.site.SiteAwareRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,6 +58,7 @@ import com.raytheon.uf.edex.site.SiteAwareRegistry;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Mar 05, 2012 #361 dgilling Initial creation
|
* Mar 05, 2012 #361 dgilling Initial creation
|
||||||
* Mar 12, 2013 #1759 dgilling Re-implement using IscScript.
|
* Mar 12, 2013 #1759 dgilling Re-implement using IscScript.
|
||||||
|
* Mar 14, 2013 1794 djohnson Consolidate common FilenameFilter implementations.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -70,12 +72,8 @@ public class IscReceiveSrv {
|
||||||
|
|
||||||
private static final String METHOD_NAME = "main";
|
private static final String METHOD_NAME = "main";
|
||||||
|
|
||||||
private static final FilenameFilter docFileFilter = new FilenameFilter() {
|
private static final FilenameFilter docFileFilter = FilenameFilters
|
||||||
@Override
|
.byFileExtension(".doc");
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
return name.endsWith(".doc");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final IPythonJobListener<String> jobListener = new IPythonJobListener<String>() {
|
private static final IPythonJobListener<String> jobListener = new IPythonJobListener<String>() {
|
||||||
|
|
||||||
|
@ -249,7 +247,7 @@ public class IscReceiveSrv {
|
||||||
statusHandler.error("Unable to delete " + xmlFileName);
|
statusHandler.error("Unable to delete " + xmlFileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArrayList<File> docFiles = FileUtil.listFiles(
|
List<File> docFiles = FileUtil.listFiles(
|
||||||
xmlFile.getParentFile(), docFileFilter, false);
|
xmlFile.getParentFile(), docFileFilter, false);
|
||||||
for (File docFile : docFiles) {
|
for (File docFile : docFiles) {
|
||||||
docFile.delete();
|
docFile.delete();
|
||||||
|
|
|
@ -73,6 +73,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
import com.raytheon.uf.common.util.FileUtil;
|
import com.raytheon.uf.common.util.FileUtil;
|
||||||
|
import com.raytheon.uf.common.util.file.FilenameFilters;
|
||||||
import com.vividsolutions.jts.geom.Coordinate;
|
import com.vividsolutions.jts.geom.Coordinate;
|
||||||
import com.vividsolutions.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
import com.vividsolutions.jts.geom.GeometryFactory;
|
import com.vividsolutions.jts.geom.GeometryFactory;
|
||||||
|
@ -96,6 +97,7 @@ import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier;
|
||||||
* Jun 25, 2008 #1210 randerso Modified to get directories from UtilityContext
|
* Jun 25, 2008 #1210 randerso Modified to get directories from UtilityContext
|
||||||
* Oct 13, 2008 #1607 njensen Added genCombinationsFiles()
|
* Oct 13, 2008 #1607 njensen Added genCombinationsFiles()
|
||||||
* Sep 18, 2012 #1091 randerso Changed to use Maps.py and localMaps.py
|
* Sep 18, 2012 #1091 randerso Changed to use Maps.py and localMaps.py
|
||||||
|
* Mar 14, 2013 1794 djohnson Consolidate common FilenameFilter implementations.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -119,13 +121,13 @@ public class MapManager {
|
||||||
|
|
||||||
private List<String> _mapErrors;
|
private List<String> _mapErrors;
|
||||||
|
|
||||||
private Map<String, ArrayList<String>> editAreaMap = new HashMap<String, ArrayList<String>>();
|
private final Map<String, List<String>> editAreaMap = new HashMap<String, List<String>>();
|
||||||
|
|
||||||
private Map<String, Map<String, Object>> editAreaAttrs = new HashMap<String, Map<String, Object>>();
|
private final Map<String, Map<String, Object>> editAreaAttrs = new HashMap<String, Map<String, Object>>();
|
||||||
|
|
||||||
private List<String> iscMarkersID = new ArrayList<String>();
|
private final List<String> iscMarkersID = new ArrayList<String>();
|
||||||
|
|
||||||
private List<Coordinate> iscMarkers = new ArrayList<Coordinate>();
|
private final List<Coordinate> iscMarkers = new ArrayList<Coordinate>();
|
||||||
|
|
||||||
private final String commonStaticConfigDir;
|
private final String commonStaticConfigDir;
|
||||||
|
|
||||||
|
@ -357,14 +359,9 @@ public class MapManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
d = new File(FileUtil.join(commonStaticConfigDir, SAMPLE_SETS_DIR));
|
d = new File(FileUtil.join(commonStaticConfigDir, SAMPLE_SETS_DIR));
|
||||||
FilenameFilter filter = new FilenameFilter() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
return name.trim().startsWith("ISC_Marker_Set");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (d.exists()) {
|
if (d.exists()) {
|
||||||
|
final FilenameFilter filter = FilenameFilters.byFilePrefix("ISC_Marker_Set");
|
||||||
for (File file : FileUtil.listFiles(d, filter, false)) {
|
for (File file : FileUtil.listFiles(d, filter, false)) {
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ package com.raytheon.edex.plugin.grib.decoderpostprocessors;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -50,6 +49,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
import com.raytheon.uf.common.util.FileUtil;
|
import com.raytheon.uf.common.util.FileUtil;
|
||||||
|
import com.raytheon.uf.common.util.file.FilenameFilters;
|
||||||
import com.raytheon.uf.edex.core.EDEXUtil;
|
import com.raytheon.uf.edex.core.EDEXUtil;
|
||||||
import com.raytheon.uf.edex.database.cluster.ClusterLockUtils;
|
import com.raytheon.uf.edex.database.cluster.ClusterLockUtils;
|
||||||
import com.raytheon.uf.edex.database.cluster.ClusterLockUtils.LockState;
|
import com.raytheon.uf.edex.database.cluster.ClusterLockUtils.LockState;
|
||||||
|
@ -69,6 +69,7 @@ import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 4/09/10 4638 bphillip Initial Creation
|
* 4/09/10 4638 bphillip Initial Creation
|
||||||
|
* Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -102,20 +103,19 @@ public class EnsembleGridAssembler implements IDecoderPostProcessor {
|
||||||
File commonPath = pm.getFile(pm.getContext(
|
File commonPath = pm.getFile(pm.getContext(
|
||||||
LocalizationType.EDEX_STATIC, LocalizationLevel.BASE),
|
LocalizationType.EDEX_STATIC, LocalizationLevel.BASE),
|
||||||
"/grib/thinnedModels");
|
"/grib/thinnedModels");
|
||||||
FilenameFilter filter = new FilenameFilter() {
|
|
||||||
@Override
|
FilenameFilter filter = FilenameFilters.byFilters(
|
||||||
public boolean accept(File dir, String name) {
|
FilenameFilters.ACCEPT_FILES,
|
||||||
return (!new File(dir.getPath() + File.separator + name)
|
FilenameFilters.byFileExtension(".xml"));
|
||||||
.isDirectory() && name.endsWith(".xml"));
|
|
||||||
}
|
List<File> thinnedModelFiles = FileUtil.listFiles(commonPath,
|
||||||
};
|
|
||||||
ArrayList<File> thinnedModelFiles = FileUtil.listFiles(commonPath,
|
|
||||||
filter, false);
|
filter, false);
|
||||||
|
|
||||||
for (File file : thinnedModelFiles) {
|
for (File file : thinnedModelFiles) {
|
||||||
try {
|
try {
|
||||||
CompositeModel model = (CompositeModel) SerializationUtil
|
CompositeModel model = SerializationUtil
|
||||||
.jaxbUnmarshalFromXmlFile(file.getPath());
|
.jaxbUnmarshalFromXmlFile(CompositeModel.class,
|
||||||
|
file.getPath());
|
||||||
thinnedModels.put(model.getModelName(), model);
|
thinnedModels.put(model.getModelName(), model);
|
||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
|
@ -124,6 +124,7 @@ public class EnsembleGridAssembler implements IDecoderPostProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public GridRecord[] process(GridRecord rec) throws GribException {
|
public GridRecord[] process(GridRecord rec) throws GribException {
|
||||||
Map<Integer, GridRecord> newRecords = new HashMap<Integer, GridRecord>();
|
Map<Integer, GridRecord> newRecords = new HashMap<Integer, GridRecord>();
|
||||||
String compositeModel = getCompositeModel(rec.getDatasetId());
|
String compositeModel = getCompositeModel(rec.getDatasetId());
|
||||||
|
|
|
@ -25,8 +25,8 @@ import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -45,6 +45,7 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||||
import com.raytheon.uf.common.util.FileUtil;
|
import com.raytheon.uf.common.util.FileUtil;
|
||||||
|
import com.raytheon.uf.common.util.file.FilenameFilters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class used to access and manage data from any defined tables.
|
* Class used to access and manage data from any defined tables.
|
||||||
|
@ -56,6 +57,7 @@ import com.raytheon.uf.common.util.FileUtil;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 4/7/09 1994 bphillip Initial Creation
|
* 4/7/09 1994 bphillip Initial Creation
|
||||||
|
* Mar 14, 2013 1794 djohnson Consolidate common FilenameFilter implementations.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -73,7 +75,7 @@ public class GribTableLookup {
|
||||||
private static final int NO_SUBCENTER = -1;
|
private static final int NO_SUBCENTER = -1;
|
||||||
|
|
||||||
/** The map of defined tables */
|
/** The map of defined tables */
|
||||||
private Map<Integer, Map<String, GribTable>> tableMap;
|
private final Map<Integer, Map<String, GribTable>> tableMap;
|
||||||
|
|
||||||
/** The singleton instance */
|
/** The singleton instance */
|
||||||
private static GribTableLookup instance;
|
private static GribTableLookup instance;
|
||||||
|
@ -219,31 +221,19 @@ public class GribTableLookup {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initTablesFromPath(String commonPath) {
|
private void initTablesFromPath(String commonPath) {
|
||||||
FilenameFilter filter = new FilenameFilter() {
|
FilenameFilter tableFilter = FilenameFilters.byFileExtension(".table");
|
||||||
@Override
|
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
return new File(dir.getPath() + File.separator + name)
|
|
||||||
.isDirectory();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
FilenameFilter tableFilter = new FilenameFilter() {
|
List<File> files = FileUtil.listFiles(new File(commonPath),
|
||||||
@Override
|
FilenameFilters.ACCEPT_DIRECTORIES, false);
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
return name.endsWith(".table");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ArrayList<File> files = FileUtil.listFiles(new File(commonPath),
|
|
||||||
filter, false);
|
|
||||||
for (File f : files) {
|
for (File f : files) {
|
||||||
int center = 0;
|
int center = 0;
|
||||||
try {
|
try {
|
||||||
center = Integer.parseInt(f.getPath().substring(
|
center = Integer.parseInt(f.getPath().substring(
|
||||||
f.getPath().lastIndexOf("/") + 1));
|
f.getPath().lastIndexOf("/") + 1));
|
||||||
|
|
||||||
ArrayList<File> files2 = FileUtil.listFiles(new File(commonPath
|
List<File> files2 = FileUtil.listFiles(new File(commonPath
|
||||||
+ File.separator + String.valueOf(center)), filter,
|
+ File.separator + String.valueOf(center)),
|
||||||
|
FilenameFilters.ACCEPT_DIRECTORIES,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
int subcenter = 0;
|
int subcenter = 0;
|
||||||
|
@ -251,7 +241,7 @@ public class GribTableLookup {
|
||||||
if (!f2.getPath().contains(".svn")) {
|
if (!f2.getPath().contains(".svn")) {
|
||||||
subcenter = Integer.parseInt(f2.getPath().substring(
|
subcenter = Integer.parseInt(f2.getPath().substring(
|
||||||
f2.getPath().lastIndexOf("/") + 1));
|
f2.getPath().lastIndexOf("/") + 1));
|
||||||
ArrayList<File> tableFiles = FileUtil.listFiles(f2,
|
List<File> tableFiles = FileUtil.listFiles(f2,
|
||||||
tableFilter, false);
|
tableFilter, false);
|
||||||
String tableName = null;
|
String tableName = null;
|
||||||
for (File table : tableFiles) {
|
for (File table : tableFiles) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ Require-Bundle: org.junit;bundle-version="1.0.0",
|
||||||
Export-Package: com.raytheon.uf.common.util,
|
Export-Package: com.raytheon.uf.common.util,
|
||||||
com.raytheon.uf.common.util.algorithm,
|
com.raytheon.uf.common.util.algorithm,
|
||||||
com.raytheon.uf.common.util.cache,
|
com.raytheon.uf.common.util.cache,
|
||||||
|
com.raytheon.uf.common.util.file,
|
||||||
com.raytheon.uf.common.util.header,
|
com.raytheon.uf.common.util.header,
|
||||||
com.raytheon.uf.common.util.mapping,
|
com.raytheon.uf.common.util.mapping,
|
||||||
com.raytheon.uf.common.util.registry,
|
com.raytheon.uf.common.util.registry,
|
||||||
|
|
|
@ -31,6 +31,7 @@ import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
@ -55,6 +56,7 @@ import java.util.zip.GZIPOutputStream;
|
||||||
* 02/15/2013 #1597 randerso Fixed error when copying empty files
|
* 02/15/2013 #1597 randerso Fixed error when copying empty files
|
||||||
* Feb 15, 2013 1638 mschenke Moved EOL field from edex.common Util
|
* Feb 15, 2013 1638 mschenke Moved EOL field from edex.common Util
|
||||||
* Mar 11, 2013 1645 djohnson Added file modification watcher.
|
* Mar 11, 2013 1645 djohnson Added file modification watcher.
|
||||||
|
* Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -114,7 +116,7 @@ public class FileUtil {
|
||||||
* whether or not to go into subdirectories
|
* whether or not to go into subdirectories
|
||||||
* @return the files that match the filter
|
* @return the files that match the filter
|
||||||
*/
|
*/
|
||||||
public static ArrayList<File> listFiles(File directory,
|
public static List<File> listFiles(File directory,
|
||||||
FilenameFilter filter, boolean recurse) {
|
FilenameFilter filter, boolean recurse) {
|
||||||
// List of files / directories
|
// List of files / directories
|
||||||
ArrayList<File> files = new ArrayList<File>();
|
ArrayList<File> files = new ArrayList<File>();
|
||||||
|
|
|
@ -0,0 +1,228 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.common.util.file;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FilenameFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Consolidates common filename filters.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Mar 14, 2013 1794 djohnson Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author djohnson
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public final class FilenameFilters {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverses a {@link FilenameFilter}
|
||||||
|
*/
|
||||||
|
private static class ReverseFilter implements FilenameFilter {
|
||||||
|
private final FilenameFilter filter;
|
||||||
|
|
||||||
|
private ReverseFilter(FilenameFilter filter) {
|
||||||
|
this.filter = filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(File dir, String name) {
|
||||||
|
return !filter.accept(dir, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link FilenameFilter} that matches files with the specified extension.
|
||||||
|
*/
|
||||||
|
private static class FileExtensionFilenameFilter implements FilenameFilter {
|
||||||
|
|
||||||
|
private final String fileExtension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param fileExtension
|
||||||
|
*/
|
||||||
|
private FileExtensionFilenameFilter(String fileExtension) {
|
||||||
|
this.fileExtension = fileExtension;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(File dir, String name) {
|
||||||
|
return name.endsWith(fileExtension);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link FilenameFilter} that matches files with the specified prefix.
|
||||||
|
*/
|
||||||
|
private static class StartsWithPrefix implements FilenameFilter {
|
||||||
|
private final String prefix;
|
||||||
|
|
||||||
|
private StartsWithPrefix(String prefix) {
|
||||||
|
this.prefix = prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(final File dir, final String name) {
|
||||||
|
return name != null && name.trim().startsWith(prefix);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link FilenameFilter} that denies files with the specified prefix.
|
||||||
|
*/
|
||||||
|
private static class SumFilter implements FilenameFilter {
|
||||||
|
private final FilenameFilter[] filters;
|
||||||
|
|
||||||
|
private SumFilter(FilenameFilter[] filters) {
|
||||||
|
this.filters = filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(final File dir, final String name) {
|
||||||
|
for (FilenameFilter filter : filters) {
|
||||||
|
if (!filter.accept(dir, name)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No construction.
|
||||||
|
*/
|
||||||
|
private FilenameFilters() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accepts all files.
|
||||||
|
*/
|
||||||
|
public static final FilenameFilter ACCEPT_ALL = new FilenameFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean accept(File dir, String name) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denies all files.
|
||||||
|
*/
|
||||||
|
public static final FilenameFilter ACCEPT_NONE = new ReverseFilter(
|
||||||
|
ACCEPT_ALL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denies all files starting with "."
|
||||||
|
*/
|
||||||
|
public static final FilenameFilter NO_LINUX_HIDDEN_FILES = new ReverseFilter(
|
||||||
|
byFilePrefix("."));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accepts directories.
|
||||||
|
*/
|
||||||
|
public static final FilenameFilter ACCEPT_DIRECTORIES = new FilenameFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean accept(File dir, String name) {
|
||||||
|
return new File(dir.getPath(), name).isDirectory();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accepts directories.
|
||||||
|
*/
|
||||||
|
public static final FilenameFilter ACCEPT_FILES = new FilenameFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean accept(File dir, String name) {
|
||||||
|
return new File(dir.getPath(), name).isFile();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a {@link FilenameFilter} that matches the specified file
|
||||||
|
* extension.
|
||||||
|
*
|
||||||
|
* @param fileExtension
|
||||||
|
* the file extension to match
|
||||||
|
* @return the file name filter
|
||||||
|
*/
|
||||||
|
public static FilenameFilter byFileExtension(final String fileExtension) {
|
||||||
|
return new FileExtensionFilenameFilter(fileExtension);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a {@link FilenameFilter} that matches the specified file name
|
||||||
|
* prefix.
|
||||||
|
*
|
||||||
|
* @param prefix
|
||||||
|
* the file prefix to match
|
||||||
|
* @return the file name filter
|
||||||
|
*/
|
||||||
|
public static FilenameFilter byFilePrefix(final String prefix) {
|
||||||
|
return new StartsWithPrefix(prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a {@link FilenameFilter} that returns true only if all filters
|
||||||
|
* return true.
|
||||||
|
*
|
||||||
|
* @param filters
|
||||||
|
* the filters
|
||||||
|
* @return the file name filter
|
||||||
|
*/
|
||||||
|
public static FilenameFilter byFilters(FilenameFilter filters) {
|
||||||
|
// This method version forces at least one filter to supplied
|
||||||
|
return byFilters(new FilenameFilter[] { filters });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a {@link FilenameFilter} that returns true only if all filters
|
||||||
|
* return true.
|
||||||
|
*
|
||||||
|
* @param filters
|
||||||
|
* the filters
|
||||||
|
* @return the file name filter
|
||||||
|
*/
|
||||||
|
public static FilenameFilter byFilters(FilenameFilter... filters) {
|
||||||
|
return new SumFilter(filters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a {@link FilenameFilter} that returns the reverse of the
|
||||||
|
* specified filter. For instance, if the supplied filter would return true
|
||||||
|
* if the file ends with .xml this version returns a filter that would
|
||||||
|
* return false.
|
||||||
|
*
|
||||||
|
* @param filter
|
||||||
|
* the filter to reverse
|
||||||
|
* @return the reversed filter
|
||||||
|
*/
|
||||||
|
public static FilenameFilter reverse(FilenameFilter filter) {
|
||||||
|
return new ReverseFilter(filter);
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,7 +20,6 @@
|
||||||
package com.raytheon.uf.edex.datadelivery.harvester.crawler;
|
package com.raytheon.uf.edex.datadelivery.harvester.crawler;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -53,6 +52,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
|
||||||
import com.raytheon.uf.common.util.CollectionUtil;
|
import com.raytheon.uf.common.util.CollectionUtil;
|
||||||
import com.raytheon.uf.common.util.FileUtil;
|
import com.raytheon.uf.common.util.FileUtil;
|
||||||
import com.raytheon.uf.common.util.StringUtil;
|
import com.raytheon.uf.common.util.StringUtil;
|
||||||
|
import com.raytheon.uf.common.util.file.FilenameFilters;
|
||||||
import com.raytheon.uf.edex.datadelivery.harvester.CrawlMetaDataHandler;
|
import com.raytheon.uf.edex.datadelivery.harvester.CrawlMetaDataHandler;
|
||||||
import com.raytheon.uf.edex.datadelivery.harvester.config.CrawlAgent;
|
import com.raytheon.uf.edex.datadelivery.harvester.config.CrawlAgent;
|
||||||
import com.raytheon.uf.edex.datadelivery.harvester.config.HarvesterConfig;
|
import com.raytheon.uf.edex.datadelivery.harvester.config.HarvesterConfig;
|
||||||
|
@ -72,6 +72,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.ProviderCollectionLinkStore;
|
||||||
* Jul 17, 2012 740 djohnson Initial creation
|
* Jul 17, 2012 740 djohnson Initial creation
|
||||||
* Aug 06, 2012 1022 djohnson Add shutdown(), write out millis with filename to prevent overwriting.
|
* Aug 06, 2012 1022 djohnson Add shutdown(), write out millis with filename to prevent overwriting.
|
||||||
* Sep 10, 2012 1154 djohnson Use JAXB instead of thrift, allowing introspection of links, return files in ascending order.
|
* Sep 10, 2012 1154 djohnson Use JAXB instead of thrift, allowing introspection of links, return files in ascending order.
|
||||||
|
* Mar 14, 2013 1794 djohnson Consolidate common FilenameFilter implementations.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -306,12 +307,8 @@ class FileCommunicationStrategy implements CommunicationStrategy {
|
||||||
|
|
||||||
private File[] readFilesInDir(final File dir, final String fileExtension) {
|
private File[] readFilesInDir(final File dir, final String fileExtension) {
|
||||||
if (dir.isDirectory()) {
|
if (dir.isDirectory()) {
|
||||||
File[] files = dir.listFiles(new FilenameFilter() {
|
File[] files = dir.listFiles(FilenameFilters
|
||||||
@Override
|
.byFileExtension(fileExtension));
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
return name.endsWith(fileExtension);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// order the files in time order
|
// order the files in time order
|
||||||
Arrays.sort(files, new Comparator<File>() {
|
Arrays.sort(files, new Comparator<File>() {
|
||||||
|
|
|
@ -47,6 +47,7 @@ import com.raytheon.uf.edex.pointdata.PointDataQuery;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 12/04/09 3408 bphillip Initial creation
|
* 12/04/09 3408 bphillip Initial creation
|
||||||
|
* Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -56,7 +57,7 @@ import com.raytheon.uf.edex.pointdata.PointDataQuery;
|
||||||
public class QCDataQuery extends PointDataQuery {
|
public class QCDataQuery extends PointDataQuery {
|
||||||
|
|
||||||
/** List of query parameters for "querying" the netCDF file */
|
/** List of query parameters for "querying" the netCDF file */
|
||||||
private List<String> queryParameters;
|
private final List<String> queryParameters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new QCDataQuery
|
* Constructs a new QCDataQuery
|
||||||
|
@ -71,7 +72,8 @@ public class QCDataQuery extends PointDataQuery {
|
||||||
queryParameters = new ArrayList<String>();
|
queryParameters = new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addParameter(String name, String value, String operand) {
|
@Override
|
||||||
|
public void addParameter(String name, String value, String operand) {
|
||||||
queryParameters.add(name + " " + value + " " + operand);
|
queryParameters.add(name + " " + value + " " + operand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,13 +84,14 @@ public class QCDataQuery extends PointDataQuery {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* if errors occur while retrieving the data
|
* if errors occur while retrieving the data
|
||||||
*/
|
*/
|
||||||
public PointDataContainer execute() throws Exception {
|
@Override
|
||||||
|
public PointDataContainer execute() throws Exception {
|
||||||
List<PointDataContainer> containers = new ArrayList<PointDataContainer>();
|
List<PointDataContainer> containers = new ArrayList<PointDataContainer>();
|
||||||
|
|
||||||
// Gets the available files for querying
|
// Gets the available files for querying
|
||||||
Map<String, File> pathMap = QCPaths.getPaths();
|
Map<String, File> pathMap = QCPaths.getPaths();
|
||||||
for (File dir : pathMap.values()) {
|
for (File dir : pathMap.values()) {
|
||||||
ArrayList<File> files = FileUtil.listFiles(dir, null, false);
|
List<File> files = FileUtil.listFiles(dir, null, false);
|
||||||
|
|
||||||
if (!files.isEmpty()) {
|
if (!files.isEmpty()) {
|
||||||
String[] fileParams = ((QCDao) dao).getParameters(files.get(0));
|
String[] fileParams = ((QCDao) dao).getParameters(files.get(0));
|
||||||
|
|
|
@ -14,7 +14,7 @@ import com.raytheon.uf.common.dataplugin.persist.IPersistable;
|
||||||
import com.raytheon.uf.common.datastorage.IDataStore;
|
import com.raytheon.uf.common.datastorage.IDataStore;
|
||||||
import com.raytheon.uf.common.util.FileUtil;
|
import com.raytheon.uf.common.util.FileUtil;
|
||||||
import com.raytheon.uf.edex.core.hdf5.HDF5PluginFilenameFilter;
|
import com.raytheon.uf.edex.core.hdf5.HDF5PluginFilenameFilter;
|
||||||
import com.raytheon.uf.edex.pointdata.*;
|
import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
|
||||||
public abstract class NcepPointDataPluginDao<T extends PluginDataObject> extends PointDataPluginDao<T>{
|
public abstract class NcepPointDataPluginDao<T extends PluginDataObject> extends PointDataPluginDao<T>{
|
||||||
|
|
||||||
protected List<String> tableClassNameList= new ArrayList<String>();
|
protected List<String> tableClassNameList= new ArrayList<String>();
|
||||||
|
@ -84,7 +84,7 @@ public abstract class NcepPointDataPluginDao<T extends PluginDataObject> extends
|
||||||
*/
|
*/
|
||||||
public void purgeAllData() throws PluginException {
|
public void purgeAllData() throws PluginException {
|
||||||
purgeAllTables();
|
purgeAllTables();
|
||||||
ArrayList<File> files = FileUtil.listFiles(new File(PLUGIN_HDF5_DIR),
|
List<File> files = FileUtil.listFiles(new File(PLUGIN_HDF5_DIR),
|
||||||
new HDF5PluginFilenameFilter(pluginName), true);
|
new HDF5PluginFilenameFilter(pluginName), true);
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
file.delete();
|
file.delete();
|
||||||
|
|
|
@ -20,37 +20,37 @@
|
||||||
|
|
||||||
package gov.noaa.nws.ncep.edex.plugin.ncgrib;
|
package gov.noaa.nws.ncep.edex.plugin.ncgrib;
|
||||||
|
|
||||||
|
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribModel;
|
||||||
|
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord;
|
||||||
|
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
||||||
|
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.LatLonNcgridCoverage;
|
||||||
|
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
|
||||||
|
import gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.NcgribDao;
|
||||||
|
import gov.noaa.nws.ncep.edex.plugin.ncgrib.spatial.NcgribSpatialCache;
|
||||||
|
import gov.noaa.nws.ncep.edex.plugin.ncgrib.util.NcgribModelCache;
|
||||||
|
import gov.noaa.nws.ncep.edex.util.ncgrib.NccompositeModel;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
|
||||||
import com.raytheon.edex.util.Util;
|
import com.raytheon.edex.util.Util;
|
||||||
|
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||||
import com.raytheon.uf.common.localization.IPathManager;
|
import com.raytheon.uf.common.localization.IPathManager;
|
||||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||||
|
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||||
import com.raytheon.uf.common.serialization.SerializationException;
|
import com.raytheon.uf.common.serialization.SerializationException;
|
||||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||||
import com.raytheon.uf.common.util.FileUtil;
|
import com.raytheon.uf.common.util.FileUtil;
|
||||||
|
import com.raytheon.uf.common.util.file.FilenameFilters;
|
||||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||||
import com.raytheon.uf.edex.database.plugin.PluginFactory;
|
import com.raytheon.uf.edex.database.plugin.PluginFactory;
|
||||||
|
|
||||||
import gov.noaa.nws.ncep.edex.util.ncgrib.NccompositeModel;
|
|
||||||
import gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.NcgribDao;
|
|
||||||
import gov.noaa.nws.ncep.edex.plugin.ncgrib.spatial.NcgribSpatialCache;
|
|
||||||
import gov.noaa.nws.ncep.edex.plugin.ncgrib.util.NcgribModelCache;
|
|
||||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribModel;
|
|
||||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord;
|
|
||||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
|
||||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
|
|
||||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.LatLonNcgridCoverage;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The GridAssmebler class is part of the ingest process for grib data. Some
|
* The GridAssmebler class is part of the ingest process for grib data. Some
|
||||||
* grib model come in as octants. This class will combine those octants into a
|
* grib model come in as octants. This class will combine those octants into a
|
||||||
|
@ -63,6 +63,7 @@ import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.LatLonNcgr
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 4/09/10 4638 bphillip Initial Creation
|
* 4/09/10 4638 bphillip Initial Creation
|
||||||
|
* Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -97,16 +98,11 @@ public class NcgridAssembler {
|
||||||
|
|
||||||
//System.out.println(" load thin models commonPath=" + commonPath);
|
//System.out.println(" load thin models commonPath=" + commonPath);
|
||||||
|
|
||||||
FilenameFilter filter = new FilenameFilter() {
|
FilenameFilter filter = FilenameFilters.byFilters(
|
||||||
@Override
|
FilenameFilters.ACCEPT_FILES,
|
||||||
public boolean accept(File dir, String name) {
|
FilenameFilters.byFileExtension(".xml"));
|
||||||
//System.out.println(" load thin models dir=" + dir.getPath() +"/" + name);
|
|
||||||
|
|
||||||
return (!new File(dir.getPath() + File.separator + name)
|
List<File> thinnedModelFiles = FileUtil.listFiles(commonPath,
|
||||||
.isDirectory() && name.endsWith(".xml"));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ArrayList<File> thinnedModelFiles = FileUtil.listFiles(commonPath,
|
|
||||||
filter, false);
|
filter, false);
|
||||||
|
|
||||||
for (File file : thinnedModelFiles) {
|
for (File file : thinnedModelFiles) {
|
||||||
|
|
|
@ -20,9 +20,15 @@
|
||||||
|
|
||||||
package gov.noaa.nws.ncep.edex.plugin.ncgrib.spatial;
|
package gov.noaa.nws.ncep.edex.plugin.ncgrib.spatial;
|
||||||
|
|
||||||
|
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
||||||
|
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
|
||||||
|
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
|
||||||
|
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.NcgridModel;
|
||||||
|
import gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.INcgridCoverageDao;
|
||||||
|
import gov.noaa.nws.ncep.edex.util.ncgrib.NcgribModelLookup;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -31,9 +37,9 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.raytheon.uf.common.localization.IPathManager;
|
import com.raytheon.uf.common.localization.IPathManager;
|
||||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||||
|
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||||
import com.raytheon.uf.common.util.FileUtil;
|
import com.raytheon.uf.common.util.FileUtil;
|
||||||
import com.raytheon.uf.edex.core.EDEXUtil;
|
import com.raytheon.uf.edex.core.EDEXUtil;
|
||||||
|
@ -41,13 +47,6 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||||
|
|
||||||
import gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.INcgridCoverageDao;
|
|
||||||
import gov.noaa.nws.ncep.edex.util.ncgrib.NcgribModelLookup;
|
|
||||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
|
||||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
|
|
||||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
|
|
||||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.NcgridModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache used for holding GridCoverage objects. Since creating geometries and
|
* Cache used for holding GridCoverage objects. Since creating geometries and
|
||||||
* CRS objects are expensive operations, this cache is used to store
|
* CRS objects are expensive operations, this cache is used to store
|
||||||
|
@ -60,6 +59,7 @@ import gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.NcgridModel;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 4/7/09 1994 bphillip Initial Creation
|
* 4/7/09 1994 bphillip Initial Creation
|
||||||
|
* Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -79,7 +79,7 @@ public class NcgribSpatialCache {
|
||||||
* The key for this map is the id field of the GridCoverage object stored as
|
* The key for this map is the id field of the GridCoverage object stored as
|
||||||
* the value of the map
|
* the value of the map
|
||||||
*/
|
*/
|
||||||
private Map<Integer, NcgridCoverage> ncspatialMap;
|
private final Map<Integer, NcgridCoverage> ncspatialMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map containing the GridCoverages<br>
|
* Map containing the GridCoverages<br>
|
||||||
|
@ -87,17 +87,17 @@ public class NcgribSpatialCache {
|
||||||
* as the value of the map. This is only used internally for lookup of a
|
* as the value of the map. This is only used internally for lookup of a
|
||||||
* coverage by name aka gridId.
|
* coverage by name aka gridId.
|
||||||
*/
|
*/
|
||||||
private Map<String, NcgridCoverage> ncspatialNameMap;
|
private final Map<String, NcgridCoverage> ncspatialNameMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map containing the subGrid coverage based on a model name.
|
* Map containing the subGrid coverage based on a model name.
|
||||||
*/
|
*/
|
||||||
private Map<String, Integer> subNcgridCoverageMap;
|
private final Map<String, Integer> subNcgridCoverageMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map containing the subGrid definition based on a model name.
|
* Map containing the subGrid definition based on a model name.
|
||||||
*/
|
*/
|
||||||
private Map<String, SubNcgrid> definedSubNcgridMap;
|
private final Map<String, SubNcgrid> definedSubNcgridMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the singleton instance of NcgribSpatialCache
|
* Gets the singleton instance of NcgribSpatialCache
|
||||||
|
@ -272,7 +272,7 @@ public class NcgribSpatialCache {
|
||||||
|
|
||||||
//System.out.println("ncep default sitePah=" + sitePath);
|
//System.out.println("ncep default sitePah=" + sitePath);
|
||||||
|
|
||||||
ArrayList<File> files = FileUtil.listFiles(new File(basePath), filter,
|
List<File> files = FileUtil.listFiles(new File(basePath), filter,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
// Add any spatial information defined by the site
|
// Add any spatial information defined by the site
|
||||||
|
@ -285,8 +285,9 @@ public class NcgribSpatialCache {
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
try {
|
try {
|
||||||
//System.out.println ("ncep default filePath=" + file.getPath());
|
//System.out.println ("ncep default filePath=" + file.getPath());
|
||||||
NcgridCoverage grid = (NcgridCoverage) SerializationUtil
|
NcgridCoverage grid = SerializationUtil
|
||||||
.jaxbUnmarshalFromXmlFile(file.getPath());
|
.jaxbUnmarshalFromXmlFile(NcgridCoverage.class,
|
||||||
|
file.getPath());
|
||||||
putGrid(grid, true);
|
putGrid(grid, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Log error but do not throw exception
|
// Log error but do not throw exception
|
||||||
|
|
|
@ -20,33 +20,33 @@
|
||||||
|
|
||||||
package gov.noaa.nws.ncep.edex.util.ncgrib;
|
package gov.noaa.nws.ncep.edex.util.ncgrib;
|
||||||
|
|
||||||
|
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcGenProcess;
|
||||||
|
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.Ncgrib1Parameter;
|
||||||
|
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribLevel;
|
||||||
|
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribParameter;
|
||||||
|
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
||||||
|
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.Ncgrib1ParameterLookup;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcGenProcess;
|
|
||||||
|
|
||||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribLevel;
|
|
||||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribParameter;
|
|
||||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
|
|
||||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.Ncgrib1Parameter;
|
|
||||||
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.Ncgrib1ParameterLookup;
|
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
|
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
|
||||||
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
|
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
|
||||||
import com.raytheon.uf.common.localization.IPathManager;
|
import com.raytheon.uf.common.localization.IPathManager;
|
||||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||||
|
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||||
import com.raytheon.uf.common.util.FileUtil;
|
import com.raytheon.uf.common.util.FileUtil;
|
||||||
|
import com.raytheon.uf.common.util.file.FilenameFilters;
|
||||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class NcgribTableLookup {
|
||||||
private static final int NO_SUBCENTER = -1;
|
private static final int NO_SUBCENTER = -1;
|
||||||
|
|
||||||
/** The map of defined tables */
|
/** The map of defined tables */
|
||||||
private Map<Integer, Map<String, NcgribTable>> tableMap;
|
private final Map<Integer, Map<String, NcgribTable>> tableMap;
|
||||||
|
|
||||||
/** The singleton instance */
|
/** The singleton instance */
|
||||||
private static NcgribTableLookup instance;
|
private static NcgribTableLookup instance;
|
||||||
|
@ -236,14 +236,9 @@ public class NcgribTableLookup {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
FilenameFilter tableFilter = new FilenameFilter() {
|
FilenameFilter tableFilter = FilenameFilters.byFileExtension(".table");
|
||||||
@Override
|
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
return name.endsWith(".table");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ArrayList<File> files = FileUtil.listFiles(new File(commonPath),
|
List<File> files = FileUtil.listFiles(new File(commonPath),
|
||||||
filter, false);
|
filter, false);
|
||||||
for (File f : files) {
|
for (File f : files) {
|
||||||
int center = 0;
|
int center = 0;
|
||||||
|
@ -251,7 +246,7 @@ public class NcgribTableLookup {
|
||||||
center = Integer.parseInt(f.getPath().substring(
|
center = Integer.parseInt(f.getPath().substring(
|
||||||
f.getPath().lastIndexOf("/") + 1));
|
f.getPath().lastIndexOf("/") + 1));
|
||||||
|
|
||||||
ArrayList<File> files2 = FileUtil.listFiles(new File(commonPath
|
List<File> files2 = FileUtil.listFiles(new File(commonPath
|
||||||
+ File.separator + String.valueOf(center)), filter,
|
+ File.separator + String.valueOf(center)), filter,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
@ -260,7 +255,7 @@ public class NcgribTableLookup {
|
||||||
if (!f2.getPath().contains(".svn")) {
|
if (!f2.getPath().contains(".svn")) {
|
||||||
subcenter = Integer.parseInt(f2.getPath().substring(
|
subcenter = Integer.parseInt(f2.getPath().substring(
|
||||||
f2.getPath().lastIndexOf("/") + 1));
|
f2.getPath().lastIndexOf("/") + 1));
|
||||||
ArrayList<File> tableFiles = FileUtil.listFiles(f2,
|
List<File> tableFiles = FileUtil.listFiles(f2,
|
||||||
tableFilter, false);
|
tableFilter, false);
|
||||||
String tableName = null;
|
String tableName = null;
|
||||||
for (File table : tableFiles) {
|
for (File table : tableFiles) {
|
||||||
|
|
|
@ -0,0 +1,153 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.common.util.file;
|
||||||
|
|
||||||
|
import static com.raytheon.uf.common.util.file.FilenameFilters.reverse;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FilenameFilter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.util.TestUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test {@link FilenameFilters}.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Mar 14, 2013 1794 djohnson Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author djohnson
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class FilenameFiltersTest {
|
||||||
|
|
||||||
|
private static final File UNUSED_DIR = new File(".");
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void acceptAllAlwaysReturnsTrue() {
|
||||||
|
assertTrue(FilenameFilters.ACCEPT_ALL.accept(null, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void acceptNoneAlwaysReturnsFalse() {
|
||||||
|
assertFalse(FilenameFilters.ACCEPT_NONE.accept(null, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void reverseWillReturnOppositeOfFilter() {
|
||||||
|
assertEquals(!FilenameFilters.ACCEPT_ALL.accept(null, null),
|
||||||
|
reverse(FilenameFilters.ACCEPT_ALL).accept(null, null));
|
||||||
|
assertEquals(!FilenameFilters.ACCEPT_NONE.accept(null, null),
|
||||||
|
reverse(FilenameFilters.ACCEPT_NONE).accept(null, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void byFileExtensionAcceptsFileWithExtension() {
|
||||||
|
assertTrue(FilenameFilters.byFileExtension(".xml").accept(UNUSED_DIR,
|
||||||
|
"blah.xml"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void byFileExtensionDoesNotAcceptFileWithoutExtension() {
|
||||||
|
assertFalse(FilenameFilters.byFileExtension(".xml").accept(UNUSED_DIR,
|
||||||
|
"blah.txt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void noLinuxHiddenFilesAcceptsNonHidden() {
|
||||||
|
assertTrue(FilenameFilters.NO_LINUX_HIDDEN_FILES.accept(UNUSED_DIR,
|
||||||
|
"nothidden"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void noLinuxHiddenFilesDoesNotAcceptHidden() {
|
||||||
|
assertFalse(FilenameFilters.NO_LINUX_HIDDEN_FILES.accept(UNUSED_DIR,
|
||||||
|
".hidden"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void byFiltersReturnsTrueIfAllFiltersAccept() {
|
||||||
|
FilenameFilter sumFilter = FilenameFilters.byFilters(
|
||||||
|
FilenameFilters.NO_LINUX_HIDDEN_FILES,
|
||||||
|
FilenameFilters.ACCEPT_ALL);
|
||||||
|
assertTrue(sumFilter.accept(UNUSED_DIR, "nothidden"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void byFiltersReturnsFalseIfAnyFilterDoesNotAccept() {
|
||||||
|
FilenameFilter sumFilter = FilenameFilters.byFilters(
|
||||||
|
FilenameFilters.NO_LINUX_HIDDEN_FILES,
|
||||||
|
FilenameFilters.ACCEPT_ALL);
|
||||||
|
assertFalse(sumFilter.accept(UNUSED_DIR, ".hidden"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void acceptFilesReturnsTrueForFile() throws IOException {
|
||||||
|
File testDir = TestUtil.setupTestClassDir(FilenameFiltersTest.class);
|
||||||
|
File file = new File(testDir, "realFile.txt");
|
||||||
|
file.createNewFile();
|
||||||
|
|
||||||
|
assertTrue(FilenameFilters.ACCEPT_FILES.accept(file.getParentFile(),
|
||||||
|
file.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void acceptFilesReturnsFalseForDirectory() throws IOException {
|
||||||
|
File testDir = TestUtil.setupTestClassDir(FilenameFiltersTest.class);
|
||||||
|
File file = new File(testDir, "directory");
|
||||||
|
file.mkdirs();
|
||||||
|
|
||||||
|
assertFalse(FilenameFilters.ACCEPT_FILES.accept(file.getParentFile(),
|
||||||
|
file.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void acceptDirectoriesReturnsTrueForDirectory() throws IOException {
|
||||||
|
File testDir = TestUtil.setupTestClassDir(FilenameFiltersTest.class);
|
||||||
|
File file = new File(testDir, "directory");
|
||||||
|
file.mkdirs();
|
||||||
|
|
||||||
|
assertTrue(FilenameFilters.ACCEPT_DIRECTORIES.accept(
|
||||||
|
file.getParentFile(), file.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void acceptDirectoriesReturnsFalseForFile() throws IOException {
|
||||||
|
File testDir = TestUtil.setupTestClassDir(FilenameFiltersTest.class);
|
||||||
|
|
||||||
|
File file = new File(testDir, "realFile.txt");
|
||||||
|
file.createNewFile();
|
||||||
|
|
||||||
|
assertFalse(FilenameFilters.ACCEPT_DIRECTORIES.accept(
|
||||||
|
file.getParentFile(), file.getName()));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue