Issue #1578 Changes for non-blocking DataTashCanDlg and clean up to data managers.
Review changes 2. Change-Id: I4d697ccc5a2e5ab63dfef3e52e88d039adfcdaa0 Former-commit-id: 7d2e157d20a009a2192b35f95252bdad895a91c5
This commit is contained in:
parent
bb69390c9b
commit
b2dc220bcd
4 changed files with 197 additions and 92 deletions
|
@ -39,6 +39,7 @@ import org.eclipse.ui.PlatformUI;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 6/27/06 lvenable Initial Creation.
|
||||
* 2/06/2013 1578 rferrel Change for non-blocking DataTrashCanDlg.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,14 +48,25 @@ import org.eclipse.ui.PlatformUI;
|
|||
*/
|
||||
public class DataTrashCanAction extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
DataTrashCanDlg dataTrashCanDlg = new DataTrashCanDlg(shell);
|
||||
dataTrashCanDlg.open();
|
||||
/** The dialog to display */
|
||||
private DataTrashCanDlg dataTrashCanDlg;
|
||||
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
|
||||
* .ExecutionEvent)
|
||||
*/
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
if (dataTrashCanDlg == null) {
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
dataTrashCanDlg = new DataTrashCanDlg(shell);
|
||||
}
|
||||
dataTrashCanDlg.open();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ import org.eclipse.swt.events.KeyEvent;
|
|||
import org.eclipse.swt.events.KeyListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.VerifyEvent;
|
||||
import org.eclipse.swt.events.VerifyListener;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
|
@ -42,6 +44,9 @@ import org.eclipse.swt.widgets.List;
|
|||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
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.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.hydrocommon.IGetSortType;
|
||||
import com.raytheon.viz.hydrocommon.data.DataTrashCanData;
|
||||
|
@ -57,6 +62,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 29 NOV 2007 373 lvenable Initial creation
|
||||
* 18 JUL 2010 2110 mpduff Tweaked list box labels
|
||||
* 05 FEB 2013 1578 rferrel Made dialog non-blocking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -65,6 +71,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
*
|
||||
*/
|
||||
public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(DataTrashCanDlg.class);
|
||||
|
||||
/**
|
||||
* Font used for list controls.
|
||||
|
@ -109,12 +117,12 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
/**
|
||||
* Collection of trash data.
|
||||
*/
|
||||
private ArrayList<DataTrashCanData> trashData;
|
||||
private java.util.List<DataTrashCanData> trashData;
|
||||
|
||||
/**
|
||||
* Collection of filtered trash data.
|
||||
*/
|
||||
private ArrayList<DataTrashCanData> filteredTrashData;
|
||||
private java.util.List<DataTrashCanData> filteredTrashData;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -123,10 +131,16 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
* Parent shell.
|
||||
*/
|
||||
public DataTrashCanDlg(Shell parent) {
|
||||
super(parent);
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||
setText("Data Trash Can");
|
||||
filteredTrashData = new ArrayList<DataTrashCanData>();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||
*/
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
// Create the main layout for the shell.
|
||||
|
@ -136,11 +150,23 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
return mainLayout;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
|
||||
*/
|
||||
@Override
|
||||
protected void disposed() {
|
||||
font.dispose();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||
* .eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
setReturnValue(false);
|
||||
|
@ -210,6 +236,14 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
}
|
||||
});
|
||||
|
||||
locationTF.addVerifyListener(new VerifyListener() {
|
||||
|
||||
@Override
|
||||
public void verifyText(VerifyEvent e) {
|
||||
e.text = e.text.toUpperCase();
|
||||
}
|
||||
});
|
||||
|
||||
peChk = new Button(leftComp, SWT.CHECK);
|
||||
peChk.setText("Phys. Element:");
|
||||
peChk.addSelectionListener(new SelectionAdapter() {
|
||||
|
@ -297,8 +331,7 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
|
||||
Label label = new Label(labelComp, SWT.NONE);
|
||||
String labelText = String
|
||||
.format(
|
||||
"%-8s %-33s %2s %6s %3s %4s %12s %15s %19s %2s %2s %2s %8s %6s %11.11s %-10.10s %11.11s",
|
||||
.format("%-8s %-33s %2s %6s %3s %4s %12s %15s %19s %2s %2s %2s %8s %6s %11.11s %-10.10s %11.11s",
|
||||
"Location", "Name", "PE", "Dur", "TS", "Ext", "Value",
|
||||
"ObsTime", "BasisTime", "RV", "SQ", "QC", "User",
|
||||
"Type", "PostTime", "Product", "ProdTime");
|
||||
|
@ -339,8 +372,8 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
try {
|
||||
moveToDataTables();
|
||||
} catch (VizException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error moving data: ", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -390,8 +423,8 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
trashData = DataTrashCanDataManager.getInstance()
|
||||
.getDataTrashCanData(this);
|
||||
} catch (VizException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Problem getting trash data: ", e);
|
||||
}
|
||||
|
||||
filterDisplayList();
|
||||
|
@ -408,11 +441,11 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
updateDisplayList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply add active filters to limit the display list.
|
||||
*/
|
||||
private void filterDisplayList() {
|
||||
if (filteredTrashData == null)
|
||||
filteredTrashData = new ArrayList<DataTrashCanData>();
|
||||
else
|
||||
filteredTrashData.clear();
|
||||
filteredTrashData.clear();
|
||||
|
||||
filterByLID();
|
||||
filterByRejectType();
|
||||
|
@ -421,6 +454,9 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
sortDisplayList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the list by desired location ID.
|
||||
*/
|
||||
private void filterByLID() {
|
||||
String stationSearch = locationTF.getText().toUpperCase();
|
||||
|
||||
|
@ -437,6 +473,9 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter by reject type All, Auto, or Manual.
|
||||
*/
|
||||
private void filterByRejectType() {
|
||||
String rejectType = rejectTypeCbo.getItem(rejectTypeCbo
|
||||
.getSelectionIndex());
|
||||
|
@ -457,6 +496,9 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When active filter by the selected physical element.
|
||||
*/
|
||||
private void filterByPE() {
|
||||
|
||||
if (peChk.getSelection()) {
|
||||
|
@ -479,6 +521,9 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the display list with the contents of filteredTrashData.
|
||||
*/
|
||||
private void updateDisplayList() {
|
||||
dataList.removeAll();
|
||||
|
||||
|
@ -487,6 +532,9 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the physical elements list.
|
||||
*/
|
||||
private void loadPhyElemListData() {
|
||||
try {
|
||||
for (String currPE : DataTrashCanDataManager.getInstance()
|
||||
|
@ -494,8 +542,8 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
peDataList.add(currPE);
|
||||
}
|
||||
} catch (VizException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Problem getting PE values: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -540,7 +588,7 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
*
|
||||
* @param dataToDelete
|
||||
*/
|
||||
private void deleteRecords(ArrayList<DataTrashCanData> dataToDelete) {
|
||||
private void deleteRecords(java.util.List<DataTrashCanData> dataToDelete) {
|
||||
// Have DM delete records
|
||||
try {
|
||||
DataTrashCanDataManager.getInstance().deleteTrashRecords(
|
||||
|
@ -555,8 +603,8 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
}
|
||||
|
||||
/**
|
||||
* Reposts data to the correct PE table and deletes it from the rejecteddata
|
||||
* table.
|
||||
* Repost selected data to the correct PE table and remove it from the
|
||||
* rejected data table.
|
||||
*
|
||||
* @throws VizException
|
||||
*/
|
||||
|
@ -569,7 +617,12 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
getTrashData();
|
||||
}
|
||||
|
||||
private ArrayList<DataTrashCanData> getCurrentlySelectedRange() {
|
||||
/**
|
||||
* Obtain a list of selected trash can data.
|
||||
*
|
||||
* @return rval
|
||||
*/
|
||||
private java.util.List<DataTrashCanData> getCurrentlySelectedRange() {
|
||||
ArrayList<DataTrashCanData> rval = new ArrayList<DataTrashCanData>();
|
||||
|
||||
for (int i : dataList.getSelectionIndices()) {
|
||||
|
@ -579,6 +632,11 @@ public class DataTrashCanDlg extends CaveSWTDialog implements IGetSortType {
|
|||
return rval;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.hydrocommon.IGetSortType#getSortType()
|
||||
*/
|
||||
@Override
|
||||
public String getSortType() {
|
||||
return sortByCbo.getItem(sortByCbo.getSelectionIndex());
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.viz.hydrocommon.datamanager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.hydrocommon.IGetSortType;
|
||||
|
@ -36,6 +37,7 @@ import com.raytheon.viz.hydrocommon.util.HydroDataUtils;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 03Sept2008 #1509 dhladky Initial Creation
|
||||
* 30Oct2008 askripsky Connect to DB and refactor.
|
||||
* 06Feb2013 #1578 rferrel Code clean up for non-blocking dialogs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -45,7 +47,7 @@ import com.raytheon.viz.hydrocommon.util.HydroDataUtils;
|
|||
|
||||
public class DataTrashCanDataManager extends RejectedDataManager {
|
||||
|
||||
private static DataTrashCanDataManager manager = null;
|
||||
private static final DataTrashCanDataManager manager = new DataTrashCanDataManager();
|
||||
|
||||
private static final String SELECT_PE_FILTER_QUERY = "SELECT distinct shef.pe, shef.name "
|
||||
+ "FROM shefpe shef, ingestfilter ing "
|
||||
|
@ -64,12 +66,8 @@ public class DataTrashCanDataManager extends RejectedDataManager {
|
|||
*
|
||||
* @return manager
|
||||
*/
|
||||
public static synchronized DataTrashCanDataManager getInstance() {
|
||||
if (manager == null) {
|
||||
manager = new DataTrashCanDataManager();
|
||||
}
|
||||
|
||||
return (DataTrashCanDataManager) manager;
|
||||
public static DataTrashCanDataManager getInstance() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,9 +75,9 @@ public class DataTrashCanDataManager extends RejectedDataManager {
|
|||
*
|
||||
* @return String[]
|
||||
*/
|
||||
public ArrayList<DataTrashCanData> getDataTrashCanData(IGetSortType sortType)
|
||||
public List<DataTrashCanData> getDataTrashCanData(IGetSortType sortType)
|
||||
throws VizException {
|
||||
ArrayList<DataTrashCanData> rval = new ArrayList<DataTrashCanData>();
|
||||
List<DataTrashCanData> rval = new ArrayList<DataTrashCanData>();
|
||||
|
||||
for (Object[] currData : RejectedDataManager.getInstance()
|
||||
.getRejectedDataRawData()) {
|
||||
|
@ -89,10 +87,10 @@ public class DataTrashCanDataManager extends RejectedDataManager {
|
|||
return rval;
|
||||
}
|
||||
|
||||
public ArrayList<String> getPEList() throws VizException {
|
||||
ArrayList<String> rval = new ArrayList<String>();
|
||||
public List<String> getPEList() throws VizException {
|
||||
List<String> rval = new ArrayList<String>();
|
||||
|
||||
ArrayList<Object[]> data = runQuery(SELECT_PE_FILTER_QUERY);
|
||||
List<Object[]> data = runQuery(SELECT_PE_FILTER_QUERY);
|
||||
|
||||
for (Object[] currData : data) {
|
||||
rval.add((String) currData[0] + " " + (String) currData[1]);
|
||||
|
@ -107,9 +105,9 @@ public class DataTrashCanDataManager extends RejectedDataManager {
|
|||
* @param recordsToDelete
|
||||
* @throws VizException
|
||||
*/
|
||||
public void deleteTrashRecords(ArrayList<DataTrashCanData> recordsToDelete)
|
||||
public void deleteTrashRecords(List<DataTrashCanData> recordsToDelete)
|
||||
throws VizException {
|
||||
ArrayList<RejectedData> rejected = new ArrayList<RejectedData>();
|
||||
List<RejectedData> rejected = new ArrayList<RejectedData>();
|
||||
|
||||
for (RejectedData currData : recordsToDelete) {
|
||||
rejected.add((RejectedData) currData);
|
||||
|
@ -125,7 +123,7 @@ public class DataTrashCanDataManager extends RejectedDataManager {
|
|||
* @param currentlySelectedRange
|
||||
* @throws VizException
|
||||
*/
|
||||
public void repostData(ArrayList<DataTrashCanData> dataToRepost)
|
||||
public void repostData(List<DataTrashCanData> dataToRepost)
|
||||
throws VizException {
|
||||
|
||||
for (DataTrashCanData currData : dataToRepost) {
|
||||
|
|
|
@ -20,8 +20,12 @@
|
|||
package com.raytheon.viz.hydrocommon.datamanager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.dataquery.db.QueryResult;
|
||||
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.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.hydrocommon.data.PhysicalElementData;
|
||||
import com.raytheon.viz.hydrocommon.data.RejectedData;
|
||||
|
@ -35,6 +39,7 @@ import com.raytheon.viz.hydrocommon.util.HydroDataUtils;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 29, 2008 1636 askripsky Initial Creation
|
||||
* Feb 06, 2013 1578 rferrel Code clean for non-blocking dialogs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -43,27 +48,39 @@ import com.raytheon.viz.hydrocommon.util.HydroDataUtils;
|
|||
*/
|
||||
|
||||
public class RejectedDataManager extends HydroDataManager {
|
||||
protected static RejectedDataManager manager = null;
|
||||
/** Handler for error messages. */
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(RejectedDataManager.class);
|
||||
|
||||
private static final String SELECT_COLUMNS = "rd.lid, loc.name, rd.pe, rd.dur, rd.ts, rd.extremum, rd.value, "
|
||||
/** Singleton instance of class. */
|
||||
private static final RejectedDataManager manager = new RejectedDataManager();
|
||||
|
||||
/** Select columns query should retreive. */
|
||||
private final String SELECT_COLUMNS = "rd.lid, loc.name, rd.pe, rd.dur, rd.ts, rd.extremum, rd.value, "
|
||||
+ "rd.shef_qual_code, rd.quality_code, rd.revision, rd.product_id, rd.producttime, rd.postingtime, cast(rd.probability as float), "
|
||||
+ "rd.validtime, rd.basistime, rd.reject_type, rd.userid";
|
||||
|
||||
private static final String SELECT_STATEMENT = "SELECT " + SELECT_COLUMNS
|
||||
/** The query select statement. */
|
||||
private final String SELECT_STATEMENT = "SELECT " + SELECT_COLUMNS
|
||||
+ " FROM rejecteddata rd, location loc where rd.lid=loc.lid";
|
||||
|
||||
private static final String SELECT_CHECK_STATEMENT = "SELECT lid, pe, dur, ts, extremum, value, "
|
||||
/** The first part of the select statement to check if record exists. */
|
||||
private final String SELECT_CHECK_STATEMENT = "SELECT lid, pe, dur, ts, extremum, value, "
|
||||
+ "shef_qual_code, quality_code, revision, product_id, producttime, postingtime, cast(probability as float), "
|
||||
+ "validtime, basistime, reject_type, userid from rejecteddata";
|
||||
|
||||
private static final String INSERT_INTO_STATEMENT = "INSERT INTO rejecteddata (";
|
||||
/** First part of insert statement to add a rejected record. */
|
||||
private final String INSERT_INTO_STATEMENT = "INSERT INTO rejecteddata (";
|
||||
|
||||
private static final String INSERT_COLUMNS = "lid, pe, dur, ts, extremum, probability, validtime, "
|
||||
/** The columns for the inserted rejected record. */
|
||||
private final String INSERT_COLUMNS = "lid, pe, dur, ts, extremum, probability, validtime, "
|
||||
+ "basistime, postingtime, value, revision, shef_qual_code, product_id, producttime, quality_code, reject_type, userid";
|
||||
|
||||
private static final String INSERT_VALUES = ") VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')";
|
||||
/** The formating for the values to in the insert of a rejected record. */
|
||||
private final String INSERT_VALUES = ") VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')";
|
||||
|
||||
private static final String UPDATE_STATEMENT = "UPDATE rejecteddata SET value='%s', shef_qual_code='%s', quality_code='%s', revision='%s', product_id='%s', producttime='%s', reject_type='%s', userid='%s' WHERE %s";
|
||||
/** Formated query for updating a rejected record. */
|
||||
private final String UPDATE_STATEMENT = "UPDATE rejecteddata SET value='%s', shef_qual_code='%s', quality_code='%s', revision='%s', product_id='%s', producttime='%s', reject_type='%s', userid='%s' WHERE %s";
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
|
@ -77,12 +94,8 @@ public class RejectedDataManager extends HydroDataManager {
|
|||
*
|
||||
* @return manager
|
||||
*/
|
||||
public static synchronized RejectedDataManager getInstance() {
|
||||
if (manager == null) {
|
||||
manager = new RejectedDataManager();
|
||||
}
|
||||
|
||||
return (RejectedDataManager) manager;
|
||||
public static RejectedDataManager getInstance() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,28 +110,46 @@ public class RejectedDataManager extends HydroDataManager {
|
|||
putRejectedData(new RejectedData(questionableData));
|
||||
}
|
||||
|
||||
private void addRejectedDataRecord(RejectedData newRejectedData)
|
||||
throws VizException {
|
||||
runStatement(INSERT_INTO_STATEMENT
|
||||
+ INSERT_COLUMNS
|
||||
+ String.format(INSERT_VALUES, newRejectedData.getLid(),
|
||||
newRejectedData.getPe(), newRejectedData.getDur(),
|
||||
newRejectedData.getTs(), newRejectedData.getExtremum(),
|
||||
newRejectedData.getProbability(), dbFormat
|
||||
.format(newRejectedData.getValidTime()),
|
||||
dbFormat.format(newRejectedData.getBasisTime()),
|
||||
dbFormat.format(newRejectedData.getPostingTime()),
|
||||
newRejectedData.getValue(), newRejectedData
|
||||
.getRevision(), newRejectedData
|
||||
.getShefQualCode(), newRejectedData
|
||||
.getProductID(), dbFormat
|
||||
.format(newRejectedData.getProductTime()),
|
||||
newRejectedData.getQualityCode(), newRejectedData
|
||||
.getRejectType(), newRejectedData.getUserID()));
|
||||
/**
|
||||
* Insert the rejected record into the data base.
|
||||
*
|
||||
* @param newRejectedData
|
||||
* @throws VizException
|
||||
*/
|
||||
private void addRejectedDataRecord(RejectedData newRejectedData) {
|
||||
|
||||
try {
|
||||
runStatement(INSERT_INTO_STATEMENT
|
||||
+ INSERT_COLUMNS
|
||||
+ String.format(INSERT_VALUES, newRejectedData.getLid(),
|
||||
newRejectedData.getPe(), newRejectedData.getDur(),
|
||||
newRejectedData.getTs(),
|
||||
newRejectedData.getExtremum(),
|
||||
newRejectedData.getProbability(),
|
||||
dbFormat.format(newRejectedData.getValidTime()),
|
||||
dbFormat.format(newRejectedData.getBasisTime()),
|
||||
dbFormat.format(newRejectedData.getPostingTime()),
|
||||
newRejectedData.getValue(),
|
||||
newRejectedData.getRevision(),
|
||||
newRejectedData.getShefQualCode(),
|
||||
newRejectedData.getProductID(),
|
||||
dbFormat.format(newRejectedData.getProductTime()),
|
||||
newRejectedData.getQualityCode(),
|
||||
newRejectedData.getRejectType(),
|
||||
newRejectedData.getUserID()));
|
||||
} catch (VizException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Unable to add record: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<RejectedData> getRejectedData() throws VizException {
|
||||
ArrayList<RejectedData> rval = new ArrayList<RejectedData>();
|
||||
/**
|
||||
* Get a list of rejected data.
|
||||
*
|
||||
* @return rval
|
||||
* @throws VizException
|
||||
*/
|
||||
public List<RejectedData> getRejectedData() throws VizException {
|
||||
List<RejectedData> rval = new ArrayList<RejectedData>();
|
||||
|
||||
for (Object[] currData : getRejectedDataRawData()) {
|
||||
rval.add(new RejectedData(currData));
|
||||
|
@ -132,7 +163,7 @@ public class RejectedDataManager extends HydroDataManager {
|
|||
* @return
|
||||
* @throws VizException
|
||||
*/
|
||||
public ArrayList<Object[]> getRejectedDataRawData() throws VizException {
|
||||
public List<Object[]> getRejectedDataRawData() throws VizException {
|
||||
return runQuery(SELECT_STATEMENT);
|
||||
}
|
||||
|
||||
|
@ -142,7 +173,7 @@ public class RejectedDataManager extends HydroDataManager {
|
|||
* @param recordsToDelete
|
||||
* @throws VizException
|
||||
*/
|
||||
public void deleteRecords(ArrayList<RejectedData> recordsToDelete)
|
||||
public void deleteRecords(List<RejectedData> recordsToDelete)
|
||||
throws VizException {
|
||||
for (RejectedData currData : recordsToDelete) {
|
||||
deleteRecord(currData);
|
||||
|
@ -150,7 +181,7 @@ public class RejectedDataManager extends HydroDataManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Deletes each record passed in from the the rejecteddata table.
|
||||
* Deletes a record from the rejecteddata table.
|
||||
*
|
||||
* @param recordsToDelete
|
||||
* @throws VizException
|
||||
|
@ -177,36 +208,42 @@ public class RejectedDataManager extends HydroDataManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Updates a record
|
||||
* Updates an existing record
|
||||
*
|
||||
* @param data
|
||||
* @throws VizException
|
||||
*/
|
||||
private void updateRejectedData(RejectedData data) {
|
||||
try {
|
||||
runStatement(String.format(UPDATE_STATEMENT, data.getValue(), data
|
||||
.getShefQualCode(), data.getQualityCode(), data
|
||||
.getRevision(), data.getProductID(), dbFormat.format(data
|
||||
.getProductTime()), data.getRejectType(), data.getUserID(),
|
||||
runStatement(String.format(UPDATE_STATEMENT, data.getValue(),
|
||||
data.getShefQualCode(), data.getQualityCode(),
|
||||
data.getRevision(), data.getProductID(),
|
||||
dbFormat.format(data.getProductTime()),
|
||||
data.getRejectType(), data.getUserID(),
|
||||
HydroDataUtils.getPKStatement(data)));
|
||||
} catch (VizException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM, "Unble to update record: ",
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
public void putRejectedData(RejectedData data) {
|
||||
/**
|
||||
* Update an existing record or insert a new record.
|
||||
*
|
||||
* @param record
|
||||
*/
|
||||
public void putRejectedData(RejectedData record) {
|
||||
try {
|
||||
if (checkRejectedData(data) > 0) {
|
||||
if (checkRejectedData(record) > 0) {
|
||||
// Do an update
|
||||
updateRejectedData(data);
|
||||
updateRejectedData(record);
|
||||
} else {
|
||||
// Do an insert
|
||||
addRejectedDataRecord(data);
|
||||
addRejectedDataRecord(record);
|
||||
}
|
||||
} catch (VizException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM, "Check for record failed: ",
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue