Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

SignoffDataInterface.java

00001 package ProdDatabase;
00002 //
00003 // @Author Dave Robinson
00004 //
00005 import java.io.*;
00006 import java.util.Hashtable;
00007 import java.util.Vector;
00008 import Preferences.PreferencesInterface;
00009 import guiUtilities.userPrompt;
00010 import guiUtilities.DaveUtils;
00011 
00012 public class SignoffDataInterface implements ModuleSignoffData {
00013 
00014    Hashtable signoffDataHash;
00015    private String location;
00016    String signoffType;
00017    String finalSignoffInfo;
00018    Vector snList;
00019 
00020     public SignoffDataInterface(String serialNo, String location, String signoffType) {
00021             this.signoffType=signoffType;
00022             try {
00023               signoffDataHash = GeneralUtilities.getSignoffDataTestNo(serialNo, location, signoffType);
00024               if(!signoffDataHash.containsKey(location)) return;
00025               String testno = (String)signoffDataHash.get(location);
00026               Vector rawData = GeneralUtilities.getRawData(testno);
00027               if(rawData.size()>0) signoffDataHash.put(location,new SignoffData(GeneralUtilities.getUploaderInfo(testno),(String)rawData.elementAt(1)));
00028             }catch(Exception e){System.out.println("FAILED to download signoff data: "+e.toString());}
00029        }
00030     public SignoffDataInterface(String serialNo, String signoffType) {
00031             this.signoffType=signoffType;
00032             try {
00033               signoffDataHash = GeneralUtilities.getSignoffDataTestNo(serialNo,signoffType);
00034               // replace test numbers by SignoffData objects
00035               for (java.util.Enumeration e = signoffDataHash.keys() ; e.hasMoreElements() ;) {
00036                     String location  = (String)e.nextElement();
00037                     String testno = (String)signoffDataHash.get(location);
00038                     Vector rawData = GeneralUtilities.getRawData(testno);
00039                     if(rawData.size()>0) signoffDataHash.put(location,new SignoffData(GeneralUtilities.getUploaderInfo(testno),(String)rawData.elementAt(1)));
00040                     else signoffDataHash.remove(location);
00041                     }
00042             }catch(Exception e){System.out.println("FAILED to download signoff data: "+e.toString());}
00043        }
00044    public SignoffDataInterface(String sn1, String sn2, String currLocation, String institute, String signoffType) {
00045             try {
00046               snList = GeneralUtilities.getSignoffDataTestNos(sn1,sn2,currLocation, institute, signoffType);
00047             }catch(Exception e){System.out.println("FAILED to download signoff data: "+e.toString());}
00048        }
00049 
00050     public Vector getSignoffTable() {
00051           Vector tableList = new Vector();
00052           Vector itemList=new Vector();
00053           itemList.addElement("Serial No");
00054           itemList.addElement("Uploaded by");
00055           itemList.addElement("Date");
00056           itemList.addElement("Category");
00057           itemList.addElement("Reason");
00058           itemList.addElement("Barrel Assignment");
00059           itemList.addElement("Reason");
00060           itemList.addElement("Comments");
00061           tableList.addElement(itemList);
00062           if(snList.size()==0) return tableList;
00063 
00064           try {
00065           for(int i=0;i<snList.size();i++) {
00066              itemList = new Vector();
00067              String testno = (String)snList.elementAt(i);
00068              SignoffData signoffData = new SignoffData((String)snList.elementAt(i));  
00069              itemList.addElement(signoffData.getString(ModuleSignoffData.SERIALNO));
00070              SCTDBTestInfoHolder testInfo = GeneralUtilities.getTestInfo(testno);
00071              itemList.addElement(testInfo.get(SCTDBTestInfoHolder.LOCATION));
00072              itemList.addElement(testInfo.get(SCTDBTestInfoHolder.DATE));
00073              itemList.addElement(signoffData.getString(ModuleSignoffData.CATEGORY));
00074              String failReason = signoffData.getString(ModuleSignoffData.FAILREASON);
00075              if(failReason==null) itemList.addElement("n/a");
00076              else itemList.addElement(failReason);
00077              itemList.addElement(signoffData.getString(ModuleSignoffData.BARREL));
00078              String b56Reason = signoffData.getString(ModuleSignoffData.B56REASON);
00079              if(b56Reason==null) itemList.addElement("n/a");
00080              else itemList.addElement(b56Reason);
00081              itemList.addElement(signoffData.getString(ModuleSignoffData.COMMENT));
00082              tableList.addElement(itemList);
00083              }
00084            }catch(Exception e){System.err.println("Exception "+e.toString());}
00085            return tableList;
00086            }
00087 
00088     public Vector getQualityTable() {
00089           Vector tableList = new Vector();
00090           Vector itemList=new Vector();
00091           itemList.addElement("Serial No");
00092           itemList.addElement("Uploaded by");
00093           itemList.addElement("Date");
00094           itemList.addElement("IV Category");
00095           itemList.addElement("IV comment");
00096           itemList.addElement("Elec Category");
00097           itemList.addElement("Elec comment");
00098           itemList.addElement("Elec spec Settings");
00099           itemList.addElement("SCurve Category");
00100           itemList.addElement("SCurve comment");
00101           tableList.addElement(itemList);
00102           if(snList.size()==0) return tableList;
00103 
00104           try {
00105           for(int i=0;i<snList.size();i++) {
00106              itemList = new Vector();
00107              String testno = (String)snList.elementAt(i);
00108              System.out.println("Extracting quality data for test number "+testno);
00109              SignoffData signoffData = new SignoffData(testno);  
00110              itemList.addElement(signoffData.getString(ModuleSignoffData.SERIALNO));
00111              SCTDBTestInfoHolder testInfo = GeneralUtilities.getTestInfo(testno);
00112              itemList.addElement(testInfo.get(SCTDBTestInfoHolder.LOCATION));
00113              itemList.addElement(testInfo.get(SCTDBTestInfoHolder.DATE));
00114              itemList.addElement( (signoffData.getString(ModuleSignoffData.IVCATEGORY)!=null) ? signoffData.getString(ModuleSignoffData.IVCATEGORY) : "Not known");
00115              itemList.addElement( (signoffData.getString(ModuleSignoffData.IVCOMMENT)!=null) ? signoffData.getString(ModuleSignoffData.IVCOMMENT) : "None");
00116              itemList.addElement( (signoffData.getString(ModuleSignoffData.ELECTRICALCATEGORY)!=null) ? signoffData.getString(ModuleSignoffData.ELECTRICALCATEGORY) : "Unknown");
00117              itemList.addElement( (signoffData.getString(ModuleSignoffData.ELECTRICALCOMMENT)!=null) ? signoffData.getString(ModuleSignoffData.ELECTRICALCOMMENT) : "None");
00118              itemList.addElement( (signoffData.getString(ModuleSignoffData.ELEC_SPECIAL_SETTING)!=null) ? signoffData.getString(ModuleSignoffData.ELEC_SPECIAL_SETTING) : "None");
00119              itemList.addElement( (signoffData.getString(ModuleSignoffData.SCURVECATEGORY)!=null) ? signoffData.getString(ModuleSignoffData.SCURVECATEGORY) : "Ok");
00120              itemList.addElement( (signoffData.getString(ModuleSignoffData.SCURVECOMMENT)!=null) ? signoffData.getString(ModuleSignoffData.SCURVECOMMENT) : "None");
00121              tableList.addElement(itemList);
00122              }
00123            }catch(Exception e){System.err.println("Exception "+e.toString());}
00124            return tableList;
00125            }
00126    public Vector getTestNoList() {
00127        return snList;
00128        }
00129 
00130        
00131 
00132     public String getString(String location,int index, boolean isHTML) {
00133         if(!signoffDataHash.containsKey(location)) return "None uploaded";
00134         String value=null;
00135         if((value=((SignoffData)signoffDataHash.get(location)).getString(index))!=null) {
00136                if(isHTML) value = value.replaceAll("\\n","<br>");
00137                switch(index) {
00138                     case ModuleSignoffData.IVCATEGORY:
00139                     case ModuleSignoffData.ELECTRICALCATEGORY:
00140                     case ModuleSignoffData.SCURVECATEGORY:
00141                       if(value.matches(".*GOOD|Good.*")) value="<font color=green>"+value+"</font>";
00142                       else value="<font color=red>"+value+"</font>";
00143                       break;
00144                     default:
00145                 }
00146             }
00147         return (value==null) ? "None uploaded" : value;
00148         }
00149 //**************************************8
00150 // this method specifically for FINALSIGNOFF data
00151 // where the hash should have only one key-value pair
00152     public String getString(int index, boolean isHTML) {
00153         String value=null;
00154         if(signoffDataHash.size()!=1) return null;
00155         for (java.util.Enumeration e = signoffDataHash.keys() ; e.hasMoreElements() ;) {
00156             String location  = (String)e.nextElement();     
00157             value=((SignoffData)signoffDataHash.get(location)).getString(index);
00158             if(isHTML) value = value.replaceAll("\\n","<br>");
00159             }
00160         return value;
00161         }
00162 //**************************************************
00163     public boolean qualityInfoIsPresent() {
00164        if(signoffDataHash.size()==0) return false;
00165        for (java.util.Enumeration e = signoffDataHash.keys() ; e.hasMoreElements() ;) {
00166             String location  = (String)e.nextElement();     
00167             String value;
00168             if((value=((SignoffData)signoffDataHash.get(location)).getString(ModuleSignoffData.IVCATEGORY))==null) return false;
00169             }
00170         return true;
00171         }
00172 
00173     public Hashtable getSignoffDataHash() {
00174         return signoffDataHash;
00175         }
00176     public void setParameter(String location, int index, String value) {
00177         if(!signoffDataHash.containsKey(location)) signoffDataHash.put(location, new SignoffData());
00178         ((SignoffData)signoffDataHash.get(location)).put(keywords[index],value);
00179         }
00180     public String getUploaderInfo(String location) {
00181         if(!signoffDataHash.containsKey(location)) return null;
00182         return ((SignoffData)signoffDataHash.get(location)).getUploaderInfo();
00183         }
00184 
00185 //**********************************************************************************
00186     public String writeUploadFiles(String sn, String location) {
00187         String userInitials=null;
00188         if(!signoffDataHash.containsKey(location)) return null;
00189         SignoffData signoffData = (SignoffData)signoffDataHash.get(location);
00190         try {
00191           userPrompt thisPrompt = new userPrompt(null,"","Your initials", GeneralUtilities.getNameList(location));
00192           thisPrompt.pack();
00193           thisPrompt.setVisible(true);
00194           userInitials = thisPrompt.getValidatedText();
00195           if (userInitials.equals("None")) return null;
00196           } catch(Exception e1){System.out.println("ERROR retrieving list of users from SCTDB: "+e1.toString()); return null;}
00197         try {
00198           return ProdDatabase.BarrelUtilities.writeUploadFile(sn,signoffData.writeUploadDataFile(sn),userInitials, location,signoffType);
00199           }catch(Exception e) {System.out.println("FAILED to create upload file: "+e.toString()); return null;}
00200         }
00201 
00202 //*****************************************************************************
00203 }

Generated on Thu Jul 15 09:55:49 2004 for SCT DAQ/DCS Software - Java by doxygen 1.3.5