Issue #1965 Initial archive retention dialog work.
updated archive creation, purge, and test cases after Roger's last checkin. added edex plugin for feature. added an abstract base archive dialog. Change-Id: I7c9ca3df40a7591815a1aae4fabf660217d44574 Former-commit-id: 64b75031afaecd74649392a19cc0b10dcdb79a2b
This commit is contained in:
parent
67cd73c655
commit
f53d6bf4ff
10 changed files with 683 additions and 177 deletions
|
@ -0,0 +1,430 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.viz.archive.ui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.graphics.Cursor;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Combo;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.archive.config.ArchiveConfig;
|
||||||
|
import com.raytheon.uf.common.archive.config.ArchiveConfigManager;
|
||||||
|
import com.raytheon.uf.common.archive.config.ArchiveConfigManager.DisplayData;
|
||||||
|
import com.raytheon.uf.common.archive.config.CategoryConfig;
|
||||||
|
import com.raytheon.uf.common.util.SizeUtil;
|
||||||
|
import com.raytheon.uf.viz.archive.data.ArchiveInfo;
|
||||||
|
import com.raytheon.uf.viz.archive.data.CategoryInfo;
|
||||||
|
import com.raytheon.uf.viz.archive.data.DirInfo;
|
||||||
|
import com.raytheon.uf.viz.archive.data.IArchiveTotals;
|
||||||
|
import com.raytheon.uf.viz.archive.ui.ArchiveTableComp.TableType;
|
||||||
|
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
|
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract base class for Archive dialogs. Contains and manages information
|
||||||
|
* needed for the archive and category selectors and populates the selection
|
||||||
|
* table of display labels elements.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* May 30, 2013 1965 bgonzale Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author bgonzale
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public abstract class AbstractArchiveDlg extends CaveSWTDialog implements
|
||||||
|
IArchiveTotals {
|
||||||
|
|
||||||
|
private static final String UNKNOWN_SIZE_TEXT = "????MB";
|
||||||
|
|
||||||
|
/** Table composite that holds the table controls. */
|
||||||
|
private ArchiveTableComp tableComp;
|
||||||
|
|
||||||
|
/** Archive config combo box. */
|
||||||
|
private Combo archCfgCbo;
|
||||||
|
|
||||||
|
/** Category combo box. */
|
||||||
|
private Combo categoryCbo;
|
||||||
|
|
||||||
|
/** Information for populating the various table displays. */
|
||||||
|
private final Map<String, ArchiveInfo> archiveInfoMap = new HashMap<String, ArchiveInfo>();
|
||||||
|
|
||||||
|
private Cursor busyCursor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param parentShell
|
||||||
|
*/
|
||||||
|
public AbstractArchiveDlg(Shell parentShell) {
|
||||||
|
super(parentShell);
|
||||||
|
setupCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param parentShell
|
||||||
|
* @param swtStyle
|
||||||
|
*/
|
||||||
|
public AbstractArchiveDlg(Shell parentShell, int swtStyle) {
|
||||||
|
super(parentShell, swtStyle);
|
||||||
|
setupCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param parentShell
|
||||||
|
* @param style
|
||||||
|
* @param caveStyle
|
||||||
|
*/
|
||||||
|
public AbstractArchiveDlg(Shell parentShell, int style, int caveStyle) {
|
||||||
|
super(parentShell, style, caveStyle);
|
||||||
|
setupCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.raytheon.uf.viz.archive.data.IArchiveTotals#getTotalSelectedItems()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getTotalSelectedItems() {
|
||||||
|
int totalSelected = 0;
|
||||||
|
for (ArchiveInfo archiveInfo : archiveInfoMap.values()) {
|
||||||
|
for (String categoryName : archiveInfo.getCategoryNames()) {
|
||||||
|
CategoryInfo categoryInfo = archiveInfo.get(categoryName);
|
||||||
|
for (DisplayData displayInfo : categoryInfo
|
||||||
|
.getDisplayInfoList()) {
|
||||||
|
if (displayInfo.isSelected()) {
|
||||||
|
++totalSelected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateTotalSizeLabel();
|
||||||
|
return totalSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DisplayData> getAllSelected() {
|
||||||
|
List<DisplayData> allSelected = new ArrayList<ArchiveConfigManager.DisplayData>();
|
||||||
|
for (String archiveName : archiveInfoMap.keySet()) {
|
||||||
|
ArchiveInfo archiveInfo = archiveInfoMap.get(archiveName);
|
||||||
|
for (String categoryName : archiveInfo.getCategoryNames()) {
|
||||||
|
CategoryInfo categoryInfo = archiveInfo.get(categoryName);
|
||||||
|
for (DisplayData displayData : categoryInfo
|
||||||
|
.getDisplayInfoList()) {
|
||||||
|
if (displayData.isSelected()) {
|
||||||
|
allSelected.add(displayData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return allSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of the currently selected archive in the dialog; null if
|
||||||
|
* none found
|
||||||
|
*/
|
||||||
|
public String getSelectedArchiveName() {
|
||||||
|
int archiveSelection = archCfgCbo.getSelectionIndex();
|
||||||
|
String archiveName = archiveSelection == -1 ? null : archCfgCbo
|
||||||
|
.getItem(archiveSelection);
|
||||||
|
return archiveName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of the currently selected category in the dialog; null
|
||||||
|
* if none found
|
||||||
|
*/
|
||||||
|
public String getSelectedCategoryName() {
|
||||||
|
int categorySelection = categoryCbo.getSelectionIndex();
|
||||||
|
String categoryName = categorySelection == -1 ? null : categoryCbo
|
||||||
|
.getItem(categorySelection);
|
||||||
|
return categoryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the currently selected archive in the dialog; null if none found
|
||||||
|
*/
|
||||||
|
public ArchiveConfig getSelectedArchive() {
|
||||||
|
int archiveSelection = archCfgCbo.getSelectionIndex();
|
||||||
|
String archiveName = archiveSelection == -1 ? null : archCfgCbo
|
||||||
|
.getItem(archiveSelection);
|
||||||
|
return ArchiveConfigManager.getInstance().getArchive(archiveName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the currently selected category in the dialog; null if none found
|
||||||
|
*/
|
||||||
|
public CategoryConfig getSelectedCategory() {
|
||||||
|
String archiveName = getSelectedArchiveName();
|
||||||
|
ArchiveConfig archive = ArchiveConfigManager.getInstance().getArchive(
|
||||||
|
archiveName);
|
||||||
|
if (archive != null) {
|
||||||
|
String categoryName = getSelectedCategoryName();
|
||||||
|
return archive.getCategory(categoryName);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateTotalSizeLabel() {
|
||||||
|
long totalSize = 0;
|
||||||
|
for (String archiveName : archiveInfoMap.keySet()) {
|
||||||
|
ArchiveInfo archiveInfo = archiveInfoMap.get(archiveName);
|
||||||
|
for (String categoryName : archiveInfo.getCategoryNames()) {
|
||||||
|
CategoryInfo categoryInfo = archiveInfo.get(categoryName);
|
||||||
|
for (DisplayData displayData : categoryInfo
|
||||||
|
.getDisplayInfoList()) {
|
||||||
|
if (displayData.isSelected()) {
|
||||||
|
long size = displayData.getSize();
|
||||||
|
if (size < 0) {
|
||||||
|
// Size still being computed.
|
||||||
|
setTotalSizeText(UNKNOWN_SIZE_TEXT);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
totalSize += size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setTotalSizeText(SizeUtil.prettyByteSize(totalSize));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called by the AbstractArchiveDlg to set the size text.
|
||||||
|
*
|
||||||
|
* @param prettyByteSize
|
||||||
|
*/
|
||||||
|
protected abstract void setTotalSizeText(String sizeStringText);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called by the AbstractArchiveDlg to get the start of the
|
||||||
|
* time frame that bounds the data for the dialog.
|
||||||
|
*
|
||||||
|
* @return GMT Calendar
|
||||||
|
*/
|
||||||
|
protected abstract Calendar getStart();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called by the AbstractArchiveDlg to get the end of the
|
||||||
|
* time frame that bounds the data for the dialog.
|
||||||
|
*
|
||||||
|
* @return GMT Calendar
|
||||||
|
*/
|
||||||
|
protected abstract Calendar getEnd();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called by the AbstractArchiveDlg when the combo boxes are
|
||||||
|
* updated.
|
||||||
|
*/
|
||||||
|
protected abstract void selectionsUpdated();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the Archive and Category combo controls.
|
||||||
|
*
|
||||||
|
* @param comp
|
||||||
|
* Composite to put the controls in.
|
||||||
|
*/
|
||||||
|
protected void createComboControls(Composite comp) {
|
||||||
|
Composite comboComp = new Composite(comp, SWT.NONE);
|
||||||
|
GridLayout gl = new GridLayout(2, false);
|
||||||
|
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
comboComp.setLayout(gl);
|
||||||
|
comboComp.setLayoutData(gd);
|
||||||
|
|
||||||
|
Label archCfgLbl = new Label(comboComp, SWT.NONE);
|
||||||
|
archCfgLbl.setText("Archive Config: ");
|
||||||
|
|
||||||
|
gd = new GridData(200, SWT.DEFAULT);
|
||||||
|
archCfgCbo = new Combo(comboComp, SWT.VERTICAL | SWT.DROP_DOWN
|
||||||
|
| SWT.BORDER | SWT.READ_ONLY);
|
||||||
|
archCfgCbo.setLayoutData(gd);
|
||||||
|
archCfgCbo.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
String archiveName = archCfgCbo.getItem(archCfgCbo
|
||||||
|
.getSelectionIndex());
|
||||||
|
populateCategoryCbo(archiveName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Label catLbl = new Label(comboComp, SWT.NONE);
|
||||||
|
catLbl.setText("Category: ");
|
||||||
|
|
||||||
|
gd = new GridData(200, SWT.DEFAULT);
|
||||||
|
categoryCbo = new Combo(comboComp, SWT.VERTICAL | SWT.DROP_DOWN
|
||||||
|
| SWT.BORDER | SWT.READ_ONLY);
|
||||||
|
categoryCbo.setLayoutData(gd);
|
||||||
|
categoryCbo.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
String archiveName = archCfgCbo.getItem(archCfgCbo
|
||||||
|
.getSelectionIndex());
|
||||||
|
String categoryName = categoryCbo.getItem(categoryCbo
|
||||||
|
.getSelectionIndex());
|
||||||
|
populateTableComp(archiveName, categoryName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ArchiveConfigManager.getInstance().reset();
|
||||||
|
|
||||||
|
createTable();
|
||||||
|
populateComboBoxes();
|
||||||
|
updateTableComp();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the table control.
|
||||||
|
*/
|
||||||
|
protected void createTable() {
|
||||||
|
tableComp = new ArchiveTableComp(shell, TableType.Case, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update table based on current item selections in archive and category.
|
||||||
|
*/
|
||||||
|
protected void updateTableComp() {
|
||||||
|
populateTableComp(getSelectedArchiveName(), getSelectedCategoryName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a separator line to the provided container.
|
||||||
|
*
|
||||||
|
* @param container
|
||||||
|
* Composite.
|
||||||
|
* @param orientation
|
||||||
|
* Vertical or horizontal orientation.
|
||||||
|
*/
|
||||||
|
protected void addSeparator(Composite container, int orientation) {
|
||||||
|
// Separator label
|
||||||
|
GridData gd;
|
||||||
|
|
||||||
|
if (orientation == SWT.HORIZONTAL) {
|
||||||
|
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
} else {
|
||||||
|
gd = new GridData(SWT.DEFAULT, SWT.FILL, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Label sepLbl = new Label(container, SWT.SEPARATOR | orientation);
|
||||||
|
sepLbl.setLayoutData(gd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init busyCursor. On close, make sure that cursor reverts back to unbusy
|
||||||
|
* state if it isn't already.
|
||||||
|
*/
|
||||||
|
private void setupCursor() {
|
||||||
|
busyCursor = getParent().getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
|
||||||
|
this.setCloseCallback(new ICloseCallback() {
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
setCursorBusy(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initial population up of the combo boxes.
|
||||||
|
*/
|
||||||
|
private void populateComboBoxes() {
|
||||||
|
ArchiveConfigManager manager = ArchiveConfigManager.getInstance();
|
||||||
|
boolean doSelect = false;
|
||||||
|
for (String archiveName : manager.getArchiveDataNamesList()) {
|
||||||
|
archCfgCbo.add(archiveName);
|
||||||
|
doSelect = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doSelect) {
|
||||||
|
archCfgCbo.select(0);
|
||||||
|
String archiveName = archCfgCbo.getItem(0);
|
||||||
|
populateCategoryCbo(archiveName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populate the category combo based on the archive name and populate the
|
||||||
|
* table.
|
||||||
|
*
|
||||||
|
* @param archiveName
|
||||||
|
*/
|
||||||
|
private void populateCategoryCbo(String archiveName) {
|
||||||
|
ArchiveConfigManager manager = ArchiveConfigManager.getInstance();
|
||||||
|
categoryCbo.removeAll();
|
||||||
|
for (String categoryName : manager.getCategoryNames(archiveName)) {
|
||||||
|
categoryCbo.add(categoryName);
|
||||||
|
}
|
||||||
|
categoryCbo.select(0);
|
||||||
|
String categoryName = categoryCbo.getItem(0);
|
||||||
|
populateTableComp(archiveName, categoryName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateTableComp(String archiveName, String categoryName) {
|
||||||
|
|
||||||
|
setCursorBusy(true);
|
||||||
|
DirInfo.clearQueue();
|
||||||
|
ArchiveInfo archiveInfo = archiveInfoMap.get(archiveName);
|
||||||
|
if (archiveInfo == null) {
|
||||||
|
archiveInfo = new ArchiveInfo();
|
||||||
|
archiveInfoMap.put(archiveName, archiveInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
CategoryInfo categoryInfo = archiveInfo.get(categoryName);
|
||||||
|
if (categoryInfo == null) {
|
||||||
|
ArchiveConfigManager manager = ArchiveConfigManager.getInstance();
|
||||||
|
List<DisplayData> displayInfos = manager.getDisplayInfo(
|
||||||
|
archiveName, categoryName);
|
||||||
|
categoryInfo = new CategoryInfo(archiveName, categoryName,
|
||||||
|
displayInfos);
|
||||||
|
archiveInfo.add(categoryInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DisplayData displayInfo : categoryInfo.getDisplayInfoList()) {
|
||||||
|
new DirInfo(displayInfo, getStart(), getEnd());
|
||||||
|
}
|
||||||
|
|
||||||
|
tableComp.populateTable(categoryInfo.getDisplayInfoList());
|
||||||
|
selectionsUpdated();
|
||||||
|
setCursorBusy(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setCursorBusy(boolean state) {
|
||||||
|
Cursor cursor = null;
|
||||||
|
if (state) {
|
||||||
|
cursor = busyCursor;
|
||||||
|
}
|
||||||
|
shell.setCursor(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,6 +19,8 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.viz.archive.ui;
|
package com.raytheon.uf.viz.archive.ui;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
@ -32,9 +34,11 @@ import org.eclipse.swt.widgets.Layout;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.swt.widgets.Spinner;
|
import org.eclipse.swt.widgets.Spinner;
|
||||||
|
|
||||||
import com.raytheon.uf.viz.archive.data.IArchiveTotals;
|
import com.raytheon.uf.common.archive.config.ArchiveConfig;
|
||||||
import com.raytheon.uf.viz.archive.ui.ArchiveTableComp.TableType;
|
import com.raytheon.uf.common.archive.config.ArchiveConfigManager;
|
||||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
import com.raytheon.uf.common.archive.config.CategoryConfig;
|
||||||
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Archive retention dialog.
|
* Archive retention dialog.
|
||||||
|
@ -46,22 +50,24 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* May 23, 2013 #1964 lvenable Initial creation
|
* May 23, 2013 #1964 lvenable Initial creation
|
||||||
|
* May 31, 2013 #1965 bgonzale Initial work for updating retention configurations.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author lvenable
|
* @author lvenable
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class ArchiveRetentionDlg extends CaveSWTDialog implements IArchiveTotals {
|
public class ArchiveRetentionDlg extends AbstractArchiveDlg {
|
||||||
|
|
||||||
/** Table composite that holds the table controls. */
|
private final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
private ArchiveTableComp tableComp;
|
.getHandler(ArchiveRetentionDlg.class);
|
||||||
|
|
||||||
/** Archive config combo box. */
|
private Spinner minRetentionSpnr;
|
||||||
private Combo archCfgCbo;
|
|
||||||
|
|
||||||
/** Category combo box. */
|
private Spinner extRetentionSpnr;
|
||||||
private Combo categoryCbo;
|
|
||||||
|
// TODO in the future, get this value from a user text box
|
||||||
|
protected static final String ARCHIVE_DIR = "/archive_dir";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -80,7 +86,6 @@ public class ArchiveRetentionDlg extends CaveSWTDialog implements IArchiveTotals
|
||||||
GridLayout mainLayout = new GridLayout(1, false);
|
GridLayout mainLayout = new GridLayout(1, false);
|
||||||
mainLayout.marginHeight = 2;
|
mainLayout.marginHeight = 2;
|
||||||
mainLayout.marginWidth = 2;
|
mainLayout.marginWidth = 2;
|
||||||
|
|
||||||
return mainLayout;
|
return mainLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +98,6 @@ public class ArchiveRetentionDlg extends CaveSWTDialog implements IArchiveTotals
|
||||||
gl.marginWidth = 0;
|
gl.marginWidth = 0;
|
||||||
gl.horizontalSpacing = 0;
|
gl.horizontalSpacing = 0;
|
||||||
mainComp.setLayout(gl);
|
mainComp.setLayout(gl);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,12 +106,9 @@ public class ArchiveRetentionDlg extends CaveSWTDialog implements IArchiveTotals
|
||||||
*/
|
*/
|
||||||
private void init() {
|
private void init() {
|
||||||
createRetentionControls();
|
createRetentionControls();
|
||||||
createTable();
|
|
||||||
addSeparator(shell, SWT.HORIZONTAL);
|
addSeparator(shell, SWT.HORIZONTAL);
|
||||||
createBottomActionButtons();
|
createBottomActionButtons();
|
||||||
|
selectionsUpdated();
|
||||||
// TODO : Remove this when functionality is implemented
|
|
||||||
populateComboBoxes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -123,42 +124,41 @@ public class ArchiveRetentionDlg extends CaveSWTDialog implements IArchiveTotals
|
||||||
/*
|
/*
|
||||||
* Top row of controls.
|
* Top row of controls.
|
||||||
*/
|
*/
|
||||||
Label archCfgLbl = new Label(retentionComp, SWT.NONE);
|
createComboControls(retentionComp);
|
||||||
archCfgLbl.setText("Archive Config: ");
|
|
||||||
|
|
||||||
gd = new GridData(200, SWT.DEFAULT);
|
// composite for retention time selection
|
||||||
archCfgCbo = new Combo(retentionComp, SWT.VERTICAL | SWT.DROP_DOWN
|
Composite selectionComp = new Composite(retentionComp, SWT.NONE);
|
||||||
| SWT.BORDER | SWT.READ_ONLY);
|
selectionComp.setLayout(new GridLayout(3, true));
|
||||||
archCfgCbo.setLayoutData(gd);
|
selectionComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true,
|
||||||
archCfgCbo.addSelectionListener(new SelectionAdapter() {
|
false));
|
||||||
@Override
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
/*
|
|
||||||
* TODO - add code to update the category combo box
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
gd = new GridData();
|
gd = new GridData();
|
||||||
gd.horizontalIndent = 20;
|
gd.horizontalIndent = 20;
|
||||||
Label minRetentionLbl = new Label(retentionComp, SWT.NONE);
|
Label minRetentionLbl = new Label(selectionComp, SWT.NONE);
|
||||||
minRetentionLbl.setText("Minimum Retention: ");
|
minRetentionLbl.setText("Minimum Retention: ");
|
||||||
minRetentionLbl.setLayoutData(gd);
|
minRetentionLbl.setLayoutData(gd);
|
||||||
|
|
||||||
gd = new GridData(60, SWT.DEFAULT);
|
gd = new GridData(60, SWT.DEFAULT);
|
||||||
final Spinner minRetentionSpnr = new Spinner(retentionComp, SWT.BORDER);
|
minRetentionSpnr = new Spinner(selectionComp, SWT.BORDER);
|
||||||
minRetentionSpnr.setIncrement(1);
|
minRetentionSpnr.setIncrement(1);
|
||||||
minRetentionSpnr.setPageIncrement(5);
|
minRetentionSpnr.setPageIncrement(5);
|
||||||
minRetentionSpnr.setMaximum(Integer.MAX_VALUE);
|
minRetentionSpnr.setMaximum(Integer.MAX_VALUE);
|
||||||
minRetentionSpnr.setMinimum(1);
|
minRetentionSpnr.setMinimum(1);
|
||||||
minRetentionSpnr.setLayoutData(gd);
|
minRetentionSpnr.setLayoutData(gd);
|
||||||
|
|
||||||
final Combo minRetentionCbo = new Combo(retentionComp, SWT.VERTICAL
|
final Combo minRetentionCbo = new Combo(selectionComp, SWT.VERTICAL
|
||||||
| SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
|
| SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
|
||||||
minRetentionCbo.addSelectionListener(new SelectionAdapter() {
|
minRetentionCbo.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
handleRetentionSelection(minRetentionCbo, minRetentionSpnr);
|
int retentionHours = handleRetentionSelection(minRetentionCbo,
|
||||||
|
minRetentionSpnr);
|
||||||
|
if (retentionHours != -1) {
|
||||||
|
ArchiveConfig archive = getSelectedArchive();
|
||||||
|
if (archive != null) {
|
||||||
|
archive.setRetentionHours(retentionHours);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
minRetentionCbo.add("Hours");
|
minRetentionCbo.add("Hours");
|
||||||
|
@ -170,42 +170,34 @@ public class ArchiveRetentionDlg extends CaveSWTDialog implements IArchiveTotals
|
||||||
/*
|
/*
|
||||||
* Bottom row of controls.
|
* Bottom row of controls.
|
||||||
*/
|
*/
|
||||||
Label catLbl = new Label(retentionComp, SWT.NONE);
|
|
||||||
catLbl.setText("Category: ");
|
|
||||||
|
|
||||||
gd = new GridData(200, SWT.DEFAULT);
|
|
||||||
categoryCbo = new Combo(retentionComp, SWT.VERTICAL | SWT.DROP_DOWN
|
|
||||||
| SWT.BORDER | SWT.READ_ONLY);
|
|
||||||
categoryCbo.setLayoutData(gd);
|
|
||||||
categoryCbo.addSelectionListener(new SelectionAdapter() {
|
|
||||||
@Override
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
/*
|
|
||||||
* TODO - add code to update the information in the table
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
gd = new GridData();
|
gd = new GridData();
|
||||||
gd.horizontalIndent = 20;
|
gd.horizontalIndent = 20;
|
||||||
Label extRetentionLbl = new Label(retentionComp, SWT.NONE);
|
Label extRetentionLbl = new Label(selectionComp, SWT.NONE);
|
||||||
extRetentionLbl.setText("Extended Retention: ");
|
extRetentionLbl.setText("Extended Retention: ");
|
||||||
extRetentionLbl.setLayoutData(gd);
|
extRetentionLbl.setLayoutData(gd);
|
||||||
|
|
||||||
gd = new GridData(60, SWT.DEFAULT);
|
gd = new GridData(60, SWT.DEFAULT);
|
||||||
final Spinner extRetentionSpnr = new Spinner(retentionComp, SWT.BORDER);
|
extRetentionSpnr = new Spinner(selectionComp, SWT.BORDER);
|
||||||
extRetentionSpnr.setIncrement(1);
|
extRetentionSpnr.setIncrement(1);
|
||||||
extRetentionSpnr.setPageIncrement(5);
|
extRetentionSpnr.setPageIncrement(5);
|
||||||
extRetentionSpnr.setMaximum(Integer.MAX_VALUE);
|
extRetentionSpnr.setMaximum(Integer.MAX_VALUE);
|
||||||
extRetentionSpnr.setMinimum(1);
|
extRetentionSpnr.setMinimum(1);
|
||||||
extRetentionSpnr.setLayoutData(gd);
|
extRetentionSpnr.setLayoutData(gd);
|
||||||
|
|
||||||
final Combo extRetentionCbo = new Combo(retentionComp, SWT.VERTICAL
|
final Combo extRetentionCbo = new Combo(selectionComp, SWT.VERTICAL
|
||||||
| SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
|
| SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
|
||||||
extRetentionCbo.addSelectionListener(new SelectionAdapter() {
|
extRetentionCbo.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
handleRetentionSelection(extRetentionCbo, extRetentionSpnr);
|
int retentionHours = handleRetentionSelection(extRetentionCbo,
|
||||||
|
extRetentionSpnr);
|
||||||
|
if (retentionHours != -1) {
|
||||||
|
CategoryConfig category = getSelectedCategory();
|
||||||
|
if (category != null) {
|
||||||
|
category.setRetentionHours(retentionHours);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
extRetentionCbo.add("Hours");
|
extRetentionCbo.add("Hours");
|
||||||
|
@ -215,13 +207,6 @@ public class ArchiveRetentionDlg extends CaveSWTDialog implements IArchiveTotals
|
||||||
.getSelectionIndex()));
|
.getSelectionIndex()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the table control.
|
|
||||||
*/
|
|
||||||
private void createTable() {
|
|
||||||
tableComp = new ArchiveTableComp(shell, TableType.Case, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the bottom action buttons.
|
* Create the bottom action buttons.
|
||||||
*/
|
*/
|
||||||
|
@ -239,6 +224,8 @@ public class ArchiveRetentionDlg extends CaveSWTDialog implements IArchiveTotals
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
// TODO : add calculate size functionality
|
// TODO : add calculate size functionality
|
||||||
|
// With Roger's automated size calculation code, this doesn't
|
||||||
|
// seem relevant unless it is for calculating compressed size
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -246,8 +233,12 @@ public class ArchiveRetentionDlg extends CaveSWTDialog implements IArchiveTotals
|
||||||
saveBtn.setText(" Save... ");
|
saveBtn.setText(" Save... ");
|
||||||
saveBtn.addSelectionListener(new SelectionAdapter() {
|
saveBtn.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent selectionEvent) {
|
||||||
// TODO : add save functionality
|
ArchiveConfigManager manager = ArchiveConfigManager
|
||||||
|
.getInstance();
|
||||||
|
// TODO
|
||||||
|
// List<DisplayData> allSelected = getAllSelected();
|
||||||
|
// manager.save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -270,12 +261,13 @@ public class ArchiveRetentionDlg extends CaveSWTDialog implements IArchiveTotals
|
||||||
* Retention combo box.
|
* Retention combo box.
|
||||||
* @param spinner
|
* @param spinner
|
||||||
* Retention spinner.
|
* Retention spinner.
|
||||||
|
* @return hours entered if changed; -1 if not changed
|
||||||
*/
|
*/
|
||||||
private void handleRetentionSelection(Combo comboBox, Spinner spinner) {
|
private int handleRetentionSelection(Combo comboBox, Spinner spinner) {
|
||||||
// If the selection didn't change then just return.
|
// If the selection didn't change then just return.
|
||||||
if (comboBox.getItem(comboBox.getSelectionIndex()).equals(
|
if (comboBox.getItem(comboBox.getSelectionIndex()).equals(
|
||||||
(String) comboBox.getData())) {
|
(String) comboBox.getData())) {
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int time = 0;
|
int time = 0;
|
||||||
|
@ -288,6 +280,7 @@ public class ArchiveRetentionDlg extends CaveSWTDialog implements IArchiveTotals
|
||||||
|
|
||||||
spinner.setSelection(time);
|
spinner.setSelection(time);
|
||||||
comboBox.setData(comboBox.getItem(comboBox.getSelectionIndex()));
|
comboBox.setData(comboBox.getItem(comboBox.getSelectionIndex()));
|
||||||
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -307,50 +300,48 @@ public class ArchiveRetentionDlg extends CaveSWTDialog implements IArchiveTotals
|
||||||
} else {
|
} else {
|
||||||
convertedTime = time / 24;
|
convertedTime = time / 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
return convertedTime;
|
return convertedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Add a separator line to the provided container.
|
protected void setTotalSizeText(String sizeStringText) {
|
||||||
*
|
// TODO Auto-generated method stub
|
||||||
* @param container
|
|
||||||
* Composite.
|
|
||||||
* @param orientation
|
|
||||||
* Vertical or horizontal orientation.
|
|
||||||
*/
|
|
||||||
private void addSeparator(Composite container, int orientation) {
|
|
||||||
// Separator label
|
|
||||||
GridData gd;
|
|
||||||
|
|
||||||
if (orientation == SWT.HORIZONTAL) {
|
|
||||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
|
||||||
} else {
|
|
||||||
gd = new GridData(SWT.DEFAULT, SWT.FILL, false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Label sepLbl = new Label(container, SWT.SEPARATOR | orientation);
|
|
||||||
sepLbl.setLayoutData(gd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************
|
/*
|
||||||
* TEST METHODS - to be removed when functionality is implemented.
|
* (non-Javadoc)
|
||||||
* ******************************************************
|
*
|
||||||
|
* @see com.raytheon.uf.viz.archive.ui.AbstractArchiveDlg#getStart()
|
||||||
*/
|
*/
|
||||||
private void populateComboBoxes() {
|
@Override
|
||||||
archCfgCbo.add("Raw");
|
protected Calendar getStart() {
|
||||||
archCfgCbo.add("Processed");
|
// display all elements so no start bound
|
||||||
archCfgCbo.select(0);
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
categoryCbo.add("Radar");
|
/*
|
||||||
categoryCbo.add("Point");
|
* (non-Javadoc)
|
||||||
categoryCbo.add("Satellite");
|
*
|
||||||
categoryCbo.select(0);
|
* @see com.raytheon.uf.viz.archive.ui.AbstractArchiveDlg#getEnd()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Calendar getEnd() {
|
||||||
|
// display all elements so no end bound
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTotalSelectedItems() {
|
protected void selectionsUpdated() {
|
||||||
// TODO Auto-generated method stub
|
ArchiveConfig archive = getSelectedArchive();
|
||||||
return 0;
|
if (archive != null) {
|
||||||
|
if (minRetentionSpnr != null) {
|
||||||
|
minRetentionSpnr.setSelection(archive.getRetentionHours());
|
||||||
|
CategoryConfig category = getSelectedCategory();
|
||||||
|
if (category != null) {
|
||||||
|
extRetentionSpnr.setSelection(category.getRetentionHours());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
4
edexOsgi/com.raytheon.uf.common.archive/build.properties
Normal file
4
edexOsgi/com.raytheon.uf.common.archive/build.properties
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
source.. = src/
|
||||||
|
output.. = bin/
|
||||||
|
bin.includes = META-INF/,\
|
||||||
|
.,\
|
|
@ -56,6 +56,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* May 1, 2013 1966 rferrel Initial creation
|
* May 1, 2013 1966 rferrel Initial creation
|
||||||
|
* May 31, 2013 1965 bgonzale Added getCategory(categoryName)
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -168,6 +169,19 @@ public class ArchiveConfig implements Comparable<ArchiveConfig> {
|
||||||
return new ArrayList<CategoryConfig>(categoryList);
|
return new ArrayList<CategoryConfig>(categoryList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param categoryName
|
||||||
|
* @return The named CategoryConfig; null if not found
|
||||||
|
*/
|
||||||
|
public CategoryConfig getCategory(String categoryName) {
|
||||||
|
for (CategoryConfig category : categoryList) {
|
||||||
|
if (category.getName().equals(categoryName)) {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the category list.
|
* Set the category list.
|
||||||
*
|
*
|
||||||
|
|
|
@ -67,7 +67,7 @@ import com.raytheon.uf.common.util.FileUtil;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* May 1, 2013 1966 rferrel Initial creation
|
* May 1, 2013 1966 rferrel Initial creation
|
||||||
* May 29, 2013 1965 bgonzale Added archive creation method and purge.
|
* May 29, 2013 1965 bgonzale Added archive creation, purge, and save methods.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -84,6 +84,8 @@ public class ArchiveConfigManager {
|
||||||
|
|
||||||
private IPathManager pathMgr;
|
private IPathManager pathMgr;
|
||||||
|
|
||||||
|
private final Map<String, LocalizationFile> archiveNameToLocalizationFileMap = new HashMap<String, LocalizationFile>();
|
||||||
|
|
||||||
private final Map<String, ArchiveConfig> archiveMap = new HashMap<String, ArchiveConfig>();
|
private final Map<String, ArchiveConfig> archiveMap = new HashMap<String, ArchiveConfig>();
|
||||||
|
|
||||||
public final static ArchiveConfigManager getInstance() {
|
public final static ArchiveConfigManager getInstance() {
|
||||||
|
@ -175,12 +177,9 @@ public class ArchiveConfigManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an archive in the given archive directory from the Files filtered
|
* Create an archive in the given archive directory from the Files filtered
|
||||||
* by the given Archive out of the ArchiveElements.
|
* by the ArchiveElements that are within the start and end time frame
|
||||||
|
* parameters.
|
||||||
*
|
*
|
||||||
* @param archive
|
|
||||||
* Archive configuration to create Archive from
|
|
||||||
* @param category
|
|
||||||
* Archive Category configuration
|
|
||||||
* @param archiveDir
|
* @param archiveDir
|
||||||
* Destination directory of the Archive
|
* Destination directory of the Archive
|
||||||
* @param displaysSelectedForArchive
|
* @param displaysSelectedForArchive
|
||||||
|
@ -193,52 +192,48 @@ public class ArchiveConfigManager {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ArchiveException
|
* @throws ArchiveException
|
||||||
*/
|
*/
|
||||||
public Collection<File> createArchive(ArchiveConfig archive,
|
public Collection<File> createArchive(File archiveDir,
|
||||||
CategoryConfig category, File archiveDir,
|
Collection<DisplayData> displaysSelectedForArchive, Calendar start,
|
||||||
Collection<String> displaysSelectedForArchive, Calendar start,
|
|
||||||
Calendar end) throws IOException, ArchiveException {
|
Calendar end) throws IOException, ArchiveException {
|
||||||
Collection<File> archivedFiles = null;
|
Collection<File> archivedFiles = null;
|
||||||
if (archiveDir.exists() || archiveDir.mkdirs()) {
|
FileUtils.forceMkdir(archiveDir);
|
||||||
|
if (archiveDir.exists()) {
|
||||||
Collection<File> filesToArchive = new ArrayList<File>();
|
Collection<File> filesToArchive = new ArrayList<File>();
|
||||||
|
|
||||||
// TODO Brad will fix.
|
for (DisplayData display : displaysSelectedForArchive) {
|
||||||
// for (String displayLabel : displaysSelectedForArchive) {
|
List<File> files = getDisplayFiles(display, start, end);
|
||||||
// File[] files = getDisplayFiles(archive.getName(),
|
filesToArchive.addAll(files);
|
||||||
// category.getName(), displayLabel, start, end);
|
String rootDirString = display.archiveConfig.getRootDir();
|
||||||
// filesToArchive.addAll(Arrays.asList(files));
|
String archiveDirString = archiveDir.getAbsolutePath();
|
||||||
// }
|
|
||||||
|
|
||||||
String rootDirString = archive.getRootDir();
|
archivedFiles = new ArrayList<File>(filesToArchive.size());
|
||||||
String archiveDirString = archiveDir.getAbsolutePath();
|
rootDirString = (rootDirString.endsWith(File.separator) ? rootDirString
|
||||||
|
.substring(0,
|
||||||
|
rootDirString.lastIndexOf(File.separatorChar))
|
||||||
|
: rootDirString);
|
||||||
|
for (File srcFile : filesToArchive) {
|
||||||
|
String fileAbsPath = srcFile.getAbsolutePath();
|
||||||
|
File newArchiveDir = getDirRelativeToArchiveDirFromRoot(
|
||||||
|
srcFile.isDirectory(), fileAbsPath, rootDirString,
|
||||||
|
archiveDirString);
|
||||||
|
FileUtils.forceMkdir(newArchiveDir);
|
||||||
|
|
||||||
archivedFiles = new ArrayList<File>(filesToArchive.size());
|
if (srcFile.isDirectory()) {
|
||||||
rootDirString = (rootDirString.endsWith(File.separator) ? rootDirString
|
FileUtils.copyDirectory(srcFile, newArchiveDir);
|
||||||
.substring(0, rootDirString.lastIndexOf(File.separatorChar))
|
archivedFiles.addAll(Arrays.asList(newArchiveDir
|
||||||
: rootDirString);
|
.listFiles()));
|
||||||
for (File srcFile : filesToArchive) {
|
} else {
|
||||||
String fileAbsPath = srcFile.getAbsolutePath();
|
FileUtils.copyFileToDirectory(srcFile, newArchiveDir);
|
||||||
File newArchiveDir = getDirRelativeToArchiveDirFromRoot(
|
String filename = FilenameUtils.getName(fileAbsPath);
|
||||||
srcFile.isDirectory(), fileAbsPath, rootDirString,
|
File dstFile = new File(newArchiveDir, filename);
|
||||||
archiveDirString);
|
archivedFiles.add(dstFile);
|
||||||
FileUtils.forceMkdir(newArchiveDir);
|
}
|
||||||
|
|
||||||
if (srcFile.isDirectory()) {
|
|
||||||
FileUtils.copyDirectory(srcFile, newArchiveDir);
|
|
||||||
archivedFiles.addAll(Arrays.asList(newArchiveDir
|
|
||||||
.listFiles()));
|
|
||||||
} else {
|
|
||||||
FileUtils.copyFileToDirectory(srcFile, newArchiveDir);
|
|
||||||
String filename = FilenameUtils.getName(fileAbsPath);
|
|
||||||
File dstFile = new File(newArchiveDir, filename);
|
|
||||||
archivedFiles.add(dstFile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
StringBuilder sbuff = new StringBuilder(
|
StringBuilder sbuff = new StringBuilder(
|
||||||
"Failed to create archive for Archive: ");
|
"Failed to create archive in: ");
|
||||||
sbuff.append(archive);
|
sbuff.append(archiveDir);
|
||||||
sbuff.append(" and Category: ");
|
|
||||||
sbuff.append(category);
|
|
||||||
throw new ArchiveException(sbuff.toString());
|
throw new ArchiveException(sbuff.toString());
|
||||||
}
|
}
|
||||||
return archivedFiles;
|
return archivedFiles;
|
||||||
|
@ -270,22 +265,21 @@ public class ArchiveConfigManager {
|
||||||
for (CategoryConfig category : archive.getCategoryList()) {
|
for (CategoryConfig category : archive.getCategoryList()) {
|
||||||
Calendar purgeTime = calculateExpiration(archive, category);
|
Calendar purgeTime = calculateExpiration(archive, category);
|
||||||
|
|
||||||
// TODO Brad will fix.
|
for (DisplayData display : getDisplayInfo(archive.getName(),
|
||||||
// for (String displayLabel : getDisplayLabels(archive.getName(),
|
category.getName())) {
|
||||||
// category.getName())) {
|
List<File> displayFiles = getDisplayFiles(display, null,
|
||||||
// File[] displayFiles = getDisplayFiles(archive.getName(),
|
purgeTime);
|
||||||
// category.getName(), displayLabel, null, purgeTime);
|
for (File file : displayFiles) {
|
||||||
// for (File file : displayFiles) {
|
if (file.isFile()) {
|
||||||
// if (file.isFile()) {
|
filesPurged.add(file);
|
||||||
// filesPurged.add(file);
|
} else if (file.isDirectory()) {
|
||||||
// } else if (file.isDirectory()) {
|
filesPurged.addAll(FileUtils.listFiles(file,
|
||||||
// filesPurged.addAll(FileUtils.listFiles(file,
|
FileFilterUtils.fileFileFilter(),
|
||||||
// FileFilterUtils.fileFileFilter(),
|
FileFilterUtils.trueFileFilter()));
|
||||||
// FileFilterUtils.trueFileFilter()));
|
}
|
||||||
// }
|
FileUtils.deleteQuietly(file);
|
||||||
// FileUtils.deleteQuietly(file);
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
return filesPurged;
|
return filesPurged;
|
||||||
}
|
}
|
||||||
|
@ -334,11 +328,13 @@ public class ArchiveConfigManager {
|
||||||
*/
|
*/
|
||||||
public void reset() {
|
public void reset() {
|
||||||
archiveMap.clear();
|
archiveMap.clear();
|
||||||
|
archiveNameToLocalizationFileMap.clear();
|
||||||
LocalizationFile[] files = getArchiveConfigFiles();
|
LocalizationFile[] files = getArchiveConfigFiles();
|
||||||
for (LocalizationFile lFile : files) {
|
for (LocalizationFile lFile : files) {
|
||||||
try {
|
try {
|
||||||
ArchiveConfig archiveConfig;
|
ArchiveConfig archiveConfig = unmarshalArhiveConfigFromXmlFile(lFile);
|
||||||
archiveConfig = unmarshalArhiveConfigFromXmlFile(lFile);
|
archiveNameToLocalizationFileMap.put(archiveConfig.getName(),
|
||||||
|
lFile);
|
||||||
archiveMap.put(archiveConfig.getName(), archiveConfig);
|
archiveMap.put(archiveConfig.getName(), archiveConfig);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
|
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
|
||||||
|
@ -350,6 +346,18 @@ public class ArchiveConfigManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save the cached configuration.
|
||||||
|
*/
|
||||||
|
public void save() {
|
||||||
|
for (String archiveName : archiveMap.keySet()) {
|
||||||
|
ArchiveConfig archiveConfig = archiveMap.get(archiveName);
|
||||||
|
LocalizationFile lFile = archiveNameToLocalizationFileMap
|
||||||
|
.get(archiveName);
|
||||||
|
saveArchiveConfig(lFile, archiveConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of directories/files for the desired display label bounded by
|
* Get a list of directories/files for the desired display label bounded by
|
||||||
* the start and end time inclusive.
|
* the start and end time inclusive.
|
||||||
|
@ -719,4 +727,5 @@ public class ArchiveConfigManager {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
17
edexOsgi/com.raytheon.uf.edex.archive.feature/.project
Normal file
17
edexOsgi/com.raytheon.uf.edex.archive.feature/.project
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>com.raytheon.uf.edex.archive.feature</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.pde.FeatureBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.pde.FeatureNature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -0,0 +1 @@
|
||||||
|
bin.includes = feature.xml
|
40
edexOsgi/com.raytheon.uf.edex.archive.feature/feature.xml
Normal file
40
edexOsgi/com.raytheon.uf.edex.archive.feature/feature.xml
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<feature
|
||||||
|
id="com.raytheon.uf.edex.archive.feature"
|
||||||
|
label="Archive Edex feature"
|
||||||
|
version="1.0.0.qualifier"
|
||||||
|
provider-name="RAYTHEON">
|
||||||
|
|
||||||
|
<description url="http://www.example.com/description">
|
||||||
|
[Enter Feature Description here.]
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<copyright url="http://www.example.com/copyright">
|
||||||
|
[Enter Copyright Description here.]
|
||||||
|
</copyright>
|
||||||
|
|
||||||
|
<license url="http://www.example.com/license">
|
||||||
|
[Enter License Description here.]
|
||||||
|
</license>
|
||||||
|
|
||||||
|
<plugin
|
||||||
|
id="com.raytheon.uf.common.archive"
|
||||||
|
download-size="0"
|
||||||
|
install-size="0"
|
||||||
|
version="0.0.0"
|
||||||
|
unpack="false"/>
|
||||||
|
|
||||||
|
<plugin
|
||||||
|
id="com.raytheon.uf.edex.archive"
|
||||||
|
download-size="0"
|
||||||
|
install-size="0"
|
||||||
|
version="0.0.0"
|
||||||
|
unpack="false"/>
|
||||||
|
|
||||||
|
<plugin
|
||||||
|
id="org.apache.commons.io"
|
||||||
|
download-size="0"
|
||||||
|
install-size="0"
|
||||||
|
version="0.0.0"/>
|
||||||
|
|
||||||
|
</feature>
|
5
edexOsgi/com.raytheon.uf.edex.archive/build.properties
Normal file
5
edexOsgi/com.raytheon.uf.edex.archive/build.properties
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
source.. = src/
|
||||||
|
output.. = bin/
|
||||||
|
bin.includes = META-INF/,\
|
||||||
|
.,\
|
||||||
|
res/
|
|
@ -43,6 +43,7 @@ import org.junit.Test;
|
||||||
|
|
||||||
import com.raytheon.uf.common.archive.config.ArchiveConfig;
|
import com.raytheon.uf.common.archive.config.ArchiveConfig;
|
||||||
import com.raytheon.uf.common.archive.config.ArchiveConfigManager;
|
import com.raytheon.uf.common.archive.config.ArchiveConfigManager;
|
||||||
|
import com.raytheon.uf.common.archive.config.ArchiveConfigManager.DisplayData;
|
||||||
import com.raytheon.uf.common.archive.config.CategoryConfig;
|
import com.raytheon.uf.common.archive.config.CategoryConfig;
|
||||||
import com.raytheon.uf.common.archive.exception.ArchiveException;
|
import com.raytheon.uf.common.archive.exception.ArchiveException;
|
||||||
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
||||||
|
@ -73,6 +74,8 @@ public class ArchiveConfigManagerTest {
|
||||||
|
|
||||||
private static final String SAT_CAT_NAME = "Satellite";
|
private static final String SAT_CAT_NAME = "Satellite";
|
||||||
|
|
||||||
|
private static final String satNameForArchive = "GOES-13";
|
||||||
|
|
||||||
private static File TEST_DIR = TestUtil
|
private static File TEST_DIR = TestUtil
|
||||||
.setupTestClassDir(ArchiveConfigManagerTest.class);
|
.setupTestClassDir(ArchiveConfigManagerTest.class);
|
||||||
|
|
||||||
|
@ -100,8 +103,6 @@ public class ArchiveConfigManagerTest {
|
||||||
|
|
||||||
private Calendar archiveEnd;
|
private Calendar archiveEnd;
|
||||||
|
|
||||||
private List<String> selectedForArchive;
|
|
||||||
|
|
||||||
private File archiveDir;
|
private File archiveDir;
|
||||||
|
|
||||||
private static String TEST_ARCHIVE_DIR = "testArchiveDir";
|
private static String TEST_ARCHIVE_DIR = "testArchiveDir";
|
||||||
|
@ -148,9 +149,6 @@ public class ArchiveConfigManagerTest {
|
||||||
CategoryConfig grib1Cat = getCategory(archive, "Model grib");
|
CategoryConfig grib1Cat = getCategory(archive, "Model grib");
|
||||||
createTestFiles(grib1Format, getRetentionHours(archive, grib1Cat),
|
createTestFiles(grib1Format, getRetentionHours(archive, grib1Cat),
|
||||||
false, archiveStart, archiveEnd);
|
false, archiveStart, archiveEnd);
|
||||||
// manager is not configured internally until this is called...
|
|
||||||
// TODO Brad will fix.
|
|
||||||
// manager.getDisplayLabels(archive.getName(), grib1Cat.getName());
|
|
||||||
|
|
||||||
// **** sat ****
|
// **** sat ****
|
||||||
CategoryConfig satCat = getCategory(archive, SAT_CAT_NAME);
|
CategoryConfig satCat = getCategory(archive, SAT_CAT_NAME);
|
||||||
|
@ -158,9 +156,6 @@ public class ArchiveConfigManagerTest {
|
||||||
"/sat/{0}{1}/{2}/GOES-13/{2}{3}Z_SOUND-VIS_10km_EAST-CONUS-TIGE59_KNES_128453.satz.{0}{1}{2}");
|
"/sat/{0}{1}/{2}/GOES-13/{2}{3}Z_SOUND-VIS_10km_EAST-CONUS-TIGE59_KNES_128453.satz.{0}{1}{2}");
|
||||||
createTestFiles(satFormat, getRetentionHours(archive, satCat), true,
|
createTestFiles(satFormat, getRetentionHours(archive, satCat), true,
|
||||||
archiveStart, archiveEnd);
|
archiveStart, archiveEnd);
|
||||||
// manager is not configured internally until this is called...
|
|
||||||
// TODO Brad will fix.
|
|
||||||
// manager.getDisplayLabels(archive.getName(), satCat.getName());
|
|
||||||
|
|
||||||
// **** acars ****
|
// **** acars ****
|
||||||
CategoryConfig otherCat = getCategory(archive, "Model other");
|
CategoryConfig otherCat = getCategory(archive, "Model other");
|
||||||
|
@ -181,16 +176,9 @@ public class ArchiveConfigManagerTest {
|
||||||
"/bufrsigwx/{0}{1}/{2}/JUWE96_KKCI_{1}{2}{3}_31368878.bufr.{0}{1}{2}");
|
"/bufrsigwx/{0}{1}/{2}/JUWE96_KKCI_{1}{2}{3}_31368878.bufr.{0}{1}{2}");
|
||||||
createTestFiles(bufrsigwxFormat, otherCatRetentionHours, false,
|
createTestFiles(bufrsigwxFormat, otherCatRetentionHours, false,
|
||||||
archiveStart, archiveEnd);
|
archiveStart, archiveEnd);
|
||||||
// manager is not configured internally until this is called...
|
|
||||||
// TODO Brad will fix.
|
|
||||||
// manager.getDisplayLabels(archive.getName(), otherCat.getName());
|
|
||||||
|
|
||||||
// create test archive data dir
|
// create test archive data dir
|
||||||
archiveDir = new File(TEST_DIR, TEST_ARCHIVE_DIR);
|
archiveDir = new File(TEST_DIR, TEST_ARCHIVE_DIR);
|
||||||
// create archive elements for selected list
|
|
||||||
selectedForArchive = new ArrayList<String>();
|
|
||||||
selectedForArchive.add("GOES-13");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getRetentionHours(ArchiveConfig archive, CategoryConfig category) {
|
private int getRetentionHours(ArchiveConfig archive, CategoryConfig category) {
|
||||||
|
@ -305,9 +293,16 @@ public class ArchiveConfigManagerTest {
|
||||||
public void testArchiveManagerCreateArchive() throws IOException,
|
public void testArchiveManagerCreateArchive() throws IOException,
|
||||||
ArchiveException {
|
ArchiveException {
|
||||||
CategoryConfig satCategory = getCategory(archive, SAT_CAT_NAME);
|
CategoryConfig satCategory = getCategory(archive, SAT_CAT_NAME);
|
||||||
Collection<File> archivedFiles = manager.createArchive(archive,
|
List<DisplayData> displays =
|
||||||
satCategory, archiveDir, selectedForArchive, archiveStart,
|
manager.getDisplayInfo(archive.getName(), satCategory.getName());
|
||||||
archiveEnd);
|
List<DisplayData> selectedDisplays = new ArrayList<ArchiveConfigManager.DisplayData>();
|
||||||
|
for (DisplayData displayData : displays) {
|
||||||
|
if (displayData.getDisplayLabel().equals(satNameForArchive)) {
|
||||||
|
selectedDisplays.add(displayData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collection<File> archivedFiles = manager.createArchive(archiveDir,
|
||||||
|
selectedDisplays, archiveStart, archiveEnd);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"The expected archive files and the archived files are not the same",
|
"The expected archive files and the archived files are not the same",
|
||||||
createFileNameListNoRootDir(new File(archive.getRootDir()),
|
createFileNameListNoRootDir(new File(archive.getRootDir()),
|
||||||
|
|
Loading…
Add table
Reference in a new issue