01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/sam/tags/sakai_2-4-1/samigo-app/src/java/org/sakaiproject/tool/assessment/ws/SamigoToolWebService.java $
03: * $Id: SamigoToolWebService.java 9290 2006-05-11 08:52:23Z lydial@stanford.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the"License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/
21:
22: /**
23: * SamigoToolWebService.java
24: *
25: * This was part of the web services demo files
26: * This file used to be called by an Apache Axis generated
27: * SamigoToolServiceSoapBindingImpl.java
28: * all the wsdl2java generated files are deleted due to Axis 1.1 imcompatible
29: * with jdk 1.5
30: * Will regenerate them if we need to use this again.
31: * Keep this file in case we want to reuse any of the methods here.
32: */package org.sakaiproject.tool.assessment.ws;
33:
34: import java.util.HashMap;
35: import java.util.Iterator;
36:
37: import org.sakaiproject.tool.assessment.facade.ItemFacade;
38: import org.sakaiproject.tool.assessment.services.ItemService;
39: import org.sakaiproject.tool.assessment.services.qti.QTIService;
40: import org.sakaiproject.tool.assessment.qti.util.XmlUtil;
41: import org.w3c.dom.Document;
42:
43: public class SamigoToolWebService {
44:
45: /**
46: * Creates a new SamigoToolWebService object.
47: */
48: public SamigoToolWebService() {
49: }
50:
51: /**
52: * Get an array of items from the backend, with all questions.
53: */
54: public Item[] getItemObjArrayByKeyword(String keyword) {
55: ItemService itemservice = new ItemService();
56: HashMap map = itemservice.getItemsByKeyword(keyword);
57: Item[] itemArray = new Item[map.size()];
58:
59: // converting to Object Array for transmitting through Axis SOAP
60: int i = 0;
61: Iterator iter = map.keySet().iterator();
62: while (iter.hasNext()) {
63: String itemid = (String) iter.next();
64: if (map.get(itemid) != null) {
65: ItemFacade a = (ItemFacade) map.get(itemid);
66: String itemtext = a.getText();
67: String idstring = a.getItemIdString();
68: Item item = new Item();
69: item.setItemid(idstring);
70: item.setItemtext(itemtext);
71: item.setUrl(showItem(idstring));
72: itemArray[i] = item;
73: i++;
74: }
75: }
76:
77: return itemArray;
78:
79: }
80:
81: public java.lang.String showItem(java.lang.String itemid) {
82: String ret = "jsf/test/previewQuestion.faces?itemid=" + itemid;
83: return ret;
84: }
85:
86: public String download(String[] idStringArray, String qtiVersion) {
87:
88: // move this to TestWSBean.getItembankxml
89:
90: QTIService qtiservice = new QTIService();
91:
92: Document doc = qtiservice.getExportedItemBank(idStringArray,
93: new Integer(qtiVersion).intValue());
94: String xmlString = XmlUtil.getDOMString(doc);
95: return xmlString;
96: }
97:
98: }
|