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