List of usage examples for java.util ArrayList indexOf
public int indexOf(Object o)
From source file:org.pentaho.di.core.xml.XMLHandler.java
public static String[] getNodeElements(Node node) { ArrayList<String> elements = new ArrayList<String>(); // List of String NodeList nodeList = node.getChildNodes(); if (nodeList == null) { return null; }//from w w w . jav a 2 s .c om for (int i = 0; i < nodeList.getLength(); i++) { String nodeName = nodeList.item(i).getNodeName(); if (elements.indexOf(nodeName) < 0) { elements.add(nodeName); } } if (elements.isEmpty()) { return null; } return elements.toArray(new String[elements.size()]); }
From source file:org.jasig.ssp.web.api.reports.ReportBaseController.java
protected List<EarlyAlertStudentReportTO> processReports(PagingWrapper<EarlyAlertStudentReportTO> reports, EarlyAlertResponseService earlyAlertResponseService) { ArrayList<EarlyAlertStudentReportTO> compressedReports = new ArrayList<EarlyAlertStudentReportTO>(); if (reports == null || reports.getRows().size() <= 0) return compressedReports; for (EarlyAlertStudentReportTO reportTO : reports) { Integer index = compressedReports.indexOf(reportTO); if (index != null && index >= 0) { BaseStudentReportTO compressedReportTo = compressedReports.get(index); compressedReportTo.processDuplicate(reportTO); } else {/* w ww .ja v a 2s. c o m*/ reportTO.normalize(); compressedReports.add(reportTO); } } for (EarlyAlertStudentReportTO reportTO : compressedReports) { EarlyAlertResponseCounts countOfResponses = earlyAlertResponseService .getCountEarlyAlertRespondedToForEarlyAlerts(reportTO.getEarlyAlertIds()); reportTO.setPending(countOfResponses.getTotalEARespondedToNotClosed()); } return compressedReports; }
From source file:de.main.sessioncreator.ReportingHelper.java
/** * Creates a sample dataset//ww w. j ava 2 s .co m */ private PieDataset createDataset() { DefaultPieDataset result = new DefaultPieDataset(); ArrayList<String> Tester = new ArrayList<String>(); ArrayList<String> sessionList = fileHelper.getSessionList(fileHelper.getApprovedDir()); Tester = fileHelper.getTester(); int[] counter = new int[Tester.size()]; for (String s : sessionList) { for (String n : Tester) { if (s.contains(n.substring(0, 3))) { counter[Tester.indexOf(n)]++; break; } } } for (String n : Tester) { result.setValue(n.substring(4), counter[Tester.indexOf(n)]); } return result; }
From source file:org.mda.bcb.tcgagsdata.create.Compilation.java
public void process() throws IOException, Exception { TcgaGSData.printWithFlag("Compilation::process - mClinicalDir=" + mClinicalDir); TcgaGSData.printWithFlag("Compilation::process - mInputFiles=" + mInputFiles); TcgaGSData.printWithFlag("Compilation::process - mOutputFile=" + mOutputFile); Collection<File> results = FileUtils.listFiles(new File(mClinicalDir), FileFilterUtils.nameFileFilter(mInputFiles), TrueFileFilter.INSTANCE); ArrayList<String> headers = getHeaders(results); TreeSet<String> patients = new TreeSet<>(); TreeSet<String> lines = new TreeSet<>(); String headerLine = null;// w w w. j a v a 2 s. co m for (String header : headers) { if (null == headerLine) { headerLine = header; } else { headerLine = headerLine + "\t" + header; } } boolean headersNeeded = true; for (File clinFile : results) { TcgaGSData.printWithFlag("Compilation::process - clinFile=" + clinFile.getAbsolutePath()); try (BufferedReader br = Files.newBufferedReader(Paths.get(clinFile.getAbsolutePath()), Charset.availableCharsets().get("ISO-8859-1"))) { String line = br.readLine(); ArrayList<String> currentHeaders = new ArrayList<>(); currentHeaders.addAll(Arrays.asList(line.split("\t", -1))); for (line = br.readLine(); null != line; line = br.readLine()) { String newLine = null; String[] splitted = line.split("\t", -1); for (String header : headers) { String token = "NA"; int index = currentHeaders.indexOf(header); if (index > -1) { token = splitted[index]; } if (null == newLine) { newLine = token; } else { newLine = newLine + "\t" + token; } } lines.add(newLine); String patient = GSStringUtils.beforeTab(newLine); if (false == patients.add(patient)) { throw new Exception("ERROR - patient duplicated " + patient); } } } } try (BufferedWriter bw = Files.newBufferedWriter(Paths.get(mOutputFile), Charset.availableCharsets().get("ISO-8859-1"))) { bw.write(headerLine); bw.newLine(); for (String line : lines) { bw.write(line); bw.newLine(); } } }
From source file:org.alfresco.po.share.site.calendar.AbstractCalendarContainer.java
/** * @param month/*from ww w . jav a2 s.c om*/ */ public void setMonth(String month) { if (month == null) { throw new IllegalArgumentException("Month is required"); } try { ArrayList<String> monthValues = new ArrayList<String>(Arrays.asList("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")); String currentMonth = getMonthHeader(); if (!currentMonth.equals(month)) { String buttonToClickXpath = ""; int count = monthValues.indexOf(month) - monthValues.indexOf(currentMonth); if (count > 0) buttonToClickXpath = NEXT_MONTH__BUTTON; else buttonToClickXpath = PREVIOUS_MONTH_BUTTON; for (int i = 0; i < Math.abs(count); i++) { WebElement buttonToClick = findAndWait(By.xpath(buttonToClickXpath)); buttonToClick.click(); } } } catch (TimeoutException te) { if (logger.isTraceEnabled()) { logger.trace("Exceeded time to find the date button ", te); } } }
From source file:IK.AbstractArmature.java
private void insertIntoSortedChainList(ArrayList<SegmentedArmature> chainList, SegmentedArmature sa) { if (chainList.indexOf(sa) == -1) { int insertAt = -1; for (int i = 0; i < chainList.size(); i++) { if (chainList.get(i).distanceToRoot < sa.distanceToRoot) { insertAt = i;/*ww w.j av a 2 s .c o m*/ break; } } if (insertAt == -1) chainList.add(sa); else chainList.add(insertAt, sa); } }
From source file:org.eclipse.emf.emfstore.internal.client.ui.views.emfstorebrowser.views.NewRepositoryWizardPageOne.java
private void initCombo() { try {//from w ww . j av a 2 s .co m final ArrayList<String> certificates = KeyStoreManager.getInstance().getCertificates(); certificateCombo.setItems(certificates.toArray(new String[certificates.size()])); final NewRepositoryWizard wizard = (NewRepositoryWizard) getWizard(); final ESServer server = wizard.getServer(); final String selectedCertificate = server.getCertificateAlias(); certificateCombo.select(certificates.indexOf(selectedCertificate)); } catch (final ESCertificateException e) { WorkspaceUtil.logException(e.getMessage(), e); } }
From source file:org.videolan.vlc.gui.SearchFragment.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { if (getListAdapter() == mHistoryAdapter) { String selection = ((TextView) v.findViewById(android.R.id.text1)).getText().toString(); mSearchText.setText(selection);/* ww w . java 2s .c om*/ mSearchText.setSelection(selection.length()); mSearchText.requestFocus(); } else if (getListAdapter() == mResultAdapter) { // add search text to the database (history) MediaDatabase db = MediaDatabase.getInstance(); db.addSearchhistoryItem(mSearchText.getText().toString()); // open media in the player Media item = (Media) getListView().getItemAtPosition(position); if (item != null) { if (item.getType() == Media.TYPE_VIDEO) { VideoPlayerActivity.start(getActivity(), item.getLocation()); } else { ArrayList<String> arr = new ArrayList<String>(); for (int i = 0; i < getListAdapter().getCount(); i++) { Media audioItem = (Media) getListAdapter().getItem(i); if (audioItem.getType() == Media.TYPE_AUDIO) arr.add(audioItem.getLocation()); } AudioServiceController.getInstance().load(arr, arr.indexOf(item.getLocation())); return; } } super.onListItemClick(l, v, position, id); } }
From source file:org.openmrs.module.accessmonitor.web.controller.AccessMonitorPersonController.java
@RequestMapping(value = "/module/accessmonitor/person", method = RequestMethod.GET) public void person(ModelMap model, HttpServletRequest request) { offset = 0;//from w ww. j a v a 2 s . com // parse them to Date, null is acceptabl DateFormat format = new SimpleDateFormat("MM/dd/yyyy"); // Get the from date and to date Date to = null; Date from = null; try { from = format.parse(request.getParameter("datepickerFrom")); } catch (Exception e) { //System.out.println("======From Date Empty======="); } try { to = format.parse(request.getParameter("datepickerTo")); } catch (Exception e) { //System.out.println("======To Date Empty======="); } // get all the records in the date range personAccessData = ((PersonAccessService) Context.getService(PersonAccessService.class)) .getPersonAccessesByAccessDateOrderByPersonId(from, to); if (personAccessData == null) { personAccessData = new ArrayList<PersonServiceAccess>(); } // get date for small graph Date toSmall = to; Date fromSmall = null; Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 1); if (toSmall == null) { toSmall = calendar.getTime(); } else { calendar.setTime(toSmall); } calendar.add(Calendar.DATE, -DAYNUM); fromSmall = calendar.getTime(); List<String> dateStrings = new ArrayList<String>(); for (int i = 0; i < DAYNUM; i++) { if (i == DAYNUM - 1) { dateStrings.add(format.format(toSmall)); } else if (i == 0) { dateStrings.add(format.format(fromSmall)); } else { dateStrings.add(""); } } ArrayList<ArrayList<Integer>> tooltip = new ArrayList<ArrayList<Integer>>(); tooltip.add(new ArrayList<Integer>()); for (int j = 0; j < SHOWNUM + 1; j++) { tooltip.get(0).add(1000 + j); } for (int i = 1; i < DAYNUM + 1; i++) { tooltip.add(new ArrayList<Integer>()); tooltip.get(i).add(i); for (int j = 0; j < SHOWNUM; j++) { tooltip.get(i).add(0); } } ArrayList<String> personIds = new ArrayList<String>(); ArrayList<Integer> personCounts = new ArrayList<Integer>(); for (PersonServiceAccess pa : personAccessData) { // data for big graph String idString = (pa.getPersonId() == null) ? "No ID" : pa.getPersonId().toString(); int index = personIds.indexOf(idString); if (index < 0) { if (personIds.size() >= SHOWNUM) break; personIds.add(idString); personCounts.add(1); index = personIds.size() - 1;//index = personIds.indexOf(idString); } else { personCounts.set(index, personCounts.get(index) + 1); } // data for small graph if (pa.getAccessDate().after(fromSmall) && pa.getAccessDate().before(toSmall)) { int index2 = (int) ((pa.getAccessDate().getTime() - fromSmall.getTime()) / (1000 * 60 * 60 * 24)); if (index2 < DAYNUM && index2 >= 0) tooltip.get(index2 + 1).set(index + 1, tooltip.get(index2 + 1).get(index + 1) + 1); } } String personIdString = JSONValue.toJSONString(personIds); String personCountString = JSONValue.toJSONString(personCounts); String dateSmallString = JSONValue.toJSONString(dateStrings); String tooltipdata = JSONValue.toJSONString(tooltip); model.addAttribute("personIds", personIdString); model.addAttribute("personCounts", personCountString); model.addAttribute("dateSmallString", dateSmallString); model.addAttribute("tooltipdata", tooltipdata); model.addAttribute("user", Context.getAuthenticatedUser()); //model.addAttribute("tables1", personAccessData); //model.addAttribute("dateSmall", dateStrings); model.addAttribute("currentoffset", String.valueOf(offset)); }
From source file:org.openmrs.module.accessmonitor.web.controller.AccessMonitorOrderController.java
@RequestMapping(value = "/module/accessmonitor/order", method = RequestMethod.GET) public void person(ModelMap model, HttpServletRequest request) { offset = 0;/*from ww w.java 2 s . co m*/ // parse them to Date, null is acceptable DateFormat format = new SimpleDateFormat("MM/dd/yyyy"); // Get the from date and to date Date to = null; Date from = null; try { from = format.parse(request.getParameter("datepickerFrom")); } catch (Exception e) { //System.out.println("======From Date Empty======="); } try { to = format.parse(request.getParameter("datepickerTo")); } catch (Exception e) { //System.out.println("======To Date Empty======="); } // get all the records in the date range orderAccessData = ((OrderAccessService) Context.getService(OrderAccessService.class)) .getOrderAccessesByAccessDateOrderByPatientId(from, to); if (orderAccessData == null) { orderAccessData = new ArrayList<OrderServiceAccess>(); } // get date for small graph Date toSmall = to; Date fromSmall = null; Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 1); if (toSmall == null) { toSmall = calendar.getTime(); } else { calendar.setTime(toSmall); } calendar.add(Calendar.DATE, -DAYNUM); fromSmall = calendar.getTime(); List<String> dateStrings = new ArrayList<String>(); for (int i = 0; i < DAYNUM; i++) { if (i == DAYNUM - 1) { dateStrings.add(format.format(toSmall)); } else if (i == 0) { dateStrings.add(format.format(fromSmall)); } else { dateStrings.add(""); } } ArrayList<ArrayList<Integer>> tooltip = new ArrayList<ArrayList<Integer>>(); tooltip.add(new ArrayList<Integer>()); for (int j = 0; j < SHOWNUM + 1; j++) { tooltip.get(0).add(1000 + j); } for (int i = 1; i < DAYNUM + 1; i++) { tooltip.add(new ArrayList<Integer>()); tooltip.get(i).add(i); for (int j = 0; j < SHOWNUM; j++) { tooltip.get(i).add(0); } } ArrayList<String> patientIds = new ArrayList<String>(); ArrayList<Integer> patientCounts = new ArrayList<Integer>(); for (OrderServiceAccess oa : orderAccessData) { // data for big graph String idString = (oa.getPatientId() == null) ? "No ID" : oa.getPatientId().toString(); int index = patientIds.indexOf(idString); if (index < 0) { if (patientIds.size() >= SHOWNUM) break; patientIds.add(idString); patientCounts.add(1); index = patientIds.size() - 1;//index = personIds.indexOf(idString); } else { patientCounts.set(index, patientCounts.get(index) + 1); } // data for small graph if (oa.getAccessDate().after(fromSmall) && oa.getAccessDate().before(toSmall)) { int index2 = (int) ((oa.getAccessDate().getTime() - fromSmall.getTime()) / (1000 * 60 * 60 * 24)); if (index2 < DAYNUM && index2 >= 0) tooltip.get(index2 + 1).set(index + 1, tooltip.get(index2 + 1).get(index + 1) + 1); } } String patientIdString = JSONValue.toJSONString(patientIds); String patientCountString = JSONValue.toJSONString(patientCounts); String dateSmallString = JSONValue.toJSONString(dateStrings); String tooltipdata = JSONValue.toJSONString(tooltip); model.addAttribute("patientIds", patientIdString); model.addAttribute("patientCounts", patientCountString); model.addAttribute("dateSmallString", dateSmallString); model.addAttribute("tooltipdata", tooltipdata); model.addAttribute("user", Context.getAuthenticatedUser()); //model.addAttribute("tables1", orderAccessData); //model.addAttribute("dateSmall", dateStrings); model.addAttribute("currentoffset", String.valueOf(offset)); }