Merge "VLab Issue #10346 - Revert 'DCS15102 implements preferred order' fixes #10346" into asdt_16.2.1
Former-commit-id: 19b2a1c4b7735e7c7bc10cd0e9a434f09bf48e0a
This commit is contained in:
commit
c71b15065a
3 changed files with 2 additions and 227 deletions
|
@ -80,7 +80,6 @@ import com.raytheon.viz.hydro.timeseries.util.GraphData;
|
|||
import com.raytheon.viz.hydro.timeseries.util.GroupInfo;
|
||||
import com.raytheon.viz.hydro.timeseries.util.LIDData;
|
||||
import com.raytheon.viz.hydro.timeseries.util.PageInfo;
|
||||
import com.raytheon.viz.hydro.timeseries.util.PreferredOrderManager;
|
||||
import com.raytheon.viz.hydro.timeseries.util.TimeSeriesUtil;
|
||||
import com.raytheon.viz.hydro.timeseries.util.TraceData;
|
||||
import com.raytheon.viz.hydrocommon.HydroConstants;
|
||||
|
@ -125,8 +124,6 @@ import com.raytheon.viz.hydrocommon.util.StnClassSyncUtil;
|
|||
* 06 Jun 2013 2076 mpduff Fix station list selection and graph button enabling.
|
||||
* 0 Jun 2013 15980 wkwock Fix selected station not update
|
||||
* Jul 21, 2015 4500 rjpeter Use Number in blind cast.
|
||||
* 14 Sep, 2015 15102 wkwock Implements preferred order for PE-D-TS-EXT list
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author lvenable
|
||||
|
@ -1512,13 +1509,9 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
|
|||
ArrayList<Object[]> data = (ArrayList<Object[]>) dataManager
|
||||
.getSitePEData(selectedLid);
|
||||
|
||||
PreferredOrderManager pom = PreferredOrderManager.getInstance();
|
||||
Map<String, String[]> peMap = pom.getPreferedOrder(selectedLid);
|
||||
|
||||
bottomDataList.removeAll();
|
||||
|
||||
/* Get the lists of PE data */
|
||||
LinkedHashMap<String, ArrayList<SiteInfo>> preferredMap = new LinkedHashMap<String, ArrayList<SiteInfo>>();
|
||||
LinkedHashMap<String, ArrayList<SiteInfo>> hMap = new LinkedHashMap<String, ArrayList<SiteInfo>>();
|
||||
LinkedHashMap<String, ArrayList<SiteInfo>> qMap = new LinkedHashMap<String, ArrayList<SiteInfo>>();
|
||||
LinkedHashMap<String, ArrayList<SiteInfo>> pMap = new LinkedHashMap<String, ArrayList<SiteInfo>>();
|
||||
|
@ -1537,30 +1530,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
|
|||
si.setExt((String) row[3]);
|
||||
si.setDur(((Number) row[4]).intValue());
|
||||
|
||||
boolean preferredLstFlg = false;
|
||||
if (peMap!=null){
|
||||
String[] typeSrcLst = peMap.get(si.getPe());
|
||||
|
||||
if (typeSrcLst != null) {
|
||||
for (String typesrc : typeSrcLst) {
|
||||
|
||||
if (typesrc.equalsIgnoreCase(si.getTs())) {
|
||||
preferredLstFlg = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (peMap.containsKey(si.getPe())) {
|
||||
preferredLstFlg = true;
|
||||
}
|
||||
}
|
||||
if (preferredLstFlg) {
|
||||
if (!si.getPe().equals(prevPE)) {
|
||||
preferredMap.put(si.getPe(), new ArrayList<SiteInfo>());
|
||||
prevPE = si.getPe();
|
||||
}
|
||||
|
||||
preferredMap.get(si.getPe()).add(si);
|
||||
} else if (si.getPe().startsWith("H")) {
|
||||
if (si.getPe().startsWith("H")) {
|
||||
if (!si.getPe().equals(prevPE)) {
|
||||
hMap.put(si.getPe(), new ArrayList<SiteInfo>());
|
||||
prevPE = si.getPe();
|
||||
|
@ -1618,7 +1588,6 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
|
|||
tsSelected = false;
|
||||
}
|
||||
|
||||
populatePreferredDataInOrder(preferredMap,peMap);
|
||||
processDataList(hMap, tsSelected);
|
||||
processDataList(qMap, tsSelected);
|
||||
processDataList(pMap, tsSelected);
|
||||
|
@ -1629,41 +1598,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
|
|||
selectedDataLbl.setText(selectedLid);
|
||||
bottomDataList.setSelection(0);
|
||||
} catch (VizException e) {
|
||||
statusHandler.error("Failed to populate time series list",e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* populate data to bottomDataList base on preferred predefined order
|
||||
* @param preferredMap
|
||||
* @param peMap
|
||||
*/
|
||||
private void populatePreferredDataInOrder (LinkedHashMap<String, ArrayList<SiteInfo>>preferredMap, Map<String, String[]> peMap) {
|
||||
if (peMap!=null && preferredMap!=null ){
|
||||
for (String pe:peMap.keySet()){
|
||||
java.util.List<SiteInfo> siList = preferredMap.get(pe);
|
||||
|
||||
if (siList == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] tsList = peMap.get(pe);
|
||||
if (tsList==null) { //There's PE but no TS in preffered_order.txt
|
||||
for(SiteInfo si : siList) {
|
||||
bottomDataList.add(formatDataLine(si));
|
||||
siteInfoList.add(si);
|
||||
}
|
||||
} else { //There's both PE and TS in preferred_order.txt
|
||||
for (String ts: tsList){
|
||||
for(SiteInfo si : siList) {
|
||||
if (ts.equalsIgnoreCase(si.getTs())) {
|
||||
bottomDataList.add(formatDataLine(si));
|
||||
siteInfoList.add(si);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,157 +0,0 @@
|
|||
package com.raytheon.viz.hydro.timeseries.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.viz.hydrocommon.HydroConstants;
|
||||
|
||||
/**
|
||||
* This class read the user preferred predefined PE-D-TS-EXT list from file:
|
||||
* hydro/preferred_order.txt File format: lines start with # is a comment One
|
||||
* line per LID LID PE1:TS1,TS2 PE2:TS2,TS3 ... Duplicated LID will replaced by
|
||||
* last one.
|
||||
*
|
||||
* @author wkwock
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ---------- ---------- ----------- --------------------------
|
||||
* 6/22/2015 DCS15102 wkwock Initial creation.
|
||||
* </pre>
|
||||
*/
|
||||
public class PreferredOrderManager implements ILocalizationFileObserver {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(PreferredOrderManager.class);
|
||||
|
||||
private static PreferredOrderManager pom = null;
|
||||
|
||||
private Map<String, LinkedHashMap<String, String[]>> lidHm = new LinkedHashMap<String, LinkedHashMap<String, String[]>>();
|
||||
|
||||
private boolean readFileFlag = true;
|
||||
|
||||
private static final String COMMA_REGEX = "\\s*,\\s*";
|
||||
// For remove space around commas.
|
||||
|
||||
private static final String COLON_REGEX = "\\s*:\\s*";
|
||||
// For remove spaces around colons.
|
||||
|
||||
private static final String SPACE_REGEX = "\\s+";
|
||||
|
||||
private PreferredOrderManager() {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationFile file = pm
|
||||
.getStaticLocalizationFile(HydroConstants.PREFERRED_ORDER);
|
||||
if (file == null || !file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
file.addFileUpdatedObserver(this);
|
||||
}
|
||||
|
||||
private void readPreferredOrderFile() {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationFile file = pm
|
||||
.getStaticLocalizationFile(HydroConstants.PREFERRED_ORDER);
|
||||
lidHm.clear();
|
||||
|
||||
if (file == null || !file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder message = new StringBuilder();
|
||||
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
in = new BufferedReader(new InputStreamReader(
|
||||
file.openInputStream()));
|
||||
String line;
|
||||
inloop: while ((line = in.readLine()) != null) {
|
||||
String str = line.trim();
|
||||
if (str.startsWith("#") || str.length() == 0) {
|
||||
continue;// This is a comment or blank line
|
||||
}
|
||||
|
||||
str = str.replaceAll(COMMA_REGEX, ",").replaceAll(COLON_REGEX,
|
||||
":");
|
||||
String[] lineSplit = str.split(SPACE_REGEX);
|
||||
if (lineSplit.length < 2) {
|
||||
message.append(line + "\n");
|
||||
continue;
|
||||
}
|
||||
String lid = lineSplit[0].toUpperCase();
|
||||
LinkedHashMap<String, String[]> peHm = new LinkedHashMap<String, String[]>();
|
||||
for (int index = 1; index < lineSplit.length; index++) {
|
||||
String[] peSplit = lineSplit[index].split(":");
|
||||
if (peSplit.length > 2) {
|
||||
message.append(line + "\n");
|
||||
continue inloop;
|
||||
}
|
||||
String pe = peSplit[0].toUpperCase();
|
||||
|
||||
if (peSplit.length == 2) {
|
||||
String[] tsSplit = peSplit[1].split(",");
|
||||
peHm.put(pe, tsSplit);
|
||||
} else {
|
||||
peHm.put(pe, null);
|
||||
}
|
||||
}
|
||||
lidHm.put(lid, peHm);
|
||||
}
|
||||
|
||||
if (message.length() > 0) {
|
||||
message.insert(0,"Invalid line in file "+HydroConstants.PREFERRED_ORDER+":\n");
|
||||
message.append("Valid example: ACCM2 PP:RZ,RG TA:RZ\n");
|
||||
}
|
||||
} catch (IOException | LocalizationException e) {
|
||||
message.append("Failed to read file "+HydroConstants.PREFERRED_ORDER);
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
message.append("Failed to close file "+HydroConstants.PREFERRED_ORDER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (message.length() > 0) {
|
||||
statusHandler.warn(message.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public final static synchronized PreferredOrderManager getInstance() {
|
||||
if (pom == null) {
|
||||
pom = new PreferredOrderManager();
|
||||
}
|
||||
|
||||
return pom;
|
||||
}
|
||||
|
||||
public Map<String, String[]> getPreferedOrder(String lid) {
|
||||
if (readFileFlag) {
|
||||
readPreferredOrderFile();
|
||||
readFileFlag = false;
|
||||
}
|
||||
|
||||
Map<String, String[]> peMap = lidHm.get(lid);
|
||||
return peMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileUpdated(FileUpdatedMessage message) {
|
||||
readFileFlag = true;
|
||||
}
|
||||
}
|
|
@ -33,7 +33,6 @@ import org.eclipse.swt.graphics.RGB;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 17, 2008 1194 M. Duff Initial creation.
|
||||
* 11/18/2008 1662 grichard Added physical element enum type.
|
||||
* 14 Sep, 2015 15102 wkwock Implements preferred order for PE-D-TS-EXT list
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -263,8 +262,6 @@ public class HydroConstants {
|
|||
|
||||
public static final String RFCMOSAIC_DIR_TOKEN = "gaq_xmrg_1hr_dir";
|
||||
|
||||
public static final String PREFERRED_ORDER = "/hydro/preferred_order.txt";
|
||||
|
||||
/**
|
||||
* Enumeration used for selection of physical element.
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue