Coverage details for umich.cac.pbs.DeleteRecord

LineHitsSource
1 package umich.cac.pbs;
2  
3 import java.util.logging.Logger;
4  
5 import umich.cac.data.Field;
6 import umich.cac.data.FieldName;
7 import umich.cac.data.FieldType;
8  
9 /**
10  * Process the DELETE record, "D" record in PBS. This is when a user cancels a
11  * job for example
12  * <p>
13  *
14  * An example from PBS accounting file is below
15  *
16  * <pre>
17  * 11/21/2002 13:56:46;D;15094.head;requestor=bwickman@head
18  * </pre>
19  *
20  * @author rmach@umich.edu
21  * @version $Header: /cvsroot/pbsaccounting/pbsaccounting/src/umich/cac/pbs/DeleteRecord.java,v 1.4 2003/10/21 19:39:03 rodmach Exp $
22  */
23  
246public class DeleteRecord implements PbsRecordParser {
25  
26     /** Logger instance */
279    private Logger logger = Logger.getLogger(DeleteRecord.class.getName());
28  
29     /**
30      * Return the XML representation of an D record, inside &ltdelete_record&gt
31      * tags.
32      * <p>
33      *
34      * @param rawfields
35      * Array from PBS containing the delete record (D record)
36      * @return The delete record converted to XML
37      */
38     public String processRecord(String[] rawfields) {
39  
40         //This field
413        Field deleteField =
42             new Field(
43                 FieldName.DELETE_FIELD,
44                 "delete_record",
45                 FieldType.GENERIC);
46  
47         //The JOB ID
483        Field jobIdField =
49             FieldFactory.getInstance().getField(
50                 FieldName.JOBID,
51                 rawfields[RecordPosition.JOB_ID]);
523        deleteField.addChild(jobIdField);
53  
54         //The DATE
553        Field dateField =
56             FieldFactory.getInstance().getField(
57                 FieldName.DATE,
58                 rawfields[RecordPosition.DATE_TIME]);
593        deleteField.addChild(dateField);
60  
61         //Split message area that is space seperated string into an array.
623        String[] fields = rawfields[RecordPosition.MESSAGE_AREA].split(" ");
63  
64         //PBS encodes in FIELD=VALUE pairs
653        int FIELD_NAME = 0;
663        int FIELD_VALUE = 1;
67  
683        String fieldName = "";
693        String fieldValue = "";
70  
71         //Go through all the fields, querying FieldFactory for fields
726        for (int i = 0; i < fields.length; i++) {
733            String[] hashPair = fields[i].split("=");
74  
753            fieldName = hashPair[FIELD_NAME];
763            fieldValue = hashPair[FIELD_VALUE];
77  
783            Field theField =
79                 FieldFactory.getInstance().getField(fieldName, fieldValue);
80  
81             //This type only has GENERIC fields, only requestor field
823            if (theField.getFieldType() == FieldType.GENERIC) {
833                deleteField.addChild(theField);
84             }
85         }
86  
873        return deleteField.toXML();
88  
89     }
90  
91 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.