List of usage examples for java.util ArrayList iterator
public Iterator<E> iterator()
From source file:com.max2idea.android.limbo.main.LimboActivity.java
private void populateKernel() { // Add from History ArrayList<String> kernels = favDB.getFavURL("kernel"); int length = 0; if (kernels == null || kernels.size() == 0) { length = 0;/*from w ww. ja va 2 s. co m*/ } else { length = kernels.size(); } ArrayList<String> arraySpinner = new ArrayList<String>(); arraySpinner.add("None"); arraySpinner.add("Open"); Iterator i = kernels.iterator(); while (i.hasNext()) { String file = (String) i.next(); if (file != null) { arraySpinner.add(file); } } kernelAdapter = new ArrayAdapter(this, R.layout.custom_spinner_item, arraySpinner); kernelAdapter.setDropDownViewResource(R.layout.custom_spinner_dropdown_item); this.mKernel.setAdapter(kernelAdapter); this.mKernel.invalidate(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
private void populateInitrd() { // Add from History ArrayList<String> initrds = favDB.getFavURL("initrd"); int length = 0; if (initrds == null || initrds.size() == 0) { length = 0;//ww w . j a va 2 s .c o m } else { length = initrds.size(); } ArrayList<String> arraySpinner = new ArrayList<String>(); arraySpinner.add("None"); arraySpinner.add("Open"); Iterator i = initrds.iterator(); while (i.hasNext()) { String file = (String) i.next(); if (file != null) { arraySpinner.add(file); } } initrdAdapter = new ArrayAdapter(this, R.layout.custom_spinner_item, arraySpinner); initrdAdapter.setDropDownViewResource(R.layout.custom_spinner_dropdown_item); this.mInitrd.setAdapter(initrdAdapter); this.mInitrd.invalidate(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
private void populateCDRom(String fileType) { this.userPressedCDROM = false; // Add from History ArrayList<String> oldCDs = favDB.getFavURL(fileType); int length = 0; if (oldCDs == null || oldCDs.size() == 0) { length = 0;/* ww w .j av a 2 s. c om*/ } else { length = oldCDs.size(); } ArrayList<String> arraySpinner = new ArrayList<String>(); arraySpinner.add("None"); arraySpinner.add("Open"); if (oldCDs != null) { Iterator i = oldCDs.iterator(); while (i.hasNext()) { String file = (String) i.next(); if (file != null) { arraySpinner.add(file); } } } cdromAdapter = new ArrayAdapter(this, R.layout.custom_spinner_item, arraySpinner); cdromAdapter.setDropDownViewResource(R.layout.custom_spinner_dropdown_item); this.mCD.setAdapter(cdromAdapter); this.mCD.invalidate(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
private void populateHD(String fileType) { // Add from History ArrayList<String> oldHDs = favDB.getFavURL(fileType); int length = 0; if (oldHDs == null || oldHDs.size() == 0) { length = 0;// w ww .j a v a2 s .c o m } else { length = oldHDs.size(); } ArrayList<String> arraySpinner = new ArrayList<String>(); arraySpinner.add("None"); arraySpinner.add("New"); arraySpinner.add("Open"); Iterator i = oldHDs.iterator(); while (i.hasNext()) { String file = (String) i.next(); if (file != null) { arraySpinner.add(file); } } if (fileType.equals("hda")) { hdaAdapter = new ArrayAdapter(this, R.layout.custom_spinner_item, arraySpinner); hdaAdapter.setDropDownViewResource(R.layout.custom_spinner_dropdown_item); this.mHDA.setAdapter(hdaAdapter); this.mHDA.invalidate(); } else if (fileType.equals("hdb")) { hdbAdapter = new ArrayAdapter(this, R.layout.custom_spinner_item, arraySpinner); hdbAdapter.setDropDownViewResource(R.layout.custom_spinner_dropdown_item); this.mHDB.setAdapter(hdbAdapter); this.mHDB.invalidate(); } }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
private void populateFloppy(String fileType) { // Add from History ArrayList<String> oldFDs = favDB.getFavURL(fileType); int length = 0; if (oldFDs == null || oldFDs.size() == 0) { length = 0;// ww w.j a v a 2 s. c om } else { length = oldFDs.size(); } ArrayList<String> arraySpinner = new ArrayList<String>(); arraySpinner.add("None"); arraySpinner.add("Open"); if (oldFDs != null) { Iterator i = oldFDs.iterator(); while (i.hasNext()) { String file = (String) i.next(); if (file != null) { arraySpinner.add(file); } } } if (fileType.equals("fda")) { fdaAdapter = new ArrayAdapter(this, R.layout.custom_spinner_item, arraySpinner); fdaAdapter.setDropDownViewResource(R.layout.custom_spinner_dropdown_item); this.mFDA.setAdapter(fdaAdapter); this.mFDA.invalidate(); } else if (fileType.equals("fdb")) { fdbAdapter = new ArrayAdapter(this, R.layout.custom_spinner_item, arraySpinner); fdbAdapter.setDropDownViewResource(R.layout.custom_spinner_dropdown_item); this.mFDB.setAdapter(fdbAdapter); this.mFDB.invalidate(); } }
From source file:main.MainClass.java
private boolean autoMailForward(String mode, String mailid) { loggerObj.log(Level.INFO, "Inside Automail Forward"); //Need to check properly with external for this getTicketIdsFromMEMDM alone. Because it gives all the ticketids and we need to //use it properly because it will involve lot of requests to the support.zoho.com if we get threadIds and threadContents for all the //ticketIds returned by this method. //Don't Delete this line as this is needed for external //String[] TicketIdsFileDtls = getTicketIdsFromMEMDM(mode); //This is used for test purpose String[] TicketIdsFileDtls = new String[] { "./TestFiles/fromServer/AutoMailForward/memdm", "1" }; if (TicketIdsFileDtls == null) { System.out.println("The ticketIds file received from MEDC portal is empy"); return false; }/*from w w w . j av a 2s .c o m*/ String folderToReadTicketIds = TicketIdsFileDtls[0]; int tickedIdFileCount = Integer.parseInt(TicketIdsFileDtls[1]); String configFile = "./conf/AutoMailForward/medcs/connectionConfig.props"; JSONObject supDetails = initializeSupportDetails(configFile); loggerObj.log(Level.INFO, "connection config details obtained form " + configFile + "is: " + supDetails.toJSONString()); if (supDetails == null) { loggerObj.log(Level.SEVERE, "Problem in parsing " + configFile + "to get support.zoho.com details"); return false; } for (int fileCount = 1; fileCount <= tickedIdFileCount; fileCount++) { String fileToReadTicketIdsFrom = folderToReadTicketIds + "/ticketsIds_" + fileCount + ".csv"; List<String> ticketIds = FileOperations.readStringArrFromCSVFile(fileToReadTicketIdsFrom); loggerObj.log(Level.INFO, "Ticket Ids obtained from " + fileToReadTicketIdsFrom + ticketIds.toString()); for (Iterator ticketIdItr = ticketIds.iterator(); ticketIdItr.hasNext();) { String[] searchParams = (String[]) supDetails.get("searchparams"); if (searchParams == null) { searchParams = new String[] { "Request Id", ticketIdItr.next().toString() }; } supDetails.put(SEARCHPARAMS, searchParams); String rootFolder = null; String[] dataFromSupport = null; if (mode.equals("external")) { rootFolder = "./fromServer/AutoMailForward/caseIds"; } if (mode.equals("internal")) { // Dont know whether this is the correct internal file. If it is not working , then proeprly change it after testing. rootFolder = "./TestFiles/fromServer/AutoMailForward/caseIds/medcs/27_02_16_21_03_39"; } dataFromSupport = getSupportDataWithConfigDetails(supDetails, mode, rootFolder, false, "AutoMailForward_CaseIds"); supDetails = null; if (dataFromSupport == null) { loggerObj.log(Level.SEVERE, "Problem in getting details from support.zoho.com"); return false; } int index = Integer.parseInt(dataFromSupport[1]); String folderToReadFrom = dataFromSupport[0]; loggerObj.log(Level.INFO, "The details obtained from support is: index: " + index + " folderToreadFrom: " + folderToReadFrom); JSONOperations parserObj = new JSONOperations(); String[] caseId = new String[index]; for (int i = 1; i <= index; i++) { String fileToReadFrom = folderToReadFrom + i + ".json"; JSONObject responseFromSup = (JSONObject) FileOperations.readFromJSONFile(fileToReadFrom); ArrayList<String> caseIdObj = parserObj.parseWithColumnHeaderCri(responseFromSup, "CASEID", "row"); if (caseIdObj != null && caseIdObj.size() == 1) { caseId[i - 1] = caseIdObj.get(0); loggerObj.log(Level.INFO, "Case Id obtained from support is " + caseId[i - 1] + "by reading file " + fileToReadFrom); } else { loggerObj.log(Level.SEVERE, "Problem in retrieving Case ID from given Tickt Id"); return false; } } folderToReadFrom = null; parserObj = null; supDetails = initializeSupportDetails("./conf/AutoMailForward/medcs/connectionConfig.props"); Object[] threadIdList = new Object[index]; for (int i = 0; i < index; i++) { // need to change the internal implementation with getThreadIDsFromSupportApi method itself. if (mode.equals("external")) { rootFolder = "./fromServer/AutoMailForward/threadIds/" + getCurrTimeInDD_MM_YY_HH_MM_SS(); dataFromSupport = getThreadIDsFromSupportApi(supDetails, new String[] { caseId[i], "true" }, rootFolder); } else if (mode.equals("internal")) { String testrootFolder = "./TestFiles/fromServer/AutoMailForward/threadIds/255000005096068/JSONResponse_"; dataFromSupport = readFromInternalAutoForward(testrootFolder); loggerObj.log(Level.INFO, "running in internal mode reading from " + testrootFolder); } if (dataFromSupport == null) { loggerObj.log(Level.SEVERE, "Issue is getting ThreadIds from support for caseId" + caseId[i]); return false; } loggerObj.log(Level.SEVERE, "Received ThreadId details from support for caseId " + caseId[i] + " is " + "folderToRead " + dataFromSupport[0] + " index " + dataFromSupport[1]); threadIdList[i] = dataFromSupport; } JSONObject caseIds = new JSONObject(); for (int i = 0; i < index; i++) { dataFromSupport = (String[]) threadIdList[i]; int threadIdIndex = Integer.parseInt(dataFromSupport[1]); folderToReadFrom = dataFromSupport[0]; loggerObj.log(Level.INFO, "Going to read from file " + folderToReadFrom + "1 to " + folderToReadFrom + threadIdIndex); parserObj = new JSONOperations(); ArrayList<String> threadIds = new ArrayList<>(); for (int j = 1; j <= threadIdIndex; j++) { String fileToReadFrom = folderToReadFrom + j + ".json"; loggerObj.log(Level.INFO, "Reading from " + fileToReadFrom); JSONObject responseFromSup = (JSONObject) FileOperations.readFromJSONFile(fileToReadFrom); Object threadIdsObj = parserObj.parseWithColumnHeaderCri(responseFromSup, "Thread Id", "threadinfo"); if (threadIdsObj == null) { loggerObj.log(Level.SEVERE, "Problem in retrieving Ticket ID from given Case ID" + caseId[i]); return false; } threadIds.addAll((ArrayList<String>) threadIdsObj); } caseIds.put(caseId[i], threadIds); loggerObj.log(Level.INFO, "ThreadIds for caseId " + caseId[i] + " is " + caseIds.toJSONString()); } JSONObject caseIDsToFiles = new JSONObject(); Set<String> CaseIdSet = caseIds.keySet(); if (mode.equals("external")) { for (Iterator caseIdItr = CaseIdSet.iterator(); caseIdItr.hasNext();) { String caseIdStr = (String) caseIdItr.next(); String folderRootForThreadContent = "./fromServer/AutoMailForward/ThreadContents/" + getCurrTimeInDD_MM_YY_HH_MM_SS() + "/" + caseIdStr; boolean createFolderToWriteResponse = new File(folderRootForThreadContent).mkdirs(); if (!createFolderToWriteResponse) { loggerObj.log(Level.INFO, "Cannot create a folder" + folderRootForThreadContent + " to write threadcontent"); return false; } ArrayList<String> threadIds = (ArrayList<String>) caseIds.get(caseIdStr); String[] fileNames = new String[threadIds.size()]; int i = 0; for (Iterator threadItr = threadIds.iterator(); threadItr.hasNext();) { String threadId = (String) threadItr.next(); String fileForThreadContent = folderRootForThreadContent + "/" + threadId + ".xml"; loggerObj.log(Level.INFO, "The file to write the thread content for threadId " + threadId + "is " + fileForThreadContent); fileNames[i] = getThreadContentFromSupportApi(fileForThreadContent, supDetails, threadId, caseIdStr); if (fileNames[i] == null) { loggerObj.log(Level.SEVERE, "Problem in reading thread content for thread id " + threadId + "for case id" + caseIdStr); } loggerObj.log(Level.INFO, "Thread content for thread Id" + threadId + "is written to the file" + fileNames[i]); i++; } caseIDsToFiles.put(caseIdStr, fileNames); loggerObj.log(Level.INFO, "CaseIds along with file names consisting their thread ID is as follows " + caseIDsToFiles.toJSONString()); } } else if (mode.equals("internal")) { String rootTestFolder = "./TestFiles/fromServer/AutoMailForward/ThreadContents/27_02_16_21_03_41/255000005096068"; String testFile1 = rootTestFolder + "/" + "255000005078234.xml"; String testfile2 = rootTestFolder + "/" + "255000005096070.xml"; caseIDsToFiles.put("255000004261482", new String[] { testFile1, testfile2 }); loggerObj.log(Level.INFO, "running in Test mode with reading from files" + testFile1 + testfile2); } String folderToWriteToStr = ""; Set<String> caseIDsToFilesSet = caseIDsToFiles.keySet(); for (Iterator fileNameItr = caseIDsToFilesSet.iterator(); fileNameItr.hasNext();) { String caseIDstr = (String) fileNameItr.next(); loggerObj.log(Level.INFO, "case ID found is " + caseIDstr); String[] fileNames = (String[]) caseIDsToFiles.get(caseIDstr); if (fileNames == null) { loggerObj.log(Level.INFO, "Error in getting file name which contains the thread content for the caseId " + caseIDstr); } String[] folderToWriteTo = fileNames[0].split("/"); for (int i = 0; i < folderToWriteTo.length - 1; i++) { folderToWriteToStr += folderToWriteTo[i] + "/"; } folderToWriteToStr += "output.html"; loggerObj.log(Level.INFO, "Going to convert xml files " + getStringFromStringArray(fileNames) + "html files for case Id" + caseIDstr); SAXParser xmlParser = new SAXParser(); for (String fileToReadFrom : fileNames) { xmlParser.xmlFileToHTMLConverter(fileToReadFrom, folderToWriteToStr); } } loggerObj.log(Level.INFO, "Going to send auto forward mail using the file" + folderToWriteToStr); StringWriter writer = new StringWriter(); try { IOUtils.copy(new FileInputStream(new File(folderToWriteToStr)), writer); } catch (IOException ex) { loggerObj.log(Level.SEVERE, "Issue in prsing the file" + folderToWriteToStr + "to send mail"); return false; } String[] content = new String[2]; content[0] = writer.toString(); content[1] = "text/html"; MailOperations.sendMail(mailid, content, "Testing purpose"); loggerObj.log(Level.INFO, "Successfully sent the mail using" + folderToWriteToStr); } } return false; }
From source file:edu.mayo.informatics.lexgrid.convert.directConversions.UMLSToSQL.java
private void loadOtherProperties(String UMLSCodingSchemeName, String cui, String codingSchemeName, String conceptCode, LRUMap TValues) throws SQLException { // Drop the CUI in. supportedPropertyTypes_.add("UMLS_CUI"); addToEntityProperty(codingSchemeName, SQLTableConstants.ENTITYTYPE_CONCEPT, conceptCode, "CUI-" + cuiCounter_++, "property", "UMLS_CUI", null, null, null, null, null, null, cui); // get the semantic type(s) supportedPropertyTypes_.add("Semantic_Type"); PreparedStatement getSemTypes = umlsConnection_.prepareStatement("SELECT STY FROM MRSTY WHERE CUI = ?"); getSemTypes.setString(1, cui);//w w w . ja v a 2 s .c om ResultSet semTypes = getSemTypes.executeQuery(); while (semTypes.next()) { addToEntityProperty(codingSchemeName, SQLTableConstants.ENTITYTYPE_CONCEPT, conceptCode, "SemType-" + semTypeCounter_++, "property", "Semantic_Type", null, SQLTableConstants.TBLCOLVAL_FORMAT_TXT_PLAIN, null, null, null, null, semTypes.getString("STY")); } getSemTypes.close(); // load the other properties PreparedStatement getProperties = umlsConnection_ .prepareStatement("SELECT ATN, ATV, STYPE, METAUI FROM MRSAT WHERE CODE = ? AND SAB = ?"); getProperties.setString(1, conceptCode); getProperties.setString(2, UMLSCodingSchemeName); ResultSet properties = getProperties.executeQuery(); ArrayList auiProps = new ArrayList(); while (properties.next()) { String propertyFlag = properties.getString("ATN"); String propertyValue = properties.getString("ATV"); String propertyStype = properties.getString("STYPE"); String propertyMetaui = properties.getString("METAUI"); String propertyId = null; String propertyName = null; String propertyType = null; String representationalForm = null; Boolean isPreferred = null; if (mrsatMap_.get(propertyFlag) != null && (propertyStype.equalsIgnoreCase("CODE") || propertyStype.equalsIgnoreCase("SCUI") || propertyStype.equalsIgnoreCase("SDUI"))) { Integer type = (Integer) mrsatMap_.get(propertyFlag); if (type.intValue() == SKIP.intValue()) { continue; } else if (type.intValue() == COMMENT.intValue()) { propertyId = "C-" + commentCounter_++; propertyType = SQLTableConstants.TBLCOLVAL_COMMENT; propertyName = SQLTableConstants.TBLCOLVAL_COMMENT; isPreferred = new Boolean(false); } else if (type.intValue() == INSTRUCTION.intValue()) { propertyId = "I-" + instructionCounter_++; propertyType = SQLTableConstants.TBLCOLVAL_INSTRUCTION; propertyName = SQLTableConstants.TBLCOLVAL_INSTRUCTION; isPreferred = new Boolean(false); } else if (type.intValue() == PRESENTATION.intValue()) { propertyId = "T-" + presentationCounter_++; propertyType = SQLTableConstants.TBLCOLVAL_PRESENTATION; propertyName = SQLTableConstants.TBLCOLVAL_TEXTUALPRESENTATION; TValues.put(propertyMetaui, propertyId); isPreferred = new Boolean(false); } } else if (propertyStype.equalsIgnoreCase("SAUI")) { auiProps.add(new AUI_PROP(propertyFlag, propertyValue, propertyStype, propertyMetaui)); continue; } else { propertyId = "P-" + propertyCounter_++; propertyType = SQLTableConstants.TBLCOLVAL_PROPERTY; propertyName = propertyFlag; } representationalForm = (String) atnRepresentationalMap_.get(propertyFlag); supportedPropertyTypes_.add(propertyName); addToEntityProperty(codingSchemeName, SQLTableConstants.ENTITYTYPE_CONCEPT, conceptCode, propertyId, propertyType, propertyName, null, SQLTableConstants.TBLCOLVAL_FORMAT_TXT_PLAIN, isPreferred, null, null, representationalForm, propertyValue); } Iterator aPIter = auiProps.iterator(); while (aPIter.hasNext()) { AUI_PROP ap = (AUI_PROP) aPIter.next(); String apPropertyId = (String) TValues.get(ap.metaui); if (apPropertyId == null) continue; if (!supportedPropertyQualifiers_.contains(ap.atn)) supportedPropertyQualifiers_.add(ap.atn); addConceptToEntityPropertyMultiAttributes(codingSchemeName, SQLTableConstants.ENTITYTYPE_CONCEPT, conceptCode, apPropertyId, SQLTableConstants.TBLCOLVAL_QUALIFIER, ap.atn, ap.atv, ""); } getProperties.close(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
private void populateSnapshot() { // Add from History ArrayList<String> oldSnapshots = null; if (currMachine != null) { oldSnapshots = machineDB.getSnapshots(currMachine); }/* w ww .j a v a 2 s .co m*/ int length = 0; if (oldSnapshots == null) { length = 0; } else { length = oldSnapshots.size(); } ArrayList<String> arraySpinner = new ArrayList<String>(); arraySpinner.add("None"); if (oldSnapshots != null) { Iterator i = oldSnapshots.iterator(); while (i.hasNext()) { String file = (String) i.next(); if (file != null) { arraySpinner.add(file); } } } this.userPressedSnapshot = false; snapshotAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner); snapshotAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); this.mSnapshot.setAdapter(snapshotAdapter); this.mSnapshot.invalidate(); if (oldSnapshots == null) { this.mSnapshot.setEnabled(false); } else { this.mSnapshot.setEnabled(true); } }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
private void populateMachines() { this.userPressedMachine = false; // Add from History ArrayList<String> machines = machineDB.getMachines(); int length = 0; if (machines == null || machines.size() == 0) { // Log.v(TAG, "No machine in DB"); length = 0;//from ww w . ja va 2s .c om } else { // Log.v("PopMachines", "Found " + length + " machines in DB"); length = machines.size(); } String[] arraySpinner = new String[machines.size() + 2]; arraySpinner[0] = "Open"; arraySpinner[1] = "New"; int index = 2; Iterator i = machines.iterator(); while (i.hasNext()) { String file = (String) i.next(); if (file != null) { arraySpinner[index++] = file; } } machineAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner); machineAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); this.mMachine.setAdapter(machineAdapter); this.mMachine.invalidate(); }