1 /***
2 * Created on Aug 5, 2005, Copyright UC Regents
3 */
4 package wise2.converter.converters;
5
6 import java.net.MalformedURLException;
7 import java.net.URL;
8 import java.util.HashMap;
9 import java.util.List;
10 import java.util.Map;
11
12 import org.dom4j.Node;
13 import org.telscenter.pas.beans.PasStep;
14 import org.telscenter.pas.steps.WobbleModule;
15
16 import wise2.converter.AbstractStepConverter;
17
18 /***
19 * @author turadg
20 */
21 public class UnsupportedConverter extends AbstractStepConverter {
22
23 /***
24 * @param list
25 * @return
26 */
27 private static Map<String, String> nodeListToMap(List<Node> list) {
28 Map<String, String> map = new HashMap<String, String>();
29 for (Node entryNode : list) {
30 String key = entryNode.getName();
31 String value = entryNode.getText();
32 map.put(key, value);
33 }
34 return map;
35 }
36
37 @SuppressWarnings("unchecked")
38 @Override
39 public PasStep getTypedPasStep() {
40 WobbleModule step = new WobbleModule();
41
42 Node urlNode = stepNode.selectSingleNode("./url");
43 if (urlNode != null) {
44 try {
45 String relativeUrl = urlNode.getText();
46
47 String absoluteUrl = "http://wise.berkeley.edu" + relativeUrl;
48 URL studentUrl = new URL(absoluteUrl);
49 step.setUrl(studentUrl);
50 } catch (MalformedURLException e) {
51
52 e.printStackTrace();
53 }
54 }
55
56 Node otherDataNode = stepNode.selectSingleNode("./otherData");
57 if (otherDataNode != null) {
58 String otherData = otherDataNode.getText();
59 step.setModuleOtherData(otherData);
60 }
61
62 Node otherNumberNode = stepNode.selectSingleNode("./otherNumber");
63 if (otherNumberNode != null) {
64 String otherNumberStr = otherNumberNode.getText();
65 int otherNumber = Integer.parseInt(otherNumberStr);
66 step.setModuleOtherNumber(otherNumber);
67 }
68
69 return step;
70 }
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 }