private CIJobStatus deleteCI(CIJob job, List<String> builds) throws PhrescoException { S_LOGGER.debug("Entering Method CIManagerImpl.deleteCI(CIJob job)"); S_LOGGER.debug("Job name " + job.getName()); cli = getCLI(job); String deleteType = null; List<String> argList = new ArrayList<String>(); S_LOGGER.debug("job name " + job.getName()); S_LOGGER.debug("Builds " + builds); if (CollectionUtils.isEmpty(builds)) { // delete job S_LOGGER.debug("Job deletion started"); S_LOGGER.debug("Command " + FrameworkConstants.CI_JOB_DELETE_COMMAND); deleteType = DELETE_TYPE_JOB; argList.add(FrameworkConstants.CI_JOB_DELETE_COMMAND); argList.add(job.getName()); } else { // delete Build S_LOGGER.debug("Build deletion started"); deleteType = DELETE_TYPE_BUILD; argList.add(FrameworkConstants.CI_BUILD_DELETE_COMMAND); argList.add(job.getName()); StringBuilder result = new StringBuilder(); for (String string : builds) { result.append(string); result.append(","); } String buildNos = result.substring(0, result.length() - 1); argList.add(buildNos); S_LOGGER.debug("Command " + FrameworkConstants.CI_BUILD_DELETE_COMMAND); S_LOGGER.debug("Build numbers " + buildNos); } try { int status = cli.execute(argList); String message = deleteType + " deletion started in jenkins"; if (status == FrameworkConstants.JOB_STATUS_NOTOK) { deleteType = deleteType.substring(0, 1).toLowerCase() + deleteType.substring(1); message = "Error while deleting " + deleteType + " in jenkins"; } S_LOGGER.debug("Delete CI Status " + status); S_LOGGER.debug("Delete CI Message " + message); return new CIJobStatus(status, message); } finally { if (cli != null) { try { cli.close(); } catch (IOException e) { if (debugEnabled) { S_LOGGER.error( "Entered into catch block of CIManagerImpl.deleteCI(CIJob job) " + e.getLocalizedMessage()); } } catch (InterruptedException e) { if (debugEnabled) { S_LOGGER.error( "Entered into catch block of CIManagerImpl.deleteCI(CIJob job) " + e.getLocalizedMessage()); } } } } }
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 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 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; }
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; }
@Override public boolean run(final Item item) { final LocalPlayerCharacter character = WakfuGameEntity.getInstance().getLocalPlayer(); if (character.getBags().getItemFromInventories(item.getUniqueId()) == null) { ReduceDeadStateItemAction.m_logger.error( (Object) "[ItemAction] On essaye de lancer une action avec un item qui n'est pas dans les bags"); return false; } boolean hasDeadState = false; final List<StateRunningEffect> states = character.getRunningEffectManager().getRunningState(); for (int i = 0; i < states.size(); ++i) { final StateRunningEffect effect = states.get(i); if (effect.getState() == null || effect.getState().isStateForDeath()) { hasDeadState = true; break; } } if (!hasDeadState) { ReduceDeadStateItemAction.m_logger.warn( (Object) "Tentative d'utilisation d'un item de reduction de DEAD_STATE sans en avoir"); return false; } this.sendRequest(item.getUniqueId()); return true; }
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()); } } } } }
public void removeStream(StreamDataSource stream) { Iterator it = streams.iterator(); while (it.hasNext()) { StreamDataSource sds = (StreamDataSource) it.next(); sds.removeStream(stream); } streams.remove(stream); fireRemovedEvent(stream); }
public void addRequestForStream(StreamDataSource sds, int serial) { if (afterLoadMap.containsKey(sds)) { List sList = (List) afterLoadMap.get(sds); sList.add(new Integer(serial)); } else { List sList = new LinkedList(); sList.add(new Integer(serial)); afterLoadMap.put(sds, sList); } }
public ControllerRequest(Class<? extends Controller> controllerClass, Matcher matchedUrl) { this.controllerClass = controllerClass; if (matchedUrl.groupCount() > 0) { List<String> argsList = new ArrayList<String>(matchedUrl.groupCount()); for (int i = 1; i <= matchedUrl.groupCount(); i++) { argsList.add(matchedUrl.group(i)); } this.args = argsList; } else { this.args = new ArrayList<String>(0); } }
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; }
/** * @param arg0 * @roseuid 3F4E5F400123 */ public void connectionClosed(ConnectionEvent event) { logger.debug("Enter: " + event.getSource()); synchronized (connectionPool) { if (!SHUTTING_DOWN) { if (connectionPool.size() < connectionPoolSize) { logger.debug("Reading Connection: " + event.getSource()); connectionPool.add(event.getSource()); } } } }
public void saveStreams() throws IOException { Config config = Config.getConfiguration("manager.streams"); config.setArray("streams", streams.toArray()); Iterator it = streams.iterator(); while (it.hasNext()) { DataSource ds = (DataSource) it.next(); ds.save(); } config.save(); }
/** Removes the empty iterators. */ private void removeEmptyIterators() { List<ResolvedConceptReferencesIterator> newList = new ArrayList<ResolvedConceptReferencesIterator>(); for (ResolvedConceptReferencesIterator itr : _iterators) { try { if (itr.hasNext()) { newList.add(itr); } } catch (LBResourceUnavailableException e) { throw new RuntimeException(e); } } _iterators = newList; }
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; }
private void addDefault(StreamDataSource sds) { Iterator it = defaultProcs.iterator(); while (it.hasNext()) { FlowProcessor proc = (FlowProcessor) it.next(); sds.registerRaw(proc); } }
/** * Instantiates a new Iterator. Be sure that any desired restrictions have already been placed on * the CodedNodeSets before passing into this constructor * * @param codedNodeSets the coded node sets * @param sortOptions the sort options * @param filterOptions the filter options * @param restrictToProperties the restrict to properties * @param restrictToPropertyTypes the restrict to property types * @param resolve the resolve * @throws LBException the LB exception */ public QuickUnionIterator( Vector<CodedNodeSet> codedNodeSets, SortOptionList sortOptions, LocalNameList filterOptions, LocalNameList restrictToProperties, PropertyType[] restrictToPropertyTypes, boolean resolve) throws LBException { for (CodedNodeSet cns : codedNodeSets) { // KLO 012310 if (cns != null) { try { ResolvedConceptReferencesIterator iterator = cns.resolve( sortOptions, filterOptions, restrictToProperties, restrictToPropertyTypes, resolve); if (iterator != null) { _iterators.add(iterator); } } catch (Exception ex) { _logger.error("QuickUnionIterator constructor - cns.resolve throws exception???"); // ex.printStackTrace(); System.out.println( "WARNING: QuickUnionIteratorWrapper constructor - cns.resolve throws exception???"); } } } Collections.sort(_iterators, new IteratorSizeComparator()); }
private void fireAddedEvent(StreamDataSource sds) { Iterator it = listeners.iterator(); while (it.hasNext()) { ((StreamManagerListener) it.next()).streamAdded(sds); } }
/** Creates a Pooled connection and adds it to the connection pool. */ private void installConnection() throws EmanagerDatabaseException { logger.debug("enter"); PooledConnection connection; try { connection = poolDataSource.getPooledConnection(); connection.addConnectionEventListener(this); connection.getConnection().setAutoCommit(false); synchronized (connectionPool) { connectionPool.add(connection); logger.debug("Database connection added."); } } catch (SQLException ex) { logger.fatal("exception caught while obtaining database " + "connection: ex = " + ex); SQLException ex1 = ex.getNextException(); while (ex1 != null) { logger.fatal("chained sql exception ex1 = " + ex1); SQLException nextEx = ex1.getNextException(); ex1 = nextEx; } String logString; EmanagerDatabaseException ede; logString = EmanagerDatabaseStatusCode.DatabaseConnectionFailure.getStatusCodeDescription() + ex.getMessage(); logger.fatal(logString); ede = new EmanagerDatabaseException( EmanagerDatabaseStatusCode.DatabaseConnectionFailure, logString); throw ede; } }
/** * @param arg0 * @roseuid 3F4E5F40012D */ public void connectionErrorOccurred(ConnectionEvent event) { logger.debug("Connection Error " + event.getSQLException().getMessage()); synchronized (connectionPool) { if (connectionPool.size() <= connectionPoolSize) { connectionPool.remove(event.getSource()); if (!SHUTTING_DOWN) { try { installConnection(); } catch (EmanagerDatabaseException e) { // noop. can't throw an exception here, so we'll ignore. // It will surface later. } } } } }
/** * Gets the next from list. * * @return the next from list */ private ResolvedConceptReference getNextFromList() { try { while (hasNext()) { int iterator = _currentIterator % _iterators.size(); ResolvedConceptReferencesIterator itr = _iterators.get(iterator); if (itr.hasNext()) { _currentIterator++; return itr.next(); } else { _currentIterator++; } } return null; } catch (Exception e) { throw new RuntimeException(e); } }
public List getProjectList() { List<Map> list = new ArrayList<Map>(); try { String apiUrl = rallyApiHost + "/project?" + "fetch=true&order=Name&start=1&pagesize=200"; log.info("rallyApiUrl:" + 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 objId = item.getChildText("ObjectID"); String name = item.getChildText("Name"); String state = item.getChildText("State"); map.put("objId", objId); map.put("name", name); map.put("state", state); list.add(map); } } catch (Exception ex) { log.error("ERROR: ", ex); } return list; }
/** @roseuid 3F3A89D40175 */ public void shutdown() { logger.debug("Enter"); Iterator iter; PooledConnection pooledConnection; SHUTTING_DOWN = true; iter = connectionPool.iterator(); while (iter.hasNext()) { pooledConnection = (PooledConnection) iter.next(); try { if (!pooledConnection.getConnection().isClosed()) { pooledConnection.getConnection().close(); } } catch (Exception ex) { // We don't care what happens here, we're on the way out! } } connectionPool.clear(); }
private void writeJsonJobs(ApplicationInfo appInfo, List<CIJob> jobs, String status) throws PhrescoException { try { if (jobs == null) { return; } Gson gson = new Gson(); List<CIJob> existingJobs = getJobs(appInfo); if (CI_CREATE_NEW_JOBS.equals(status) || existingJobs == null) { existingJobs = new ArrayList<CIJob>(); } existingJobs.addAll(jobs); FileWriter writer = null; File ciJobFile = new File(getCIJobPath(appInfo)); String jobJson = gson.toJson(existingJobs); writer = new FileWriter(ciJobFile); writer.write(jobJson); writer.flush(); } catch (Exception e) { throw new PhrescoException(e); } }
public StringBuilder listToCSVForUserView(List list) { StringBuilder csv = new StringBuilder(); csv.append( "Project,Iteration,Work Product,Name,State,Owner,Task Estimate,Task Remaining,Time Spent\n"); for (int i = 0; i < list.size(); i++) { Map map = (Map) list.get(i); String projectName = (String) map.get("projectName"); String iterationName = (String) map.get("iterationName"); String formattedId = (String) map.get("taskFormattedId"); String taskName = (String) map.get("taskName"); String taskState = (String) map.get("taskState"); String owner = (String) map.get("owner"); String taskEstimate = (String) map.get("taskEstimate"); String taskRemaining = (String) map.get("taskRemaining"); String taskTimeSpent = (String) map.get("hours"); if (taskEstimate == null) { taskEstimate = ""; } if (taskRemaining == null) { taskRemaining = ""; } csv.append("" + projectName + ","); csv.append("\"" + iterationName + "\","); csv.append(formattedId + ","); csv.append(taskName + ","); csv.append(taskState + ","); csv.append(owner + ","); csv.append(taskEstimate + ","); csv.append(taskRemaining + ","); csv.append(taskTimeSpent + "\n"); } return csv; }
private boolean adaptExistingJobs(ApplicationInfo appInfo) { try { CIJob existJob = getJob(appInfo); S_LOGGER.debug("Going to get existing jobs to relocate!!!!!"); if (existJob != null) { S_LOGGER.debug("Existing job found " + existJob.getName()); boolean deleteExistJob = deleteCIJobFile(appInfo); Gson gson = new Gson(); List<CIJob> existingJobs = new ArrayList<CIJob>(); existingJobs.addAll(Arrays.asList(existJob)); FileWriter writer = null; File ciJobFile = new File(getCIJobPath(appInfo)); String jobJson = gson.toJson(existingJobs); writer = new FileWriter(ciJobFile); writer.write(jobJson); writer.flush(); S_LOGGER.debug("Existing job moved to new type of project!!"); } return true; } catch (Exception e) { S_LOGGER.debug("It is already adapted !!!!! "); } return false; }
public void loadStreams() throws Exception { Config config = Config.getConfiguration("manager.streams"); afterLoadMap = new HashMap(); Object[] names = config.getArray("streams", null); if (names == null) { return; } for (int i = 0; i < names.length; i++) { StreamDataSource sds = new StreamDataSource(names[i].toString()); sds.load(); sds.initiate(); addStreamNoFire(sds); addDefault(sds); } Iterator it = afterLoadMap.keySet().iterator(); while (it.hasNext()) { StreamDataSource sds = (StreamDataSource) it.next(); List sList = (List) afterLoadMap.get(sds); Iterator addIt = sList.iterator(); while (addIt.hasNext()) { Integer serial = (Integer) addIt.next(); StreamDataSource addStream = getStream(serial.intValue()); if (addStream != null) { sds.addStream(addStream); } else { logger.warn("Unable to find source (" + serial + ") for " + sds); } } } afterLoadMap = null; }
/** * @return Connection * @roseuid 3F3A5FFD0338 */ public Connection getConnection() throws EmanagerDatabaseException { long connectionId; Connection connection; PooledConnection pooledConnection; connection = null; pooledConnection = null; connectionId = InvalidConnectionId; try { synchronized (connectionPool) { if (!connectionPool.isEmpty()) { try { boolean connectionClosed; connectionClosed = false; pooledConnection = (PooledConnection) connectionPool.remove(0); connection = pooledConnection.getConnection(); connection.clearWarnings(); connectionId = getConnectionID(connection); connectionClosed = connection.isClosed(); if (connectionId == InvalidConnectionId || connectionClosed == true) { logger.debug("Pooled connection closed."); connection = null; } } catch (SQLException sqe) { logger.debug("Pooled connection closed."); connection = null; } } } if (connection == null) { logger.debug("Getting a new connection."); pooledConnection = poolDataSource.getPooledConnection(); pooledConnection.addConnectionEventListener(this); connection = pooledConnection.getConnection(); connection.clearWarnings(); connectionId = getConnectionID(connection); } } catch (SQLException sqe) { String logString; EmanagerDatabaseException ede; logString = EmanagerDatabaseStatusCode.UnableToGetPooledConnection.getStatusCodeDescription() + sqe.getMessage(); logger.error(logString); ede = new EmanagerDatabaseException( EmanagerDatabaseStatusCode.UnableToGetPooledConnection, logString); throw ede; } if (connectionId == InvalidConnectionId) { EmanagerDatabaseException ede; ede = new EmanagerDatabaseException( EmanagerDatabaseStatusCode.UnableToGetPooledConnection, EmanagerDatabaseStatusCode.UnableToGetPooledConnection.getStatusCodeDescription()); throw ede; } logger.debug( "\n*****************************" + "\nPooled Connection Init" + "\nCon ID:" + connectionId + "\nCon Object:" + pooledConnection + "\nPool Object:" + connection + "\n*****************************"); return connection; }
// public List getUserStoryList(String sessionId,String iterationId,ServletOutputStream out) { public List getUserStoryList(String sessionId, String iterationId, PrintWriter out) { List<Map> list = new ArrayList<Map>(); statusMap.put(sessionId, "0"); try { String apiURL = rallyApiHost + "/hierarchicalrequirement?" + "query=(Iteration%20=%20" + rallyApiHost + "/iteration/" + iterationId + ")&fetch=true&start=1&pagesize=100"; log.info("getUserStoryList 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); int totalSteps = xlist.size() + 1; int currentStep = 0; List taskRefLink = new ArrayList(); Iterator iter = xlist.iterator(); while (iter.hasNext()) { double totalTimeSpent = 0.0D; Map map = new HashMap(); Element item = (Element) iter.next(); String objId = item.getChildText("ObjectID"); String name = item.getChildText("Name"); String planEstimate = item.getChildText("PlanEstimate"); String formattedId = item.getChildText("FormattedID"); String taskActualTotal = item.getChildText("TaskActualTotal"); String taskEstimateTotal = item.getChildText("TaskEstimateTotal"); String taskRemainingTotal = item.getChildText("TaskRemainingTotal"); String scheduleState = item.getChildText("ScheduleState"); Element ownerElement = item.getChild("Owner"); String owner = ""; String ownerRef = ""; if (ownerElement != null) { owner = ownerElement.getAttributeValue("refObjectName"); } Element taskElements = item.getChild("Tasks"); // List taskElementList=taskElements.getContent(); List taskElementList = taskElements.getChildren(); List taskList = new ArrayList(); log.info("taskElements.getChildren=" + taskElements); log.info("taskList=" + taskElementList); for (int i = 0; i < taskElementList.size(); i++) { Element taskElement = (Element) taskElementList.get(i); String taskRef = taskElement.getAttributeValue("ref"); String[] objectIdArr = taskRef.split("/"); String objectId = objectIdArr[objectIdArr.length - 1]; log.info("objectId=" + objectId); // Map taskMap=getTaskMap(taskRef); Map taskMap = getTaskMapBatch(objectId); double taskTimeSpentTotal = Double.parseDouble((String) taskMap.get("taskTimeSpentTotal")); totalTimeSpent += taskTimeSpentTotal; taskList.add(taskMap); } map.put("type", "userstory"); map.put("formattedId", formattedId); map.put("name", name); map.put("taskStatus", scheduleState); map.put("owner", owner); map.put("planEstimate", planEstimate); map.put("taskEstimateTotal", taskEstimateTotal); map.put("taskRemainingTotal", taskRemainingTotal); map.put("taskTimeSpentTotal", "" + totalTimeSpent); list.add(map); list.addAll(taskList); ++currentStep; double percentage = 100.0D * currentStep / totalSteps; String status = "" + Math.round(percentage); statusMap.put(sessionId, status); out.println("<script>parent.updateProcessStatus('" + status + "%')</script>" + status); out.flush(); log.info("out.flush..." + status); // log.info("status="+status+" sessionId="+sessionId); // log.info("L1 statusMap="+statusMap+" "+statusMap.hashCode()); } double planEstimate = 0.0D; double taskEstimateTotal = 0.0D; double taskRemainingTotal = 0.0D; double taskTimeSpentTotal = 0.0D; Map iterationMap = new HashMap(); for (Map map : list) { String type = (String) map.get("type"); String planEstimateStr = (String) map.get("planEstimate"); log.info("planEstimateStr=" + planEstimateStr); if ("userstory".equals(type)) { if (planEstimateStr != null) { planEstimate += Double.parseDouble(planEstimateStr); } taskEstimateTotal += Double.parseDouble((String) map.get("taskEstimateTotal")); taskRemainingTotal += Double.parseDouble((String) map.get("taskRemainingTotal")); taskTimeSpentTotal += Double.parseDouble((String) map.get("taskTimeSpentTotal")); } } apiURL = rallyApiHost + "/iteration/" + iterationId + "?fetch=true"; log.info("iteration apiURL=" + apiURL); responseXML = getRallyXML(apiURL); bSAX = new org.jdom.input.SAXBuilder(); doc = bSAX.build(new StringReader(responseXML)); root = doc.getRootElement(); xpath = XPath.newInstance("//Iteration"); xlist = xpath.selectNodes(root); String projName = ""; String iterName = ""; String iterState = ""; iter = xlist.iterator(); while (iter.hasNext()) { Element item = (Element) iter.next(); iterName = item.getChildText("Name"); iterState = item.getChildText("State"); Element projElement = item.getChild("Project"); projName = projElement.getAttributeValue("refObjectName"); } iterationMap.put("type", "iteration"); iterationMap.put("formattedId", ""); iterationMap.put("name", projName + " - " + iterName); iterationMap.put("taskStatus", iterState); iterationMap.put("owner", ""); iterationMap.put("planEstimate", "" + planEstimate); iterationMap.put("taskEstimateTotal", "" + taskEstimateTotal); iterationMap.put("taskRemainingTotal", "" + taskRemainingTotal); iterationMap.put("taskTimeSpentTotal", "" + taskTimeSpentTotal); list.add(0, iterationMap); statusMap.put(sessionId, "100"); log.info("L2 statusMap=" + statusMap); log.info("L2 verify=" + getProcessStatus(sessionId)); log.info("-----------"); // String jsonData=JsonUtil.encodeObj(list); String jsonData = JSONValue.toJSONString(list); out.println("<script>parent.tableResult=" + jsonData + "</script>"); out.println("<script>parent.showTableResult()</script>"); } catch (Exception ex) { log.error("ERROR: ", ex); } return list; }
public List getIterationList(String projectId) { List<Map> list = new ArrayList<Map>(); try { String apiUrl = rallyApiHost + "/iteration?" + "project=" + rallyApiHost + "/project/" + projectId + "&fetch=true&order=Name%20desc&start=1&pagesize=100"; String checkProjectRef = rallyApiHost + "/project/" + projectId; log.info("rallyApiUrl:" + apiUrl); log.info("checkProjectRef:" + checkProjectRef); String responseXML = getRallyXML(apiUrl); SimpleDateFormat ISO8601FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); Date currentDate = new Date(); 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 objId = item.getChildText("ObjectID"); String name = item.getChildText("Name"); String state = item.getChildText("State"); String startDateStr = item.getChildText("StartDate"); String endDateStr = item.getChildText("EndDate"); Date startDate = ISO8601FORMAT.parse(startDateStr); Date endDate = ISO8601FORMAT.parse(endDateStr); boolean isCurrent = false; int startCheck = startDate.compareTo(currentDate); int endCheck = endDate.compareTo(currentDate); if (startCheck < 0 && endCheck > 0) { isCurrent = true; } log.info("name=" + name + " isCurrent=" + isCurrent); String releaseRef = item.getAttribute("ref").getValue(); // In child project, parent object have to be filiered Element projectElement = item.getChild("Project"); String projectRef = projectElement.getAttributeValue("ref"); if (projectRef.equals(checkProjectRef)) { map.put("objId", objId); map.put("rallyRef", releaseRef); map.put("name", name); map.put("state", state); map.put("isCurrent", "" + isCurrent); list.add(map); } } log.info("-----------"); } catch (Exception ex) { log.error("ERROR: ", ex); } return list; }