 package com.connor.erp.toolkit;
 
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import org.jdom.Attribute;
 import org.jdom.Document;
 import org.jdom.Element;
 import org.jdom.JDOMException;
 import org.jdom.input.SAXBuilder;
 
 public class ReadResultXMLStr {
   public static boolean xmlElements(File xmlFilePath, Map<String, Object> map) {
/*  37 */     SAXBuilder sb = new SAXBuilder();
     try {
/*  40 */       Document doc = sb.build(xmlFilePath);
/*  42 */       Element root = doc.getRootElement();
/*  43 */       List<?> attributes = root.getAttributes();
/*  44 */       int attrSize = attributes.size();
/*  45 */       for (int j = 0; j < attrSize; j++) {
/*  46 */         Attribute attr = (Attribute)attributes.get(j);
/*  47 */         String attr_name = attr.getName();
/*  48 */         String attr_value = attr.getValue();
/*  49 */         if (attr_name.equals("fileType") && attr_value.equals("result")) {
///*  50 */           loadElements(root.getChildren(), map);
/*  51 */           return true;
         } 
       } 
/*  54 */     } catch (JDOMException e) {
/*  55 */       e.printStackTrace();
/*  56 */     } catch (IOException e) {
/*  57 */       e.printStackTrace();
     } 
/*  59 */     return false;
   }
   
   public static Boolean loadElements(Map<String, Object> resultMap, Map<String, Object> map) {
/*  64 */     if (resultMap == null)
					return true; 
///*  67 */     for (int m = 0; m < resultlistSize; m++) {
///*  68 */       Element childEle = (Element)resultMap.get(m);
///*  69 */       String childEle_name = childEle.getName();
///*  70 */       String childEle_value = childEle.getValue();
///*  71 */       if (childEle_name.equals("taskSN")) {
///*  72 */         map.put(childEle_name, childEle_value);
///*  73 */       } else if (childEle_name.equals("taskResult")) {
///*  74 */         map.put(childEle_name, childEle_value);
///*  75 */       } else if (childEle_name.equals("currentStep")) {
///*  76 */         map.put(childEle_name, childEle_value);
///*  77 */       } else 
				map.put("taskSN", resultMap.get("sid"));
				map.put("taskResult", resultMap.get("result"));
				map.put("currentStep", resultMap.get("status"));
//				if (childEle_name.equals("executeLog")) {
///*  78 */         List<?> wronglinelist = childEle.getChildren();
///*  79 */         int wronglinelistSize = wronglinelist.size();
///*  80 */         List<String> listWronglineInfo = new ArrayList<String>();
///*  81 */         if (wronglinelistSize > 0)
///*  82 */           for (int i = 0; i < wronglinelistSize; i++) {
///*  83 */             Element wronglineEle = (Element)wronglinelist.get(i);
///*  84 */             String wrongItem = wronglineEle.getValue();
///*  85 */             List<?> attributes = wronglineEle.getAttributes();
///*  86 */             int attrSize = attributes.size();
///*  87 */             String wrongType = "";
///*  88 */             for (int j = 0; j < attrSize; j++) {
///*  89 */               Attribute attr = (Attribute)attributes.get(j);
///*  90 */               String attr_name = attr.getName();
///*  91 */               String attr_value = attr.getValue();
///*  92 */               if (attr_name.equals("wrongType")) {
///*  93 */                 wrongType = UtilApi.getWrongType(Integer.parseInt(attr_value));
//                 break;
//               } 
//             } 
///*  97 */             listWronglineInfo.add(wrongItem + " " + wrongType);
//           }  
///* 100 */         map.put("wrongLine", listWronglineInfo);
//       } 
//     } 
				return true;
   }
   
   public static String getFileType(File xmlFilePath) {
/* 107 */     SAXBuilder sb = new SAXBuilder();
/* 108 */     String fileType = "";
     try {
/* 111 */       Document doc = sb.build(xmlFilePath);
/* 113 */       Element root = doc.getRootElement();
/* 114 */       if (root.getAttribute("fileType") != null)
/* 115 */         fileType = root.getAttribute("fileType").getValue(); 
/* 117 */     } catch (JDOMException e) {
/* 118 */       e.printStackTrace();
/* 119 */     } catch (IOException e) {
/* 120 */       e.printStackTrace();
     } 
/* 122 */     return fileType;
   }
 }

