Issue #3592 Fixed several localization issue in GFE
Change-Id: I2e65649d490372b5c1738f07c79b5ed15885f8c7 Former-commit-id:6471f81a7f
[formerly57a3542038
] [formerly52e5636261
] [formerly6471f81a7f
[formerly57a3542038
] [formerly52e5636261
] [formerlyb91141ef7b
[formerly52e5636261
[formerly a5ef55df33009948fec139e7729dd53ae4251667]]]] Former-commit-id:b91141ef7b
Former-commit-id:2ff7cdc2b7
[formerly99e223ba91
] [formerly dd2d3a8470cb3ae49ca6cea84cfcaed0474acfe1 [formerlyc23122797d
]] Former-commit-id: 9c8b38cb807e8fc53e55d3f54f170833cfebdb61 [formerlybe55fa4984
] Former-commit-id:6cb8a0602a
This commit is contained in:
parent
558702d535
commit
ad9d944b4c
11 changed files with 405 additions and 218 deletions
|
@ -100,6 +100,7 @@ import com.raytheon.viz.gfe.textformatter.TextProductManager;
|
||||||
* 09/05/2013 2307 dgilling Use better PythonScript constructor.
|
* 09/05/2013 2307 dgilling Use better PythonScript constructor.
|
||||||
* 09/16/2013 2033 dgilling Remove unused IToolController.
|
* 09/16/2013 2033 dgilling Remove unused IToolController.
|
||||||
* 12/09/2013 2367 dgilling Instantiate ProcedureJobPool here.
|
* 12/09/2013 2367 dgilling Instantiate ProcedureJobPool here.
|
||||||
|
* 09/09/2014 3592 randerso Added call to SampleSetManager.dispose()
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -290,6 +291,7 @@ public class DataManager {
|
||||||
* {@link DataManagerFactory#dispose(Object)}
|
* {@link DataManagerFactory#dispose(Object)}
|
||||||
*/
|
*/
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
sampleSetManager.dispose();
|
||||||
selectTimeRangeManager.dispose();
|
selectTimeRangeManager.dispose();
|
||||||
refManager.dispose();
|
refManager.dispose();
|
||||||
parmManager.dispose();
|
parmManager.dispose();
|
||||||
|
|
|
@ -25,7 +25,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataplugin.gfe.sample.SampleId;
|
import com.raytheon.uf.common.dataplugin.gfe.sample.SampleId;
|
||||||
import com.raytheon.uf.viz.core.exception.VizException;
|
|
||||||
import com.raytheon.viz.gfe.GFEException;
|
import com.raytheon.viz.gfe.GFEException;
|
||||||
import com.raytheon.viz.gfe.core.msgs.ISampleSetChangedListener;
|
import com.raytheon.viz.gfe.core.msgs.ISampleSetChangedListener;
|
||||||
import com.raytheon.viz.gfe.edittool.GridID;
|
import com.raytheon.viz.gfe.edittool.GridID;
|
||||||
|
@ -39,7 +38,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jun 30, 2008 chammack Initial creation
|
* Jun 30, 2008 chammack Initial creation
|
||||||
* Apr 9, 2009 1288 rjpeter Added add/remove method for sample set listener
|
* Apr 09, 2009 1288 rjpeter Added add/remove method for sample set listener
|
||||||
|
* Sep 09, 2014 3592 randerso Added dispose method, removed networkNotification method
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author chammack
|
* @author chammack
|
||||||
|
@ -52,6 +52,11 @@ public interface ISampleSetManager {
|
||||||
|
|
||||||
public static final float DEFAULT_THRESHOLD = 0.0f;
|
public static final float DEFAULT_THRESHOLD = 0.0f;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispose the SampleSetManager
|
||||||
|
*/
|
||||||
|
public void dispose();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the set of sample points for the named sample set. If the sample
|
* Returns the set of sample points for the named sample set. If the sample
|
||||||
* set is not known, an empty list will be returned.
|
* set is not known, an empty list will be returned.
|
||||||
|
@ -196,15 +201,6 @@ public interface ISampleSetManager {
|
||||||
*/
|
*/
|
||||||
public boolean deleteSampleSet(final SampleId sampleId);
|
public boolean deleteSampleSet(final SampleId sampleId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Input network sample notification from NetworkMgr indicating that the
|
|
||||||
* sample set inventory has changed or the contents of a sample set has
|
|
||||||
* changed.
|
|
||||||
*/
|
|
||||||
public void networkNotification(final SampleId[] anInventory,
|
|
||||||
final SampleId[] additions, final SampleId[] deletions,
|
|
||||||
final SampleId[] changes) throws VizException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the loadedSet
|
* @return the loadedSet
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -36,6 +36,7 @@ import com.raytheon.viz.gfe.core.internal.SampleSetManager;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jan 25, 2011 njensen Initial creation
|
* Jan 25, 2011 njensen Initial creation
|
||||||
|
* Sep 09, 2014 #3592 randerso Removed unused DataManager parameter to SampleSetManager constructor
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -60,7 +61,7 @@ public class SampleSetMgrInitJob extends Job {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
dataMgr.sampleSetManager = new SampleSetManager(dataMgr);
|
dataMgr.sampleSetManager = new SampleSetManager();
|
||||||
dataMgr.getInitStatus().setSampleSetMgrDone(true);
|
dataMgr.getInitStatus().setSampleSetMgrDone(true);
|
||||||
|
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
|
|
|
@ -143,6 +143,7 @@ import com.raytheon.viz.gfe.types.MutableInteger;
|
||||||
* 04/02/2014 #2969 randerso Fix error when Toop parm is unloaded.
|
* 04/02/2014 #2969 randerso Fix error when Toop parm is unloaded.
|
||||||
* 05/01/2014 #3105 dgilling Ensure mutable db gets into availableServerDatabases
|
* 05/01/2014 #3105 dgilling Ensure mutable db gets into availableServerDatabases
|
||||||
* if it has to be created during ParmManager construction.
|
* if it has to be created during ParmManager construction.
|
||||||
|
* 09/08/2104 #3592 randerso Changed to use new pm listStaticFiles()
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author chammack
|
* @author chammack
|
||||||
|
@ -3099,11 +3100,10 @@ public class ParmManager implements IParmManager, IMessageClient {
|
||||||
private List<VCModule> initVirtualCalcParmDefinitions() {
|
private List<VCModule> initVirtualCalcParmDefinitions() {
|
||||||
// retrieve the inventory from the ifpServer
|
// retrieve the inventory from the ifpServer
|
||||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||||
LocalizationFile[] modules = pathMgr
|
LocalizationFile[] modules = pathMgr.listStaticFiles(
|
||||||
.listFiles(
|
LocalizationType.COMMON_STATIC,
|
||||||
pathMgr.getLocalSearchHierarchy(LocalizationType.COMMON_STATIC),
|
FileUtil.join("gfe", "vcmodule"), new String[] { "py" }, false,
|
||||||
FileUtil.join("gfe", "vcmodule"),
|
true);
|
||||||
new String[] { "py" }, false, true);
|
|
||||||
|
|
||||||
List<VCModule> definitions = new ArrayList<VCModule>(modules.length);
|
List<VCModule> definitions = new ArrayList<VCModule>(modules.length);
|
||||||
for (LocalizationFile mod : modules) {
|
for (LocalizationFile mod : modules) {
|
||||||
|
@ -3112,6 +3112,7 @@ public class ParmManager implements IParmManager, IMessageClient {
|
||||||
File textData = mod.getFile(true);
|
File textData = mod.getFile(true);
|
||||||
|
|
||||||
// create the VCModule
|
// create the VCModule
|
||||||
|
statusHandler.debug("Loading VCModule: " + mod);
|
||||||
VCModule m = new VCModule(dataManager, this, textData);
|
VCModule m = new VCModule(dataManager, this, textData);
|
||||||
if (!m.isValid()) {
|
if (!m.isValid()) {
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
|
|
|
@ -109,6 +109,7 @@ import com.vividsolutions.jts.geom.Envelope;
|
||||||
* 06/21/2013 14983 ryu Added method for synchronous evaluation of query.
|
* 06/21/2013 14983 ryu Added method for synchronous evaluation of query.
|
||||||
* 08/06/2013 1561 njensen Use pm.listFiles() instead of pm.listStaticFiles()
|
* 08/06/2013 1561 njensen Use pm.listFiles() instead of pm.listStaticFiles()
|
||||||
* 09/30/2013 2361 njensen Use JAXBManager for XML
|
* 09/30/2013 2361 njensen Use JAXBManager for XML
|
||||||
|
* 09/08/2104 #3592 randerso Changed to use new pm listStaticFiles()
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -231,9 +232,8 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
||||||
// load the complete list of edit areas
|
// load the complete list of edit areas
|
||||||
List<ReferenceID> refIDs = new ArrayList<ReferenceID>();
|
List<ReferenceID> refIDs = new ArrayList<ReferenceID>();
|
||||||
IPathManager pm = PathManagerFactory.getPathManager();
|
IPathManager pm = PathManagerFactory.getPathManager();
|
||||||
LocalizationContext[] ctx = pm
|
LocalizationFile[] contents = pm.listStaticFiles(
|
||||||
.getLocalSearchHierarchy(LocalizationType.COMMON_STATIC);
|
LocalizationType.COMMON_STATIC, EDIT_AREAS_DIR,
|
||||||
LocalizationFile[] contents = pm.listFiles(ctx, EDIT_AREAS_DIR,
|
|
||||||
new String[] { ".xml" }, false, true);
|
new String[] { ".xml" }, false, true);
|
||||||
if (contents != null) {
|
if (contents != null) {
|
||||||
for (LocalizationFile lf : contents) {
|
for (LocalizationFile lf : contents) {
|
||||||
|
@ -245,7 +245,8 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
||||||
}
|
}
|
||||||
|
|
||||||
// load the edit area group lists
|
// load the edit area group lists
|
||||||
LocalizationFile[] groupFiles = pm.listFiles(ctx, EDIT_AREA_GROUPS_DIR,
|
LocalizationFile[] groupFiles = pm.listStaticFiles(
|
||||||
|
LocalizationType.COMMON_STATIC, EDIT_AREA_GROUPS_DIR,
|
||||||
new String[] { ".txt" }, false, true);
|
new String[] { ".txt" }, false, true);
|
||||||
if (groupFiles != null) {
|
if (groupFiles != null) {
|
||||||
for (LocalizationFile lf : groupFiles) {
|
for (LocalizationFile lf : groupFiles) {
|
||||||
|
@ -779,8 +780,8 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
||||||
|
|
||||||
if (lf != null) {
|
if (lf != null) {
|
||||||
try {
|
try {
|
||||||
refData = ReferenceData.getJAXBManager()
|
refData = ReferenceData.getJAXBManager().unmarshalFromXmlFile(
|
||||||
.unmarshalFromXmlFile(lf.getFile().getPath());
|
lf.getFile().getPath());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
"Error reading xml file "
|
"Error reading xml file "
|
||||||
|
@ -921,7 +922,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
||||||
LocalizationFile lf = pm.getLocalizationFile(ctx,
|
LocalizationFile lf = pm.getLocalizationFile(ctx,
|
||||||
FileUtil.join(EDIT_AREAS_DIR, refID.getName() + ".xml"));
|
FileUtil.join(EDIT_AREAS_DIR, refID.getName() + ".xml"));
|
||||||
|
|
||||||
if (lf != null
|
if ((lf != null)
|
||||||
&& (!withVerification || AccessMgr.verifyDelete(lf.getName(),
|
&& (!withVerification || AccessMgr.verifyDelete(lf.getName(),
|
||||||
LocalizationType.COMMON_STATIC, false))) {
|
LocalizationType.COMMON_STATIC, false))) {
|
||||||
try {
|
try {
|
||||||
|
@ -1124,7 +1125,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
||||||
if (pointyTaper) {
|
if (pointyTaper) {
|
||||||
for (i = ll.x; i <= ur.x; i++) {
|
for (i = ll.x; i <= ur.x; i++) {
|
||||||
for (j = ll.y; j <= ur.y; j++) {
|
for (j = ll.y; j <= ur.y; j++) {
|
||||||
grid.set(i, j, grid.get(i, j) * taperFactor / maxDist);
|
grid.set(i, j, (grid.get(i, j) * taperFactor) / maxDist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1192,7 +1193,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
||||||
int y = j;
|
int y = j;
|
||||||
while ((x >= 0) && (y >= 0) && (x < dim.x) && (y < dim.y)
|
while ((x >= 0) && (y >= 0) && (x < dim.x) && (y < dim.y)
|
||||||
&& bitGrid.getAsBoolean(x, y)) {
|
&& bitGrid.getAsBoolean(x, y)) {
|
||||||
vdist = vdist + Math.sqrt(v.x * v.x + v.y * v.y);
|
vdist = vdist + Math.sqrt((v.x * v.x) + (v.y * v.y));
|
||||||
x = x + v.x;
|
x = x + v.x;
|
||||||
y = y + v.y;
|
y = y + v.y;
|
||||||
}
|
}
|
||||||
|
@ -1200,11 +1201,12 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
||||||
y = j;
|
y = j;
|
||||||
while ((x >= 0) && (y >= 0) && (x < dim.x) && (y < dim.y)
|
while ((x >= 0) && (y >= 0) && (x < dim.x) && (y < dim.y)
|
||||||
&& bitGrid.getAsBoolean(x, y)) {
|
&& bitGrid.getAsBoolean(x, y)) {
|
||||||
avdist = avdist + Math.sqrt(av.x * av.x + av.y * av.y);
|
avdist = avdist
|
||||||
|
+ Math.sqrt((av.x * av.x) + (av.y * av.y));
|
||||||
x = x + av.x;
|
x = x + av.x;
|
||||||
y = y + av.y;
|
y = y + av.y;
|
||||||
}
|
}
|
||||||
if (vdist + avdist == 0) {
|
if ((vdist + avdist) == 0) {
|
||||||
grid.set(i, j, 0.0f);
|
grid.set(i, j, 0.0f);
|
||||||
} else {
|
} else {
|
||||||
grid.set(i, j, (float) (vdist / (vdist + avdist)));
|
grid.set(i, j, (float) (vdist / (vdist + avdist)));
|
||||||
|
@ -1352,7 +1354,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ref
|
* @param ref
|
||||||
* @param mode2
|
* @param mode
|
||||||
*/
|
*/
|
||||||
private void setRefSet(ReferenceData ref, RefSetMode mode) {
|
private void setRefSet(ReferenceData ref, RefSetMode mode) {
|
||||||
mode = determineMode(mode);
|
mode = determineMode(mode);
|
||||||
|
@ -1383,7 +1385,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mode2
|
* @param mode
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private RefSetMode determineMode(RefSetMode mode) {
|
private RefSetMode determineMode(RefSetMode mode) {
|
||||||
|
@ -1666,7 +1668,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
||||||
LocalizationFile lf = PathManagerFactory.getPathManager()
|
LocalizationFile lf = PathManagerFactory.getPathManager()
|
||||||
.getStaticLocalizationFile(filePath);
|
.getStaticLocalizationFile(filePath);
|
||||||
|
|
||||||
if (lf != null && lf.exists()) {
|
if ((lf != null) && lf.exists()) {
|
||||||
changes.add(refId);
|
changes.add(refId);
|
||||||
} else {
|
} else {
|
||||||
deletions.add(refId);
|
deletions.add(refId);
|
||||||
|
@ -1718,7 +1720,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
||||||
.getFileName());
|
.getFileName());
|
||||||
|
|
||||||
// if it exists, load it
|
// if it exists, load it
|
||||||
if (lf != null && lf.exists()) {
|
if ((lf != null) && lf.exists()) {
|
||||||
loadGroup(lf);
|
loadGroup(lf);
|
||||||
}
|
}
|
||||||
checkGroupConsistency();
|
checkGroupConsistency();
|
||||||
|
@ -1824,7 +1826,7 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
||||||
|
|
||||||
Date spedTime = dataManager.getSpatialDisplayManager()
|
Date spedTime = dataManager.getSpatialDisplayManager()
|
||||||
.getSpatialEditorTime();
|
.getSpatialEditorTime();
|
||||||
if (spedTime != null && msg.getTimeRange().contains(spedTime)) {
|
if ((spedTime != null) && msg.getTimeRange().contains(spedTime)) {
|
||||||
evaluateActiveRefSet(listener);
|
evaluateActiveRefSet(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ package com.raytheon.viz.gfe.core.internal;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -33,6 +34,8 @@ import org.geotools.referencing.GeodeticCalculator;
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataplugin.gfe.sample.SampleData;
|
import com.raytheon.uf.common.dataplugin.gfe.sample.SampleData;
|
||||||
import com.raytheon.uf.common.dataplugin.gfe.sample.SampleId;
|
import com.raytheon.uf.common.dataplugin.gfe.sample.SampleId;
|
||||||
|
import com.raytheon.uf.common.localization.FileUpdatedMessage;
|
||||||
|
import com.raytheon.uf.common.localization.ILocalizationFileObserver;
|
||||||
import com.raytheon.uf.common.localization.IPathManager;
|
import com.raytheon.uf.common.localization.IPathManager;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||||
|
@ -47,10 +50,8 @@ 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.viz.core.exception.VizException;
|
|
||||||
import com.raytheon.viz.gfe.Activator;
|
import com.raytheon.viz.gfe.Activator;
|
||||||
import com.raytheon.viz.gfe.GFEException;
|
import com.raytheon.viz.gfe.GFEException;
|
||||||
import com.raytheon.viz.gfe.core.DataManager;
|
|
||||||
import com.raytheon.viz.gfe.core.ISampleSetManager;
|
import com.raytheon.viz.gfe.core.ISampleSetManager;
|
||||||
import com.raytheon.viz.gfe.core.msgs.ISampleSetChangedListener;
|
import com.raytheon.viz.gfe.core.msgs.ISampleSetChangedListener;
|
||||||
import com.raytheon.viz.gfe.edittool.GridID;
|
import com.raytheon.viz.gfe.edittool.GridID;
|
||||||
|
@ -68,13 +69,15 @@ import com.vividsolutions.jts.geom.Coordinate;
|
||||||
* Apr 9, 2009 1288 rjpeter Added ISampleSetChangedListener handling.
|
* Apr 9, 2009 1288 rjpeter Added ISampleSetChangedListener handling.
|
||||||
* Aug 6, 2013 1561 njensen Use pm.listFiles() instead of pm.listStaticFiles()
|
* Aug 6, 2013 1561 njensen Use pm.listFiles() instead of pm.listStaticFiles()
|
||||||
* Sep 30, 2013 2361 njensen Use JAXBManager for XML
|
* Sep 30, 2013 2361 njensen Use JAXBManager for XML
|
||||||
|
* Sep 08, 2104 #3592 randerso Changed to use new pm listStaticFiles()
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author rbell
|
* @author rbell
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SampleSetManager implements ISampleSetManager {
|
public class SampleSetManager implements ISampleSetManager,
|
||||||
|
ILocalizationFileObserver {
|
||||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
.getHandler(SampleSetManager.class);
|
.getHandler(SampleSetManager.class);
|
||||||
|
|
||||||
|
@ -91,19 +94,20 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
|
|
||||||
private Map<String, List<Coordinate>> markerLocations;
|
private Map<String, List<Coordinate>> markerLocations;
|
||||||
|
|
||||||
private final DataManager dataManager;
|
|
||||||
|
|
||||||
private final Set<ISampleSetChangedListener> sampleSetChangedListeners;
|
private final Set<ISampleSetChangedListener> sampleSetChangedListeners;
|
||||||
|
|
||||||
private boolean showLatLon;
|
private boolean showLatLon;
|
||||||
|
|
||||||
|
private IPathManager pathManager;
|
||||||
|
|
||||||
|
private LocalizationFile sampleSetDir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*
|
*
|
||||||
* Gets the initial sample inventory.
|
* Gets the initial sample inventory.
|
||||||
*/
|
*/
|
||||||
public SampleSetManager(DataManager dataManager) {
|
public SampleSetManager() {
|
||||||
this.dataManager = dataManager;
|
|
||||||
this.loadedSet = new SampleId();
|
this.loadedSet = new SampleId();
|
||||||
|
|
||||||
this.inventory = new HashSet<SampleId>();
|
this.inventory = new HashSet<SampleId>();
|
||||||
|
@ -114,17 +118,23 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
|
|
||||||
this.sampleSetChangedListeners = new HashSet<ISampleSetChangedListener>();
|
this.sampleSetChangedListeners = new HashSet<ISampleSetChangedListener>();
|
||||||
|
|
||||||
IPathManager pm = PathManagerFactory.getPathManager();
|
this.pathManager = PathManagerFactory.getPathManager();
|
||||||
|
|
||||||
LocalizationFile[] files = pm.listFiles(
|
this.sampleSetDir = pathManager.getLocalizationFile(pathManager
|
||||||
pm.getLocalSearchHierarchy(LocalizationType.COMMON_STATIC),
|
.getContext(LocalizationType.COMMON_STATIC,
|
||||||
SAMPLE_SETS_DIR, new String[] { ".xml" }, true, true);
|
LocalizationLevel.BASE), SAMPLE_SETS_DIR);
|
||||||
|
|
||||||
|
// initialize the inventory
|
||||||
|
LocalizationFile[] files = pathManager.listStaticFiles(
|
||||||
|
LocalizationType.COMMON_STATIC, SAMPLE_SETS_DIR,
|
||||||
|
new String[] { ".xml" }, true, true);
|
||||||
|
|
||||||
for (LocalizationFile file : files) {
|
for (LocalizationFile file : files) {
|
||||||
String fn = LocalizationUtil.extractName(file.getName()).replace(
|
String fn = LocalizationUtil.extractName(file.getName()).replace(
|
||||||
".xml", "");
|
".xml", "");
|
||||||
this.inventory.add(new SampleId(fn));
|
this.inventory.add(new SampleId(fn));
|
||||||
}
|
}
|
||||||
|
this.sampleSetDir.addFileUpdatedObserver(this);
|
||||||
|
|
||||||
// load default sample points
|
// load default sample points
|
||||||
String[] sampleSets = Activator.getDefault().getPreferenceStore()
|
String[] sampleSets = Activator.getDefault().getPreferenceStore()
|
||||||
|
@ -133,24 +143,22 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
for (String id : sampleSets) {
|
for (String id : sampleSets) {
|
||||||
SampleId sid = new SampleId(id);
|
SampleId sid = new SampleId(id);
|
||||||
if (this.inventory.contains(sid)) {
|
if (this.inventory.contains(sid)) {
|
||||||
try {
|
loadSampleSet(sid, SampleSetLoadMode.ADD);
|
||||||
loadSampleSet(sid, SampleSetLoadMode.ADD);
|
|
||||||
} catch (GFEException e) {
|
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
|
||||||
e.getLocalizedMessage(), e);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get initial marker points
|
getMarkerPoints();
|
||||||
try {
|
}
|
||||||
getMarkerPoints();
|
|
||||||
} catch (VizException e) {
|
/*
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
* (non-Javadoc)
|
||||||
"Unable to get initial sampleset marker points", e);
|
*
|
||||||
}
|
* @see com.raytheon.viz.gfe.core.ISampleSetManager#dispose()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
this.sampleSetDir.removeFileUpdatedObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -160,8 +168,8 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
* com.raytheon.viz.gfe.core.ISampleSetManager#sampleSetLocations(java.lang
|
* com.raytheon.viz.gfe.core.ISampleSetManager#sampleSetLocations(java.lang
|
||||||
* .String)
|
* .String)
|
||||||
*/
|
*/
|
||||||
public List<Coordinate> sampleSetLocations(final String setName)
|
@Override
|
||||||
throws GFEException {
|
public List<Coordinate> sampleSetLocations(final String setName) {
|
||||||
// verify set in inventory
|
// verify set in inventory
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (SampleId thisId : this.inventory) {
|
for (SampleId thisId : this.inventory) {
|
||||||
|
@ -172,9 +180,10 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
throw new GFEException(
|
statusHandler
|
||||||
"Attempt to get locations for unknown sample set ["
|
.error("Attempt to get locations for unknown sample set ["
|
||||||
+ setName + "]");
|
+ setName + "]");
|
||||||
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
String fileName = FileUtil.join(SAMPLE_SETS_DIR, setName + ".xml");
|
String fileName = FileUtil.join(SAMPLE_SETS_DIR, setName + ".xml");
|
||||||
|
@ -187,9 +196,9 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
f = file.getFile(true);
|
f = file.getFile(true);
|
||||||
} catch (LocalizationException e) {
|
} catch (LocalizationException e) {
|
||||||
if (f == null) {
|
if (f == null) {
|
||||||
throw new GFEException(
|
statusHandler.error("An error occurred retrieving SampleSet: "
|
||||||
"An error occurred retrieving SampleSet: " + fileName,
|
+ fileName, e);
|
||||||
e);
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +207,8 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
sampleData = SampleData.getJAXBManager().unmarshalFromXmlFile(
|
sampleData = SampleData.getJAXBManager().unmarshalFromXmlFile(
|
||||||
f.getAbsolutePath());
|
f.getAbsolutePath());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new GFEException("Unable to load sampledata: " + f, e);
|
statusHandler.error("Unable to load sampledata: " + f, e);
|
||||||
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return sampleData.getPoints();
|
return sampleData.getPoints();
|
||||||
|
@ -212,8 +222,9 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
* .edex.plugin.gfe.sample.SampleId,
|
* .edex.plugin.gfe.sample.SampleId,
|
||||||
* com.raytheon.viz.gfe.core.internal.SampleSetManager.SampleSetLoadMode)
|
* com.raytheon.viz.gfe.core.internal.SampleSetManager.SampleSetLoadMode)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void loadSampleSet(final SampleId sampleId,
|
public void loadSampleSet(final SampleId sampleId,
|
||||||
SampleSetLoadMode loadMode) throws GFEException {
|
SampleSetLoadMode loadMode) {
|
||||||
File f = PathManagerFactory.getPathManager().getStaticFile(
|
File f = PathManagerFactory.getPathManager().getStaticFile(
|
||||||
FileUtil.join(SAMPLE_SETS_DIR, sampleId.getName() + ".xml"));
|
FileUtil.join(SAMPLE_SETS_DIR, sampleId.getName() + ".xml"));
|
||||||
|
|
||||||
|
@ -221,8 +232,9 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
try {
|
try {
|
||||||
sampleData = SampleData.getJAXBManager().unmarshalFromXmlFile(
|
sampleData = SampleData.getJAXBManager().unmarshalFromXmlFile(
|
||||||
f.getPath());
|
f.getPath());
|
||||||
|
sampleData.setSampleId(sampleId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new GFEException("Unable to load sampledata: " + f);
|
statusHandler.error("Unable to load sampledata: " + f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the loadedSet flag appropriately
|
// set the loadedSet flag appropriately
|
||||||
|
@ -247,6 +259,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
*
|
*
|
||||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#clearSamples()
|
* @see com.raytheon.viz.gfe.core.ISampleSetManager#clearSamples()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void clearSamples() {
|
public void clearSamples() {
|
||||||
mergeSamples(new ArrayList<Coordinate>(), SampleSetLoadMode.REPLACE);
|
mergeSamples(new ArrayList<Coordinate>(), SampleSetLoadMode.REPLACE);
|
||||||
this.loadedSet = new SampleId(); // no loaded set
|
this.loadedSet = new SampleId(); // no loaded set
|
||||||
|
@ -260,6 +273,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
* @seecom.raytheon.viz.gfe.core.ISampleSetManager#addAnchoredSample(com.
|
* @seecom.raytheon.viz.gfe.core.ISampleSetManager#addAnchoredSample(com.
|
||||||
* vividsolutions.jts.geom.Coordinate)
|
* vividsolutions.jts.geom.Coordinate)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void addAnchoredSample(final Coordinate sampleLocation) {
|
public void addAnchoredSample(final Coordinate sampleLocation) {
|
||||||
mergeSamples(Arrays.asList(sampleLocation), SampleSetLoadMode.ADD);
|
mergeSamples(Arrays.asList(sampleLocation), SampleSetLoadMode.ADD);
|
||||||
this.loadedSet = new SampleId(); // no longer a loaded set
|
this.loadedSet = new SampleId(); // no longer a loaded set
|
||||||
|
@ -274,6 +288,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
* com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredSample(com.
|
* com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredSample(com.
|
||||||
* vividsolutions.jts.geom.Coordinate)
|
* vividsolutions.jts.geom.Coordinate)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void removeAnchoredSample(final Coordinate sampleLocation) {
|
public void removeAnchoredSample(final Coordinate sampleLocation) {
|
||||||
removeAnchoredSample(sampleLocation,
|
removeAnchoredSample(sampleLocation,
|
||||||
ISampleSetManager.DEFAULT_THRESHOLD);
|
ISampleSetManager.DEFAULT_THRESHOLD);
|
||||||
|
@ -286,6 +301,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
* com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredSample(com.
|
* com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredSample(com.
|
||||||
* vividsolutions.jts.geom.Coordinate, float)
|
* vividsolutions.jts.geom.Coordinate, float)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void removeAnchoredSample(final Coordinate sampleLocation,
|
public void removeAnchoredSample(final Coordinate sampleLocation,
|
||||||
float threshold) {
|
float threshold) {
|
||||||
mergeSamples(Arrays.asList(sampleLocation), SampleSetLoadMode.REMOVE,
|
mergeSamples(Arrays.asList(sampleLocation), SampleSetLoadMode.REMOVE,
|
||||||
|
@ -301,6 +317,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
* @seecom.raytheon.viz.gfe.core.ISampleSetManager#addAnchoredMarker(com.
|
* @seecom.raytheon.viz.gfe.core.ISampleSetManager#addAnchoredMarker(com.
|
||||||
* vividsolutions.jts.geom.Coordinate)
|
* vividsolutions.jts.geom.Coordinate)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void addAnchoredMarker(final Coordinate location, final GridID gid) {
|
public void addAnchoredMarker(final Coordinate location, final GridID gid) {
|
||||||
String set = activeMarkerSet(gid);
|
String set = activeMarkerSet(gid);
|
||||||
List<Coordinate> locations = markerLocations.get(set);
|
List<Coordinate> locations = markerLocations.get(set);
|
||||||
|
@ -319,6 +336,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
* com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredMarker(com.
|
* com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredMarker(com.
|
||||||
* vividsolutions.jts.geom.Coordinate)
|
* vividsolutions.jts.geom.Coordinate)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void removeAnchoredMarker(final Coordinate location, final GridID gid) {
|
public void removeAnchoredMarker(final Coordinate location, final GridID gid) {
|
||||||
removeAnchoredMarker(location, gid, ISampleSetManager.DEFAULT_THRESHOLD);
|
removeAnchoredMarker(location, gid, ISampleSetManager.DEFAULT_THRESHOLD);
|
||||||
}
|
}
|
||||||
|
@ -330,6 +348,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
* com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredMarker(com.
|
* com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredMarker(com.
|
||||||
* vividsolutions.jts.geom.Coordinate, float)
|
* vividsolutions.jts.geom.Coordinate, float)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void removeAnchoredMarker(final Coordinate location,
|
public void removeAnchoredMarker(final Coordinate location,
|
||||||
final GridID gid, float threshold) {
|
final GridID gid, float threshold) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
@ -361,6 +380,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
* com.raytheon.viz.gfe.core.ISampleSetManager#anchoredMarkerAtLocation(
|
* com.raytheon.viz.gfe.core.ISampleSetManager#anchoredMarkerAtLocation(
|
||||||
* com.vividsolutions.jts.geom.Coordinate, float)
|
* com.vividsolutions.jts.geom.Coordinate, float)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean anchoredMarkerAtLocation(final Coordinate location,
|
public boolean anchoredMarkerAtLocation(final Coordinate location,
|
||||||
final GridID gid, float threshold) {
|
final GridID gid, float threshold) {
|
||||||
String set = activeMarkerSet(gid);
|
String set = activeMarkerSet(gid);
|
||||||
|
@ -388,6 +408,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
* com.raytheon.viz.gfe.core.ISampleSetManager#saveSampleSet(com.vividsolutions
|
* com.raytheon.viz.gfe.core.ISampleSetManager#saveSampleSet(com.vividsolutions
|
||||||
* .jts.geom.Coordinate[], com.raytheon.edex.plugin.gfe.sample.SampleId)
|
* .jts.geom.Coordinate[], com.raytheon.edex.plugin.gfe.sample.SampleId)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean saveSampleSet(final List<Coordinate> sampleLocations,
|
public boolean saveSampleSet(final List<Coordinate> sampleLocations,
|
||||||
final SampleId sampleId) {
|
final SampleId sampleId) {
|
||||||
|
|
||||||
|
@ -413,13 +434,6 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
e);
|
e);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.inventory.add(sampleId);
|
|
||||||
|
|
||||||
// // send a notification to interested users
|
|
||||||
// networkNotification(notification.inventory(),
|
|
||||||
// notification.additions(),
|
|
||||||
// notification.deletions(), notification.changes());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,6 +444,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
* com.raytheon.viz.gfe.core.ISampleSetManager#saveActiveSampleSet(com.raytheon
|
* com.raytheon.viz.gfe.core.ISampleSetManager#saveActiveSampleSet(com.raytheon
|
||||||
* .edex.plugin.gfe.sample.SampleId)
|
* .edex.plugin.gfe.sample.SampleId)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean saveActiveSampleSet(final SampleId sampleId) {
|
public boolean saveActiveSampleSet(final SampleId sampleId) {
|
||||||
this.loadedSet = sampleId;
|
this.loadedSet = sampleId;
|
||||||
return saveSampleSet(this.locations, sampleId);
|
return saveSampleSet(this.locations, sampleId);
|
||||||
|
@ -442,6 +457,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
* com.raytheon.viz.gfe.core.ISampleSetManager#deleteSampleSet(com.raytheon
|
* com.raytheon.viz.gfe.core.ISampleSetManager#deleteSampleSet(com.raytheon
|
||||||
* .edex.plugin.gfe.sample.SampleId)
|
* .edex.plugin.gfe.sample.SampleId)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean deleteSampleSet(final SampleId sampleId) {
|
public boolean deleteSampleSet(final SampleId sampleId) {
|
||||||
LocalizationFile file = PathManagerFactory.getPathManager()
|
LocalizationFile file = PathManagerFactory.getPathManager()
|
||||||
.getStaticLocalizationFile(
|
.getStaticLocalizationFile(
|
||||||
|
@ -458,7 +474,6 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
file.delete();
|
file.delete();
|
||||||
this.inventory.remove(sampleId);
|
|
||||||
} catch (LocalizationOpFailedException e) {
|
} catch (LocalizationOpFailedException e) {
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
"Error deleting from localization server", e);
|
"Error deleting from localization server", e);
|
||||||
|
@ -471,69 +486,55 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see
|
* @see
|
||||||
* com.raytheon.viz.gfe.core.ISampleSetManager#networkNotification(com.raytheon
|
* com.raytheon.uf.common.localization.ILocalizationFileObserver#fileUpdated
|
||||||
* .edex.plugin.gfe.sample.SampleId[],
|
* (com.raytheon.uf.common.localization.FileUpdatedMessage)
|
||||||
* com.raytheon.edex.plugin.gfe.sample.SampleId[],
|
|
||||||
* com.raytheon.edex.plugin.gfe.sample.SampleId[],
|
|
||||||
* com.raytheon.edex.plugin.gfe.sample.SampleId[])
|
|
||||||
*/
|
*/
|
||||||
public void networkNotification(final SampleId[] anInventory,
|
@Override
|
||||||
final SampleId[] additions, final SampleId[] deletions,
|
public void fileUpdated(FileUpdatedMessage message) {
|
||||||
final SampleId[] changes) throws VizException {
|
|
||||||
|
|
||||||
// logDebug << "NetworkNotification newInv=" << anInventory
|
String name = LocalizationUtil.extractName(message.getFileName())
|
||||||
// << " add=" << additions << " del=" << deletions << " chg="
|
.replace(".xml", "");
|
||||||
// << changes << std::endl;
|
SampleId id = new SampleId(name);
|
||||||
// logDebug << "OldInventory=" << anInventory << std::endl;
|
|
||||||
// logDebug << "Active loaded set=" << _loadedSet << std::endl;
|
|
||||||
|
|
||||||
// store the new inventory
|
switch (message.getChangeType()) {
|
||||||
this.inventory = new HashSet<SampleId>(Arrays.asList(anInventory));
|
case ADDED:
|
||||||
|
case UPDATED:
|
||||||
|
this.inventory.add(id);
|
||||||
|
|
||||||
// loaded sample set changed?, check by name field for a match
|
// loaded sample set "added", may simply be a rename
|
||||||
for (SampleId changesId : changes) {
|
if (id.getName().equals(this.loadedSet.getName())) {
|
||||||
if (changesId.getName().equals(this.loadedSet.getName())) {
|
loadSampleSet(id, SampleSetLoadMode.REPLACE);
|
||||||
// logDebug << "LoadedSampleSet changed " << _loadedSet <<
|
|
||||||
// std::endl;
|
|
||||||
loadSampleSet(changesId, SampleSetLoadMode.REPLACE);
|
|
||||||
}
|
}
|
||||||
if (changesId.getName().equals(SampleSetManager.MARKER_NAME)) {
|
if (id.getName().equals(SampleSetManager.MARKER_NAME)) {
|
||||||
// logDebug << "MarkerSet changed " << changesId << std::endl;
|
|
||||||
getMarkerPoints();
|
getMarkerPoints();
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
|
||||||
// loaded sample set deleted?
|
case DELETED:
|
||||||
for (SampleId deletionsId : deletions) {
|
LocalizationFile[] files = pathManager.listStaticFiles(
|
||||||
if (deletionsId.getName().equals(this.loadedSet.getName())) {
|
LocalizationType.COMMON_STATIC, message.getFileName(),
|
||||||
// logDebug << "LoadedSampleSet deleted " << _loadedSet
|
new String[] { ".xml" }, false, true);
|
||||||
// << ' ' << deletionsId << std::endl;
|
|
||||||
this.loadedSet = new SampleId();
|
if (id.getName().equals(this.loadedSet.getName())) {
|
||||||
|
if (files.length > 0) {
|
||||||
|
loadSampleSet(id, SampleSetLoadMode.REPLACE);
|
||||||
|
} else {
|
||||||
|
this.inventory.remove(id);
|
||||||
|
this.loadedSet = new SampleId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (deletionsId.getName().equals(SampleSetManager.MARKER_NAME)) {
|
|
||||||
// logDebug << "MarkerSet deleted " << deletionsId << std::endl;
|
if (id.getName().equals(SampleSetManager.MARKER_NAME)) {
|
||||||
getMarkerPoints();
|
getMarkerPoints();
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
statusHandler.error("Unexpected FileChangeType received: "
|
||||||
|
+ message.getChangeType().name());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// loaded sample set "added", may simply be a rename
|
|
||||||
for (SampleId additionsId : additions) {
|
|
||||||
if (additionsId.getName().equals(this.loadedSet.getName())) {
|
|
||||||
// logDebug << "LoadedSampleSet added " << _loadedSet
|
|
||||||
// << " " << additionsId << std::endl;
|
|
||||||
loadSampleSet(additionsId, SampleSetLoadMode.REPLACE);
|
|
||||||
}
|
|
||||||
if (additionsId.getName().equals(SampleSetManager.MARKER_NAME)) {
|
|
||||||
// logDebug << "MarkerSet added " << additionsId << std::endl;
|
|
||||||
getMarkerPoints();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// inventory changed?
|
|
||||||
if ((additions.length > 0) || (deletions.length > 0)
|
|
||||||
|| (changes.length > 0)) {
|
|
||||||
}
|
|
||||||
// logDebug << "Active set is now: " << _loadedSet << std::endl;
|
|
||||||
fireSampleSetChangedListeners();
|
fireSampleSetChangedListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -603,7 +604,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
*
|
*
|
||||||
* Gets the set of points, sends out notification of changes.
|
* Gets the set of points, sends out notification of changes.
|
||||||
*/
|
*/
|
||||||
private void getMarkerPoints() throws VizException {
|
private void getMarkerPoints() {
|
||||||
// ensure it is in the inventory
|
// ensure it is in the inventory
|
||||||
this.markerLocations.clear();
|
this.markerLocations.clear();
|
||||||
|
|
||||||
|
@ -621,6 +622,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
*
|
*
|
||||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getLoadedSet()
|
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getLoadedSet()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public SampleId getLoadedSet() {
|
public SampleId getLoadedSet() {
|
||||||
return this.loadedSet;
|
return this.loadedSet;
|
||||||
}
|
}
|
||||||
|
@ -630,6 +632,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
*
|
*
|
||||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getInventory()
|
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getInventory()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public SampleId[] getInventory() {
|
public SampleId[] getInventory() {
|
||||||
return this.inventory.toArray(new SampleId[this.inventory.size()]);
|
return this.inventory.toArray(new SampleId[this.inventory.size()]);
|
||||||
}
|
}
|
||||||
|
@ -639,6 +642,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
*
|
*
|
||||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getInventoryAsList()
|
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getInventoryAsList()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ArrayList<SampleId> getInventoryAsList() {
|
public ArrayList<SampleId> getInventoryAsList() {
|
||||||
ArrayList<SampleId> ids = new ArrayList<SampleId>();
|
ArrayList<SampleId> ids = new ArrayList<SampleId>();
|
||||||
for (SampleId id : this.inventory) {
|
for (SampleId id : this.inventory) {
|
||||||
|
@ -652,6 +656,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
*
|
*
|
||||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getInventoryAsStrings()
|
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getInventoryAsStrings()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String[] getInventoryAsStrings() {
|
public String[] getInventoryAsStrings() {
|
||||||
String[] retVal = new String[this.inventory.size()];
|
String[] retVal = new String[this.inventory.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -663,6 +668,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String activeMarkerSet(GridID gid) {
|
public String activeMarkerSet(GridID gid) {
|
||||||
// get office type from GridID
|
// get office type from GridID
|
||||||
String ot = gid.getParm().getOfficeType();
|
String ot = gid.getParm().getOfficeType();
|
||||||
|
@ -678,6 +684,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
*
|
*
|
||||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getLocations()
|
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getLocations()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public List<Coordinate> getLocations() {
|
public List<Coordinate> getLocations() {
|
||||||
return new ArrayList<Coordinate>(this.locations);
|
return new ArrayList<Coordinate>(this.locations);
|
||||||
}
|
}
|
||||||
|
@ -687,6 +694,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
*
|
*
|
||||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getMarkerLocations()
|
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getMarkerLocations()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Map<String, List<Coordinate>> getMarkerLocations() {
|
public Map<String, List<Coordinate>> getMarkerLocations() {
|
||||||
return this.markerLocations;
|
return this.markerLocations;
|
||||||
}
|
}
|
||||||
|
@ -696,6 +704,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
*
|
*
|
||||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#isShowLatLon()
|
* @see com.raytheon.viz.gfe.core.ISampleSetManager#isShowLatLon()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isShowLatLon() {
|
public boolean isShowLatLon() {
|
||||||
return showLatLon;
|
return showLatLon;
|
||||||
}
|
}
|
||||||
|
@ -705,6 +714,7 @@ public class SampleSetManager implements ISampleSetManager {
|
||||||
*
|
*
|
||||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#setShowLatLon(boolean)
|
* @see com.raytheon.viz.gfe.core.ISampleSetManager#setShowLatLon(boolean)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setShowLatLon(boolean showLatLon) {
|
public void setShowLatLon(boolean showLatLon) {
|
||||||
this.showLatLon = showLatLon;
|
this.showLatLon = showLatLon;
|
||||||
fireSampleSetChangedListeners();
|
fireSampleSetChangedListeners();
|
||||||
|
|
|
@ -22,15 +22,15 @@ package com.raytheon.viz.gfe.core.internal;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange;
|
import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange;
|
||||||
import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange.Mode;
|
import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange.Mode;
|
||||||
|
@ -62,6 +62,7 @@ import com.raytheon.viz.gfe.core.msgs.SelectTimeRangesChangedMsg;
|
||||||
* Dec 3, 2009 #3135 randerso Initial creation
|
* Dec 3, 2009 #3135 randerso Initial creation
|
||||||
* Aug 1, 2012 #965 dgilling Change location of SelectTimeRange.
|
* Aug 1, 2012 #965 dgilling Change location of SelectTimeRange.
|
||||||
* Aug 6, 2013 #1561 njensen Use pm.listFiles() instead of pm.listStaticFiles()
|
* Aug 6, 2013 #1561 njensen Use pm.listFiles() instead of pm.listStaticFiles()
|
||||||
|
* Sep 8, 2104 #3592 randerso Changed to use new pm listStaticFiles()
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -78,23 +79,17 @@ public class SelectTimeRangeManager implements ISelectTimeRangeManager,
|
||||||
|
|
||||||
private static final String FILE_EXT = ".SELECTTR";
|
private static final String FILE_EXT = ".SELECTTR";
|
||||||
|
|
||||||
private static final IPathManager pathManager = PathManagerFactory
|
|
||||||
.getPathManager();
|
|
||||||
|
|
||||||
private static final TimeZone ZULU = TimeZone.getTimeZone("GMT");
|
private static final TimeZone ZULU = TimeZone.getTimeZone("GMT");
|
||||||
|
|
||||||
protected DataManager dataManager;
|
private IPathManager pathManager;
|
||||||
|
|
||||||
private TimeZone timeZone;
|
private TimeZone timeZone;
|
||||||
|
|
||||||
private String[] inventory;
|
|
||||||
|
|
||||||
private Map<String, SelectTimeRange> rangeMap;
|
private Map<String, SelectTimeRange> rangeMap;
|
||||||
|
|
||||||
private LocalizationFile selectTRDir;
|
private LocalizationFile selectTRDir;
|
||||||
|
|
||||||
public SelectTimeRangeManager(DataManager dataManager) {
|
public SelectTimeRangeManager(DataManager dataManager) {
|
||||||
this.dataManager = dataManager;
|
|
||||||
// Find the referenced time zone
|
// Find the referenced time zone
|
||||||
timeZone = TimeZone.getTimeZone("GMT");
|
timeZone = TimeZone.getTimeZone("GMT");
|
||||||
try {
|
try {
|
||||||
|
@ -105,13 +100,13 @@ public class SelectTimeRangeManager implements ISelectTimeRangeManager,
|
||||||
"Unable to retrieve GFE time zone, using GMT", e);
|
"Unable to retrieve GFE time zone, using GMT", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
this.pathManager = PathManagerFactory.getPathManager();
|
||||||
selectTRDir = pathMgr.getLocalizationFile(pathMgr.getContext(
|
selectTRDir = pathManager.getLocalizationFile(pathManager.getContext(
|
||||||
LocalizationType.COMMON_STATIC, LocalizationLevel.BASE),
|
LocalizationType.COMMON_STATIC, LocalizationLevel.BASE),
|
||||||
FILE_PATH);
|
FILE_PATH);
|
||||||
selectTRDir.addFileUpdatedObserver(this);
|
selectTRDir.addFileUpdatedObserver(this);
|
||||||
|
|
||||||
fileUpdated(null);
|
loadInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,15 +118,17 @@ public class SelectTimeRangeManager implements ISelectTimeRangeManager,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] inventory() {
|
public String[] inventory() {
|
||||||
|
String[] inventory = this.rangeMap.keySet().toArray(
|
||||||
|
new String[this.rangeMap.size()]);
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SelectTimeRange loadTimeRange(LocalizationFile lf) {
|
private SelectTimeRange loadTimeRange(LocalizationFile lf) {
|
||||||
File file = lf.getFile();
|
String rangeName = rangeNameFromFileName(lf.getName());
|
||||||
|
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
try {
|
try {
|
||||||
in = new BufferedReader(new FileReader(file));
|
in = new BufferedReader(new InputStreamReader(lf.openInputStream()));
|
||||||
String[] s = in.readLine().split("\\s+");
|
String[] s = in.readLine().split("\\s+");
|
||||||
int start = Integer.parseInt(s[0]);
|
int start = Integer.parseInt(s[0]);
|
||||||
int end = Integer.parseInt(s[1]);
|
int end = Integer.parseInt(s[1]);
|
||||||
|
@ -140,21 +137,22 @@ public class SelectTimeRangeManager implements ISelectTimeRangeManager,
|
||||||
mode = Mode.values()[Integer.parseInt(s[2])];
|
mode = Mode.values()[Integer.parseInt(s[2])];
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectTimeRange range = new SelectTimeRange(FileUtil.unmangle(file
|
SelectTimeRange range = new SelectTimeRange(rangeName, start, end,
|
||||||
.getName().replace(FILE_EXT, "")), start, end, mode, lf
|
mode, lf.getContext().getLocalizationLevel(),
|
||||||
.getContext().getLocalizationLevel(),
|
|
||||||
(mode.equals(Mode.ZULU) ? ZULU : timeZone));
|
(mode.equals(Mode.ZULU) ? ZULU : timeZone));
|
||||||
return range;
|
return range;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
"Error reading SELECTTR file " + file.getAbsolutePath(), e);
|
"Error reading SELECTTR file "
|
||||||
|
+ lf.getFile().getAbsolutePath(), e);
|
||||||
} finally {
|
} finally {
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
try {
|
try {
|
||||||
in.close();
|
in.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
"Error closing file " + file.getAbsolutePath(), e);
|
"Error closing file "
|
||||||
|
+ lf.getFile().getAbsolutePath(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,22 +171,26 @@ public class SelectTimeRangeManager implements ISelectTimeRangeManager,
|
||||||
LocalizationLevel.USER), FileUtil.join(FILE_PATH,
|
LocalizationLevel.USER), FileUtil.join(FILE_PATH,
|
||||||
FileUtil.mangle(name) + FILE_EXT));
|
FileUtil.mangle(name) + FILE_EXT));
|
||||||
|
|
||||||
File file = lf.getFile();
|
|
||||||
BufferedWriter out = null;
|
BufferedWriter out = null;
|
||||||
try {
|
try {
|
||||||
out = new BufferedWriter(new FileWriter(file));
|
out = new BufferedWriter(new OutputStreamWriter(
|
||||||
|
lf.openOutputStream()));
|
||||||
out.write(String.format("%d %d %d", start, end, mode.ordinal()));
|
out.write(String.format("%d %d %d", start, end, mode.ordinal()));
|
||||||
out.close();
|
out.close();
|
||||||
|
out = null;
|
||||||
lf.save();
|
lf.save();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
"Error writing SELECTTR file " + file.getAbsolutePath(), e);
|
"Error writing SELECTTR file "
|
||||||
|
+ lf.getFile().getAbsolutePath(), e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
out.close();
|
if (out != null) {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
statusHandler.handle(Priority.PROBLEM, "Error closing file "
|
statusHandler.handle(Priority.PROBLEM, "Error closing file "
|
||||||
+ file.getAbsolutePath(), e);
|
+ lf.getFile().getAbsolutePath(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,9 +212,48 @@ public class SelectTimeRangeManager implements ISelectTimeRangeManager,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fileUpdated(FileUpdatedMessage message) {
|
public void fileUpdated(FileUpdatedMessage message) {
|
||||||
LocalizationFile[] files = pathManager.listFiles(pathManager
|
SelectTimeRange range;
|
||||||
.getLocalSearchHierarchy(LocalizationType.COMMON_STATIC),
|
|
||||||
FILE_PATH, new String[] { FILE_EXT }, false, true);
|
switch (message.getChangeType()) {
|
||||||
|
case ADDED:
|
||||||
|
case UPDATED:
|
||||||
|
LocalizationFile lf = pathManager.getLocalizationFile(
|
||||||
|
message.getContext(), message.getFileName());
|
||||||
|
range = loadTimeRange(lf);
|
||||||
|
if (range != null) {
|
||||||
|
this.rangeMap.put(range.getName(), range);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DELETED:
|
||||||
|
LocalizationFile[] files = pathManager.listStaticFiles(
|
||||||
|
LocalizationType.COMMON_STATIC, message.getFileName(),
|
||||||
|
new String[] { FILE_EXT }, false, true);
|
||||||
|
|
||||||
|
if (files.length > 0) {
|
||||||
|
range = loadTimeRange(files[0]); // should only be one
|
||||||
|
if (range != null) {
|
||||||
|
this.rangeMap.put(range.getName(), range);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String rangeName = rangeNameFromFileName(message.getFileName());
|
||||||
|
this.rangeMap.remove(rangeName);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
statusHandler.error("Unexpected FileChangeType received: "
|
||||||
|
+ message.getChangeType().name());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
new SelectTimeRangesChangedMsg().send();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadInventory() {
|
||||||
|
LocalizationFile[] files = pathManager.listStaticFiles(
|
||||||
|
LocalizationType.COMMON_STATIC, FILE_PATH,
|
||||||
|
new String[] { FILE_EXT }, false, true);
|
||||||
|
|
||||||
List<SelectTimeRange> ranges = new ArrayList<SelectTimeRange>(
|
List<SelectTimeRange> ranges = new ArrayList<SelectTimeRange>(
|
||||||
files.length);
|
files.length);
|
||||||
|
@ -224,19 +265,22 @@ public class SelectTimeRangeManager implements ISelectTimeRangeManager,
|
||||||
}
|
}
|
||||||
Collections.sort(ranges);
|
Collections.sort(ranges);
|
||||||
|
|
||||||
String[] inv = new String[ranges.size()];
|
Map<String, SelectTimeRange> map = new TreeMap<String, SelectTimeRange>();
|
||||||
Map<String, SelectTimeRange> map = new HashMap<String, SelectTimeRange>();
|
|
||||||
int i = 0;
|
|
||||||
for (SelectTimeRange range : ranges) {
|
for (SelectTimeRange range : ranges) {
|
||||||
inv[i++] = range.getName();
|
|
||||||
map.put(range.getName(), range);
|
map.put(range.getName(), range);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
this.inventory = inv;
|
|
||||||
this.rangeMap = map;
|
this.rangeMap = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
new SelectTimeRangesChangedMsg().send();
|
new SelectTimeRangesChangedMsg().send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String rangeNameFromFileName(String fileName) {
|
||||||
|
File file = new File(fileName);
|
||||||
|
String rangeName = FileUtil.unmangle(file.getName().replace(FILE_EXT,
|
||||||
|
""));
|
||||||
|
return rangeName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,8 @@ import com.raytheon.viz.gfe.textformatter.CombinationsFileUtil.ComboData.Entry;
|
||||||
* Sep 30, 2013 2361 njensen Use JAXBManager for XML
|
* Sep 30, 2013 2361 njensen Use JAXBManager for XML
|
||||||
* Feb 05, 2014 #2591 randerso Forced retrieval of combinations file
|
* Feb 05, 2014 #2591 randerso Forced retrieval of combinations file
|
||||||
* Implemented retry on error
|
* Implemented retry on error
|
||||||
|
* Sep 08, 2104 #3592 randerso Changed to use only list site level files as all
|
||||||
|
* combo files are saved to the site level
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -138,8 +140,8 @@ public class CombinationsFileUtil {
|
||||||
|
|
||||||
public static LocalizationFile[] getSavedCombos() {
|
public static LocalizationFile[] getSavedCombos() {
|
||||||
IPathManager pm = PathManagerFactory.getPathManager();
|
IPathManager pm = PathManagerFactory.getPathManager();
|
||||||
LocalizationFile[] combos = pm.listFiles(
|
LocalizationFile[] combos = pm.listFiles(pm.getContext(
|
||||||
pm.getLocalSearchHierarchy(LocalizationType.CAVE_STATIC),
|
LocalizationType.CAVE_STATIC, LocalizationLevel.SITE),
|
||||||
SAVED_COMBO_DIR, new String[] { ".xml" }, false, true);
|
SAVED_COMBO_DIR, new String[] { ".xml" }, false, true);
|
||||||
|
|
||||||
return combos;
|
return combos;
|
||||||
|
@ -222,8 +224,9 @@ public class CombinationsFileUtil {
|
||||||
IPathManager pm = PathManagerFactory.getPathManager();
|
IPathManager pm = PathManagerFactory.getPathManager();
|
||||||
|
|
||||||
// retrieve combinations file if it's changed
|
// retrieve combinations file if it's changed
|
||||||
LocalizationFile lf = pm.getStaticLocalizationFile(FileUtil.join(
|
LocalizationFile lf = pm.getStaticLocalizationFile(
|
||||||
COMBO_DIR_PATH, comboName + ".py"));
|
LocalizationType.CAVE_STATIC,
|
||||||
|
FileUtil.join(COMBO_DIR_PATH, comboName + ".py"));
|
||||||
File pyFile = null;
|
File pyFile = null;
|
||||||
if (lf != null) {
|
if (lf != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -234,7 +237,7 @@ public class CombinationsFileUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pyFile == null || !pyFile.exists()) {
|
if ((pyFile == null) || !pyFile.exists()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,24 +253,24 @@ public class CombinationsFileUtil {
|
||||||
map.put("comboName", comboName);
|
map.put("comboName", comboName);
|
||||||
PythonScript python = null;
|
PythonScript python = null;
|
||||||
for (int retryCount = 0; retryCount < MAX_TRIES; retryCount++) {
|
for (int retryCount = 0; retryCount < MAX_TRIES; retryCount++) {
|
||||||
try {
|
try {
|
||||||
python = new PythonScript(scriptPath,
|
python = new PythonScript(scriptPath,
|
||||||
PyUtil.buildJepIncludePath(
|
PyUtil.buildJepIncludePath(
|
||||||
GfePyIncludeUtil.getCombinationsIncludePath(),
|
GfePyIncludeUtil.getCombinationsIncludePath(),
|
||||||
GfePyIncludeUtil.getCommonPythonIncludePath()),
|
GfePyIncludeUtil.getCommonPythonIncludePath()),
|
||||||
CombinationsFileUtil.class.getClassLoader());
|
CombinationsFileUtil.class.getClassLoader());
|
||||||
|
|
||||||
Object com = python.execute("getCombinations", map);
|
Object com = python.execute("getCombinations", map);
|
||||||
combos = (List<List<String>>) com;
|
combos = (List<List<String>>) com;
|
||||||
|
|
||||||
// if successfully retrieved break out of the loop
|
// if successfully retrieved break out of the loop
|
||||||
break;
|
break;
|
||||||
} catch (JepException e) {
|
} catch (JepException e) {
|
||||||
// remove the .pyo file
|
// remove the .pyo file
|
||||||
new File(pyFile.getAbsolutePath() + "o").delete();
|
new File(pyFile.getAbsolutePath() + "o").delete();
|
||||||
|
|
||||||
// if not last try, log and try again
|
// if not last try, log and try again
|
||||||
if (retryCount < MAX_TRIES - 1) {
|
if (retryCount < (MAX_TRIES - 1)) {
|
||||||
// log but don't pop up
|
// log but don't pop up
|
||||||
statusHandler.handle(Priority.EVENTB,
|
statusHandler.handle(Priority.EVENTB,
|
||||||
"Error loading combinations file: " + comboName
|
"Error loading combinations file: " + comboName
|
||||||
|
@ -275,15 +278,15 @@ public class CombinationsFileUtil {
|
||||||
}
|
}
|
||||||
// else throw exception
|
// else throw exception
|
||||||
else {
|
else {
|
||||||
throw new GfeException("Error loading combinations file: "
|
throw new GfeException("Error loading combinations file: "
|
||||||
+ comboName, e);
|
+ comboName, e);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (python != null) {
|
||||||
|
python.dispose();
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
if (python != null) {
|
|
||||||
python.dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return combos;
|
return combos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ import com.raytheon.uf.common.util.FileUtil;
|
||||||
* Jul 24, 2012 dgilling Initial creation
|
* Jul 24, 2012 dgilling Initial creation
|
||||||
* Aug 07, 2013 1561 njensen Use pm.listFiles() instead of pm.listStaticFiles()
|
* Aug 07, 2013 1561 njensen Use pm.listFiles() instead of pm.listStaticFiles()
|
||||||
* Sep 30, 2013 2361 njensen Use JAXBManager for XML
|
* Sep 30, 2013 2361 njensen Use JAXBManager for XML
|
||||||
|
* Sep 08, 2104 3592 randerso Changed to use new pm listStaticFiles()
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -81,9 +82,9 @@ public class ReferenceMgr {
|
||||||
public ServerResponse<List<ReferenceID>> getInventory() {
|
public ServerResponse<List<ReferenceID>> getInventory() {
|
||||||
List<ReferenceID> refIDs = new ArrayList<ReferenceID>();
|
List<ReferenceID> refIDs = new ArrayList<ReferenceID>();
|
||||||
IPathManager pm = PathManagerFactory.getPathManager();
|
IPathManager pm = PathManagerFactory.getPathManager();
|
||||||
LocalizationFile[] contents = pm.listFiles(
|
LocalizationFile[] contents = pm.listStaticFiles(
|
||||||
pm.getLocalSearchHierarchy(LocalizationType.COMMON_STATIC),
|
LocalizationType.COMMON_STATIC, EDIT_AREAS_DIR,
|
||||||
EDIT_AREAS_DIR, new String[] { ".xml" }, false, true);
|
new String[] { ".xml" }, false, true);
|
||||||
if (contents != null) {
|
if (contents != null) {
|
||||||
for (LocalizationFile lf : contents) {
|
for (LocalizationFile lf : contents) {
|
||||||
String s = LocalizationUtil.extractName(lf.getName());
|
String s = LocalizationUtil.extractName(lf.getName());
|
||||||
|
@ -116,7 +117,8 @@ public class ReferenceMgr {
|
||||||
// process each ReferenceID requested
|
// process each ReferenceID requested
|
||||||
for (ReferenceID id : ids) {
|
for (ReferenceID id : ids) {
|
||||||
String path = FileUtil.join(EDIT_AREAS_DIR, id.getName() + ".xml");
|
String path = FileUtil.join(EDIT_AREAS_DIR, id.getName() + ".xml");
|
||||||
LocalizationFile lf = pathMgr.getStaticLocalizationFile(path);
|
LocalizationFile lf = pathMgr.getStaticLocalizationFile(
|
||||||
|
LocalizationType.COMMON_STATIC, path);
|
||||||
|
|
||||||
// does it exist?
|
// does it exist?
|
||||||
if (lf == null) {
|
if (lf == null) {
|
||||||
|
@ -129,8 +131,8 @@ public class ReferenceMgr {
|
||||||
// open and read the file
|
// open and read the file
|
||||||
ReferenceData refData = null;
|
ReferenceData refData = null;
|
||||||
try {
|
try {
|
||||||
refData = ReferenceData.getJAXBManager()
|
refData = ReferenceData.getJAXBManager().unmarshalFromXmlFile(
|
||||||
.unmarshalFromXmlFile(lf.getFile().getPath());
|
lf.getFile().getPath());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sr.addMessage("Unable to read reference data [" + id + "]");
|
sr.addMessage("Unable to read reference data [" + id + "]");
|
||||||
data = Collections.emptyList();
|
data = Collections.emptyList();
|
||||||
|
|
|
@ -41,6 +41,10 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 02/12/2008 chammack Initial Creation.
|
* 02/12/2008 chammack Initial Creation.
|
||||||
|
* Sep 08, 2014 3592 randerso Added single type listStaticFiles,
|
||||||
|
* getStaticLocalizationFile, and getStaticFile APIs
|
||||||
|
* Improved JavaDoc for all listStaticFiles,
|
||||||
|
* getStaticLocalizationFile, and getStaticFile APIs.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -49,13 +53,16 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||||
*/
|
*/
|
||||||
public interface IPathManager {
|
public interface IPathManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Directory separator used by Localization
|
||||||
|
*/
|
||||||
public static final String SEPARATOR = "/";
|
public static final String SEPARATOR = "/";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Checks the localization hierarchy for a static file
|
* Finds the specified file in any applicable LocalizationType. Note: If the
|
||||||
*
|
* same file exists in multiple localization levels, only the lowest level
|
||||||
* First searches user, then site and finally base to find the file.
|
* version of the file will be returned.
|
||||||
*
|
*
|
||||||
* Returns null if file is not found.
|
* Returns null if file is not found.
|
||||||
*
|
*
|
||||||
|
@ -63,13 +70,30 @@ public interface IPathManager {
|
||||||
* the name of the file to search for
|
* the name of the file to search for
|
||||||
* @return a pointer to the location on the filesystem
|
* @return a pointer to the location on the filesystem
|
||||||
*/
|
*/
|
||||||
public abstract File getStaticFile(String name);
|
public File getStaticFile(String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Checks the localization hierarchy for a static file
|
* Finds the specified file in the specified LocalizationType. Note: If the
|
||||||
|
* same file exists in multiple localization levels, only the lowest level
|
||||||
|
* version of the file will be returned.
|
||||||
*
|
*
|
||||||
* First searches user, then site and finally base to find the file.
|
* Returns null if file is not found.
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* LocalizationType of file to be found
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* the name of the file to search for
|
||||||
|
* @return a pointer to the location on the filesystem
|
||||||
|
*/
|
||||||
|
public File getStaticFile(LocalizationType type, String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Finds the specified file in any applicable LocalizationType. Note: If the
|
||||||
|
* same file exists in multiple localization levels, only the lowest level
|
||||||
|
* version of the file will be returned.
|
||||||
*
|
*
|
||||||
* Returns null if file is not found.
|
* Returns null if file is not found.
|
||||||
*
|
*
|
||||||
|
@ -77,7 +101,25 @@ public interface IPathManager {
|
||||||
* the name of the file to search for
|
* the name of the file to search for
|
||||||
* @return the file and the context it was found in
|
* @return the file and the context it was found in
|
||||||
*/
|
*/
|
||||||
public abstract LocalizationFile getStaticLocalizationFile(String name);
|
public LocalizationFile getStaticLocalizationFile(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Finds the specified file in the specified LocalizationType. Note: If the
|
||||||
|
* same file exists in multiple localization levels, only the lowest level
|
||||||
|
* version of the file will be returned.
|
||||||
|
*
|
||||||
|
* Returns null if file is not found.
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* LocalizationType of file to be found
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* the name of the file to search for
|
||||||
|
* @return the file and the context it was found in
|
||||||
|
*/
|
||||||
|
public LocalizationFile getStaticLocalizationFile(LocalizationType type,
|
||||||
|
String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -89,7 +131,7 @@ public interface IPathManager {
|
||||||
* the filename to search
|
* the filename to search
|
||||||
* @return an absolute pointer on the filesystem to the file
|
* @return an absolute pointer on the filesystem to the file
|
||||||
*/
|
*/
|
||||||
public abstract File getFile(LocalizationContext context, String name);
|
public File getFile(LocalizationContext context, String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -101,8 +143,8 @@ public interface IPathManager {
|
||||||
* the filename to search
|
* the filename to search
|
||||||
* @return an absolute pointer on the filesystem to the file
|
* @return an absolute pointer on the filesystem to the file
|
||||||
*/
|
*/
|
||||||
public abstract LocalizationFile getLocalizationFile(
|
public LocalizationFile getLocalizationFile(LocalizationContext context,
|
||||||
LocalizationContext context, String name);
|
String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a map containing a LocalizationFile for each LocalizationLevel
|
* Returns a map containing a LocalizationFile for each LocalizationLevel
|
||||||
|
@ -114,11 +156,13 @@ public interface IPathManager {
|
||||||
* the localization file name
|
* the localization file name
|
||||||
* @return map of LocalizationLevel to LocalizationFile
|
* @return map of LocalizationLevel to LocalizationFile
|
||||||
*/
|
*/
|
||||||
public abstract Map<LocalizationLevel, LocalizationFile> getTieredLocalizationFile(
|
public Map<LocalizationLevel, LocalizationFile> getTieredLocalizationFile(
|
||||||
LocalizationType type, String name);
|
LocalizationType type, String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists files in the directory
|
* Lists all files in the localization hierarchy for the specified directory
|
||||||
|
* Note: If the same file exists in multiple localization levels, all
|
||||||
|
* versions of the file will be returned in the array.
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* the localization context to use
|
* the localization context to use
|
||||||
|
@ -134,12 +178,14 @@ public interface IPathManager {
|
||||||
* directories
|
* directories
|
||||||
* @return the files on the filesystem in the directory
|
* @return the files on the filesystem in the directory
|
||||||
*/
|
*/
|
||||||
public abstract LocalizationFile[] listFiles(LocalizationContext context,
|
public LocalizationFile[] listFiles(LocalizationContext context,
|
||||||
String name, String[] extensions, boolean recursive,
|
String name, String[] extensions, boolean recursive,
|
||||||
boolean filesOnly);
|
boolean filesOnly);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists files in the directory
|
* Lists all files in the localization hierarchy for the specified directory
|
||||||
|
* Note: If the same file exists in multiple localization levels, all
|
||||||
|
* versions of the file will be returned in the array.
|
||||||
*
|
*
|
||||||
* @param contexts
|
* @param contexts
|
||||||
* the localization contexts to search
|
* the localization contexts to search
|
||||||
|
@ -156,9 +202,9 @@ public interface IPathManager {
|
||||||
* @return the files on the filesystem in the directory or null in case of
|
* @return the files on the filesystem in the directory or null in case of
|
||||||
* error
|
* error
|
||||||
*/
|
*/
|
||||||
public abstract LocalizationFile[] listFiles(
|
public LocalizationFile[] listFiles(LocalizationContext[] contexts,
|
||||||
LocalizationContext[] contexts, String name, String[] extensions,
|
String name, String[] extensions, boolean recursive,
|
||||||
boolean recursive, boolean filesOnly);
|
boolean filesOnly);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all files in all localization contexts in a particular directory.
|
* Lists all files in all localization contexts in a particular directory.
|
||||||
|
@ -177,8 +223,32 @@ public interface IPathManager {
|
||||||
* directories
|
* directories
|
||||||
* @return a list of files
|
* @return a list of files
|
||||||
*/
|
*/
|
||||||
public abstract LocalizationFile[] listStaticFiles(String name,
|
public LocalizationFile[] listStaticFiles(String name, String[] extensions,
|
||||||
String[] extensions, boolean recursive, boolean filesOnly);
|
boolean recursive, boolean filesOnly);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all files in the specified LocalizationType in a particular
|
||||||
|
* directory. Note: If the same file exists in multiple localization levels,
|
||||||
|
* only the lowest level version of the file will be returned in the array.
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* the localization type to use
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* the directory to look in
|
||||||
|
* @param extensions
|
||||||
|
* a list of file extensions to look for, or null if no filter
|
||||||
|
* @param recursive
|
||||||
|
* true for recursive directory listing, false for a single level
|
||||||
|
* listing
|
||||||
|
* @param filesOnly
|
||||||
|
* true if only files are listed, false to list both files and
|
||||||
|
* directories
|
||||||
|
* @return a list of files
|
||||||
|
*/
|
||||||
|
public LocalizationFile[] listStaticFiles(LocalizationType type,
|
||||||
|
String name, String[] extensions, boolean recursive,
|
||||||
|
boolean filesOnly);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a localization context for the given type and level for the
|
* Returns a localization context for the given type and level for the
|
||||||
|
@ -188,7 +258,7 @@ public interface IPathManager {
|
||||||
* @param level
|
* @param level
|
||||||
* @return the localization context
|
* @return the localization context
|
||||||
*/
|
*/
|
||||||
public abstract LocalizationContext getContext(LocalizationType type,
|
public LocalizationContext getContext(LocalizationType type,
|
||||||
LocalizationLevel level);
|
LocalizationLevel level);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -198,8 +268,8 @@ public interface IPathManager {
|
||||||
* @param siteId
|
* @param siteId
|
||||||
* @return the site localization context
|
* @return the site localization context
|
||||||
*/
|
*/
|
||||||
public abstract LocalizationContext getContextForSite(
|
public LocalizationContext getContextForSite(LocalizationType type,
|
||||||
LocalizationType type, String siteId);
|
String siteId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the localization contexts that should be searched given a
|
* Return the localization contexts that should be searched given a
|
||||||
|
@ -209,16 +279,16 @@ public interface IPathManager {
|
||||||
* the type
|
* the type
|
||||||
* @return the localization contexts
|
* @return the localization contexts
|
||||||
*/
|
*/
|
||||||
public abstract LocalizationContext[] getLocalSearchHierarchy(
|
public LocalizationContext[] getLocalSearchHierarchy(
|
||||||
LocalizationContext.LocalizationType type);
|
LocalizationContext.LocalizationType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the available context strings for the given level
|
* Get the available context strings for the given level
|
||||||
*
|
*
|
||||||
* @param level
|
* @param level
|
||||||
* @return
|
* @return the available contexts
|
||||||
*/
|
*/
|
||||||
public abstract String[] getContextList(LocalizationLevel level);
|
public String[] getContextList(LocalizationLevel level);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the available levels to be used, sorted from lowest search level
|
* Returns the available levels to be used, sorted from lowest search level
|
||||||
|
@ -226,5 +296,5 @@ public interface IPathManager {
|
||||||
*
|
*
|
||||||
* @return Available sorted levels
|
* @return Available sorted levels
|
||||||
*/
|
*/
|
||||||
public abstract LocalizationLevel[] getAvailableLevels();
|
public LocalizationLevel[] getAvailableLevels();
|
||||||
}
|
}
|
|
@ -55,6 +55,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 02/12/2008 chammack Initial Creation.
|
* 02/12/2008 chammack Initial Creation.
|
||||||
* Oct 23, 2012 1322 djohnson Allow test code in the same package to clear fileCache.
|
* Oct 23, 2012 1322 djohnson Allow test code in the same package to clear fileCache.
|
||||||
|
* Sep 08, 2014 3592 randerso Added single type listStaticFiles,
|
||||||
|
* getStaticLocalizationFile, and getStaticFile APIs
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -63,8 +65,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PathManager implements IPathManager {
|
public class PathManager implements IPathManager {
|
||||||
private static final IUFStatusHandler statusHandler = UFStatus
|
private static final IUFStatusHandler statusHandler = UFStatus.getHandler(
|
||||||
.getHandler(PathManager.class, "Localization");
|
PathManager.class, "Localization");
|
||||||
|
|
||||||
// @VisibleForTesting
|
// @VisibleForTesting
|
||||||
static final Map<LocalizationFileKey, LocalizationFile> fileCache = new ConcurrentHashMap<LocalizationFileKey, LocalizationFile>();
|
static final Map<LocalizationFileKey, LocalizationFile> fileCache = new ConcurrentHashMap<LocalizationFileKey, LocalizationFile>();
|
||||||
|
@ -93,6 +95,33 @@ public class PathManager implements IPathManager {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.uf.common.localization.IPathManager#getStaticFile(com.raytheon
|
||||||
|
* .uf.common.localization.LocalizationContext.LocalizationType,
|
||||||
|
* java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public File getStaticFile(LocalizationType type, String name) {
|
||||||
|
LocalizationFile locFile = getStaticLocalizationFile(type, name);
|
||||||
|
File file = null;
|
||||||
|
if (locFile != null) {
|
||||||
|
file = locFile.getFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocalizationFile getStaticLocalizationFile(LocalizationType type,
|
||||||
|
String name) {
|
||||||
|
Validate.notNull(name, "Path name must not be null");
|
||||||
|
return this.getStaticLocalizationFile(new LocalizationType[] { type },
|
||||||
|
name);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -103,11 +132,16 @@ public class PathManager implements IPathManager {
|
||||||
@Override
|
@Override
|
||||||
public LocalizationFile getStaticLocalizationFile(String name) {
|
public LocalizationFile getStaticLocalizationFile(String name) {
|
||||||
Validate.notNull(name, "Path name must not be null");
|
Validate.notNull(name, "Path name must not be null");
|
||||||
|
LocalizationType[] types = this.adapter.getStaticContexts();
|
||||||
|
return this.getStaticLocalizationFile(types, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LocalizationFile getStaticLocalizationFile(
|
||||||
|
LocalizationType[] types, String name) {
|
||||||
|
Validate.notNull(name, "Path name must not be null");
|
||||||
name = name.replace(File.separator, IPathManager.SEPARATOR);
|
name = name.replace(File.separator, IPathManager.SEPARATOR);
|
||||||
|
|
||||||
// Iterate through the types
|
// Iterate through the types
|
||||||
LocalizationType[] types = this.adapter.getStaticContexts();
|
|
||||||
List<LocalizationContext> contexts = new ArrayList<LocalizationContext>();
|
List<LocalizationContext> contexts = new ArrayList<LocalizationContext>();
|
||||||
for (LocalizationType type : types) {
|
for (LocalizationType type : types) {
|
||||||
// Iterate through the hierarchy
|
// Iterate through the hierarchy
|
||||||
|
@ -122,7 +156,7 @@ public class PathManager implements IPathManager {
|
||||||
name);
|
name);
|
||||||
|
|
||||||
for (LocalizationFile file : files) {
|
for (LocalizationFile file : files) {
|
||||||
if (file != null && file.exists()) {
|
if ((file != null) && file.exists()) {
|
||||||
// First file found in hierarchy is used
|
// First file found in hierarchy is used
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
@ -156,7 +190,7 @@ public class PathManager implements IPathManager {
|
||||||
|
|
||||||
LocalizationFile[] files = getLocalizationFile(contexts, name);
|
LocalizationFile[] files = getLocalizationFile(contexts, name);
|
||||||
for (LocalizationFile lf : files) {
|
for (LocalizationFile lf : files) {
|
||||||
if (lf != null && lf.exists()) {
|
if ((lf != null) && lf.exists()) {
|
||||||
map.put(lf.getContext().getLocalizationLevel(), lf);
|
map.put(lf.getContext().getLocalizationLevel(), lf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,7 +293,7 @@ public class PathManager implements IPathManager {
|
||||||
LocalizationFileKey key = new LocalizationFileKey(response.fileName,
|
LocalizationFileKey key = new LocalizationFileKey(response.fileName,
|
||||||
response.context);
|
response.context);
|
||||||
LocalizationFile lf = fileCache.get(key);
|
LocalizationFile lf = fileCache.get(key);
|
||||||
if (lf != null && lf.isNull() == false) {
|
if ((lf != null) && (lf.isNull() == false)) {
|
||||||
// Ensure latest data for file, will only be null if no File can be
|
// Ensure latest data for file, will only be null if no File can be
|
||||||
// returned for path/context.
|
// returned for path/context.
|
||||||
lf.update(response);
|
lf.update(response);
|
||||||
|
@ -361,6 +395,21 @@ public class PathManager implements IPathManager {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.uf.common.localization.IPathManager#listFiles(java.lang.
|
||||||
|
* String , java.lang.String[])
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public LocalizationFile[] listStaticFiles(LocalizationType type,
|
||||||
|
String name, String[] filter, boolean recursive, boolean filesOnly) {
|
||||||
|
|
||||||
|
return this.listStaticFiles(new LocalizationType[] { type }, name,
|
||||||
|
filter, recursive, filesOnly);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -375,6 +424,13 @@ public class PathManager implements IPathManager {
|
||||||
|
|
||||||
// Iterate through the types
|
// Iterate through the types
|
||||||
LocalizationType[] types = this.adapter.getStaticContexts();
|
LocalizationType[] types = this.adapter.getStaticContexts();
|
||||||
|
return this.listStaticFiles(types, name, filter, recursive, filesOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LocalizationFile[] listStaticFiles(LocalizationType[] types,
|
||||||
|
String name, String[] filter, boolean recursive, boolean filesOnly) {
|
||||||
|
Validate.notNull(name, "Path name must not be null");
|
||||||
|
|
||||||
List<LocalizationContext> contexts = new ArrayList<LocalizationContext>();
|
List<LocalizationContext> contexts = new ArrayList<LocalizationContext>();
|
||||||
for (LocalizationType type : types) {
|
for (LocalizationType type : types) {
|
||||||
// Iterate through the hierarchy
|
// Iterate through the hierarchy
|
||||||
|
@ -512,7 +568,7 @@ public class PathManager implements IPathManager {
|
||||||
ListResponseEntry lre = entry.getValue();
|
ListResponseEntry lre = entry.getValue();
|
||||||
SerializableKey key = entry.getKey();
|
SerializableKey key = entry.getKey();
|
||||||
LocalizationFile file = new LocalizationFile();
|
LocalizationFile file = new LocalizationFile();
|
||||||
if (lre.getContext() != null && lre.getFileName() != null) {
|
if ((lre.getContext() != null) && (lre.getFileName() != null)) {
|
||||||
file = new LocalizationFile(pm.adapter, lre.getContext(),
|
file = new LocalizationFile(pm.adapter, lre.getContext(),
|
||||||
pm.adapter.getPath(lre.getContext(),
|
pm.adapter.getPath(lre.getContext(),
|
||||||
lre.getFileName()), lre.getDate(),
|
lre.getFileName()), lre.getDate(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue