private void deleteJsonJobs(ApplicationInfo appInfo, List<CIJob> selectedJobs) throws PhrescoException { try { if (CollectionUtils.isEmpty(selectedJobs)) { return; } Gson gson = new Gson(); List<CIJob> jobs = getJobs(appInfo); if (CollectionUtils.isEmpty(jobs)) { return; } // all values Iterator<CIJob> iterator = jobs.iterator(); // deletable values for (CIJob selectedInfo : selectedJobs) { while (iterator.hasNext()) { CIJob itrCiJob = iterator.next(); if (itrCiJob.getName().equals(selectedInfo.getName())) { iterator.remove(); break; } } } writeJsonJobs(appInfo, jobs, CI_CREATE_NEW_JOBS); } catch (Exception e) { throw new PhrescoException(e); } }
public List<CIBuild> getBuilds(CIJob job) throws PhrescoException { if (debugEnabled) { S_LOGGER.debug("Entering Method CIManagerImpl.getCIBuilds(CIJob job)"); } List<CIBuild> ciBuilds = null; try { if (debugEnabled) { S_LOGGER.debug("getCIBuilds() JobName = " + job.getName()); } JsonArray jsonArray = getBuildsArray(job); ciBuilds = new ArrayList<CIBuild>(jsonArray.size()); Gson gson = new Gson(); CIBuild ciBuild = null; for (int i = 0; i < jsonArray.size(); i++) { ciBuild = gson.fromJson(jsonArray.get(i), CIBuild.class); setBuildStatus(ciBuild, job); String buildUrl = ciBuild.getUrl(); String jenkinUrl = job.getJenkinsUrl() + ":" + job.getJenkinsPort(); buildUrl = buildUrl.replaceAll( "localhost:" + job.getJenkinsPort(), jenkinUrl); // when displaying url it should display setup machine ip ciBuild.setUrl(buildUrl); ciBuilds.add(ciBuild); } } catch (Exception e) { if (debugEnabled) { S_LOGGER.debug( "Entering Method CIManagerImpl.getCIBuilds(CIJob job) " + e.getLocalizedMessage()); } } return ciBuilds; }
protected String getRallyAPIError(String responseXML) { String errorMsg = ""; try { org.jdom.input.SAXBuilder bSAX = new org.jdom.input.SAXBuilder(); org.jdom.Document doc = bSAX.build(new StringReader(responseXML)); Element root = doc.getRootElement(); XPath xpath = XPath.newInstance("//Errors"); List xlist = xpath.selectNodes(root); Iterator iter = xlist.iterator(); while (iter.hasNext()) { Element item = (Element) iter.next(); errorMsg = item.getChildText("OperationResultError"); } } catch (Exception e) { errorMsg = e.toString(); } return errorMsg; }
private CIJobStatus buildJob(CIJob job) throws PhrescoException { if (debugEnabled) { S_LOGGER.debug("Entering Method CIManagerImpl.buildJob(CIJob job)"); } cli = getCLI(job); List<String> argList = new ArrayList<String>(); argList.add(FrameworkConstants.CI_BUILD_JOB_COMMAND); argList.add(job.getName()); try { int status = cli.execute(argList); String message = FrameworkConstants.CI_BUILD_STARTED; if (status == FrameworkConstants.JOB_STATUS_NOTOK) { message = FrameworkConstants.CI_BUILD_STARTING_ERROR; } return new CIJobStatus(status, message); } finally { if (cli != null) { try { cli.close(); } catch (IOException e) { if (debugEnabled) { S_LOGGER.error(e.getLocalizedMessage()); } } catch (InterruptedException e) { if (debugEnabled) { S_LOGGER.error(e.getLocalizedMessage()); } } } } }
/** * 普通版填写包的公共部分 * @param root 开始节点 * @param map 参数map * @param sCycName 循环节点名 * @return */ public Element writeptPublicNode(Element root,HashMap map,String sCycName) { Element node=null; try { String sName=""; String sValue=""; List list=root.getChildren(); for(int i=0;i<list.size();i++) { node=(Element)list.get(i); sName=node.getName(); sName=sName.trim(); sValue=(String)map.get(sName); //System.err.println("sName:"+sName+":"+sValue); if(sCycName.equals(sName)&&(root.getName()).trim().equals("ReqParamSet")) { //System.err.println("find cyc node:"+sName ); return node; } else if(sValue!=null && !"".equals(sValue) ) node.setText(sValue); node=writeptPublicNode(node,map,sCycName); } }catch(Exception ex) { ex.printStackTrace(); System.err.println("error:"+ex.getMessage()); } return node; }
public Element getLookupElement() { Element e = new Element("lookup"); if (saveErrors.size() != 0) { saveErrors.clear(); } ObjEntityView view = objEntityViewField.getObjEntityView(); DataView dataView = view.getDataView(); String fieldPath = "<b>" + dataView.getName() + "." + view.getName() + "." + objEntityViewField.getName() + "</b><br>"; if (lookupObjEntityView != null) { e.setAttribute(new Attribute("obj-entity-view-name", lookupObjEntityView.getName())); } else { e.setAttribute(new Attribute("obj-entity-view-name", "")); saveErrors.add(fieldPath + "lookup hasn't attribute \"obj-entity-view-name\"<br><br>"); } if (lookupField != null) { e.setAttribute(new Attribute("field-name", lookupField.getName())); } else { e.setAttribute(new Attribute("field-name", "")); saveErrors.add(fieldPath + "lookup hasn't attribute \"field-name\"<br><br>"); } e.addContent(""); return e; }
/** * This will invoke the <code>startElement</code> callback in the <code>ContentHandler</code>. * * @param element <code>Element</code> used in callbacks. * @param nsAtts <code>List</code> of namespaces to declare with the element or <code>null</code>. */ private void startElement(Element element, Attributes nsAtts) throws JDOMException { String namespaceURI = element.getNamespaceURI(); String localName = element.getName(); String rawName = element.getQualifiedName(); // Allocate attribute list. AttributesImpl atts = (nsAtts != null) ? new AttributesImpl(nsAtts) : new AttributesImpl(); List attributes = element.getAttributes(); Iterator i = attributes.iterator(); while (i.hasNext()) { Attribute a = (Attribute) i.next(); atts.addAttribute( a.getNamespaceURI(), a.getName(), a.getQualifiedName(), getAttributeTypeName(a.getAttributeType()), a.getValue()); } try { contentHandler.startElement(namespaceURI, localName, rawName, atts); } catch (SAXException se) { throw new JDOMException("Exception in startElement", se); } }
/** * Processes the messages from the server * * @param message */ private synchronized void processServerMessage(String message) { SAXBuilder builder = new SAXBuilder(); String what = new String(); Document doc = null; try { doc = builder.build(new StringReader(message)); Element root = doc.getRootElement(); List childs = root.getChildren(); Iterator i = childs.iterator(); what = ((Element) i.next()).getName(); } catch (Exception e) { } if (what.equalsIgnoreCase("LOGIN") == true) _login(doc); else if (what.equalsIgnoreCase("LOGOUT") == true) _logout(doc); else if (what.equalsIgnoreCase("MESSAGE") == true) _message(doc); else if (what.equalsIgnoreCase("WALL") == true) _wall(doc); else if (what.equalsIgnoreCase("CREATEGROUP") == true) _creategroup(doc); else if (what.equalsIgnoreCase("JOINGROUP") == true) _joingroup(doc); else if (what.equalsIgnoreCase("PARTGROUP") == true) _partgroup(doc); else if (what.equalsIgnoreCase("GROUPMESSAGE") == true) _groupmessage(doc); else if (what.equalsIgnoreCase("KICK") == true) _kick(doc); else if (what.equalsIgnoreCase("LISTUSER") == true) _listuser(doc); else if (what.equalsIgnoreCase("LISTGROUP") == true) _listgroup(doc); }
/* * 递归完成查找 * para: Element root 开始查找节点 */ public Element findNode(Element root,String sNodeName) { Element node =null; try { String sName=""; List list=root.getChildren(); for(int i=0;i<list.size();i++) { node=(Element)list.get(i); sName=node.getName(); sName=sName.trim(); //System.err.println("node name:"+sName+"-"+sNodeName); if(sName.equals(sNodeName)) { System.err.println("find the node:"+sName); return node; } node=findNode(node,sNodeName); } }catch(Exception ex) { ex.printStackTrace(); System.err.println("error:"+ex.getMessage()); } return node; }
public List getUserListAT() { List<Map> list = new ArrayList<Map>(); String[][] data = { {"3537255778", "Alex Chen"}, {"2110989338", "Brian Wang"}, {"3537640807", "David Hsieh"}, {"5764816553", "James Yu"}, {"3756404948", "K.C."}, {"2110994764", "Neil Weinstock"}, {"6797798390", "Owen Chen"}, {"3831206627", "Randy Chen"}, {"6312460903", "Tony Shen"}, {"2110993498", "Yee Liaw"} }; for (int i = 0; i < data.length; i++) { Map map = new HashMap(); String userRef = data[i][0]; String userName = data[i][1]; map.put("userObjectId", userRef); map.put("userName", userName); list.add(map); } return list; }
// returns a macro adder for the given morph item private MacroAdder getMacAdder(MorphItem mi) { // check map MacroAdder retval = macAdderMap.get(mi); if (retval != null) return retval; // set up macro adder IntHashSetMap macrosFromLex = new IntHashSetMap(); String[] newMacroNames = mi.getMacros(); List<MacroItem> macroItems = new ArrayList<MacroItem>(); for (int i = 0; i < newMacroNames.length; i++) { Set<FeatureStructure> featStrucs = (Set<FeatureStructure>) _macros.get(newMacroNames[i]); if (featStrucs != null) { for (Iterator<FeatureStructure> fsIt = featStrucs.iterator(); fsIt.hasNext(); ) { FeatureStructure fs = fsIt.next(); macrosFromLex.put(fs.getIndex(), fs); } } MacroItem macroItem = _macroItems.get(newMacroNames[i]); if (macroItem != null) { macroItems.add(macroItem); } else { // should be checked earlier too System.err.println( "Warning: macro " + newMacroNames[i] + " not found for word '" + mi.getWord() + "'"); } } retval = new MacroAdder(macrosFromLex, macroItems); // update map and return macAdderMap.put(mi, retval); return retval; }
public ParseDoc(Object xmlFile, String rootId, TreeMap prevIdMap) { SAXBuilder saxBuilder = new SAXBuilder(); try { if (xmlFile instanceof String) { document = saxBuilder.build((String) xmlFile); } else if (xmlFile instanceof URL) { document = saxBuilder.build((URL) xmlFile); } root = ParseUtils.parseRoot(document, rootId); objects = new TreeMap(); // Build description string (but not for the snippets.xml file) if (xmlFile instanceof String) { List authorL = root.getChildren("author"); String author = "<unknown>"; if (root.getAttributeValue("name") != null) { author = root.getAttributeValue("name"); } else if (authorL.size() > 0) { author = ((Element) authorL.get(0)).getValue(); } String description = "from file " + xmlFile.toString() + " (author: " + author + ") on " + new Date().toString(); HasIdentifiers.addGlobalIdentifier("_description_", description); } // Get all macro definitions, and remove them from document TreeMap macroMap = ParseUtils.getMacroDefs(root); // Process all macro expansions; replace macro expansion request with result ParseUtils.expandMacros(root, macroMap); // Get all elements in document, and assign identifiers to them; idMap = ParseUtils.parseId(root, prevIdMap); // Rewriting done; output debug XML code if (root.getAttributeValue("debug") != null) { XMLOutputter outputter = new XMLOutputter(); FileOutputStream fos = new FileOutputStream(xmlFile + ".debug"); outputter.output(document, fos); fos.close(); } } catch (JDOMException e) { // indicates a well-formedness or other error throw new Error("JDOMException: " + e.getMessage()); } catch (IOException e) { // indicates an IO problem throw new Error("IOException: " + e.getMessage()); } }
/** * This will take the supplied <code>{@link Element}</code> and transfer its namespaces to the * global namespace storage. * * @param element <code>Element</code> to read namespaces from. */ private void transferNamespaces(Element element) { Iterator i = declaredNamespaces.iterator(); while (i.hasNext()) { Namespace ns = (Namespace) i.next(); if (ns != element.getNamespace()) { element.addNamespaceDeclaration(ns); } } declaredNamespaces.clear(); }
// look up and apply coarts for given rels to each sign in result private void applyCoarts(List<String> coartRels, Collection<Sign> result) { List<Sign> inputSigns = new ArrayList<Sign>(result); result.clear(); List<Sign> outputSigns = new ArrayList<Sign>(inputSigns.size()); // for each rel, lookup coarts and apply to input signs, storing results in output signs for (Iterator<String> it = coartRels.iterator(); it.hasNext(); ) { String rel = it.next(); Collection<String> preds = (Collection<String>) _coartRelsToPreds.get(rel); if (preds == null) continue; // not expected Collection<Sign> coartResult = getSignsFromRelAndPreds(rel, preds); if (coartResult == null) continue; for (Iterator<Sign> it2 = coartResult.iterator(); it2.hasNext(); ) { Sign coartSign = it2.next(); // apply to each input for (int j = 0; j < inputSigns.size(); j++) { Sign sign = inputSigns.get(j); grammar.rules.applyCoart(sign, coartSign, outputSigns); } } // switch output to input for next iteration inputSigns.clear(); inputSigns.addAll(outputSigns); outputSigns.clear(); } // add results back result.addAll(inputSigns); }
// get signs for rel via preds, or null if none private Collection<Sign> getSignsFromRelAndPreds(String rel, Collection<String> preds) { List<Sign> retval = new ArrayList<Sign>(); for (Iterator<String> it = preds.iterator(); it.hasNext(); ) { String pred = it.next(); Collection<Sign> signs = getSignsFromPredAndTargetRel(pred, rel); if (signs != null) retval.addAll(signs); } // return null if none survive filter if (retval.size() > 0) return retval; else return null; }
public void parseCodeGeneration() { // parse all <codeGeneration> elements List codeGenList = ParseUtils.parseDescendants(root, "codeGeneration", idMap); Iterator i = codeGenList.iterator(); while (i.hasNext()) { Element cgelt = (Element) i.next(); // It's the side effect that we're after here. new CodeGeneration(cgelt, idMap, objects); } }
/** * Método public static void leerArchivoXML(ListaUsuarios listaDeUsuarios): Este método permite * leer un archivo XML que contiene los datos de los usuarios a través de jdom */ public static void leerArchivoXML(ListaUsuario listaDeUsuarios) { try { SAXBuilder builder = new SAXBuilder(); /* Se crea un documento nuevo con el nombre del archivo */ Document doc = builder.build(nombreArchivo); /* Se obtiene la raíz del archivo (la etiqueta inicial) */ Element raiz = doc.getRootElement(); /* Se puede obtener el atributo de la raíz (de la etiqueta) */ System.out.println(raiz.getAttributeValue("tipo")); /* Se obtienen todos los hijos cuya etiqueta esa "usuario" */ /* y se asignan esos hijos a un List */ List listaUsuarios = raiz.getChildren("usuario"); System.out.println("Formada por:" + listaUsuarios.size() + " usuarios"); System.out.println("------------------"); /* Se genera un iterador para recorrer el List que se generó */ Iterator i = listaUsuarios.iterator(); /* Se recorre el List */ while (i.hasNext()) { /* Se obtiene cada uno y se asigna a un objeto de tipo Element */ Element e = (Element) i.next(); /* Se obtiene el nombre, apellido y cargo de cada una de las etiquetas */ /* hijas de usuario, es decir, nombre, apellido y cargo */ Element nick = e.getChild("nick"); Element clave = e.getChild("clave"); Element nombre = e.getChild("nombre"); Element apellido = e.getChild("apellido"); Element fechanac = e.getChild("fechanac"); Element avatar = e.getChild("avatar"); /* Se crea un nodo nuevo con la información y se agrega a la lista de usuarios */ Usuario elUsuario = new Usuario( nick.getText(), clave.getText(), nombre.getText(), apellido.getText(), fechanac.getText(), avatar.getText()); listaDeUsuarios.AgregarElemento(elUsuario); } } catch (Exception e) { e.printStackTrace(); } }
// get signs using an additional arg for a target rel private Collection<Sign> getSignsFromPredAndTargetRel(String pred, String targetRel) { Collection<Word> words = (Collection<Word>) _predToWords.get(pred); String specialTokenConst = null; // for robustness, when using supertagger, add words for pred sans sense index int dotIndex = -1; if (_supertagger != null && !Character.isDigit(pred.charAt(0)) && // skip numbers (dotIndex = pred.lastIndexOf('.')) > 0 && pred.length() > dotIndex + 1 && pred.charAt(dotIndex + 1) != '_') // skip titles, eg Mr._Smith { String barePred = pred.substring(0, dotIndex); Collection<Word> barePredWords = (Collection<Word>) _predToWords.get(barePred); if (words == null) words = barePredWords; else if (barePredWords != null) { Set<Word> unionWords = new HashSet<Word>(words); unionWords.addAll(barePredWords); words = unionWords; } } if (words == null) { specialTokenConst = tokenizer.getSpecialTokenConstant(tokenizer.isSpecialToken(pred)); if (specialTokenConst == null) return null; // lookup words with pred = special token const Collection<Word> specialTokenWords = (Collection<Word>) _predToWords.get(specialTokenConst); // replace special token const with pred if (specialTokenWords == null) return null; words = new ArrayList<Word>(specialTokenWords.size()); for (Iterator<Word> it = specialTokenWords.iterator(); it.hasNext(); ) { Word stw = it.next(); Word w = Word.createSurfaceWord(stw, pred); words.add(w); } } List<Sign> retval = new ArrayList<Sign>(); for (Iterator<Word> it = words.iterator(); it.hasNext(); ) { Word w = it.next(); try { SignHash signs = getSignsFromWord(w, specialTokenConst, pred, targetRel); retval.addAll(signs.asSignSet()); } // shouldn't happen catch (LexException exc) { System.err.println("Unexpected lex exception for word " + w + ": " + exc); } } return retval; }
// get licensing features, with appropriate defaults @SuppressWarnings("unchecked") private void loadLicensingFeatures(Element licensingElt) { List<LicensingFeature> licensingFeats = new ArrayList<LicensingFeature>(); boolean containsLexFeat = false; if (licensingElt != null) { for (Iterator<Element> it = licensingElt.getChildren("feat").iterator(); it.hasNext(); ) { Element featElt = it.next(); String attr = featElt.getAttributeValue("attr"); if (attr.equals("lex")) containsLexFeat = true; String val = featElt.getAttributeValue("val"); List<String> alsoLicensedBy = null; String alsoVals = featElt.getAttributeValue("also-licensed-by"); if (alsoVals != null) { alsoLicensedBy = Arrays.asList(alsoVals.split("\\s+")); } boolean licenseEmptyCats = true; boolean licenseMarkedCats = false; boolean instantiate = true; byte loc = LicensingFeature.BOTH; String lmc = featElt.getAttributeValue("license-marked-cats"); if (lmc != null) { licenseMarkedCats = Boolean.valueOf(lmc).booleanValue(); // change defaults licenseEmptyCats = false; loc = LicensingFeature.TARGET_ONLY; instantiate = false; } String lec = featElt.getAttributeValue("license-empty-cats"); if (lec != null) { licenseEmptyCats = Boolean.valueOf(lec).booleanValue(); } String inst = featElt.getAttributeValue("instantiate"); if (inst != null) { instantiate = Boolean.valueOf(inst).booleanValue(); } String locStr = featElt.getAttributeValue("location"); if (locStr != null) { if (locStr.equals("target-only")) loc = LicensingFeature.TARGET_ONLY; if (locStr.equals("args-only")) loc = LicensingFeature.ARGS_ONLY; if (locStr.equals("both")) loc = LicensingFeature.BOTH; } licensingFeats.add( new LicensingFeature( attr, val, alsoLicensedBy, licenseEmptyCats, licenseMarkedCats, instantiate, loc)); } } if (!containsLexFeat) { licensingFeats.add(LicensingFeature.defaultLexFeature); } _licensingFeatures = new LicensingFeature[licensingFeats.size()]; licensingFeats.toArray(_licensingFeatures); }
public List getUserList() { List<Map> list = new ArrayList<Map>(); try { /* String apiUrl=rallyApiHost+"/user?query="+ "((TeamMemberships%20%3D%20https%3A%2F%2Frally1.rallydev.com%2Fslm%2Fwebservice%2F1.34%2Fproject%2F6169133135)%20or%20"+ "(TeamMemberships%20%3D%20https%3A%2F%2Frally1.rallydev.com%2Fslm%2Fwebservice%2F1.34%2Fproject%2F6083311244))"+ "&fetch=true&order=Name&start=1&pagesize=100"; */ String apiUrl = rallyApiHost + "/user?query=(Disabled%20=%20false)" + "&fetch=true&order=Name&start=1&pagesize=100"; log.info("apiUrl=" + apiUrl); String responseXML = getRallyXML(apiUrl); org.jdom.input.SAXBuilder bSAX = new org.jdom.input.SAXBuilder(); org.jdom.Document doc = bSAX.build(new StringReader(responseXML)); Element root = doc.getRootElement(); XPath xpath = XPath.newInstance("//Object"); List xlist = xpath.selectNodes(root); Iterator iter = xlist.iterator(); while (iter.hasNext()) { Map map = new HashMap(); Element item = (Element) iter.next(); String userRef = item.getAttribute("ref").getValue(); String userName = item.getAttribute("refObjectName").getValue(); String userObjectId = item.getChildText("ObjectID"); map.put("userRef", userRef); map.put("userObjectId", userObjectId); map.put("userName", userName); list.add(map); } } catch (Exception ex) { log.error("", ex); } return list; }
/** * Process listuser from server * * @param doc */ private void _listuser(Document doc) { StringBuffer userlist = new StringBuffer(); Element root = doc.getRootElement(); Element list = root.getChild("listuser"); List users = list.getChildren("user"); Iterator i = users.iterator(); while (i.hasNext()) { userlist.append(((Element) i.next()).getText()); userlist.append("\n"); } sendMessage(SERVER, "Users: \n" + userlist); }
/** * For a string of 1 or more surface words, return all of the lexical entries for each word as a * list of sign hashes. Tokenization is performed using the configured tokenizer. * * @param w the words in string format * @return a list of sign hashes * @exception LexException thrown if word not found */ public List<SignHash> getEntriesFromWords(String s) throws LexException { List<SignHash> entries = new ArrayList<SignHash>(); List<Word> words = tokenizer.tokenize(s); for (Iterator<Word> it = words.iterator(); it.hasNext(); ) { Word w = it.next(); SignHash signs = getSignsFromWord(w); if (signs.size() == 0) { throw new LexException("Word not in lexicon: \"" + w + "\""); } entries.add(signs); } return entries; }
public void parseCode() { // Parse all <code> and <parameter> elements List codeList = ParseUtils.parseDescendants(root, "code", idMap); Iterator i = codeList.iterator(); while (i.hasNext()) { Element codeElt = (Element) i.next(); String codeId = codeElt.getAttributeValue("id"); if (objects.containsKey(codeId)) { System.out.println("Note: Shadowing definition of <code id=\"" + codeId + "\">"); } objects.put(codeId, new Code(codeElt, idMap)); } }
// look up and apply coarts for w to each sign in result @SuppressWarnings("unchecked") private void applyCoarts(Word w, SignHash result) throws LexException { List<Sign> inputSigns = new ArrayList<Sign>(result.asSignSet()); result.clear(); List<Sign> outputSigns = new ArrayList<Sign>(inputSigns.size()); // for each surface attr, lookup coarts and apply to input signs, storing results in output // signs for (Iterator<Pair<String, String>> it = w.getSurfaceAttrValPairs(); it.hasNext(); ) { Pair<String, String> p = it.next(); String attr = (String) p.a; if (!_indexedCoartAttrs.contains(attr)) continue; String val = (String) p.b; Word coartWord = Word.createWord(attr, val); SignHash coartResult = getSignsFromWord(coartWord, null, null, null); for (Iterator<Sign> it2 = coartResult.iterator(); it2.hasNext(); ) { Sign coartSign = it2.next(); // apply to each input for (int j = 0; j < inputSigns.size(); j++) { Sign sign = inputSigns.get(j); grammar.rules.applyCoart(sign, coartSign, outputSigns); } } // switch output to input for next iteration inputSigns.clear(); inputSigns.addAll(outputSigns); outputSigns.clear(); } // add results back result.addAll(inputSigns); }
public StringBuilder listToCSV(List list) { StringBuilder csv = new StringBuilder(); csv.append( "Work Product,,Name,State,Owner,Plan Estimate,Task Estimate,Task Remaining,Time Spent\n"); for (int i = 0; i < list.size(); i++) { Map map = (Map) list.get(i); String type = (String) map.get("type"); String formattedId = (String) map.get("formattedId"); String name = (String) map.get("name"); String taskStatus = (String) map.get("taskStatus"); String owner = (String) map.get("owner"); String planEstimate = (String) map.get("planEstimate"); String taskEstimateTotal = (String) map.get("taskEstimateTotal"); String taskRemainingTotal = (String) map.get("taskRemainingTotal"); String taskTimeSpentTotal = (String) map.get("taskTimeSpentTotal"); if ("task".equals(type)) { csv.append("," + formattedId + ","); } else if ("userstory".equals(type)) { csv.append(formattedId + ",,"); } else if ("iteration".equals(type)) { csv.append(",,"); } if (planEstimate == null) { planEstimate = ""; } if (taskEstimateTotal == null) { taskEstimateTotal = ""; } if (taskRemainingTotal == null) { taskRemainingTotal = ""; } csv.append("\"" + name + "\","); csv.append(taskStatus + ","); csv.append(owner + ","); csv.append(planEstimate + ","); csv.append(taskEstimateTotal + ","); csv.append(taskRemainingTotal + ","); csv.append(taskTimeSpentTotal + "\n"); } return csv; }
public boolean equals(Object obj) { if (!(obj instanceof PredLookup)) return false; PredLookup pLook = (PredLookup) obj; if (!pred.equals(pLook.pred)) return false; if (coartRels == null) return (pLook.coartRels == null); return coartRels.equals(pLook.coartRels); }
/** * This will add the prefix mapping to the JDOM <code>Document</code> object. * * @param prefix <code>String</code> namespace prefix. * @param uri <code>String</code> namespace URI. */ public void startPrefixMapping(String prefix, String uri) throws SAXException { if (suppress) return; Namespace ns = Namespace.getNamespace(prefix, uri); declaredNamespaces.add(ns); }
/** * Process listgroup from server * * @param doc */ private void _listgroup(Document doc) { StringBuffer grouplist = new StringBuffer(); Element root = doc.getRootElement(); Element list = root.getChild("listgroup"); List groups = list.getChildren("group"); Iterator i = groups.iterator(); while (i.hasNext()) { Element temp = (Element) i.next(); grouplist.append(temp.getChild("name").getText()); grouplist.append("\t"); grouplist.append(temp.getChild("description").getText()); grouplist.append("\n"); } sendMessage(SERVER, "Groups: \n" + grouplist); }
private QueryResult gatherResultInfoForSelectQuery( String queryString, int queryNr, boolean sorted, Document doc, String[] rows) { Element root = doc.getRootElement(); // Get head information Element child = root.getChild("head", Namespace.getNamespace("http://www.w3.org/2005/sparql-results#")); // Get result rows (<head>) List headChildren = child.getChildren( "variable", Namespace.getNamespace("http://www.w3.org/2005/sparql-results#")); Iterator it = headChildren.iterator(); ArrayList<String> headList = new ArrayList<String>(); while (it.hasNext()) { headList.add(((Element) it.next()).getAttributeValue("name")); } List resultChildren = root.getChild("results", Namespace.getNamespace("http://www.w3.org/2005/sparql-results#")) .getChildren( "result", Namespace.getNamespace("http://www.w3.org/2005/sparql-results#")); int nrResults = resultChildren.size(); QueryResult queryResult = new QueryResult(queryNr, queryString, nrResults, sorted, headList); it = resultChildren.iterator(); while (it.hasNext()) { Element resultElement = (Element) it.next(); String result = ""; // get the row values and paste it together to one String for (int i = 0; i < rows.length; i++) { List bindings = resultElement.getChildren( "binding", Namespace.getNamespace("http://www.w3.org/2005/sparql-results#")); String rowName = rows[i]; for (int j = 0; j < bindings.size(); j++) { Element binding = (Element) bindings.get(j); if (binding.getAttributeValue("name").equals(rowName)) if (result.equals("")) result += rowName + ": " + ((Element) binding.getChildren().get(0)).getTextNormalize(); else result += "\n" + rowName + ": " + ((Element) binding.getChildren().get(0)).getTextNormalize(); } } queryResult.addResult(result); } return queryResult; }
/** * This will output a list of JDOM nodes as a fragment of an XML document, firing off the SAX * events that have been registered. * * <p><strong>Warning</strong>: This method does not call the {@link * ContentHandler#setDocumentLocator}, {@link ContentHandler#startDocument} and {@link * ContentHandler#endDocument} callbacks on the {@link #setContentHandler ContentHandler}. The * user shall invoke these methods directly prior/after outputting the document fragments. * * @param nodes <code>List</code> of JDOM nodes to output. * @throws JDOMException if any error occurred. * @see #outputFragment(org.jdom.Content) */ public void outputFragment(List nodes) throws JDOMException { if ((nodes == null) || (nodes.size() == 0)) { return; } // Output node list as a document fragment. elementContent(nodes, new NamespaceStack()); }