Issue #1966 Changes to make manger stateless and updates for Case Creation.

Change-Id: I62118209fad2a28d6dd3cac4abf7bb86cc782387

Former-commit-id: 3f43fdc896ff616915a8aa5ef986d3a82e52aa51
This commit is contained in:
Roger Ferrel 2013-05-30 12:38:35 -05:00
parent e4578ca7ba
commit 3c875a6f44
17 changed files with 964 additions and 286 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<feature <feature
id="com.raytheon.uf.viz.archive.feature" id="com.raytheon.uf.viz.archive.feature"
label="Feature" label="CAVE Archive Feature"
version="1.0.0.qualifier" version="1.0.0.qualifier"
provider-name="RAYTHEON"> provider-name="RAYTHEON">
@ -36,4 +36,11 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="com.raytheon.uf.common.archive"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature> </feature>

View file

@ -12,6 +12,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.8.2",
com.raytheon.uf.common.localization;bundle-version="1.12.1174", com.raytheon.uf.common.localization;bundle-version="1.12.1174",
com.raytheon.uf.common.archive;bundle-version="1.0.0", com.raytheon.uf.common.archive;bundle-version="1.0.0",
com.raytheon.uf.common.time;bundle-version="1.12.1174", com.raytheon.uf.common.time;bundle-version="1.12.1174",
com.raytheon.uf.common.util;bundle-version="1.12.1174" com.raytheon.uf.common.util;bundle-version="1.12.1174",
com.raytheon.uf.viz.core;bundle-version="1.12.1174",
com.raytheon.uf.common.units;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy

View file

@ -0,0 +1,62 @@
/**
* 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.data;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* This class maintains the state of the archive selection so it can be restored
* by the GUI.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 24, 2013 1966 rferrel Initial creation
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class ArchiveInfo {
private final Map<String, CategoryInfo> categoryInfoMap = new HashMap<String, CategoryInfo>();
public void add(CategoryInfo categoryInfo) {
categoryInfoMap.put(categoryInfo.getCategoryName(), categoryInfo);
}
public CategoryInfo get(String categoryName) {
return categoryInfoMap.get(categoryName);
}
public void clear() {
categoryInfoMap.clear();
}
public Set<String> getCategoryNames() {
return categoryInfoMap.keySet();
}
}

View file

@ -0,0 +1,69 @@
/**
* 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.data;
import java.util.List;
import com.raytheon.uf.common.archive.config.ArchiveConfigManager;
/**
* This class used to maintain the state of a category so it can be restored
* when reselected.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 24, 2013 1966 rferrel Initial creation
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class CategoryInfo {
private final String archiveName;
private final String categoryName;
private final List<ArchiveConfigManager.DisplayData> displayInfoList;
public CategoryInfo(String archiveName, String categoryName,
List<ArchiveConfigManager.DisplayData> displayInfoList) {
this.archiveName = archiveName;
this.categoryName = categoryName;
this.displayInfoList = displayInfoList;
}
public String getArchiveName() {
return archiveName;
}
public String getCategoryName() {
return categoryName;
}
public List<ArchiveConfigManager.DisplayData> getDisplayInfoList() {
return displayInfoList;
}
}

View file

@ -0,0 +1,186 @@
/**
* 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.data;
import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import com.raytheon.uf.common.archive.config.ArchiveConfigManager;
import com.raytheon.uf.common.archive.config.ArchiveConfigManager.DisplayData;
import com.raytheon.uf.common.util.FileUtil;
/**
* This class uses a obtains information on a File in a Job in order to remove
* from the UI thread.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 15, 2013 1966 rferrel Initial creation
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class DirInfo {
private static final SizeJob sizeJob = new DirInfo.SizeJob();
final private DisplayData displayInfo;
private final List<File> files = new ArrayList<File>();
private Calendar startCal;
private Calendar endCal;
public static void clearQueue() {
sizeJob.clearQueue();
}
public static void addUpdateListener(IUpdateListener listener) {
sizeJob.listeners.add(listener);
}
public static void removeUpdateListener(IUpdateListener listener) {
sizeJob.listeners.remove(listener);
}
public DirInfo(DisplayData displayInfo, Calendar startCal, Calendar endCal) {
this.displayInfo = displayInfo;
this.startCal = startCal;
this.endCal = endCal;
displayInfo.setSize(-1);
DirInfo.sizeJob.queue(this);
}
public DisplayData getDisplayInfo() {
return displayInfo;
}
static private class SizeJob extends Job {
private LinkedList<DirInfo> queueList = new LinkedList<DirInfo>();
private boolean isShutdown = false;
List<IUpdateListener> listeners = new ArrayList<IUpdateListener>();
protected void queue(DirInfo fileInfo) {
synchronized (queueList) {
queueList.add(fileInfo);
if (getState() == Job.NONE) {
System.out.println("schedule queue size: "
+ queueList.size());
schedule();
}
}
}
protected void clearQueue() {
synchronized (queueList) {
queueList.clear();
if (getState() != Job.NONE) {
isShutdown = true;
}
}
}
public SizeJob() {
super("Size Job");
setSystem(true);
}
@Override
protected IStatus run(IProgressMonitor monitor) {
ArchiveConfigManager manager = ArchiveConfigManager.getInstance();
System.out.println("starting SizeJob");
long startTime = System.currentTimeMillis();
while (!isShutdown && !queueList.isEmpty()) {
List<DirInfo> list = null;
synchronized (queueList) {
list = new ArrayList<DirInfo>(queueList);
queueList.clear();
}
System.out.println("sizeJob Processing: " + list.size());
long t1 = System.currentTimeMillis();
for (DirInfo dirInfo : list) {
long t2 = System.currentTimeMillis();
if (isShutdown) {
break;
}
DisplayData displayInfo = dirInfo.displayInfo;
Calendar startCal = dirInfo.startCal;
Calendar endCal = dirInfo.endCal;
displayInfo.setSize(-1);
List<File> files = manager.getDisplayFiles(displayInfo,
startCal, endCal);
dirInfo.files.clear();
dirInfo.files.addAll(files);
long size = 0L;
for (File file : dirInfo.files) {
if (isShutdown) {
break;
}
if (file.isDirectory()) {
size += FileUtil.sizeOfDirectory(file);
} else {
size += file.length();
}
}
long t3 = System.currentTimeMillis();
System.out.println("-- \"" + displayInfo.getDisplayLabel()
+ "\": oldSize: " + displayInfo.getSize()
+ ", newSize: " + size + ", time: " + (t3 - t2)
+ " ms");
displayInfo.setSize(size);
}
if (!isShutdown) {
for (IUpdateListener listener : listeners) {
listener.update(list);
}
} else {
synchronized (queueList) {
isShutdown = false;
}
}
}
System.out.println("Ending SizeJob");
return Status.OK_STATUS;
}
}
}

View file

@ -33,7 +33,7 @@ import com.raytheon.uf.common.util.FileUtil;
/** /**
* This class uses a obtains information on a File in a Job in order to remove * This class uses a obtains information on a File in a Job in order to remove
* from the UI thread. * from the UI thread. Use DirInfo instead.
* *
* <pre> * <pre>
* *
@ -48,7 +48,7 @@ import com.raytheon.uf.common.util.FileUtil;
* @author rferrel * @author rferrel
* @version 1.0 * @version 1.0
*/ */
@Deprecated
public class FileInfo { public class FileInfo {
private static final SizeJob sizeJob = new FileInfo.SizeJob(); private static final SizeJob sizeJob = new FileInfo.SizeJob();
@ -103,7 +103,7 @@ public class FileInfo {
} }
for (IUpdateListener listener : listeners) { for (IUpdateListener listener : listeners) {
listener.update(list); // listener.update(list);
} }
} }

View file

@ -0,0 +1,46 @@
/**
* 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.data;
/**
* Interface for methods for getting totals needed by the ArchiveTableComp.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 29, 2013 1996 rferrel Initial creation
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
public interface IArchiveTotals {
/**
* Total selected items from all tables.
*
* @return totalSelectedItems.
*/
public int getTotalSelectedItems();
}

View file

@ -19,6 +19,8 @@
**/ **/
package com.raytheon.uf.viz.archive.data; package com.raytheon.uf.viz.archive.data;
import java.util.List;
/** /**
* A listener to update file/directory information. * A listener to update file/directory information.
* *
@ -35,12 +37,11 @@ package com.raytheon.uf.viz.archive.data;
* @author rferrel * @author rferrel
* @version 1.0 * @version 1.0
*/ */
public interface IUpdateListener { public interface IUpdateListener {
/** /**
* List of files/directories with updated information * Table display state entries with updated information.
* *
* @param fileInfoArray * @param dirInfos
*/ */
public void update(FileInfo[] fileInfoArray); public void update(List<DirInfo> dirInfos);
} }

View file

@ -32,6 +32,7 @@ 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.viz.archive.ui.ArchiveTableComp.TableType; import com.raytheon.uf.viz.archive.ui.ArchiveTableComp.TableType;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog; import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
@ -51,7 +52,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @author lvenable * @author lvenable
* @version 1.0 * @version 1.0
*/ */
public class ArchiveRetentionDlg extends CaveSWTDialog { public class ArchiveRetentionDlg extends CaveSWTDialog implements IArchiveTotals {
/** Table composite that holds the table controls. */ /** Table composite that holds the table controls. */
private ArchiveTableComp tableComp; private ArchiveTableComp tableComp;
@ -218,7 +219,7 @@ public class ArchiveRetentionDlg extends CaveSWTDialog {
* Create the table control. * Create the table control.
*/ */
private void createTable() { private void createTable() {
tableComp = new ArchiveTableComp(shell, TableType.Case); tableComp = new ArchiveTableComp(shell, TableType.Case, this);
} }
/** /**
@ -346,4 +347,10 @@ public class ArchiveRetentionDlg extends CaveSWTDialog {
categoryCbo.add("Satellite"); categoryCbo.add("Satellite");
categoryCbo.select(0); categoryCbo.select(0);
} }
@Override
public int getTotalSelectedItems() {
// TODO Auto-generated method stub
return 0;
}
} }

View file

@ -19,6 +19,8 @@
**/ **/
package com.raytheon.uf.viz.archive.ui; package com.raytheon.uf.viz.archive.ui;
import java.util.List;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseEvent;
@ -35,6 +37,10 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.TableItem;
import com.raytheon.uf.common.archive.config.ArchiveConfigManager.DisplayData;
import com.raytheon.uf.common.util.SizeUtil;
import com.raytheon.uf.viz.archive.data.IArchiveTotals;
/** /**
* Archive table composite that contains the SWT table. * Archive table composite that contains the SWT table.
* *
@ -53,6 +59,9 @@ import org.eclipse.swt.widgets.TableItem;
*/ */
public class ArchiveTableComp extends Composite { public class ArchiveTableComp extends Composite {
/** Key for getting Display Information state. */
private final String DISPLAY_INFO_KEY = "displayInfo";
/** Table control. */ /** Table control. */
private Table table; private Table table;
@ -62,6 +71,9 @@ public class ArchiveTableComp extends Composite {
/** Number of selected items label. */ /** Number of selected items label. */
private Label selectedLbl; private Label selectedLbl;
/** Total selected items for all tables */
private Label totalSelectedLbl;
/** Size label. */ /** Size label. */
private Label sizeLbl; private Label sizeLbl;
@ -73,6 +85,8 @@ public class ArchiveTableComp extends Composite {
/** Current table type. */ /** Current table type. */
private TableType tableType = TableType.Retention; private TableType tableType = TableType.Retention;
private IArchiveTotals iTotalSelectedSize;
/** /**
* Constructor. * Constructor.
* *
@ -81,10 +95,12 @@ public class ArchiveTableComp extends Composite {
* @param type * @param type
* Table type. * Table type.
*/ */
public ArchiveTableComp(Composite parent, TableType type) { public ArchiveTableComp(Composite parent, TableType type,
IArchiveTotals iTotalSelectedSize) {
super(parent, 0); super(parent, 0);
tableType = type; tableType = type;
this.iTotalSelectedSize = iTotalSelectedSize;
init(); init();
} }
@ -103,41 +119,35 @@ public class ArchiveTableComp extends Composite {
createTable(); createTable();
createTableLabels(); createTableLabels();
updateSelectionLabel(); updateSelectionLabels();
} }
/** /**
* Create the table control. * Create the table control.
*/ */
private void createTable() { private void createTable() {
GridData gd = null;
table = new Table(this, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL table = new Table(this, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL
| SWT.H_SCROLL | SWT.MULTI); | SWT.H_SCROLL | SWT.MULTI);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, true); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, true);
gd.widthHint = 730; gd.widthHint = 730;
gd.heightHint = 270; gd.heightHint = 270;
table.setLayoutData(gd); table.setLayoutData(gd);
table.setHeaderVisible(true); table.setHeaderVisible(true);
table.setLinesVisible(true); table.setLinesVisible(true);
TableColumn pathColumn = new TableColumn(table, SWT.CENTER); TableColumn pathColumn = new TableColumn(table, SWT.LEFT);
pathColumn.setText("Path"); pathColumn.setText("Label");
TableColumn sizeColumn = new TableColumn(table, SWT.CENTER); TableColumn sizeColumn = new TableColumn(table, SWT.CENTER);
if (tableType == TableType.Retention) { if (tableType == TableType.Retention) {
sizeColumn.setText("Current Size (MB)"); sizeColumn.setText("Current Size");
} else if (tableType == TableType.Case) { } else if (tableType == TableType.Case) {
sizeColumn.setText("Size (MB)"); sizeColumn.setText("Size");
} }
populateTable(); table.getColumn(0).setWidth(500);
for (int i = 0; i < 2; i++) {
table.getColumn(i).setResizable(false);
table.getColumn(i).setMoveable(false);
table.getColumn(i).pack();
}
table.getColumn(1).setWidth(100);
table.addMouseListener(new MouseAdapter() { table.addMouseListener(new MouseAdapter() {
@Override @Override
@ -152,7 +162,7 @@ public class ArchiveTableComp extends Composite {
table.addSelectionListener(new SelectionAdapter() { table.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
updateSelectionLabel(); updateSelectionLabels();
} }
}); });
} }
@ -162,7 +172,7 @@ public class ArchiveTableComp extends Composite {
*/ */
private void createTableLabels() { private void createTableLabels() {
Composite lblComp = new Composite(this, SWT.NONE); Composite lblComp = new Composite(this, SWT.NONE);
GridLayout gl = new GridLayout(2, true); GridLayout gl = new GridLayout(3, true);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
lblComp.setLayout(gl); lblComp.setLayout(gl);
lblComp.setLayoutData(gd); lblComp.setLayoutData(gd);
@ -171,30 +181,51 @@ public class ArchiveTableComp extends Composite {
selectedLbl = new Label(lblComp, SWT.NONE); selectedLbl = new Label(lblComp, SWT.NONE);
selectedLbl.setLayoutData(gd); selectedLbl.setLayoutData(gd);
/* gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
* TODO : keep for future use. This will be used to show the total size sizeLbl = new Label(lblComp, SWT.NONE);
* of the selected items in the table. sizeLbl.setLayoutData(gd);
*/
// gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
// sizeLbl = new Label(lblComp, SWT.NONE); totalSelectedLbl = new Label(lblComp, SWT.NONE);
// sizeLbl.setLayoutData(gd); totalSelectedLbl.setLayoutData(gd);
// sizeLbl.setText("Size of Selected items: 0" + sizeSuffix);
} }
/** /**
* Update the selection items label. * Update the selection items labels.
*/ */
private void updateSelectionLabel() { private void updateSelectionLabels() {
TableItem[] itemArray = table.getItems(); TableItem[] itemArray = table.getItems();
int count = 0; int count = 0;
long tableTotalSize = 0;
for (TableItem ti : itemArray) { for (TableItem ti : itemArray) {
DisplayData displayInfo = (DisplayData) ti
.getData(DISPLAY_INFO_KEY);
if (ti.getChecked()) { if (ti.getChecked()) {
count++; ++count;
displayInfo.setSelected(true);
if (tableTotalSize >= 0) {
long diSize = displayInfo.getSize();
if (diSize < 0) {
tableTotalSize = diSize;
} else {
tableTotalSize += diSize;
}
}
} else {
displayInfo.setSelected(false);
} }
} }
selectedLbl.setText("Selected Items: " + count); selectedLbl.setText("Table Selected Items: " + count);
int totalSelectedSize = iTotalSelectedSize.getTotalSelectedItems();
totalSelectedLbl.setText("Total Selected Items: " + totalSelectedSize);
String sizeString = "????";
if (tableTotalSize >= 0) {
sizeString = SizeUtil.prettyByteSize(tableTotalSize);
}
sizeLbl.setText("Table Selected Size: " + sizeString);
} }
/** /**
@ -260,12 +291,12 @@ public class ArchiveTableComp extends Composite {
*/ */
private void handleCheckSelectedRow(boolean check) { private void handleCheckSelectedRow(boolean check) {
TableItem[] itemArray = table.getSelection(); TableItem[] itemArray = table.getSelection();
System.out.println("handleCheckSelectedRow: " + check);
for (TableItem ti : itemArray) { for (TableItem ti : itemArray) {
ti.setChecked(check); ti.setChecked(check);
} }
updateSelectionLabel(); updateSelectionLabels();
} }
/** /**
@ -281,23 +312,51 @@ public class ArchiveTableComp extends Composite {
ti.setChecked(check); ti.setChecked(check);
} }
updateSelectionLabel(); updateSelectionLabels();
}
public void updateSize(List<DisplayData> displayInfos) {
TableItem[] itemArray = table.getItems();
for (DisplayData displayInfo : displayInfos) {
for (TableItem ti : itemArray) {
if (displayInfo.equals(ti.getData(DISPLAY_INFO_KEY))) {
setItemSize(ti);
}
}
}
} }
/* /*
* TODO : this is just for display purposes. This will go away when the * TODO : this is just for display purposes. This will go away when the
* functionality is implemented. * functionality is implemented.
*/ */
private void populateTable() { protected void populateTable(List<DisplayData> displayInfoArray) {
for (int i = 0; i < 150; i++) { table.removeAll();
for (DisplayData displayInfo : displayInfoArray) {
TableItem item = new TableItem(table, SWT.NONE); TableItem item = new TableItem(table, SWT.NONE);
item.setText(0, item.setData(DISPLAY_INFO_KEY, displayInfo);
"/home/lvenable/caveData/configuration/base/com.raytheon.uf.viz.gisdatastore/" item.setChecked(displayInfo.isSelected());
+ i + " "); item.setText(0, displayInfo.getDisplayLabel());
if (i % 5 == 0) {
item.setChecked(true); item.setChecked(displayInfo.isSelected());
} setItemSize(item);
item.setText(1, "?????"); }
for (int i = 0; i < 2; i++) {
table.getColumn(i).setResizable(false);
table.getColumn(i).setMoveable(false);
table.getColumn(i).pack();
}
table.getColumn(0).setWidth(600);
updateSelectionLabels();
}
private void setItemSize(TableItem item) {
long size = ((DisplayData) item.getData(DISPLAY_INFO_KEY)).getSize();
if (size < 0L) {
item.setText(1, "????");
} else {
item.setText(1, SizeUtil.prettyByteSize(size));
} }
} }
} }

View file

@ -19,12 +19,20 @@
**/ **/
package com.raytheon.uf.viz.archive.ui; package com.raytheon.uf.viz.archive.ui;
import java.io.File;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
@ -33,14 +41,24 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.MessageBox;
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.common.archive.config.ArchiveConfigManager;
import com.raytheon.uf.common.archive.config.ArchiveConfigManager.DisplayData;
import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.common.time.util.TimeUtil;
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.data.IUpdateListener;
import com.raytheon.uf.viz.archive.ui.ArchiveTableComp.TableType; import com.raytheon.uf.viz.archive.ui.ArchiveTableComp.TableType;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.viz.ui.dialogs.AwipsCalendar; import com.raytheon.viz.ui.dialogs.AwipsCalendar;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog; import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
@ -61,7 +79,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @author lvenable * @author lvenable
* @version 1.0 * @version 1.0
*/ */
public class CaseCreationDlg extends CaveSWTDialog { public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
IUpdateListener {
/** Table control */ /** Table control */
private ArchiveTableComp tableComp; private ArchiveTableComp tableComp;
@ -102,6 +121,9 @@ public class CaseCreationDlg extends CaveSWTDialog {
/** Directory location label. */ /** Directory location label. */
private Label locationLbl; private Label locationLbl;
/** Directory location state. */
private Label locationStateLbl;
/** Uncompressed file size label. */ /** Uncompressed file size label. */
private Label uncompressSizeLbl; private Label uncompressSizeLbl;
@ -109,6 +131,14 @@ public class CaseCreationDlg extends CaveSWTDialog {
private SimpleDateFormat dateFmt = new SimpleDateFormat( private SimpleDateFormat dateFmt = new SimpleDateFormat(
"E MMM dd yyyy HH:00 z"); "E MMM dd yyyy HH:00 z");
/** Archive configuration manager */
private ArchiveConfigManager manager = ArchiveConfigManager.getInstance();
/** Information for populating the various table displays. */
private final Map<String, ArchiveInfo> archiveInfoMap = new HashMap<String, ArchiveInfo>();
private Cursor busyCursor;
/** /**
* Constructor. * Constructor.
* *
@ -132,7 +162,8 @@ public class CaseCreationDlg extends CaveSWTDialog {
@Override @Override
protected void initializeComponents(Shell shell) { protected void initializeComponents(Shell shell) {
setText("Case Creation"); busyCursor = shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
setText("Archive Case Creation");
Composite mainComp = new Composite(shell, SWT.NONE); Composite mainComp = new Composite(shell, SWT.NONE);
GridLayout gl = new GridLayout(1, false); GridLayout gl = new GridLayout(1, false);
gl.marginHeight = 0; gl.marginHeight = 0;
@ -140,14 +171,21 @@ public class CaseCreationDlg extends CaveSWTDialog {
gl.horizontalSpacing = 0; gl.horizontalSpacing = 0;
mainComp.setLayout(gl); mainComp.setLayout(gl);
manager.reset();
init(); init();
} }
@Override
protected void disposed() {
DirInfo.removeUpdateListener(this);
}
/** /**
* Initialize method to create all of the composite & controls. * Initialize method to create all of the composite & controls.
*/ */
private void init() { private void init() {
DirInfo.addUpdateListener(this);
createTimeControls(); createTimeControls();
addSeparator(shell, SWT.HORIZONTAL); addSeparator(shell, SWT.HORIZONTAL);
createCaseCompressionControls(); createCaseCompressionControls();
@ -199,9 +237,10 @@ public class CaseCreationDlg extends CaveSWTDialog {
endTimeLbl = new Label(timeComp, SWT.BORDER); endTimeLbl = new Label(timeComp, SWT.BORDER);
endTimeLbl.setLayoutData(gd); endTimeLbl.setLayoutData(gd);
Date date = TimeUtil.newDate(); endDate = TimeUtil.newDate();
startDate = date; long time = endDate.getTime();
endDate = date; time -= TimeUtil.MILLIS_PER_DAY;
startDate = new Date(time);
startTimeLbl.setText(dateFmt.format(startDate)); startTimeLbl.setText(dateFmt.format(startDate));
endTimeLbl.setText(dateFmt.format(endDate)); endTimeLbl.setText(dateFmt.format(endDate));
} }
@ -244,9 +283,9 @@ public class CaseCreationDlg extends CaveSWTDialog {
archCfgCbo.addSelectionListener(new SelectionAdapter() { archCfgCbo.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
/* String archiveName = archCfgCbo.getItem(archCfgCbo
* TODO - add code to update the category combo box .getSelectionIndex());
*/ populateCategoryCbo(archiveName);
} }
}); });
@ -260,9 +299,11 @@ public class CaseCreationDlg extends CaveSWTDialog {
categoryCbo.addSelectionListener(new SelectionAdapter() { categoryCbo.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
/* String archiveName = archCfgCbo.getItem(archCfgCbo
* TODO - add code to update the information in the table .getSelectionIndex());
*/ String categoryName = categoryCbo.getItem(categoryCbo
.getSelectionIndex());
populateTableComp(archiveName, categoryName);
} }
}); });
} }
@ -294,9 +335,9 @@ public class CaseCreationDlg extends CaveSWTDialog {
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
uncompressSizeLbl = new Label(compressionLblComp, SWT.NONE); uncompressSizeLbl = new Label(compressionLblComp, SWT.NONE);
uncompressSizeLbl.setText("1024 MB"); // uncompressSizeLbl.setText("1024 MB");
uncompressSizeLbl.setLayoutData(gd); uncompressSizeLbl.setLayoutData(gd);
updateUncompressSizeLbl();
/* /*
* Compression controls * Compression controls
*/ */
@ -358,7 +399,7 @@ public class CaseCreationDlg extends CaveSWTDialog {
*/ */
private void createFileBrowserControls() { private void createFileBrowserControls() {
Composite fileBrowserComp = new Composite(shell, SWT.NONE); Composite fileBrowserComp = new Composite(shell, SWT.NONE);
GridLayout gl = new GridLayout(4, false); GridLayout gl = new GridLayout(6, false);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
fileBrowserComp.setLayout(gl); fileBrowserComp.setLayout(gl);
fileBrowserComp.setLayoutData(gd); fileBrowserComp.setLayoutData(gd);
@ -378,13 +419,20 @@ public class CaseCreationDlg extends CaveSWTDialog {
handleBrowserSelection(); handleBrowserSelection();
} }
}); });
Label stateLbl = new Label(fileBrowserComp, SWT.NONE);
stateLbl.setText("Full - Avaliable:");
locationStateLbl = new Label(fileBrowserComp, SWT.BORDER);
gd = new GridData(200, SWT.DEFAULT);
locationStateLbl.setLayoutData(gd);
} }
/** /**
* Create the table control. * Create the table control.
*/ */
private void createTable() { private void createTable() {
tableComp = new ArchiveTableComp(shell, TableType.Case); tableComp = new ArchiveTableComp(shell, TableType.Case, this);
} }
/** /**
@ -494,6 +542,38 @@ public class CaseCreationDlg extends CaveSWTDialog {
locationLbl.setText(trimDirectoryName(dirName)); locationLbl.setText(trimDirectoryName(dirName));
locationLbl.setToolTipText(dirName); locationLbl.setToolTipText(dirName);
locationLbl.setData(dirName); locationLbl.setData(dirName);
File dir = new File(dirName);
long totSpace = dir.getTotalSpace();
long freeSpace = dir.getUsableSpace();
long percentFull = (long) Math
.round(((totSpace - freeSpace) * 100.0) / totSpace);
String state = null;
Color bgColor = null;
Color fgColor = null;
Display display = shell.getDisplay();
if (percentFull <= 84) {
state = "GOOD";
bgColor = display.getSystemColor(SWT.COLOR_GREEN);
fgColor = display.getSystemColor(SWT.COLOR_BLACK);
} else if (percentFull <= 94) {
state = "CAUTION";
bgColor = display.getSystemColor(SWT.COLOR_YELLOW);
fgColor = display.getSystemColor(SWT.COLOR_BLACK);
} else if (percentFull <= 97) {
state = "DANGER";
bgColor = display.getSystemColor(SWT.COLOR_RED);
fgColor = display.getSystemColor(SWT.COLOR_BLACK);
} else {
state = "FATAL";
bgColor = display.getSystemColor(SWT.COLOR_DARK_MAGENTA);
fgColor = display.getSystemColor(SWT.COLOR_WHITE);
}
String text = String.format("%1$3d%% %2$s - %3$s", percentFull,
state, SizeUtil.prettyByteSize(freeSpace));
locationStateLbl.setText(text);
locationStateLbl.setBackground(bgColor);
locationStateLbl.setForeground(fgColor);
} }
} }
@ -526,9 +606,16 @@ public class CaseCreationDlg extends CaveSWTDialog {
* True for start time, false for end time. * True for start time, false for end time.
*/ */
private void displayDateTimeControls(boolean startTimeFlag) { private void displayDateTimeControls(boolean startTimeFlag) {
AwipsCalendar ac = new AwipsCalendar(shell, 1);
Date acDate = startTimeFlag ? startDate : endDate;
AwipsCalendar ac = new AwipsCalendar(shell, acDate, 1);
ac.setTimeZone(TimeUtil.newCalendar().getTimeZone());
Date date = (Date) ac.open(); Date date = (Date) ac.open();
if (date == null) {
return;
}
if (startTimeFlag) { if (startTimeFlag) {
if (date.after(endDate)) { if (date.after(endDate)) {
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION
@ -538,6 +625,12 @@ public class CaseCreationDlg extends CaveSWTDialog {
mb.open(); mb.open();
return; return;
} }
if (!startDate.equals(date)) {
startDate = date;
// TODO update all information not just the current table.
populateTableComp();
}
} else { } else {
if (date.before(startDate)) { if (date.before(startDate)) {
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION
@ -547,6 +640,11 @@ public class CaseCreationDlg extends CaveSWTDialog {
mb.open(); mb.open();
return; return;
} }
if (!endDate.equals(date)) {
endDate = date;
// TODO update all information not just the current table.
populateTableComp();
}
} }
if (startTimeFlag) { if (startTimeFlag) {
@ -587,18 +685,21 @@ public class CaseCreationDlg extends CaveSWTDialog {
return str; return str;
} }
/******************************************************** /**
* TEST METHODS ****************************************************** * Initial set up of the combo boxes.
*/ */
private void populateComboBoxes() { private void populateComboBoxes() {
archCfgCbo.add("Raw"); boolean doSelect = false;
archCfgCbo.add("Processed"); for (String archiveName : manager.getArchiveDataNamesList()) {
archCfgCbo.select(0); archCfgCbo.add(archiveName);
doSelect = true;
}
categoryCbo.add("Radar"); if (doSelect) {
categoryCbo.add("Point"); archCfgCbo.select(0);
categoryCbo.add("Satellite"); String archiveName = archCfgCbo.getItem(0);
categoryCbo.select(0); populateCategoryCbo(archiveName);
}
fileSizeCbo.add("MB"); fileSizeCbo.add("MB");
fileSizeCbo.add("GB"); fileSizeCbo.add("GB");
@ -606,4 +707,130 @@ public class CaseCreationDlg extends CaveSWTDialog {
fileSizeCbo fileSizeCbo
.setData(fileSizeCbo.getItem(fileSizeCbo.getSelectionIndex())); .setData(fileSizeCbo.getItem(fileSizeCbo.getSelectionIndex()));
} }
/**
* Populate the category combo based on the archive name and populate the
* table.
*
* @param archiveName
*/
private void populateCategoryCbo(String archiveName) {
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 = archCfgCbo.getItem(archCfgCbo.getSelectionIndex());
String categoryName = categoryCbo.getItem(categoryCbo
.getSelectionIndex());
populateTableComp(archiveName, categoryName);
}
private void populateTableComp(String archiveName, String categoryName) {
setBusy(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) {
List<DisplayData> displayInfos = manager.getDisplayInfo(
archiveName, categoryName);
categoryInfo = new CategoryInfo(archiveName, categoryName,
displayInfos);
archiveInfo.add(categoryInfo);
}
// TODO investigate using just Date or long values for start/end
Calendar startCal = TimeUtil.newCalendar();
startCal.setTimeInMillis(startDate.getTime());
Calendar endCal = TimeUtil.newCalendar();
endCal.setTimeInMillis(endDate.getTime());
for (DisplayData displayInfo : categoryInfo.getDisplayInfoList()) {
new DirInfo(displayInfo, startCal, endCal);
}
tableComp.populateTable(categoryInfo.getDisplayInfoList());
updateUncompressSizeLbl();
setBusy(false);
}
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;
}
}
}
}
updateUncompressSizeLbl();
return totalSelected;
}
private void setBusy(boolean state) {
Cursor cursor = null;
if (state) {
cursor = busyCursor;
}
shell.setCursor(cursor);
}
@Override
public void update(List<DirInfo> dirInfos) {
final List<DisplayData> displayInfos = new ArrayList<ArchiveConfigManager.DisplayData>();
for (DirInfo dirInfo : dirInfos) {
displayInfos.add(dirInfo.getDisplayInfo());
}
VizApp.runAsync(new Runnable() {
@Override
public void run() {
tableComp.updateSize(displayInfos);
updateUncompressSizeLbl();
}
});
}
/**
* Updates the estimated uncompressed size of selected entries.
*/
private void updateUncompressSizeLbl() {
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.
uncompressSizeLbl.setText("????MB");
return;
} else {
totalSize += size;
}
}
}
}
}
uncompressSizeLbl.setText(SizeUtil.prettyByteSize(totalSize));
}
} }

View file

@ -19,6 +19,7 @@
**/ **/
package com.raytheon.uf.common.archive.config; package com.raytheon.uf.common.archive.config;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -128,11 +129,16 @@ public class ArchiveConfig implements Comparable<ArchiveConfig> {
/** /**
* Set the fully qualified name of the directory all components are relative * Set the fully qualified name of the directory all components are relative
* to.
* *
* @param rootDir * @param rootDir
*/ */
public void setRootDir(String rootDir) { public void setRootDir(String rootDir) {
this.rootDir = rootDir; if (rootDir != null && !rootDir.endsWith(File.separator)) {
this.rootDir = rootDir + File.separator;
} else {
this.rootDir = rootDir;
}
} }
/** /**

View file

@ -22,8 +22,6 @@ package com.raytheon.uf.common.archive.config;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.FieldPosition; import java.text.FieldPosition;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -49,6 +47,8 @@ import org.apache.commons.io.filefilter.RegexFileFilter;
import com.raytheon.uf.common.archive.exception.ArchiveException; import com.raytheon.uf.common.archive.exception.ArchiveException;
import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.LocalizationFileInputStream;
import com.raytheon.uf.common.localization.LocalizationFileOutputStream;
import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.localization.exception.LocalizationException;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
@ -86,8 +86,6 @@ public class ArchiveConfigManager {
private final Map<String, ArchiveConfig> archiveMap = new HashMap<String, ArchiveConfig>(); private final Map<String, ArchiveConfig> archiveMap = new HashMap<String, ArchiveConfig>();
private Map<ArchiveConfig, Map<CategoryConfig, Map<String, List<File>>>> displayDirMap = new HashMap<ArchiveConfig, Map<CategoryConfig, Map<String, List<File>>>>();
public final static ArchiveConfigManager getInstance() { public final static ArchiveConfigManager getInstance() {
return instance; return instance;
} }
@ -128,7 +126,7 @@ public class ArchiveConfigManager {
} }
/** /**
* Obtain the names of the categories for the named archive data. * Get a sorted array of the archive's categories.
* *
* @param archiveConfigName * @param archiveConfigName
* @return categoryNames * @return categoryNames
@ -138,8 +136,10 @@ public class ArchiveConfigManager {
} }
/** /**
* Get a sorted array of the archive's categories.
*
* @param archiveConfig * @param archiveConfig
* @return * @return categoryNames
*/ */
public String[] getCategoryNames(ArchiveConfig archiveConfig) { public String[] getCategoryNames(ArchiveConfig archiveConfig) {
List<CategoryConfig> categories = archiveConfig.getCategoryList(); List<CategoryConfig> categories = archiveConfig.getCategoryList();
@ -154,7 +154,7 @@ public class ArchiveConfigManager {
} }
/** /**
* Load the archiveConfig information form the localized file. * Load the archiveConfig information from the localized file.
* *
* @param lFile * @param lFile
* @return archiveConfig * @return archiveConfig
@ -201,11 +201,12 @@ public class ArchiveConfigManager {
if (archiveDir.exists() || archiveDir.mkdirs()) { if (archiveDir.exists() || archiveDir.mkdirs()) {
Collection<File> filesToArchive = new ArrayList<File>(); Collection<File> filesToArchive = new ArrayList<File>();
for (String displayLabel : displaysSelectedForArchive) { // TODO Brad will fix.
File[] files = getDisplayFiles(archive.getName(), // for (String displayLabel : displaysSelectedForArchive) {
category.getName(), displayLabel, start, end); // File[] files = getDisplayFiles(archive.getName(),
filesToArchive.addAll(Arrays.asList(files)); // category.getName(), displayLabel, start, end);
} // filesToArchive.addAll(Arrays.asList(files));
// }
String rootDirString = archive.getRootDir(); String rootDirString = archive.getRootDir();
String archiveDirString = archiveDir.getAbsolutePath(); String archiveDirString = archiveDir.getAbsolutePath();
@ -244,8 +245,7 @@ public class ArchiveConfigManager {
} }
private File getDirRelativeToArchiveDirFromRoot(boolean fileIsDir, private File getDirRelativeToArchiveDirFromRoot(boolean fileIsDir,
String fileAbsPath, String fileAbsPath, String rootDirString, String archiveDirString) {
String rootDirString, String archiveDirString) {
String path = null; String path = null;
if (fileIsDir) { if (fileIsDir) {
path = fileAbsPath; path = fileAbsPath;
@ -270,21 +270,22 @@ public class ArchiveConfigManager {
for (CategoryConfig category : archive.getCategoryList()) { for (CategoryConfig category : archive.getCategoryList()) {
Calendar purgeTime = calculateExpiration(archive, category); Calendar purgeTime = calculateExpiration(archive, category);
for (String displayLabel : getDisplayLabels(archive.getName(), // TODO Brad will fix.
category.getName())) { // for (String displayLabel : getDisplayLabels(archive.getName(),
File[] displayFiles = getDisplayFiles(archive.getName(), // category.getName())) {
category.getName(), displayLabel, null, purgeTime); // File[] displayFiles = getDisplayFiles(archive.getName(),
for (File file : displayFiles) { // category.getName(), displayLabel, null, purgeTime);
if (file.isFile()) { // for (File file : displayFiles) {
filesPurged.add(file); // if (file.isFile()) {
} else if (file.isDirectory()) { // filesPurged.add(file);
filesPurged.addAll(FileUtils.listFiles(file, // } else if (file.isDirectory()) {
FileFilterUtils.fileFileFilter(), // filesPurged.addAll(FileUtils.listFiles(file,
FileFilterUtils.trueFileFilter())); // FileFilterUtils.fileFileFilter(),
} // FileFilterUtils.trueFileFilter()));
FileUtils.deleteQuietly(file); // }
} // FileUtils.deleteQuietly(file);
} // }
// }
} }
return filesPurged; return filesPurged;
} }
@ -325,99 +326,26 @@ public class ArchiveConfigManager {
} }
} }
/**
* Add the file entry to the desired display map.
*
* @param file
* @param archiveConfig
* @param categoryConfig
* @param displayLabel
*/
private void addDirToDisplayMap(File file, ArchiveConfig archiveConfig,
CategoryConfig categoryConfig, String displayLabel) {
Map<CategoryConfig, Map<String, List<File>>> cMap = displayDirMap
.get(archiveConfig);
if (cMap == null) {
cMap = new HashMap<CategoryConfig, Map<String, List<File>>>();
displayDirMap.put(archiveConfig, cMap);
}
Map<String, List<File>> dirMap = cMap.get(categoryConfig);
if (dirMap == null) {
dirMap = new HashMap<String, List<File>>();
cMap.put(categoryConfig, dirMap);
}
List<File> fileList = dirMap.get(displayLabel);
if (fileList == null) {
fileList = new ArrayList<File>();
dirMap.put(displayLabel, fileList);
}
fileList.add(file);
}
/**
* Get a list of directories associated with the display label.
*
* @param archiveConfig
* @param categoryConfig
* @param displayLabel
* @return
*/
private File[] getDirFromDisplayMap(ArchiveConfig archiveConfig,
CategoryConfig categoryConfig, String displayLabel) {
Map<CategoryConfig, Map<String, List<File>>> cMap = displayDirMap
.get(archiveConfig);
File[] result = new File[0];
if (cMap == null) {
return result;
}
Map<String, List<File>> dirMap = cMap.get(categoryConfig);
if (dirMap == null) {
return result;
}
List<File> fileList = dirMap.get(displayLabel);
if (fileList == null) {
return result;
}
return fileList.toArray(result);
}
/** /**
* Clear maps and reloads the maps from the configuration information. * Clear maps and reloads the maps from the configuration information.
* *
* @throws IOException * @throws IOException
* @throws LocalizationException * @throws LocalizationException
*/ */
public void reset() throws IOException, LocalizationException { public void reset() {
clearDisplayMap();
archiveMap.clear(); archiveMap.clear();
LocalizationFile[] files = getArchiveConfigFiles(); LocalizationFile[] files = getArchiveConfigFiles();
for (LocalizationFile lFile : files) { for (LocalizationFile lFile : files) {
ArchiveConfig archiveConfig = unmarshalArhiveConfigFromXmlFile(lFile); try {
archiveMap.put(archiveConfig.getName(), archiveConfig); ArchiveConfig archiveConfig;
} archiveConfig = unmarshalArhiveConfigFromXmlFile(lFile);
} archiveMap.put(archiveConfig.getName(), archiveConfig);
} catch (IOException e) {
/** statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
* Walk the display directory maps clearing all entries. e);
*/ } catch (LocalizationException e) {
private void clearDisplayMap() { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
for (ArchiveConfig archiveConfig : displayDirMap.keySet()) { e);
Map<CategoryConfig, Map<String, List<File>>> cMap = displayDirMap
.get(archiveConfig);
for (CategoryConfig categoryConfig : cMap.keySet()) {
Map<String, List<File>> dirMap = cMap.get(categoryConfig);
dirMap.remove(categoryConfig);
for (String displayLabel : dirMap.keySet()) {
List<File> fileList = dirMap.get(displayLabel);
fileList.clear();
}
dirMap.clear();
} }
} }
} }
@ -426,20 +354,13 @@ public class ArchiveConfigManager {
* 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.
* *
* @param archiveName * @param displayInfo
* - name of the ArchiveConfig containing the category
* @param categoryName
* - name of the CategoryConfig containing the display
* @param displayLabel
* - the display label
* @param startCal * @param startCal
* - Start time if null epoch time is used
* @param endCal * @param endCal
* - End time if null current simulated time is used.
* @return files * @return files
*/ */
public File[] getDisplayFiles(String archiveName, String categoryName, public List<File> getDisplayFiles(DisplayData displayInfo,
String displayLabel, Calendar startCal, Calendar endCal) { Calendar startCal, Calendar endCal) {
long startTime = 0L; long startTime = 0L;
if (startCal != null) { if (startCal != null) {
// Set to beginning of the hour // Set to beginning of the hour
@ -464,8 +385,7 @@ public class ArchiveConfigManager {
cal.add(Calendar.HOUR_OF_DAY, 1); cal.add(Calendar.HOUR_OF_DAY, 1);
long endTime = cal.getTimeInMillis(); long endTime = cal.getTimeInMillis();
return getDisplayFiles(archiveName, categoryName, displayLabel, return getDisplayFiles(displayInfo, startTime, endTime);
startTime, endTime);
} }
/** /**
@ -476,10 +396,8 @@ public class ArchiveConfigManager {
* @param displayLabel * @param displayLabel
* @return files * @return files
*/ */
public File[] getDisplayFiles(String archiveName, String categoryName, public List<File> getDisplayFiles(DisplayData displayInfo) {
String displayLabel) { return getDisplayFiles(displayInfo, null, null);
return getDisplayFiles(archiveName, categoryName, displayLabel, null,
null);
} }
/** /**
@ -493,11 +411,10 @@ public class ArchiveConfigManager {
* @param endTime * @param endTime
* @return files * @return files
*/ */
private File[] getDisplayFiles(String archiveName, String categoryName, private List<File> getDisplayFiles(DisplayData displayInfo, long startTime,
String displayLabel, long startTime, long endTime) { long endTime) {
ArchiveConfig archiveConfig = archiveMap.get(archiveName); ArchiveConfig archiveConfig = displayInfo.archiveConfig;
CategoryConfig categoryConfig = findCategory(archiveConfig, CategoryConfig categoryConfig = displayInfo.categoryConfig;
categoryName);
String[] indexValues = categoryConfig.getDateGroupIndices().split( String[] indexValues = categoryConfig.getDateGroupIndices().split(
"\\s*,\\s*"); "\\s*,\\s*");
@ -511,8 +428,7 @@ public class ArchiveConfigManager {
boolean dirOnly = (filePatternStr == null) boolean dirOnly = (filePatternStr == null)
|| ".*".equals(filePatternStr); || ".*".equals(filePatternStr);
File dirs[] = getDirFromDisplayMap(archiveConfig, categoryConfig, List<File> dirs = displayInfo.dirs;
displayLabel);
int beginIndex = archiveConfig.getRootDir().length(); int beginIndex = archiveConfig.getRootDir().length();
@ -573,23 +489,19 @@ public class ArchiveConfigManager {
} }
} }
File[] files = fileList.toArray(new File[0]); return fileList;
return files;
} }
/** /**
* Get the Display labels matching the pattern for the archive data's * Get a list of directories matching the categories directory pattern that
* category. Assumes the archive data's root directory is the mount point to * are sub-directories of the archive's root directory.
* start the search.
* *
* @param archiveName * @param archiveConfig
* @param categoryName * @param categoryConfig
* @return sorted array of display labels * @return dirs
*/ */
public String[] getDisplayLabels(String archiveName, String categoryName) { private List<File> getDirs(ArchiveConfig archiveConfig,
ArchiveConfig archiveConfig = archiveMap.get(archiveName); CategoryConfig categoryConfig) {
CategoryConfig categoryConfig = findCategory(archiveConfig,
categoryName);
String dirPattern = categoryConfig.getDirPattern(); String dirPattern = categoryConfig.getDirPattern();
File rootFile = new File(archiveConfig.getRootDir()); File rootFile = new File(archiveConfig.getRootDir());
@ -618,8 +530,31 @@ public class ArchiveConfigManager {
tmpDirs = swpDirs; tmpDirs = swpDirs;
tmpDirs.clear(); tmpDirs.clear();
} }
return dirs;
}
/**
* Get the Display labels matching the pattern for the archive data's
* category. Assumes the archive data's root directory is the mount point to
* start the search.
*
* @param archiveName
* @param categoryName
* @return displayInfoList order by display label
*/
public List<DisplayData> getDisplayInfo(String archiveName,
String categoryName) {
Map<String, List<File>> displayMap = new HashMap<String, List<File>>();
ArchiveConfig archiveConfig = archiveMap.get(archiveName);
CategoryConfig categoryConfig = findCategory(archiveConfig,
categoryName);
String dirPattern = categoryConfig.getDirPattern();
// index for making directory paths' relative to the root path. // index for making directory paths' relative to the root path.
List<File> dirs = getDirs(archiveConfig, categoryConfig);
File rootFile = new File(archiveMap.get(archiveName).getRootDir());
int beginIndex = rootFile.getAbsolutePath().length() + 1; int beginIndex = rootFile.getAbsolutePath().length() + 1;
Pattern pattern = Pattern.compile("^" + dirPattern + "$"); Pattern pattern = Pattern.compile("^" + dirPattern + "$");
TreeSet<String> displays = new TreeSet<String>( TreeSet<String> displays = new TreeSet<String>(
@ -629,8 +564,8 @@ public class ArchiveConfigManager {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
FieldPosition pos0 = new FieldPosition(0); FieldPosition pos0 = new FieldPosition(0);
for (File file : dirs) { for (File dir : dirs) {
String path = file.getAbsolutePath().substring(beginIndex); String path = dir.getAbsolutePath().substring(beginIndex);
Matcher matcher = pattern.matcher(path); Matcher matcher = pattern.matcher(path);
if (matcher.matches()) { if (matcher.matches()) {
sb.setLength(0); sb.setLength(0);
@ -640,13 +575,25 @@ public class ArchiveConfigManager {
args[i] = matcher.group(i); args[i] = matcher.group(i);
} }
String displayLabel = msgfmt.format(args, sb, pos0).toString(); String displayLabel = msgfmt.format(args, sb, pos0).toString();
addDirToDisplayMap(file, archiveConfig, categoryConfig, List<File> displayDirs = displayMap.get(displayLabel);
displayLabel); if (displayDirs == null) {
displayDirs = new ArrayList<File>();
displayMap.put(displayLabel, displayDirs);
}
displayDirs.add(dir);
displays.add(displayLabel); displays.add(displayLabel);
} }
} }
return displays.toArray(new String[0]); List<DisplayData> displayInfoList = new ArrayList<ArchiveConfigManager.DisplayData>();
for (String displayLabel : displays) {
DisplayData displayInfo = new DisplayData(archiveConfig,
categoryConfig, displayLabel, displayMap.get(displayLabel));
displayInfoList.add(displayInfo);
}
return displayInfoList;
} }
/** /**
@ -654,7 +601,7 @@ public class ArchiveConfigManager {
* *
* @param archiveConfig * @param archiveConfig
* @param categoryName * @param categoryName
* @return * @return categoryConfig
*/ */
private CategoryConfig findCategory(ArchiveConfig archiveConfig, private CategoryConfig findCategory(ArchiveConfig archiveConfig,
String categoryName) { String categoryName) {
@ -677,11 +624,10 @@ public class ArchiveConfigManager {
*/ */
private void marshalArchiveConfigToXmlFile(ArchiveConfig archiveConfig, private void marshalArchiveConfigToXmlFile(ArchiveConfig archiveConfig,
LocalizationFile lFile) throws IOException, LocalizationException { LocalizationFile lFile) throws IOException, LocalizationException {
OutputStream stream = null; LocalizationFileOutputStream stream = null;
stream = lFile.openOutputStream(); stream = lFile.openOutputStream();
JAXB.marshal(archiveConfig, stream); JAXB.marshal(archiveConfig, stream);
stream.close(); stream.closeAndSave();
lFile.save();
} }
/** /**
@ -696,7 +642,7 @@ public class ArchiveConfigManager {
private ArchiveConfig unmarshalArhiveConfigFromXmlFile( private ArchiveConfig unmarshalArhiveConfigFromXmlFile(
LocalizationFile lFile) throws IOException, LocalizationException { LocalizationFile lFile) throws IOException, LocalizationException {
ArchiveConfig archiveConfig = null; ArchiveConfig archiveConfig = null;
InputStream stream = null; LocalizationFileInputStream stream = null;
try { try {
stream = lFile.openInputStream(); stream = lFile.openInputStream();
archiveConfig = JAXB.unmarshal(stream, ArchiveConfig.class); archiveConfig = JAXB.unmarshal(stream, ArchiveConfig.class);
@ -711,4 +657,66 @@ public class ArchiveConfigManager {
} }
return archiveConfig; return archiveConfig;
} }
/**
* This class contains the information on directories that are associated
* with a display label. Allows a GUI to maintain the state of the display
* instead of the manager.
*/
public class DisplayData {
protected final ArchiveConfig archiveConfig;
protected final CategoryConfig categoryConfig;
protected final String displayLabel;
protected final List<File> dirs;
private boolean selected = false;
private long size = -1L;
public DisplayData(ArchiveConfig archiveConfig,
CategoryConfig categoryConfig, String displayLabel,
List<File> dirs) {
this.archiveConfig = archiveConfig;
this.categoryConfig = categoryConfig;
this.displayLabel = displayLabel;
this.dirs = dirs;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
public String getDisplayLabel() {
return displayLabel;
}
public long getSize() {
return size;
}
public void setSize(long size) {
this.size = size;
}
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof DisplayData) {
DisplayData displayInfo = (DisplayData) object;
return (archiveConfig == displayInfo.archiveConfig
&& categoryConfig == displayInfo.categoryConfig && displayLabel
.equals(displayInfo.displayLabel));
}
return false;
}
}
} }

View file

@ -35,7 +35,7 @@ import javax.xml.bind.annotation.XmlRootElement;
* &lt;!-- When 0 default to the parent archive's retentionHours --> * &lt;!-- When 0 default to the parent archive's retentionHours -->
* &lt;retentionHours>0&lt;/retentionHours> * &lt;retentionHours>0&lt;/retentionHours>
* &lt;dirPattern>hdf5/(redbook)&lt;/dirPattern> * &lt;dirPattern>hdf5/(redbook)&lt;/dirPattern>
* &lt;display>{1}&lt;/display> * &lt;displayLabel>{1}&lt;/displayLabel>
* &lt;filePattern>redbook-(\d{4})-(\d{2})-(\d{2})-(\d{2})\..*&lt;/filePattern> * &lt;filePattern>redbook-(\d{4})-(\d{2})-(\d{2})-(\d{2})\..*&lt;/filePattern>
* &lt;dateGroupIndices>2,3,4,5&lt;/dateGroupIndices> * &lt;dateGroupIndices>2,3,4,5&lt;/dateGroupIndices>
* &lt;/category> * &lt;/category>
@ -48,7 +48,7 @@ import javax.xml.bind.annotation.XmlRootElement;
* &lt;name>Model grib&lt;/name> * &lt;name>Model grib&lt;/name>
* &lt;retentionHours>0&lt;/retentionHours> * &lt;retentionHours>0&lt;/retentionHours>
* &lt;dirPattern>grib/(\d{4})(\d{2})(\d{2})/(\d{2})/(.*)&lt;/dirPattern> * &lt;dirPattern>grib/(\d{4})(\d{2})(\d{2})/(\d{2})/(.*)&lt;/dirPattern>
* &lt;display>{5}&lt;/display> * &lt;displayLabel>{5}&lt;/displayLabel>
* &lt;dateGroupIndices>1,2,3,4&lt;/dateGroupIndices> * &lt;dateGroupIndices>1,2,3,4&lt;/dateGroupIndices>
* &lt;/category> * &lt;/category>
* </pre> * </pre>
@ -101,14 +101,14 @@ public class CategoryConfig implements Comparable<CategoryConfig> {
* *
* <pre> * <pre>
* &lt;dirName>(grib2)/(\d{4})(\d{2})(\d{2})/(\d{2})/(.*)&lt;/dirName> * &lt;dirName>(grib2)/(\d{4})(\d{2})(\d{2})/(\d{2})/(.*)&lt;/dirName>
* &lt;display>{1} - {6}&lt;/display> * &lt;displayLabel>{1} - {6}&lt;/displayLabel>
* </pre> * </pre>
* *
* The {1} will be replaced by the first group (grib2) in the regex * The {1} will be replaced by the first group (grib2) in the regex
* expression in dirName. The {6} is the sixth group (.*). {0} is the whole * expression in dirName. The {6} is the sixth group (.*). {0} is the whole
* expression match. * expression match.
*/ */
@XmlElement(name = "display") @XmlElement(name = "displayLabel")
private String display; private String display;
/** /**
@ -120,7 +120,7 @@ public class CategoryConfig implements Comparable<CategoryConfig> {
* *
* <pre> * <pre>
* &lt;dirPattern>hdf5/(redbook)&lt;/dirPattern> * &lt;dirPattern>hdf5/(redbook)&lt;/dirPattern>
* &lt;display>{1}&lt;/display> * &lt;displayLabel>{1}&lt;/displayLabel>
* &lt;filePattern>redbook-(\d{4})-(\d{2})-(\d{2})-(\d{2})\..*&lt;/filePattern> * &lt;filePattern>redbook-(\d{4})-(\d{2})-(\d{2})-(\d{2})\..*&lt;/filePattern>
* &lt;dateGroupIndices>2,3,4,5&lt;/dateGroupIndices> * &lt;dateGroupIndices>2,3,4,5&lt;/dateGroupIndices>
* </pre> * </pre>
@ -199,7 +199,7 @@ public class CategoryConfig implements Comparable<CategoryConfig> {
} }
/** /**
* Get the diaplay pattern. * Get the display label pattern.
* *
* @return display * @return display
*/ */
@ -208,7 +208,7 @@ public class CategoryConfig implements Comparable<CategoryConfig> {
} }
/** /**
* Set the display pattern. * Set the display label pattern.
* *
* @param display * @param display
*/ */
@ -274,7 +274,7 @@ public class CategoryConfig implements Comparable<CategoryConfig> {
sb.append(", retentionHours: ").append(getRetentionHours()); sb.append(", retentionHours: ").append(getRetentionHours());
sb.append(", dirPattern: ").append(getDirPattern()); sb.append(", dirPattern: ").append(getDirPattern());
sb.append(", filePattern: ").append(getFilePattern()); sb.append(", filePattern: ").append(getFilePattern());
sb.append(", display: ").append(getDisplay()); sb.append(", displayLabel: ").append(getDisplay());
sb.append(", dateGroupIndices: ").append(getDateGroupIndices()); sb.append(", dateGroupIndices: ").append(getDateGroupIndices());
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();

View file

@ -23,26 +23,25 @@
<name> - Required tag. The id for the archive such as Raw or Processed. <name> - Required tag. The id for the archive such as Raw or Processed.
Used in the GUIs to filter which archive to display. Used in the GUIs to filter which archive to display.
<rootDir> - Required tag. The root directory on the edex server for the archive. <rootDir> - Required tag. The root directory on the edex server for the archive.
<retentionHours> - Required tag. The default number of hour to retain data in the <rootDir> <retentionHours> - Required tag. The default number of hours to retain data in the <rootDir>
<category> - Detail information for display information in the archive GUIs and <category> - Logical grouping of archive's sub-directories.
overriding the default retention hours. There can be several of these tags.
The <category> has six types of tags: The <category> has six types of tags:
<name> - Required tag. The id for the category such as grib2 or redbook. <name> - Required tag. The id for the category such as grib2 or redbook.
Used in the GUIs to filter what is the display in the table. Used in the GUIs to filter what is the display in the table.
<retentionHours> - Optional tag. The retentionHours for this category. <retentionHours> - Optional tag. The retentionHours for this category.
Default is the archive's <retentionHours>. Default is the archive's <retentionHours>.
<dirPattern> - Required tag. A pattern for finding directories for this category. <dirPattern> - Required tag. A regex pattern for finding directories for this category.
The pattern is relative to the archive's <rootDir>. Wildcard patterns do not cross directory The pattern is relative to the archive's <rootDir>. Wildcard patterns do not cross directory
delimiter /. Thus to match 3 levels of directories you would need .*/.*/.* . delimiter /. Thus to match 3 levels of directories you would need .*/.*/.* .
See patterns and groups section. See patterns and groups section.
<filePattern> - Optional tag. A pattern to find files in the directories that match the <dirPattern>. <filePattern> - Optional tag. A pattern to find files in the directories that match the <dirPattern>.
Default is everything in the directories that match <dirPattern>. Default is everything in the directories that match <dirPattern>.
See patterns and groups section. See patterns and groups section.
<display> - Required tag. The label to display for directories that match <dirPattern>. Any group in the <displayLabel> - Required tag. The label to display for directories that match <dirPattern>. Any group in the
<dirPattern> may be made part of the label by placing the group's index inside parenthesis, {1}. <dirPattern> may be made part of the label by placing the group's index inside parenthesis, {1}.
More then one directory may match the <dirPattern>. The archive GUIs may clapse them into a single More then one directory may match the <dirPattern>. The archive GUIs may collapse them into a
table entry. single table entry.
<dateGroupIndicies> - Required tag. A comma separated list of 4 numbers which are the index of the groups in <dateGroupIndicies> - Required tag. A comma separated list of 4 numbers which are the index of the groups in
<dirPattern> and/or <filePattern> that contain in order the year, mouth, day and hour information. <dirPattern> and/or <filePattern> that contain in order the year, mouth, day and hour information.
This is used to determine what files/directories to retain or a range of directories/files to copy This is used to determine what files/directories to retain or a range of directories/files to copy
@ -52,9 +51,9 @@
The <dirPattern> and <filePattern> use Java regex expressions; similar to the ldm's pqact.conf file. The <dirPattern> and <filePattern> use Java regex expressions; similar to the ldm's pqact.conf file.
For more details see http://docs.oracle.com/javase/tutorial/essential/regex/ For more details see http://docs.oracle.com/javase/tutorial/essential/regex/
The groupings index start at one. The groups in the <dirPattern> can be used in the <display>. For example: The groupings index start at one. The groups in the <dirPattern> can be used in the <displayLabel>. For example:
<dirPattern>(grib2)/(\d{4})(\d{2})(\d{2})/(\d{2})/(.*)</dirPattern> <dirPattern>(grib2)/(\d{4})(\d{2})(\d{2})/(\d{2})/(.*)</dirPattern>
<display>{1} - {6}</display> <displayLabel>{1} - {6}</displayLabel>
<dateGroupIndices>2,3,4,5</dateGroupIndices> <dateGroupIndices>2,3,4,5</dateGroupIndices>
Here the <dirPattern> contains six groups. The first group is the literal grib2 which matches only a directory named grib2 Here the <dirPattern> contains six groups. The first group is the literal grib2 which matches only a directory named grib2
@ -68,7 +67,7 @@
Example with <filePattern>: Example with <filePattern>:
<dirPattern>hdf5/(redbook)</dirPattern> <dirPattern>hdf5/(redbook)</dirPattern>
<display>{1}</display> <displayLabel>{1}</displayLabel>
<filePattern>redbook-(\d{4})-(\d{2})-(\d{2})-(\d{2})\..*</filePattern> <filePattern>redbook-(\d{4})-(\d{2})-(\d{2})-(\d{2})\..*</filePattern>
<dateGroupIndices>2,3,4,5</dateGroupIndices> <dateGroupIndices>2,3,4,5</dateGroupIndices>
@ -76,7 +75,7 @@
come from the <filePattern> since there is one group in the <dirPattern> the groups in the <filePattern> start at two. This come from the <filePattern> since there is one group in the <dirPattern> the groups in the <filePattern> start at two. This
matches file names redbook-YYYY-MM-DD-HH.<extension>. Thus the file name redbook-2013-05-28-00.hd5 would match the <filePattern>. matches file names redbook-YYYY-MM-DD-HH.<extension>. Thus the file name redbook-2013-05-28-00.hd5 would match the <filePattern>.
NOTE group {0} is a string that matches the whole <dirPattern>. If this is used in the <display> would see every directory that NOTE group {0} is a string that matches the whole <dirPattern>. If this is used in the <displayLabel> would see every directory that
matches the pattern. matches the pattern.
--> -->
<archive> <archive>
@ -87,7 +86,7 @@
<name>redbook</name> <name>redbook</name>
<retentionHours>0</retentionHours> <retentionHours>0</retentionHours>
<dirPattern>hdf5/(redbook)</dirPattern> <dirPattern>hdf5/(redbook)</dirPattern>
<display>{1}</display> <displayLabel>{1}</displayLabel>
<filePattern>redbook-(\d{4})-(\d{2})-(\d{2})-(\d{2})\..*</filePattern> <filePattern>redbook-(\d{4})-(\d{2})-(\d{2})-(\d{2})\..*</filePattern>
<dateGroupIndices>2,3,4,5</dateGroupIndices> <dateGroupIndices>2,3,4,5</dateGroupIndices>
</category> </category>
@ -95,7 +94,7 @@
<name>obs</name> <name>obs</name>
<retentionHours>0</retentionHours> <retentionHours>0</retentionHours>
<dirPattern>hdf5/(obs)</dirPattern> <dirPattern>hdf5/(obs)</dirPattern>
<display>{1}</display> <displayLabel>{1}</displayLabel>
<filePattern>metar-(\d{4})-(\d{2})-(\d{2})-(\d{2})\.*</filePattern> <filePattern>metar-(\d{4})-(\d{2})-(\d{2})-(\d{2})\.*</filePattern>
<dateGroupIndices>2,3,4,5</dateGroupIndices> <dateGroupIndices>2,3,4,5</dateGroupIndices>
</category> </category>

View file

@ -23,26 +23,25 @@
<name> - Required tag. The id for the archive such as Raw or Processed. <name> - Required tag. The id for the archive such as Raw or Processed.
Used in the GUIs to filter which archive to display. Used in the GUIs to filter which archive to display.
<rootDir> - Required tag. The root directory on the edex server for the archive. <rootDir> - Required tag. The root directory on the edex server for the archive.
<retentionHours> - Required tag. The default number of hour to retain data in the <rootDir> <retentionHours> - Required tag. The default number of hours to retain data in the <rootDir>
<category> - Detail information for display information in the archive GUIs and <category> - Logical grouping of archive's sub-directories.
overriding the default retention hours. There can be several of these tags.
The <category> has six types of tags: The <category> has six types of tags:
<name> - Required tag. The id for the category such as grib2 or redbook. <name> - Required tag. The id for the category such as grib2 or redbook.
Used in the GUIs to filter what is the display in the table. Used in the GUIs to filter what is the display in the table.
<retentionHours> - Optional tag. The retentionHours for this category. <retentionHours> - Optional tag. The retentionHours for this category.
Default is the archive's <retentionHours>. Default is the archive's <retentionHours>.
<dirPattern> - Required tag. A pattern for finding directories for this category. <dirPattern> - Required tag. A regex pattern for finding directories for this category.
The pattern is relative to the archive's <rootDir>. Wildcard patterns do not cross directory The pattern is relative to the archive's <rootDir>. Wildcard patterns do not cross directory
delimiter /. Thus to match 3 levels of directories you would need .*/.*/.* . delimiter /. Thus to match 3 levels of directories you would need .*/.*/.* .
See patterns and groups section. See patterns and groups section.
<filePattern> - Optional tag. A pattern to find files in the directories that match the <dirPattern>. <filePattern> - Optional tag. A pattern to find files in the directories that match the <dirPattern>.
Default is everything in the directories that match <dirPattern>. Default is everything in the directories that match <dirPattern>.
See patterns and groups section. See patterns and groups section.
<display> - Required tag. The label to display for directories that match <dirPattern>. Any group in the <displayLabel> - Required tag. The label to display for directories that match <dirPattern>. Any group in the
<dirPattern> may be made part of the label by placing the group's index inside parenthesis, {1}. <dirPattern> may be made part of the label by placing the group's index inside parenthesis, {1}.
More then one directory may match the <dirPattern>. The archive GUIs may clapse them into a single More then one directory may match the <dirPattern>. The archive GUIs may collapse them into a
table entry. single table entry.
<dateGroupIndicies> - Required tag. A comma separated list of 4 numbers which are the index of the groups in <dateGroupIndicies> - Required tag. A comma separated list of 4 numbers which are the index of the groups in
<dirPattern> and/or <filePattern> that contain in order the year, mouth, day and hour information. <dirPattern> and/or <filePattern> that contain in order the year, mouth, day and hour information.
This is used to determine what files/directories to retain or a range of directories/files to copy This is used to determine what files/directories to retain or a range of directories/files to copy
@ -52,9 +51,9 @@
The <dirPattern> and <filePattern> use Java regex expressions; similar to the ldm's pqact.conf file. The <dirPattern> and <filePattern> use Java regex expressions; similar to the ldm's pqact.conf file.
For more details see http://docs.oracle.com/javase/tutorial/essential/regex/ For more details see http://docs.oracle.com/javase/tutorial/essential/regex/
The groupings index start at one. The groups in the <dirPattern> can be used in the <display>. For example: The groupings index start at one. The groups in the <dirPattern> can be used in the <displayLabel>. For example:
<dirPattern>(grib2)/(\d{4})(\d{2})(\d{2})/(\d{2})/(.*)</dirPattern> <dirPattern>(grib2)/(\d{4})(\d{2})(\d{2})/(\d{2})/(.*)</dirPattern>
<display>{1} - {6}</display> <displayLabel>{1} - {6}</displayLabel>
<dateGroupIndices>2,3,4,5</dateGroupIndices> <dateGroupIndices>2,3,4,5</dateGroupIndices>
Here the <dirPattern> contains six groups. The first group is the literal grib2 which matches only a directory named grib2 Here the <dirPattern> contains six groups. The first group is the literal grib2 which matches only a directory named grib2
@ -68,7 +67,7 @@
Example with <filePattern>: Example with <filePattern>:
<dirPattern>hdf5/(redbook)</dirPattern> <dirPattern>hdf5/(redbook)</dirPattern>
<display>{1}</display> <displayLabel>{1}</displayLabel>
<filePattern>redbook-(\d{4})-(\d{2})-(\d{2})-(\d{2})\..*</filePattern> <filePattern>redbook-(\d{4})-(\d{2})-(\d{2})-(\d{2})\..*</filePattern>
<dateGroupIndices>2,3,4,5</dateGroupIndices> <dateGroupIndices>2,3,4,5</dateGroupIndices>
@ -76,7 +75,7 @@
come from the <filePattern> since there is one group in the <dirPattern> the groups in the <filePattern> start at two. This come from the <filePattern> since there is one group in the <dirPattern> the groups in the <filePattern> start at two. This
matches file names redbook-YYYY-MM-DD-HH.<extension>. Thus the file name redbook-2013-05-28-00.hd5 would match the <filePattern>. matches file names redbook-YYYY-MM-DD-HH.<extension>. Thus the file name redbook-2013-05-28-00.hd5 would match the <filePattern>.
NOTE group {0} is a string that matches the whole <dirPattern>. If this is used in the <display> would see every directory that NOTE group {0} is a string that matches the whole <dirPattern>. If this is used in the <displayLabel> would see every directory that
matches the pattern. matches the pattern.
--> -->
<archive> <archive>
@ -87,28 +86,28 @@
<name>Model grib</name> <name>Model grib</name>
<retentionHours>0</retentionHours> <retentionHours>0</retentionHours>
<dirPattern>grib/(\d{4})(\d{2})(\d{2})/(\d{2})/(.*)</dirPattern> <dirPattern>grib/(\d{4})(\d{2})(\d{2})/(\d{2})/(.*)</dirPattern>
<display>{5}</display> <displayLabel>{5}</displayLabel>
<dateGroupIndices>1,2,3,4</dateGroupIndices> <dateGroupIndices>1,2,3,4</dateGroupIndices>
</category> </category>
<category> <category>
<name>Model grib2</name> <name>Model grib2</name>
<retentionHours>0</retentionHours> <retentionHours>0</retentionHours>
<dirPattern>(grib2)/(\d{4})(\d{2})(\d{2})/(\d{2})/(.*)</dirPattern> <dirPattern>(grib2)/(\d{4})(\d{2})(\d{2})/(\d{2})/(.*)</dirPattern>
<display>{1} - {6}</display> <displayLabel>{1} - {6}</displayLabel>
<dateGroupIndices>2,3,4,5</dateGroupIndices> <dateGroupIndices>2,3,4,5</dateGroupIndices>
</category> </category>
<category> <category>
<name>Model other</name> <name>Model other</name>
<retentionHours>0</retentionHours> <retentionHours>0</retentionHours>
<dirPattern>(acars|airmet|binlightning|bufrmos|bufrua|bufrsigwx|convsigmet|goessndg|manual|mdlsndg|poessndg|profiler|shef|text)/(\d{4})(\d{2})(\d{2})/(\d{2})</dirPattern> <dirPattern>(acars|airmet|binlightning|bufrmos|bufrua|bufrsigwx|convsigmet|goessndg|manual|mdlsndg|poessndg|profiler|shef|text)/(\d{4})(\d{2})(\d{2})/(\d{2})</dirPattern>
<display>{1}</display> <displayLabel>{1}</displayLabel>
<dateGroupIndices>2,3,4,5</dateGroupIndices> <dateGroupIndices>2,3,4,5</dateGroupIndices>
</category> </category>
<category> <category>
<name>Satellite</name> <name>Satellite</name>
<retentionHours>101</retentionHours> <retentionHours>101</retentionHours>
<dirPattern>sat/(\d{4})(\d{2})(\d{2})/(\d{2})/(.*)</dirPattern> <dirPattern>sat/(\d{4})(\d{2})(\d{2})/(\d{2})/(.*)</dirPattern>
<display>{5}</display> <displayLabel>{5}</displayLabel>
<dateGroupIndices>1,2,3,4</dateGroupIndices> <dateGroupIndices>1,2,3,4</dateGroupIndices>
</category> </category>
</archive> </archive>

View file

@ -87,7 +87,7 @@ public class ArchiveConfigManagerTest {
private ArchiveConfigManager manager; private ArchiveConfigManager manager;
private ArchiveConfig archive; private ArchiveConfig archive;
private Collection<File> archiveFiles = new ArrayList<File>(); private Collection<File> archiveFiles = new ArrayList<File>();
private Collection<File> expiredFiles = new ArrayList<File>(); private Collection<File> expiredFiles = new ArrayList<File>();
@ -97,7 +97,7 @@ public class ArchiveConfigManagerTest {
private Calendar referenceCalendar; private Calendar referenceCalendar;
private Calendar archiveStart; private Calendar archiveStart;
private Calendar archiveEnd; private Calendar archiveEnd;
private List<String> selectedForArchive; private List<String> selectedForArchive;
@ -149,7 +149,8 @@ public class ArchiveConfigManagerTest {
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... // manager is not configured internally until this is called...
manager.getDisplayLabels(archive.getName(), grib1Cat.getName()); // 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,7 +159,8 @@ public class ArchiveConfigManagerTest {
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... // manager is not configured internally until this is called...
manager.getDisplayLabels(archive.getName(), satCat.getName()); // TODO Brad will fix.
// manager.getDisplayLabels(archive.getName(), satCat.getName());
// **** acars **** // **** acars ****
CategoryConfig otherCat = getCategory(archive, "Model other"); CategoryConfig otherCat = getCategory(archive, "Model other");
@ -180,7 +182,8 @@ public class ArchiveConfigManagerTest {
createTestFiles(bufrsigwxFormat, otherCatRetentionHours, false, createTestFiles(bufrsigwxFormat, otherCatRetentionHours, false,
archiveStart, archiveEnd); archiveStart, archiveEnd);
// manager is not configured internally until this is called... // manager is not configured internally until this is called...
manager.getDisplayLabels(archive.getName(), otherCat.getName()); // 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);
@ -224,12 +227,9 @@ public class ArchiveConfigManagerTest {
createDataFile(moreThanOneDayOld, dataFileNameFormat); createDataFile(moreThanOneDayOld, dataFileNameFormat);
// create data file older than purge time // create data file older than purge time
Calendar lessThanExpiredCalendar = (Calendar) referenceCalendar Calendar lessThanExpiredCalendar = (Calendar) referenceCalendar.clone();
.clone(); lessThanExpiredCalendar.add(Calendar.HOUR, (-1 * retentionHours - 1));
lessThanExpiredCalendar.add(Calendar.HOUR, (-1 dataFile = createDataFile(lessThanExpiredCalendar, dataFileNameFormat);
* retentionHours - 1));
dataFile = createDataFile(lessThanExpiredCalendar,
dataFileNameFormat);
expiredFiles.add(dataFile); expiredFiles.add(dataFile);
purgeFiles.add(dataFile); purgeFiles.add(dataFile);
@ -250,7 +250,7 @@ public class ArchiveConfigManagerTest {
archiveStart.add(Calendar.HOUR, -20); archiveStart.add(Calendar.HOUR, -20);
archiveEnd.add(Calendar.HOUR, -3); archiveEnd.add(Calendar.HOUR, -3);
yyyyMMFormat.setCalendar(referenceCalendar); yyyyMMFormat.setCalendar(referenceCalendar);
ddFormat.setCalendar(referenceCalendar); ddFormat.setCalendar(referenceCalendar);
hhFormat.setCalendar(referenceCalendar); hhFormat.setCalendar(referenceCalendar);