Merge "Issue #3045 Code cleanup for CategoryConfig and ArchiveConfig," into development
Former-commit-id:b4af2bc502
[formerly 8166eaf9cda2c653bf348ff556af64151e6e70e5] Former-commit-id:61e75364dd
This commit is contained in:
commit
c0ba0cf76b
3 changed files with 96 additions and 49 deletions
|
@ -57,6 +57,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* May 1, 2013 1966 rferrel Initial creation
|
||||
* May 31, 2013 1965 bgonzale Added getCategory(categoryName)
|
||||
* Apr 17, 2014 3045 rferrel Code cleanup to prevent null pointer.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -91,7 +92,7 @@ public class ArchiveConfig implements Comparable<ArchiveConfig> {
|
|||
* for the archiver.
|
||||
*/
|
||||
@XmlElement(name = "category")
|
||||
List<CategoryConfig> categoryList;
|
||||
List<CategoryConfig> categoryList = new ArrayList<CategoryConfig>();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -157,7 +158,11 @@ public class ArchiveConfig implements Comparable<ArchiveConfig> {
|
|||
* @param retentionHours
|
||||
*/
|
||||
public void setRetentionHours(int retentionHours) {
|
||||
this.retentionHours = retentionHours;
|
||||
if (retentionHours > 0) {
|
||||
this.retentionHours = retentionHours;
|
||||
} else {
|
||||
this.retentionHours = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,7 +171,10 @@ public class ArchiveConfig implements Comparable<ArchiveConfig> {
|
|||
* @return
|
||||
*/
|
||||
public List<CategoryConfig> getCategoryList() {
|
||||
return new ArrayList<CategoryConfig>(categoryList);
|
||||
List<CategoryConfig> list = new ArrayList<CategoryConfig>(
|
||||
categoryList.size());
|
||||
list.addAll(categoryList);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -188,15 +196,17 @@ public class ArchiveConfig implements Comparable<ArchiveConfig> {
|
|||
* @param categoryList
|
||||
*/
|
||||
public void setCategoryList(List<CategoryConfig> categoryList) {
|
||||
this.categoryList = categoryList;
|
||||
this.categoryList.clear();
|
||||
if (categoryList != null) {
|
||||
this.categoryList.addAll(categoryList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for required entries.
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return (name != null) && (rootDir != null) && (categoryList != null)
|
||||
&& (categoryList.size() > 0);
|
||||
return (name != null) && (rootDir != null) && (categoryList.size() > 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -73,6 +73,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
* May 1, 2013 1966 rferrel Initial creation
|
||||
* Aug 03, 2013 2224 rferrel Changes to include DataSet.
|
||||
* Jan 09, 2014 2603 rferrel Fix bug in setSelectedDisplayNames
|
||||
* Apr 17, 2014 3045 rferrel Code cleanup to prevent null pointer.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -97,7 +98,7 @@ public class CategoryConfig implements Comparable<CategoryConfig> {
|
|||
private int retentionHours;
|
||||
|
||||
@XmlElement(name = "dataSet")
|
||||
private List<CategoryDataSet> dataSetList;
|
||||
private List<CategoryDataSet> dataSetList = new ArrayList<CategoryDataSet>();
|
||||
|
||||
@XmlElement(name = "selectedDisplayName")
|
||||
private final Collection<String> selectedDisplayNames = new TreeSet<String>();
|
||||
|
@ -138,31 +139,66 @@ public class CategoryConfig implements Comparable<CategoryConfig> {
|
|||
* Set the retention hours must be greater then zero.
|
||||
*/
|
||||
public void setRetentionHours(int retentionHours) {
|
||||
this.retentionHours = retentionHours;
|
||||
if (retentionHours > 0) {
|
||||
this.retentionHours = retentionHours;
|
||||
} else {
|
||||
this.retentionHours = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return dataSetList
|
||||
*/
|
||||
public List<CategoryDataSet> getDataSetList() {
|
||||
return new ArrayList<CategoryDataSet>(dataSetList);
|
||||
List<CategoryDataSet> list = new ArrayList<CategoryDataSet>(
|
||||
dataSetList.size());
|
||||
list.addAll(dataSetList);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataSetList
|
||||
*/
|
||||
public void setDataSetList(List<CategoryDataSet> dataSetList) {
|
||||
this.dataSetList = dataSetList;
|
||||
this.dataSetList.clear();
|
||||
if (dataSetList != null) {
|
||||
this.dataSetList.addAll(dataSetList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return selectedDisplayNames
|
||||
*/
|
||||
public Collection<String> getSelectedDisplayNames() {
|
||||
return selectedDisplayNames;
|
||||
}
|
||||
|
||||
public void setSelectedDisplayNames(
|
||||
Collection<String> selectedDisplayNameList) {
|
||||
selectedDisplayNames.clear();
|
||||
selectedDisplayNames.addAll(selectedDisplayNameList);
|
||||
/**
|
||||
*
|
||||
* @param selectedDisplayNames
|
||||
*/
|
||||
public void setSelectedDisplayNames(Collection<String> selectedDisplayNames) {
|
||||
this.selectedDisplayNames.clear();
|
||||
if (selectedDisplayNames != null) {
|
||||
this.selectedDisplayNames.addAll(selectedDisplayNames);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param displayName
|
||||
*/
|
||||
public void addSelectedDisplayName(String displayName) {
|
||||
selectedDisplayNames.add(displayName);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param displayName
|
||||
*/
|
||||
public void removeSelectedDisplayName(String displayName) {
|
||||
selectedDisplayNames.remove(displayName);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
|||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
import com.raytheon.uf.common.util.TestUtil;
|
||||
import com.raytheon.uf.edex.archive.purge.ArchivePurgeManager;
|
||||
|
||||
/**
|
||||
* Test ArchiveConfigManager Archive Ingest Purge and Archive Creation.
|
||||
|
@ -68,6 +67,7 @@ import com.raytheon.uf.edex.archive.purge.ArchivePurgeManager;
|
|||
* Aug 28, 2013 2299 rferrel purgeExpiredFromArchive now returns number of files purged.
|
||||
* Apr 14, 2014 3023 rferrel Remove archive purge test no long works with implementation
|
||||
* cluster locks.
|
||||
* Apr 17, 2014 3045 rferrel Commented out test so no longer have dependence ArchivPurgeManger.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -555,39 +555,40 @@ public class ArchiveConfigManagerTest {
|
|||
* awips.cluster_task table to perform the locks.
|
||||
*/
|
||||
// @Test
|
||||
public void testArchiveManagerPurge() throws IOException {
|
||||
ArchivePurgeManager manager = ArchivePurgeManager.getInstance();
|
||||
Collection<File> filesFoundInPurge = new ArrayList<File>();
|
||||
int purgeCount = 0;
|
||||
|
||||
for (ArchiveConfig a : manager.getArchives()) {
|
||||
purgeCount += manager.purgeExpiredFromArchive(a);
|
||||
}
|
||||
|
||||
// assertEquals(
|
||||
//
|
||||
// "The expected number of purged files and number of purge files not the same",
|
||||
// purgeCount, purgeFiles.size());
|
||||
|
||||
for (File file : allFiles) {
|
||||
if (!file.exists()) {
|
||||
filesFoundInPurge.add(file);
|
||||
}
|
||||
}
|
||||
System.out.println("purgeCount: " + purgeCount + ", pureFiles.size:"
|
||||
+ purgeFiles.size() + ", filesFoundInPurge.size(): "
|
||||
+ filesFoundInPurge.size());
|
||||
|
||||
for (File file : purgeFiles) {
|
||||
if (!filesFoundInPurge.contains(file)) {
|
||||
System.out.println("not purged: " + file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals(
|
||||
"The expected purge files and the files purged are not the same",
|
||||
createFileNameListRemoveTestDir(purgeFiles),
|
||||
createFileNameListRemoveTestDir(filesFoundInPurge));
|
||||
}
|
||||
// public void testArchiveManagerPurge() throws IOException {
|
||||
// ArchivePurgeManager manager = ArchivePurgeManager.getInstance();
|
||||
// Collection<File> filesFoundInPurge = new ArrayList<File>();
|
||||
// int purgeCount = 0;
|
||||
//
|
||||
// for (ArchiveConfig a : manager.getArchives()) {
|
||||
// purgeCount += manager.purgeExpiredFromArchive(a);
|
||||
// }
|
||||
//
|
||||
// // assertEquals(
|
||||
// //
|
||||
// //
|
||||
// "The expected number of purged files and number of purge files not the same",
|
||||
// // purgeCount, purgeFiles.size());
|
||||
//
|
||||
// for (File file : allFiles) {
|
||||
// if (!file.exists()) {
|
||||
// filesFoundInPurge.add(file);
|
||||
// }
|
||||
// }
|
||||
// System.out.println("purgeCount: " + purgeCount + ", pureFiles.size:"
|
||||
// + purgeFiles.size() + ", filesFoundInPurge.size(): "
|
||||
// + filesFoundInPurge.size());
|
||||
//
|
||||
// for (File file : purgeFiles) {
|
||||
// if (!filesFoundInPurge.contains(file)) {
|
||||
// System.out.println("not purged: " + file.getAbsolutePath());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// assertEquals(
|
||||
// "The expected purge files and the files purged are not the same",
|
||||
// createFileNameListRemoveTestDir(purgeFiles),
|
||||
// createFileNameListRemoveTestDir(filesFoundInPurge));
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue