Include automation arguments and deeper folder searching for fiber link
folders.
This commit is contained in:
commit
d74971613d
27
CCSDFolderAnalyzer/.project
Normal file
27
CCSDFolderAnalyzer/.project
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>CCSDFolderAnalyzer</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||||
|
<triggers>full,incremental,</triggers>
|
||||||
|
<arguments>
|
||||||
|
<dictionary>
|
||||||
|
<key>LaunchConfigHandle</key>
|
||||||
|
<value><project>/.externalToolBuilders/New_Builder (8).launch</value>
|
||||||
|
</dictionary>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
BIN
CCSDFolderAnalyzer/CCSD Folder Analyzer.jar
Normal file
BIN
CCSDFolderAnalyzer/CCSD Folder Analyzer.jar
Normal file
Binary file not shown.
18
CCSDFolderAnalyzer/projectBuilder.xml
Normal file
18
CCSDFolderAnalyzer/projectBuilder.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<project default="create_run_jar" name="Create Runnable Jar for Project CCSD Folder Analyzer">
|
||||||
|
<!--this file was created by Eclipse Runnable JAR Export Wizard-->
|
||||||
|
<!--ANT 1.7 is required -->
|
||||||
|
<!--define folder properties-->
|
||||||
|
<property name="dir.buildfile" value="."/>
|
||||||
|
<property name="dir.workspace" value="${dir.buildfile}/.."/>
|
||||||
|
<property name="dir.jarfile" value="${dir.buildfile}"/>
|
||||||
|
<target name="create_run_jar">
|
||||||
|
<jar destfile="${dir.jarfile}/CCSD Folder Analyzer.jar" filesetmanifest="mergewithoutmain">
|
||||||
|
<manifest>
|
||||||
|
<attribute name="Main-Class" value="sig.ccsd.Analyzer"/>
|
||||||
|
<attribute name="Class-Path" value="."/>
|
||||||
|
</manifest>
|
||||||
|
<fileset dir="${dir.jarfile}/bin"/>
|
||||||
|
</jar>
|
||||||
|
</target>
|
||||||
|
</project>
|
324
CCSDFolderAnalyzer/src/sig/ccsd/Analyzer.java
Normal file
324
CCSDFolderAnalyzer/src/sig/ccsd/Analyzer.java
Normal file
@ -0,0 +1,324 @@
|
|||||||
|
package sig.ccsd;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JProgressBar;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.ScrollPaneConstants;
|
||||||
|
|
||||||
|
public class Analyzer {
|
||||||
|
public static String BASEPATH;
|
||||||
|
public static List<CCSD> ccsd_list = new ArrayList<CCSD>();
|
||||||
|
public static Analyzer ANALYZER;
|
||||||
|
public static boolean SILENT = false;
|
||||||
|
|
||||||
|
static void validate(File f) {
|
||||||
|
DateTimeFormatter dtf = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
|
||||||
|
String datestamp = dtf.format(LocalDateTime.now());
|
||||||
|
if (f==null) {
|
||||||
|
Analyzer.writetoFile(new StringBuilder("["+datestamp+"] null folder detected. THIS SHOULD NOT BE HAPPENING."), new File("error.log"));
|
||||||
|
} else
|
||||||
|
if (f.exists()) {
|
||||||
|
Analyzer.writetoFile(new StringBuilder("["+datestamp+"] Could not find folder "+f.getAbsolutePath()), new File("error.log"));
|
||||||
|
} else
|
||||||
|
if (!f.isDirectory()) {
|
||||||
|
Analyzer.writetoFile(new StringBuilder("["+datestamp+"] Location "+f.getAbsolutePath()+" is not a directory."), new File("error.log"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
File user_folder_path = null;
|
||||||
|
File results_folder_path = null;
|
||||||
|
|
||||||
|
for (int i=0;i<args.length;i++) {
|
||||||
|
String arg = args[i];
|
||||||
|
switch (i) {
|
||||||
|
case 0:{
|
||||||
|
user_folder_path = new File(arg);
|
||||||
|
validate(user_folder_path);
|
||||||
|
}break;
|
||||||
|
case 1:{
|
||||||
|
results_folder_path = new File(arg);
|
||||||
|
validate(results_folder_path);
|
||||||
|
}break;
|
||||||
|
default:{
|
||||||
|
if (arg.equalsIgnoreCase("silent")) {
|
||||||
|
SILENT=true;
|
||||||
|
System.out.println("Running in silent mode...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final JFrame frame = new JFrame("CCSD Analyzer");
|
||||||
|
final JFrame warning_frame = new JFrame("CCSD Analyzer - Warnings");
|
||||||
|
ANALYZER = new Analyzer();
|
||||||
|
if (user_folder_path!=null && user_folder_path.exists() && user_folder_path.isDirectory()) {
|
||||||
|
BASEPATH = user_folder_path.getAbsolutePath();
|
||||||
|
} else {
|
||||||
|
JFileChooser j = new JFileChooser();
|
||||||
|
j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||||
|
j.setDialogTitle("Select a folder containing all CCSD folders.");
|
||||||
|
while (BASEPATH==null) {
|
||||||
|
if (j.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
|
||||||
|
BASEPATH = j.getSelectedFile().getAbsolutePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<File> directorylist = GetDirectories(BASEPATH);
|
||||||
|
ANALYZER.AnalyzeDirectories(directorylist);
|
||||||
|
//System.out.println(directorylist);
|
||||||
|
|
||||||
|
String[] columnlist = new String[]{
|
||||||
|
"CCSD","T&A","TSO","SAM","CLR","UNL","TSR","IER","EXR","DSR","RFU","MISC"
|
||||||
|
};
|
||||||
|
Object[][] objects = new Object[ANALYZER.ccsd_list.size()][];
|
||||||
|
int count=0;
|
||||||
|
for (CCSD c : ANALYZER.ccsd_list) {
|
||||||
|
System.out.println("S:"+c);
|
||||||
|
objects[count++] = c.getTableData();
|
||||||
|
}
|
||||||
|
//System.out.println(Arrays.deepToString(objects));
|
||||||
|
|
||||||
|
|
||||||
|
String[] warningcolumnlist = new String[]{
|
||||||
|
"CCSD","Component","Location","Warning Description"
|
||||||
|
};
|
||||||
|
Object[][] warningobjects = new Object[ANALYZER.GetWarningSize()][];
|
||||||
|
count=0;
|
||||||
|
for (CCSD c : ANALYZER.ccsd_list) {
|
||||||
|
for (Warning w : c.warnings) {
|
||||||
|
warningobjects[count++] =
|
||||||
|
new Object[]{
|
||||||
|
c.id,
|
||||||
|
"",
|
||||||
|
w.f,
|
||||||
|
w.type.desc
|
||||||
|
};
|
||||||
|
//System.out.print("count: "+count);
|
||||||
|
}
|
||||||
|
for (String s : c.map.keySet()) {
|
||||||
|
for (CCSDComponent cc : c.map.get(s)) {
|
||||||
|
for (Warning w : cc.warnings) {
|
||||||
|
warningobjects[count++] =
|
||||||
|
new Object[]{
|
||||||
|
c.id,
|
||||||
|
cc.label,
|
||||||
|
w.f,
|
||||||
|
w.type.desc
|
||||||
|
};
|
||||||
|
//System.out.print("count: "+count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final JTable table = new JTable(objects,columnlist);
|
||||||
|
JButton button = new JButton("Select All");
|
||||||
|
button.addActionListener(new ActionListener(){
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
table.selectAll();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
table.setAutoCreateRowSorter(true);
|
||||||
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
||||||
|
table.setColumnSelectionAllowed(true);
|
||||||
|
table.setDefaultRenderer(Object.class, new TableRenderer());
|
||||||
|
JScrollPane scroll = new JScrollPane(table);
|
||||||
|
table.setFillsViewportHeight(true);
|
||||||
|
frame.getContentPane().setLayout(new BorderLayout());
|
||||||
|
frame.getContentPane().add(scroll,BorderLayout.CENTER);
|
||||||
|
frame.getContentPane().add(button,BorderLayout.PAGE_END);
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
frame.setSize(800, 600);
|
||||||
|
if (!SILENT) {
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
JTable warning_table = new JTable(warningobjects,warningcolumnlist);
|
||||||
|
JButton fixbutton = new JButton("Create Missing Folders");
|
||||||
|
fixbutton.addActionListener(new ActionListener(){
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
CreateMissingFolders();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateMissingFolders() {
|
||||||
|
for (CCSD cc : Analyzer.ANALYZER.ccsd_list) {
|
||||||
|
for (Warning w : cc.warnings) {
|
||||||
|
if (w.type == WarningLabel.MISSING_FOLDER) {
|
||||||
|
w.f.mkdirs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
frame.dispose();
|
||||||
|
warning_frame.dispose();
|
||||||
|
//Analyzer.BASEPATH = null;
|
||||||
|
Analyzer.ANALYZER = null;
|
||||||
|
Analyzer.ccsd_list.clear();
|
||||||
|
Analyzer.main(new String[]{});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
warning_table.setAutoCreateRowSorter(true);
|
||||||
|
warning_table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
||||||
|
warning_table.setColumnSelectionAllowed(true);
|
||||||
|
warning_table.setDefaultRenderer(Object.class, new TableRenderer());
|
||||||
|
warning_table.getColumnModel().getColumn(0).setWidth(120);
|
||||||
|
warning_table.getColumnModel().getColumn(1).setWidth(120);
|
||||||
|
warning_table.getColumnModel().getColumn(2).setWidth(320);
|
||||||
|
warning_table.getColumnModel().getColumn(3).setWidth(480);
|
||||||
|
JScrollPane warning_scroll = new JScrollPane(warning_table);
|
||||||
|
warning_table.setFillsViewportHeight(true);
|
||||||
|
warning_frame.getContentPane().setLayout(new BorderLayout());
|
||||||
|
warning_frame.getContentPane().add(warning_scroll,BorderLayout.CENTER);
|
||||||
|
warning_frame.getContentPane().add(fixbutton,BorderLayout.PAGE_END);
|
||||||
|
warning_frame.setSize(800, 600);
|
||||||
|
if (!SILENT) {
|
||||||
|
warning_frame.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (results_folder_path!=null && results_folder_path.exists() && results_folder_path.isDirectory()) {
|
||||||
|
StringBuilder sb_results1 = new StringBuilder();
|
||||||
|
StringBuilder sb_results2 = new StringBuilder();
|
||||||
|
for (int i=0;i<columnlist.length;i++) {
|
||||||
|
if (sb_results1.length()!=0) {
|
||||||
|
sb_results1.append("\t");
|
||||||
|
}
|
||||||
|
sb_results1.append(columnlist[i]);
|
||||||
|
}
|
||||||
|
for (int i=0;i<objects.length;i++) {
|
||||||
|
sb_results1.append("\n");
|
||||||
|
Object[] data = objects[i];
|
||||||
|
for (int j=0;j<data.length;j++) {
|
||||||
|
if (j!=0) {
|
||||||
|
sb_results1.append("\t");
|
||||||
|
}
|
||||||
|
sb_results1.append((String)data[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Analyzer.writetoFile(sb_results1,new File(results_folder_path,"ccsd_results.txt"));
|
||||||
|
|
||||||
|
for (int i=0;i<warningcolumnlist.length;i++) {
|
||||||
|
if (sb_results2.length()!=0) {
|
||||||
|
sb_results2.append("\t");
|
||||||
|
}
|
||||||
|
sb_results2.append(warningcolumnlist[i]);
|
||||||
|
}
|
||||||
|
for (int i=0;i<warningobjects.length;i++) {
|
||||||
|
sb_results2.append("\n");
|
||||||
|
Object[] data = warningobjects[i];
|
||||||
|
for (int j=0;j<data.length;j++) {
|
||||||
|
if (j!=0) {
|
||||||
|
sb_results2.append("\t");
|
||||||
|
}
|
||||||
|
if (data[j] instanceof File) {
|
||||||
|
sb_results2.append(((File)(data[j])).getAbsolutePath());
|
||||||
|
} else {
|
||||||
|
sb_results2.append((String)data[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Analyzer.writetoFile(sb_results2,new File(results_folder_path,"warning_results.txt"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeToFile(StringBuilder data, File filename, boolean append) {
|
||||||
|
File file = filename;
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.createNewFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
FileWriter fw = new FileWriter(file,append);
|
||||||
|
PrintWriter pw = new PrintWriter(fw);
|
||||||
|
|
||||||
|
pw.print(data.toString());
|
||||||
|
pw.flush();
|
||||||
|
pw.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writetoFile(StringBuilder data, File filename) {
|
||||||
|
Analyzer.writeToFile(data, filename, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetWarningSize() {
|
||||||
|
int warnings=0;
|
||||||
|
for (CCSD c : ccsd_list) {
|
||||||
|
warnings+=c.warnings.size();
|
||||||
|
for (String s : c.map.keySet()) {
|
||||||
|
for (CCSDComponent cc : c.map.get(s)) {
|
||||||
|
warnings+=cc.warnings.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return warnings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<File> GetDirectories(String basepath) {
|
||||||
|
File[] filelist = new File(basepath).listFiles();
|
||||||
|
List<File> directorylist = new ArrayList<File>();
|
||||||
|
if (filelist!=null) {
|
||||||
|
for (File f : filelist) {
|
||||||
|
if (f!=null && f.isDirectory() && !f.isFile()) {
|
||||||
|
directorylist.add(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return directorylist;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalyzeDirectories(List<File> directories) {
|
||||||
|
JFrame progressmeter = new JFrame("Progress Meter");
|
||||||
|
JProgressBar progressbar = new JProgressBar(0,directories.size());
|
||||||
|
if (!SILENT) {
|
||||||
|
progressbar.setStringPainted(true);
|
||||||
|
progressmeter.getContentPane().setLayout(new BorderLayout());
|
||||||
|
progressmeter.getContentPane().add(progressbar, BorderLayout.CENTER);
|
||||||
|
progressmeter.setSize(240,120);
|
||||||
|
progressmeter.setVisible(true);
|
||||||
|
}
|
||||||
|
int count=0;
|
||||||
|
for (File f : directories) {
|
||||||
|
ccsd_list.add(new CCSD(f));
|
||||||
|
if (!SILENT) {
|
||||||
|
progressbar.setValue(++count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i=0;i<ccsd_list.size();i++) {
|
||||||
|
CCSD c = ccsd_list.get(i);
|
||||||
|
if (c.toBeRemoved) {
|
||||||
|
ccsd_list.remove(i--);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!SILENT) {
|
||||||
|
progressmeter.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
141
CCSDFolderAnalyzer/src/sig/ccsd/CCSD.java
Normal file
141
CCSDFolderAnalyzer/src/sig/ccsd/CCSD.java
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
package sig.ccsd;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CCSD{
|
||||||
|
String id;
|
||||||
|
File file;
|
||||||
|
HashMap<String,List<CCSDComponent>> map = new HashMap<String,List<CCSDComponent>>();
|
||||||
|
List<Warning> warnings = new ArrayList<Warning>();
|
||||||
|
public static String[] map_req_list = new String[]{
|
||||||
|
"T&A","TSO","IER","EXR","DSR","SAM","MISC","CLR","UNL","TSR","RFU","REPORTS"
|
||||||
|
};
|
||||||
|
boolean toBeRemoved=false;
|
||||||
|
|
||||||
|
public CCSD(File f) {
|
||||||
|
if (f.getName().equalsIgnoreCase("FIBER LINK")) {
|
||||||
|
List<File> directories = Analyzer.GetDirectories(f.getAbsolutePath());
|
||||||
|
for (File ff : directories) {
|
||||||
|
Analyzer.ccsd_list.add(new CCSD(ff));
|
||||||
|
}
|
||||||
|
toBeRemoved=true;
|
||||||
|
} else {
|
||||||
|
id = RemoveErroneousData(f.getName());
|
||||||
|
this.file = f;
|
||||||
|
PopulateHashMap();
|
||||||
|
IterateThroughDirectories();
|
||||||
|
System.out.println(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void IterateThroughDirectories() {
|
||||||
|
List<File> directorylist = Analyzer.GetDirectories(file.getAbsolutePath());
|
||||||
|
for (File f : directorylist) {
|
||||||
|
String actualname = f.getName();
|
||||||
|
String[] wrong_location_list = new String[]{"IER","EXR","DSR","RFU"};
|
||||||
|
if (!CheckIfExistsInMapAndAddToComponentList(f, actualname, wrong_location_list)) {
|
||||||
|
String fixedname = RemoveErroneousData(actualname);
|
||||||
|
if (!CheckIfExistsInMapAndAddToComponentList(f, fixedname, wrong_location_list)) {
|
||||||
|
warnings.add(new Warning(f,WarningLabel.EXTRA_FILES));
|
||||||
|
} else {
|
||||||
|
warnings.add(new Warning(f,WarningLabel.TYPO));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String s : map.keySet()) {
|
||||||
|
if (map.get(s).size()==0) {
|
||||||
|
String[] wrong_location_list = new String[]{"IER","EXR","DSR","RFU"};
|
||||||
|
boolean belongsInReport = false;
|
||||||
|
for (String ss : wrong_location_list) {
|
||||||
|
if (ss.equalsIgnoreCase(s)) {
|
||||||
|
belongsInReport=true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
File newfile;
|
||||||
|
if (belongsInReport) {
|
||||||
|
newfile = new File(new File(file.getAbsolutePath(),"REPORTS"),s);
|
||||||
|
} else {
|
||||||
|
newfile = new File(file.getAbsolutePath(),s);
|
||||||
|
}
|
||||||
|
warnings.add(new Warning(newfile,WarningLabel.MISSING_FOLDER));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private boolean CheckIfExistsInMapAndAddToComponentList(File f, String actualname, String[] wrong_location_list) {
|
||||||
|
if (map.containsKey(actualname)) {
|
||||||
|
List<CCSDComponent> tempmap = map.get(actualname);
|
||||||
|
CCSDComponent cc = new CCSDComponent(f,this);
|
||||||
|
tempmap.add(cc);
|
||||||
|
map.put(actualname, tempmap);
|
||||||
|
for (String s : wrong_location_list) {
|
||||||
|
if (actualname.equalsIgnoreCase(s)) {
|
||||||
|
cc.warnings.add(new Warning(f,WarningLabel.WRONG_LOCATION));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private void PopulateHashMap() {
|
||||||
|
for (String s : map_req_list) {
|
||||||
|
map.put(s, new ArrayList<CCSDComponent>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static String RemoveErroneousData(String name) {
|
||||||
|
for (int i=0;i<name.length();i++) {
|
||||||
|
if (!ComposedOfAlphanumbericCharacters(name, i)) {
|
||||||
|
name = name.substring(0,i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//System.out.println("Created CCSD with id "+name+".");
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public static boolean ComposedOfAlphanumbericCharacters(String name, int i) {
|
||||||
|
return (name.charAt(i)>='0' && name.charAt(i)<='9') ||
|
||||||
|
(name.charAt(i)>='A' && name.charAt(i)<='Z') ||
|
||||||
|
(name.charAt(i)>='a' && name.charAt(i)<='z') || name.charAt(i)=='&';
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder("CCSD{\n");
|
||||||
|
sb.append(" "+id+" ("+warnings.size()+" warnings):\n");
|
||||||
|
for (String s : map.keySet()) {
|
||||||
|
int count=0;
|
||||||
|
for (CCSDComponent cc : map.get(s)) {
|
||||||
|
sb.append(" "+cc.label+"["+(count++)+"]: "+cc.filelist.size()+" files, "+cc.warnings.size()+" warnings\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
public Object[] getTableData() {
|
||||||
|
return new Object[]{id,
|
||||||
|
GetOutput("T&A"),
|
||||||
|
GetOutput("TSO"),
|
||||||
|
GetOutput("SAM"),
|
||||||
|
GetOutput("CLR"),
|
||||||
|
GetOutput("UNL"),
|
||||||
|
GetOutput("TSR"),
|
||||||
|
GetOutput("IER"),
|
||||||
|
GetOutput("EXR"),
|
||||||
|
GetOutput("DSR"),
|
||||||
|
GetOutput("RFU"),
|
||||||
|
GetOutput("MISC"),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
private Object GetOutput(String string) {
|
||||||
|
if (map.get(string).size()==0) {
|
||||||
|
return "DOES NOT EXIST";
|
||||||
|
} else
|
||||||
|
if (map.get(string).size()>1){
|
||||||
|
return "DUPLICATE";
|
||||||
|
} else {
|
||||||
|
return map.get(string).get(0).filelist.size()+"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
51
CCSDFolderAnalyzer/src/sig/ccsd/CCSDComponent.java
Normal file
51
CCSDFolderAnalyzer/src/sig/ccsd/CCSDComponent.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package sig.ccsd;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CCSDComponent {
|
||||||
|
File f;
|
||||||
|
String label;
|
||||||
|
CCSD ccsd_parent;
|
||||||
|
List<Warning> warnings = new ArrayList<Warning>();
|
||||||
|
List<File> filelist = new ArrayList<File>();
|
||||||
|
|
||||||
|
public CCSDComponent(File f, CCSD parent) {
|
||||||
|
this.ccsd_parent = parent;
|
||||||
|
this.f=f;
|
||||||
|
this.label = CCSD.RemoveErroneousData(f.getName());
|
||||||
|
File[] files = f.listFiles();
|
||||||
|
for (File f1 : files) {
|
||||||
|
if (f1.isFile() || f1.isDirectory()) {
|
||||||
|
filelist.add(f1);
|
||||||
|
if (f1.isDirectory()) {
|
||||||
|
if (ccsd_parent.map.containsKey(f1.getName())) {
|
||||||
|
List<CCSDComponent> list = ccsd_parent.map.get(f1.getName());
|
||||||
|
CCSDComponent cc = new CCSDComponent(f1,ccsd_parent);
|
||||||
|
list.add(cc);
|
||||||
|
if (list.size()>1) {
|
||||||
|
warnings.add(new Warning(f,WarningLabel.DUPLICATE_FOLDER));
|
||||||
|
}
|
||||||
|
ccsd_parent.map.put(f1.getName(), list);
|
||||||
|
boolean found=false;
|
||||||
|
if (label.equalsIgnoreCase("REPORTS")) {
|
||||||
|
String[] correct_location_list = new String[]{"IER","EXR","DSR","RFU"};
|
||||||
|
for (String s : correct_location_list) {
|
||||||
|
if (s.equalsIgnoreCase(f1.getName())) {
|
||||||
|
found=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
cc.warnings.add(new Warning(f1,WarningLabel.WRONG_LOCATION));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (filelist.size()==0) {
|
||||||
|
warnings.add(new Warning(f,WarningLabel.MISSING_FILES));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
CCSDFolderAnalyzer/src/sig/ccsd/SelectAllButton.java
Normal file
7
CCSDFolderAnalyzer/src/sig/ccsd/SelectAllButton.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package sig.ccsd;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
|
||||||
|
public class SelectAllButton extends JButton{
|
||||||
|
|
||||||
|
}
|
60
CCSDFolderAnalyzer/src/sig/ccsd/TableRenderer.java
Normal file
60
CCSDFolderAnalyzer/src/sig/ccsd/TableRenderer.java
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package sig.ccsd;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
|
|
||||||
|
public class TableRenderer extends DefaultTableCellRenderer{
|
||||||
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
|
||||||
|
{
|
||||||
|
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||||
|
Color ccc = Color.WHITE;
|
||||||
|
if(column!=0 && value instanceof String) {
|
||||||
|
String s = (String)value;
|
||||||
|
switch (s.trim()) {
|
||||||
|
case "DOES NOT EXIST":{
|
||||||
|
ccc=Color.RED;
|
||||||
|
}break;
|
||||||
|
case "DUPLICATE":{
|
||||||
|
ccc=Color.MAGENTA;
|
||||||
|
}break;
|
||||||
|
case "0":{
|
||||||
|
ccc=Color.YELLOW;
|
||||||
|
}break;
|
||||||
|
default:{
|
||||||
|
ccc=Color.GREEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (table.getValueAt(row, 3) instanceof String) {
|
||||||
|
String s = (String)table.getValueAt(row, 3);
|
||||||
|
if (s.equalsIgnoreCase(WarningLabel.DUPLICATE_FOLDER.desc)) {
|
||||||
|
ccc = Color.MAGENTA;
|
||||||
|
} else
|
||||||
|
if (s.equalsIgnoreCase(WarningLabel.EXTRA_FILES.desc)) {
|
||||||
|
ccc = Color.CYAN;
|
||||||
|
} else
|
||||||
|
if (s.equalsIgnoreCase(WarningLabel.MISSING_FILES.desc)) {
|
||||||
|
ccc = Color.YELLOW;
|
||||||
|
} else
|
||||||
|
if (s.equalsIgnoreCase(WarningLabel.TYPO.desc)) {
|
||||||
|
ccc = Color.GREEN;
|
||||||
|
} else
|
||||||
|
if (s.equalsIgnoreCase(WarningLabel.MISSING_FOLDER.desc)) {
|
||||||
|
ccc = Color.RED;
|
||||||
|
} else
|
||||||
|
if (s.equalsIgnoreCase(WarningLabel.WRONG_LOCATION.desc)) {
|
||||||
|
ccc = new Color(120,120,255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isSelected) {
|
||||||
|
ccc = new Color((int)(ccc.getRed()/1.5f),(int)(ccc.getGreen()/1.5f),(int)(ccc.getBlue()/1.5f));
|
||||||
|
} else {
|
||||||
|
ccc = new Color((int)Math.min(ccc.getRed()+64,255),(int)Math.min((ccc.getGreen()+64),255),(int)Math.min((ccc.getBlue()+64),255));
|
||||||
|
}
|
||||||
|
c.setBackground(ccc);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
13
CCSDFolderAnalyzer/src/sig/ccsd/Warning.java
Normal file
13
CCSDFolderAnalyzer/src/sig/ccsd/Warning.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package sig.ccsd;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class Warning {
|
||||||
|
WarningLabel type;
|
||||||
|
File f;
|
||||||
|
|
||||||
|
public Warning(File f, WarningLabel type) {
|
||||||
|
this.f=f;
|
||||||
|
this.type=type;
|
||||||
|
}
|
||||||
|
}
|
20
CCSDFolderAnalyzer/src/sig/ccsd/WarningLabel.java
Normal file
20
CCSDFolderAnalyzer/src/sig/ccsd/WarningLabel.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package sig.ccsd;
|
||||||
|
|
||||||
|
public enum WarningLabel {
|
||||||
|
WRONG_LOCATION("The folder is located in the wrong place."),
|
||||||
|
TYPO("The folder is not named properly."),
|
||||||
|
MISSING_FILES("There are no files located in this folder."),
|
||||||
|
EXTRA_FILES("There are extra folders that don't belong in this folder."),
|
||||||
|
DUPLICATE_FOLDER("There is already a copy of this folder elsewhere for this CCSD."),
|
||||||
|
MISSING_FOLDER("Folder does not exist in this location.");
|
||||||
|
|
||||||
|
String desc;
|
||||||
|
|
||||||
|
WarningLabel(String desc) {
|
||||||
|
this.desc=desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user