List of usage examples for java.util ListIterator hasNext
boolean hasNext();
From source file:it.doqui.index.ecmengine.business.personalization.multirepository.index.lucene.RepositoryAwareADMLuceneSearcherImpl.java
private String parameterise(String unparameterised, Map<QName, QueryParameterDefinition> map, QueryParameter[] queryParameters, NamespacePrefixResolver nspr) throws QueryParameterisationException { Map<QName, List<Serializable>> valueMap = new HashMap<QName, List<Serializable>>(); if (queryParameters != null) { for (QueryParameter parameter : queryParameters) { List<Serializable> list = valueMap.get(parameter.getQName()); if (list == null) { list = new ArrayList<Serializable>(); valueMap.put(parameter.getQName(), list); }//from w w w . j a va 2 s .c o m list.add(parameter.getValue()); } } Map<QName, ListIterator<Serializable>> iteratorMap = new HashMap<QName, ListIterator<Serializable>>(); List<QName> missing = new ArrayList<QName>(1); StringBuilder buffer = new StringBuilder(unparameterised); int index = 0; while ((index = buffer.indexOf("${", index)) != -1) { int endIndex = buffer.indexOf("}", index); String qNameString = buffer.substring(index + 2, endIndex); QName key = QName.createQName(qNameString, nspr); QueryParameterDefinition parameterDefinition = map.get(key); if (parameterDefinition == null) { missing.add(key); buffer.replace(index, endIndex + 1, ""); } else { ListIterator<Serializable> it = iteratorMap.get(key); if ((it == null) || (!it.hasNext())) { List<Serializable> list = valueMap.get(key); if ((list != null) && (list.size() > 0)) { it = list.listIterator(); } if (it != null) { iteratorMap.put(key, it); } } String value; if (it == null) { value = parameterDefinition.getDefault(); } else { value = DefaultTypeConverter.INSTANCE.convert(String.class, it.next()); } buffer.replace(index, endIndex + 1, value); } } if (missing.size() > 0) { StringBuilder error = new StringBuilder(); error.append("The query uses the following parameters which are not defined: "); for (QName qName : missing) { error.append(qName); error.append(", "); } error.delete(error.length() - 1, error.length() - 1); error.delete(error.length() - 1, error.length() - 1); throw new QueryParameterisationException(error.toString()); } return buffer.toString(); }
From source file:junk.gui.HazardDataSetCalcCondorApp.java
/** * Returns the metadata associated with this calculation * * @returns the String containing the values selected for different parameters *///from www . ja va2s . c o m public String getParametersInfo() { String lf = SystemUtils.LINE_SEPARATOR; String metadata = "IMR Param List:" + lf + "---------------" + lf + this.imrGuiBean.getVisibleParametersCloned().getParameterListMetadataString() + lf + lf + "Region Param List: " + lf + "----------------" + lf + sitesGuiBean.getVisibleParametersCloned().getParameterListMetadataString() + lf + lf + "IMT Param List: " + lf + "---------------" + lf + imtGuiBean.getVisibleParametersCloned().getParameterListMetadataString() + lf + lf + "Forecast Param List: " + lf + "--------------------" + lf + erfGuiBean.getERFParameterList().getParameterListMetadataString() + lf + lf + "TimeSpan Param List: " + lf + "--------------------" + lf + erfGuiBean.getSelectedERFTimespanGuiBean().getParameterListMetadataString() + lf + lf + "Miscellaneous Metadata:" + lf + "--------------------" + lf + "Maximum Site Source Distance = " + maxDistance + lf + lf + "X Values = "; //getting the X values used to generate the metadata. ListIterator it = function.getXValuesIterator(); String xVals = ""; while (it.hasNext()) xVals += (Double) it.next() + " , "; xVals = xVals.substring(0, xVals.lastIndexOf(",")); //adding the X Vals used to the Metadata. metadata += xVals; return metadata; }
From source file:playground.christoph.evacuation.analysis.EvacuationTimePictureWriter.java
private ScreenOverlayType createHistogram(String transportMode, Map<Id, Double> evacuationTimes) throws IOException { /*// www . j ava2s. c o m * Remove NaN entries from the List */ List<Double> listWithoutNaN = new ArrayList<Double>(); for (Double d : evacuationTimes.values()) if (!d.isNaN()) listWithoutNaN.add(d); /* * If trip with significant to high evacuation times should be cut off */ if (limitMaxEvacuationTime) { double cutOffValue = meanEvacuationTime + standardDeviation * evacuationTimeCutOffFactor; ListIterator<Double> iter = listWithoutNaN.listIterator(); while (iter.hasNext()) { double value = iter.next(); if (value > cutOffValue) iter.remove(); } } double[] array = new double[listWithoutNaN.size()]; int i = 0; for (double d : listWithoutNaN) array[i++] = d; JFreeChart chart = createHistogramChart(transportMode, array); BufferedImage chartImage = chart.createBufferedImage(OVERALLHISTOGRAMWIDTH, OVERALLHISTOGRAMHEIGHT); BufferedImage image = new BufferedImage(OVERALLHISTOGRAMWIDTH, OVERALLHISTOGRAMHEIGHT, BufferedImage.TYPE_4BYTE_ABGR); // clone image and set alpha value for (int x = 0; x < OVERALLHISTOGRAMWIDTH; x++) { for (int y = 0; y < OVERALLHISTOGRAMHEIGHT; y++) { int rgb = chartImage.getRGB(x, y); Color c = new Color(rgb); int r = c.getRed(); int b = c.getBlue(); int g = c.getGreen(); int argb = 225 << 24 | r << 16 | g << 8 | b; // 225 as transparency value image.setRGB(x, y, argb); } } byte[] imageBytes = bufferedImageToByteArray(image); this.kmzWriter.addNonKMLFile(imageBytes, transportMode + OVERALLHISTROGRAM); ScreenOverlayType overlay = kmlObjectFactory.createScreenOverlayType(); LinkType icon = kmlObjectFactory.createLinkType(); icon.setHref(transportMode + OVERALLHISTROGRAM); overlay.setIcon(icon); overlay.setName("Histogram " + transportMode); // place the image top right Vec2Type overlayXY = kmlObjectFactory.createVec2Type(); overlayXY.setX(0.0); overlayXY.setY(1.0); overlayXY.setXunits(UnitsEnumType.FRACTION); overlayXY.setYunits(UnitsEnumType.FRACTION); overlay.setOverlayXY(overlayXY); Vec2Type screenXY = kmlObjectFactory.createVec2Type(); screenXY.setX(0.02); screenXY.setY(0.98); screenXY.setXunits(UnitsEnumType.FRACTION); screenXY.setYunits(UnitsEnumType.FRACTION); overlay.setScreenXY(screenXY); return overlay; }
From source file:TimestreamsTests.java
/** * Returns a HMAC for given parameters// w w w . j a v a2s . c o m * * @param params * are all the parameters to hash * @return the HMAC as a String */ private String getSecurityString(List<String> params) { java.util.Collections.sort(params); String toHash = ""; ListIterator<String> it = params.listIterator(); while (it.hasNext()) { toHash += it.next() + "&"; } System.out.println(toHash); return hmacString(toHash, PRIKEY, "HmacSHA256"); }
From source file:TimestreamsTests.java
/** * Creates a HMAC for given parameters and returns a URL with security * parameters//from www. j a va2 s .co m * * @param url * is the URL to add the security parameters to * @param params * are all the parameters to hash * @param now * is a UTC timestamp * @return the URL with security parameters */ private String getSecurityString(String url, List<String> params, String now) { java.util.Collections.sort(params); String toHash = ""; ListIterator<String> it = params.listIterator(); while (it.hasNext()) { toHash += it.next(); } String hmac = hmacString(toHash, PRIKEY, "HmacSHA256"); String urlStr = url + "?pubkey=" + PUBKEY + "&now=" + now; urlStr += "&hmac=" + hmac; return urlStr; }
From source file:com.abm.mainet.common.service.EmployeeService.java
public List<LookUp> getAllEmployee(List<Object[]> emp) { List<LookUp> list = new ArrayList<LookUp>(0); ListIterator<Object[]> listIterator = emp.listIterator(); while (listIterator.hasNext()) { Object[] obj = listIterator.next(); LookUp title = getEmpTitle(obj); String fname = (String) obj[1]; String lname = " "; if (obj[2] != null) { lname = (String) obj[2]; }/*from ww w .j av a 2s. c om*/ String fullName = " "; if (title.getLookUpDesc() != null) { fullName = title.getLookUpDesc() + " " + fname + " " + lname; } else { fullName = " " + fname + " " + lname; } // fullName = fname + " " + lname; LookUp lookUp = new LookUp("", fullName); lookUp.setLookUpId((long) obj[4]); list.add(lookUp); } return list; }
From source file:com.projity.pm.graphic.model.transform.NodeCacheTransformer.java
private void handleGroup(List destList, ListIterator groupIterator, Node parentGroup, NodeGroup group, GraphicNode last, List nodes, NodeTransformer composition, boolean preserveHierarchy) { GraphicNode groupNode = createGroup(groupIterator.nextIndex(), group, group.getSorter(), last.getNode()); destList.add(groupNode);/* w w w .j ava 2 s . c om*/ model.addRelationship(parentGroup, groupNode.getNode()); if (groupIterator.hasNext()) { groupList(nodes, destList, groupIterator, groupNode.getNode(), composition, preserveHierarchy); } else { for (Iterator j = nodes.iterator(); j.hasNext();) model.addRelationship(groupNode.getNode(), ((GraphicNode) j.next()).getNode()); destList.addAll(nodes); } }
From source file:org.slc.sli.dashboard.unit.client.SDKAPIClientTest.java
@Test public void testGetAssessmentsForStudent() throws URISyntaxException, IOException, MessageProcessingException, SLIClientException { String token = "token"; String key = "studentId"; String studentId = "288598192"; String filename = getFilename(MOCK_DATA_DIRECTORY + "common/" + MOCK_ASSESSMENTS_FILE); when(mockSdk.read(anyString())).thenReturn(fromFileWithValue(filename, studentId, key)); List<GenericEntity> assessments = client.getAssessmentsForStudent(token, studentId); assertNotNull(assessments);// ww w . j ava 2s .c o m assertEquals(18, assessments.size()); ListIterator<GenericEntity> li = assessments.listIterator(); int count = 0; while (li.hasNext()) { GenericEntity ge = li.next(); assertEquals(ge.getString(key), studentId); if (ge.getString("assessmentName").equals("StateTest_READING")) { count++; } } assertEquals(count, 6); }
From source file:com.projity.pm.criticalpath.CriticalPath.java
private void doPass(Task startTask, TaskSchedule.CalculationContext context) { if (startTask != null) { startTask.getSchedule(context.scheduleType).invalidate(); startTask.setCalculationStateCount(getCalculationStateCount()); }/*from w w w . java 2 s .c om*/ PredecessorTaskList.TaskReference taskReference; boolean forward = context.forward; ListIterator i = forward ? predecessorTaskList.listIterator() : predecessorTaskList.reverseIterator(); Task task; TaskSchedule schedule; // int count = 0; // long z = System.currentTimeMillis(); boolean projectForward = project.isForward(); while (forward ? i.hasNext() : i.hasPrevious()) { taskReference = (PredecessorTaskList.TaskReference) (forward ? i.next() : i.previous()); traceTask = task = taskReference.getTask(); context.taskReferenceType = taskReference.getType(); schedule = task.getSchedule(context.scheduleType); if (!forward) context.taskReferenceType = -taskReference.getType(); if (task.isReverseScheduled()) {// reverse scheduled must always be calculated schedule.invalidate(); task.setCalculationStateCount(context.stateCount); } if (task.getCalculationStateCount() >= context.stateCount) { schedule.calcDates(context); if (context.assign && (projectForward || !task.isWbsParent())) { // in reverse scheduling, I see some parents have 0 or 1 as their dates. This is a workaround. if (schedule.getBegin() != 0L && !isSentinel(task)) earliestStart = Math.min(earliestStart, schedule.getStart()); if (schedule.getEnd() != 0 && !isSentinel(task)) latestFinish = Math.max(latestFinish, schedule.getFinish()); } // schedule.dump(); } } // System.out.println("pass forward=" + forward + " tasks:" + count + " time " + (System.currentTimeMillis() -z) + " ms"); }
From source file:oscar.form.study.hsfo2.pageUtil.ManageHSFOAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { logger.info("ContextPath: " + request.getContextPath()); logger.info("pathInfo: " + request.getPathInfo()); Map<String, String[]> params = request.getParameterMap(); Hsfo2Visit latestHsfo2Visit = new Hsfo2Visit(); PatientList historyList = new PatientList(); // RecordList record = new RecordList(); List recordList = new LinkedList(); String patientId = (String) request.getAttribute("demographic_no"); if (patientId == null) { patientId = request.getParameter("demographic_no"); }/* www . ja v a2s. c o m*/ String isfirstrecord = ""; boolean isFirstRecord = false; String user = (String) request.getSession().getAttribute("user"); HSFODAO hsfoDAO = new HSFODAO(); isFirstRecord = hsfoDAO.isFirstRecord(patientId); DemographicData demoData = new DemographicData(); //DemographicData.Demographic de = demoData.getDemographic( patientId ); Demographic de = demoData.getDemographic(patientId); boolean isDisplayGraphs = "displayGraphs".equalsIgnoreCase(request.getParameter("operation")); boolean isFromRegistrationForm = false; if ("true".equalsIgnoreCase(request.getParameter("isFromRegistrationForm"))) { //true means the request is from registration form, should goto followup form isFromRegistrationForm = true; } FORM forwardToForm = null; int patientHistorySize = 0; boolean isFirstVisitRecordForThePatient = false; // boolean isFromRegistrationForm = false; Integer formId = getFormIdFromRequest(request); Hsfo2Visit formHsfo2Visit = null; if (formId != null) formHsfo2Visit = hsfoDAO.retrieveSelectedRecord(formId); boolean isHistoryForm = !isFromRegistrationForm && (formId != null && formHsfo2Visit != null); if (formId != null) isFirstVisitRecordForThePatient = hsfoDAO.isFirstVisitRecordForThePatient(patientId, formId); boolean isRegistForm = !isDisplayGraphs && !isFromRegistrationForm && (isFirstRecord || isFirstVisitRecordForThePatient); //prepare data Hsfo2Patient hsfo2Patient = hsfoDAO.retrievePatientRecord(patientId); if (hsfo2Patient == null) hsfo2Patient = new Hsfo2Patient(); List patientHistory = hsfoDAO.retrieveVisitRecord(patientId); //save only or submit, it's for registration form and stay in that form boolean isSaveOnly = "Save".equalsIgnoreCase(request.getParameter("Save")); if (!isSaveOnly && !isFirstRecord) { isSaveOnly = !hsfo2Patient.isSubmitted(); } if (isSaveOnly) { //stay in regist form and treat as history isRegistForm = true; isHistoryForm = true; if (patientHistory.size() > 0) formHsfo2Visit = (Hsfo2Visit) patientHistory.get(patientHistory.size() - 1); } if (isHistoryForm) { latestHsfo2Visit = formHsfo2Visit; } else // create new form { patientHistorySize = patientHistory.size(); if (patientHistorySize >= 1) { latestHsfo2Visit = (Hsfo2Visit) patientHistory.get(patientHistorySize - 1); latestHsfo2Visit.setVisitDateIdToday(); latestHsfo2Visit.setId(hsfoDAO.getMaxVisitId() + 1); cleanNonePrefilledData(latestHsfo2Visit); getLabWork(latestHsfo2Visit, hsfo2Patient, ConvertUtil.toInt(patientId)); //If it's followup form, BP should not be prepopulated. Clean again. latestHsfo2Visit.setSBP(0); latestHsfo2Visit.setDBP(0); } else { latestHsfo2Visit = new Hsfo2Visit(); latestHsfo2Visit.setVisitDateIdToday(); getLabWork(latestHsfo2Visit, hsfo2Patient, ConvertUtil.toInt(patientId)); } } if (isRegistForm) { // registration, get data from DemographicData; isfirstrecord = "true"; hsfo2Patient.setPatient_Id(patientId); if (!isHistoryForm) { hsfo2Patient.setFName(de.getFirstName()); hsfo2Patient.setLName(de.getLastName()); hsfo2Patient.setBirthDate(oscar.util.DateUtils.toDate(de.getFormattedDob())); hsfo2Patient.setSex(de.getSex()); hsfo2Patient.setPostalCode(de.getPostal()); hsfo2Patient.setRegistrationId(HsfoUtil.getRegistrationId()); latestHsfo2Visit.setVisitDateIdToday(); } request.setAttribute("EmrHCPId1", user); request.setAttribute("EmrHCPId2", de.getProviderNo()); // TODO: may need to convert to provider name forwardToForm = FORM.registration; } else { //populate graphy data for followup form. the latestHsfo2Visit already keep the information of last visit. isfirstrecord = "false"; if (!isDisplayGraphs) forwardToForm = FORM.flowsheet; else { // If patientHistory is greater than 1 than fill the graphing arrays TimeSeries sbpSeries = new TimeSeries("Systolic Blood Pressure", Day.class); TimeSeries dbpSeries = new TimeSeries("Diastolic Blood Pressure", Day.class); TimeSeries bmiSeries = new TimeSeries("BMI", Day.class); TimeSeries waistSeries = new TimeSeries("Waist", Day.class); TimeSeries ldlSeries = new TimeSeries("LDL", Day.class); TimeSeries tcHdlSeries = new TimeSeries("TC/HDL", Day.class); TimeSeries importanceSeries = new TimeSeries("Importance", Day.class); TimeSeries confidenceSeries = new TimeSeries("Confidence", Day.class); Map<GraphDesc, TimeSeries> graphDescSeriesMap = new HashMap<GraphDesc, TimeSeries>(); graphDescSeriesMap.put(new GraphDesc("Systolic Blood Pressure", "Dates", "SBP(mmHg)"), sbpSeries); graphDescSeriesMap.put(new GraphDesc("Diastolic Blood Pressure", "Dates", "DBP(mmHg)"), dbpSeries); graphDescSeriesMap.put(new GraphDesc("BMI", "Dates", "BMI(kg/m2)"), bmiSeries); graphDescSeriesMap.put(new GraphDesc("Waist", "Dates", "Waist(cm)"), waistSeries); graphDescSeriesMap.put(new GraphDesc("LDL", "Dates", "LDL(mmol/L)"), ldlSeries); { GraphDesc tcHdlDesc = new GraphDesc("TC/HDL", "Dates", "TC/HDL(ratio)"); tcHdlDesc.setFileName("TC_HDL"); graphDescSeriesMap.put(tcHdlDesc, tcHdlSeries); } graphDescSeriesMap.put(new GraphDesc("Importance", "Dates", "Importance(1-10)"), importanceSeries); graphDescSeriesMap.put(new GraphDesc("Confidence", "Dates", "Confidence(1-10)"), confidenceSeries); if (patientHistorySize >= 1) { ListIterator patientHistoryIt = patientHistory.listIterator(); // int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0; while (patientHistoryIt.hasNext()) { Hsfo2Visit Hsfo2Visit = (Hsfo2Visit) patientHistoryIt.next(); // visitDateArray.add( setDateFull( Hsfo2Visit.getVisitDate_Id() ) ); // visitIdArray.add( "" + Hsfo2Visit.getID() ); // //////// final Date visitDate = Hsfo2Visit.getVisitDate_Id(); if (visitDate != null) { final Day visitDay = new Day(visitDate); if (Hsfo2Visit.getSBP() != 0) { sbpSeries.addOrUpdate(visitDay, Hsfo2Visit.getSBP()); } if (Hsfo2Visit.getDBP() != 0) { dbpSeries.addOrUpdate(visitDay, Hsfo2Visit.getDBP()); } if (Hsfo2Visit.getWeight() != 0) { Double bmi = getBmi(Hsfo2Visit, hsfo2Patient); if (bmi > 0) bmiSeries.addOrUpdate(visitDay, bmi); } // modified by victor for waist_unit null bug,2007 // if (Hsfo2Visit.getWaist() != 0{ if (Hsfo2Visit.getWaist() != 0 && Hsfo2Visit.getWaist_unit() != null) { double waistv = Hsfo2Visit.getWaist(); String waistunit = Hsfo2Visit.getWaist_unit(); double waist = 0.0; if (waistunit.equals("cm")) { waist = waistv; } else { // 1 inch = 2.54 cm waist = waistv * 2.54; } waistSeries.addOrUpdate(visitDay, waist); } if (Hsfo2Visit.getChange_importance() != 0) { importanceSeries.addOrUpdate(visitDay, Hsfo2Visit.getChange_importance()); } if (Hsfo2Visit.getChange_confidence() != 0) { confidenceSeries.addOrUpdate(visitDay, Hsfo2Visit.getChange_confidence()); } } final Date labResultDate = Hsfo2Visit.getTC_HDL_LabresultsDate(); if (labResultDate != null) { final Day labResultDay = new Day(labResultDate); if (Hsfo2Visit.getTC_HDL() != 0) { tcHdlSeries.addOrUpdate(labResultDay, Hsfo2Visit.getTC_HDL()); } if (Hsfo2Visit.getLDL() != 0) { ldlSeries.addOrUpdate(labResultDay, Hsfo2Visit.getLDL()); } } } } //generate the graph and export as picture. generateGraphs(request, response, graphDescSeriesMap); forwardToForm = FORM.graphs; ; } } historyList.setPatientHistory(patientHistory); // set request attributes to forward to jsp request.setAttribute("siteId", OscarProperties.getInstance().getProperty("hsfo2.loginSiteCode", "xxx")); request.setAttribute("Hsfo2Patient", hsfo2Patient); request.setAttribute("historyList", historyList); request.setAttribute("Hsfo2Visit", latestHsfo2Visit); //getDay() is date of week request.setAttribute("isFirstRecord", isfirstrecord); return mapping.findForward(forwardToForm.name()); }