List of usage examples for java.util HashMap isEmpty
public boolean isEmpty()
From source file:com.sckftr.android.utils.net.Network.java
/** * Call the webservice using the given parameters to construct the request and return the * result./*from w w w . j a v a 2s. c o m*/ * * * @param context The context to use for this operation. Used to generate the user agent if * needed. * @param urlValue The webservice URL. * @param method The request method to use. * @param handler *@param parameterList The parameters to add to the request. * @param headerMap The headers to add to the request. * @param isGzipEnabled Whether the request will use gzip compression if available on the * server. * @param userAgent The user agent to set in the request. If null, a default Android one will be * created. * @param postText The POSTDATA text to add in the request. * @param credentials The credentials to use for authentication. * @param isSslValidationEnabled Whether the request will validate the SSL certificates. @return The result of the webservice call. */ static <Out> Out execute(Context context, String urlValue, Method method, Executor<BufferedReader, Out> handler, ArrayList<BasicNameValuePair> parameterList, HashMap<String, String> headerMap, boolean isGzipEnabled, String userAgent, String postText, UsernamePasswordCredentials credentials, boolean isSslValidationEnabled) throws NetworkConnectionException { HttpURLConnection connection = null; try { // Prepare the request information if (userAgent == null) { userAgent = UserAgentUtils.get(context); } if (headerMap == null) { headerMap = new HashMap<String, String>(); } headerMap.put(HTTP.USER_AGENT, userAgent); if (isGzipEnabled) { headerMap.put(ACCEPT_ENCODING_HEADER, "gzip"); } headerMap.put(ACCEPT_CHARSET_HEADER, UTF8_CHARSET); if (credentials != null) { headerMap.put(AUTHORIZATION_HEADER, createAuthenticationHeader(credentials)); } StringBuilder paramBuilder = new StringBuilder(); if (parameterList != null && !parameterList.isEmpty()) { for (int i = 0, size = parameterList.size(); i < size; i++) { BasicNameValuePair parameter = parameterList.get(i); String name = parameter.getName(); String value = parameter.getValue(); if (TextUtils.isEmpty(name)) { // Empty parameter name. Check the next one. continue; } if (value == null) { value = ""; } paramBuilder.append(URLEncoder.encode(name, UTF8_CHARSET)); paramBuilder.append("="); paramBuilder.append(URLEncoder.encode(value, UTF8_CHARSET)); paramBuilder.append("&"); } } // Log the request //if (Log.canLog(Log.DEBUG)) { Log.d(TAG, method.toString() + ": " + urlValue); if (parameterList != null && !parameterList.isEmpty()) { //Log.d(TAG, "Parameters:"); for (int i = 0, size = parameterList.size(); i < size; i++) { BasicNameValuePair parameter = parameterList.get(i); String message = "- \"" + parameter.getName() + "\" = \"" + parameter.getValue() + "\""; Log.d(TAG, message); } //Log.d(TAG, "Parameters String: \"" + paramBuilder.toString() + "\""); } if (postText != null) { Log.d(TAG, "Post data: " + postText); } if (headerMap != null && !headerMap.isEmpty()) { //Log.d(TAG, "Headers:"); for (Entry<String, String> header : headerMap.entrySet()) { //Log.d(TAG, "- " + header.getKey() + " = " + header.getValue()); } } //} // Create the connection object URL url = null; String outputText = null; switch (method) { case GET: case DELETE: String fullUrlValue = urlValue; if (paramBuilder.length() > 0) { fullUrlValue += "?" + paramBuilder.toString(); } url = new URL(fullUrlValue); connection = (HttpURLConnection) url.openConnection(); break; case PUT: case POST: url = new URL(urlValue); connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); if (paramBuilder.length() > 0) { outputText = paramBuilder.toString(); headerMap.put(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded"); headerMap.put(HTTP.CONTENT_LEN, String.valueOf(outputText.getBytes().length)); } else if (postText != null) { outputText = postText; } break; } // Set the request method connection.setRequestMethod(method.toString()); // If it's an HTTPS request and the SSL Validation is disabled if (url.getProtocol().equals("https") && !isSslValidationEnabled) { HttpsURLConnection httpsConnection = (HttpsURLConnection) connection; httpsConnection.setSSLSocketFactory(getAllHostsValidSocketFactory()); httpsConnection.setHostnameVerifier(getAllHostsValidVerifier()); } // Add the headers if (!headerMap.isEmpty()) { for (Entry<String, String> header : headerMap.entrySet()) { connection.addRequestProperty(header.getKey(), header.getValue()); } } // Set the connection and read timeout connection.setConnectTimeout(OPERATION_TIMEOUT); connection.setReadTimeout(OPERATION_TIMEOUT); // Set the outputStream content for POST and PUT requests if ((method == Method.POST || method == Method.PUT) && outputText != null) { OutputStream output = null; try { output = connection.getOutputStream(); output.write(outputText.getBytes()); } finally { if (output != null) { try { output.close(); } catch (IOException e) { // Already catching the first IOException so nothing to do here. } } } } String contentEncoding = connection.getHeaderField(HTTP.CONTENT_ENCODING); int responseCode = connection.getResponseCode(); boolean isGzip = contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip"); Log.d(TAG, "Response code: " + responseCode); if (responseCode == HttpStatus.SC_MOVED_PERMANENTLY) { String redirectionUrl = connection.getHeaderField(LOCATION_HEADER); throw new NetworkConnectionException("New location : " + redirectionUrl, redirectionUrl); } InputStream errorStream = connection.getErrorStream(); if (errorStream != null) { String err = evaluateStream(errorStream, new StringReaderHandler(), isGzip); throw new NetworkConnectionException(err, responseCode); } return evaluateStream(connection.getInputStream(), handler, isGzip); } catch (IOException e) { Log.e(TAG, "IOException", e); throw new NetworkConnectionException(e); } catch (KeyManagementException e) { Log.e(TAG, "KeyManagementException", e); throw new NetworkConnectionException(e); } catch (NoSuchAlgorithmException e) { Log.e(TAG, "NoSuchAlgorithmException", e); throw new NetworkConnectionException(e); } finally { if (connection != null) { connection.disconnect(); } } }
From source file:edu.umass.cs.gigapaxos.PaxosInstanceStateMachine.java
private void getActualDecisions(HashMap<Integer, PValuePacket> missing) { if (missing.isEmpty()) return;// w w w .j a v a2s. co m Integer minSlot = null, maxSlot = null; // find meta value commits for (Integer slot : missing.keySet()) { if (missing.get(slot).isMetaValue()) { if (minSlot == null) minSlot = (maxSlot = slot); if (slot - minSlot < 0) minSlot = slot; if (slot - maxSlot > 0) maxSlot = slot; } } if (!(minSlot == null || (minSlot - this.paxosState.getMaxAcceptedSlot() > 0))) { // get logged accepts for meta commit slots Map<Integer, PValuePacket> accepts = this.paxosManager.getPaxosLogger() .getLoggedAccepts(this.getPaxosID(), this.getVersion(), minSlot, maxSlot + 1); // reconstruct decision from accept for (PValuePacket pvalue : accepts.values()) if (missing.containsKey(pvalue.slot) && missing.get(pvalue.slot).isMetaValue()) missing.put(pvalue.slot, pvalue.makeDecision(pvalue.getMedianCheckpointedSlot())); } // remove remaining meta value decisions for (Iterator<PValuePacket> pvalueIter = missing.values().iterator(); pvalueIter.hasNext();) { PValuePacket decision = pvalueIter.next(); if (decision.isMetaValue()) { if (this.paxosState.getSlot() - decision.slot > 0) log.log(Level.FINE, "{0} has no body for executed meta-decision {1} " + " likely because placeholder decision was " + "logged without corresponding accept)", new Object[] { this, decision }); pvalueIter.remove(); } } }
From source file:it.unibas.spicy.persistence.DAOMappingTaskLines.java
@SuppressWarnings("unchecked") private Element createCSVDetail(Map<String, Object> annotations, String mappingTaskFilePath) { Element sourceCSV = new Element("csv"); //source-csv-db-name Element sourceCsvSchema = new Element("csv-db-name"); String dbName = (String) annotations.get(SpicyEngineConstants.CSV_DB_NAME); sourceCsvSchema.setText(dbName);/*from w ww .j a v a 2s . co m*/ sourceCSV.addContent(sourceCsvSchema); //source-csv-tables Element sourceCsvTables = new Element("csv-tables"); sourceCSV.addContent(sourceCsvTables); //source-csv-table List<String> sourceCsvTablesList = (List<String>) annotations.get(SpicyEngineConstants.CSV_TABLE_FILE_LIST); HashMap<String, ArrayList<Object>> sourceCsvInstancesList = new HashMap<String, ArrayList<Object>>(); //if there are instance files, get their values to the list if (annotations.containsKey(SpicyEngineConstants.CSV_INSTANCES_INFO_LIST)) { sourceCsvInstancesList = (HashMap<String, ArrayList<Object>>) annotations .get(SpicyEngineConstants.CSV_INSTANCES_INFO_LIST); } if (!sourceCsvTablesList.isEmpty()) { for (String absoluteTablePath : sourceCsvTablesList) { String relativeTablePath = filePathTransformator.relativize(mappingTaskFilePath, absoluteTablePath); Element sourceCsvTable = new Element("csv-table"); sourceCsvTables.addContent(sourceCsvTable); Element schemaCsvTable = new Element("schema"); schemaCsvTable.setText(relativeTablePath); sourceCsvTable.addContent(schemaCsvTable); Element instancesCsvTable = new Element("instances"); sourceCsvTable.addContent(instancesCsvTable); if (!sourceCsvInstancesList.isEmpty()) { for (Map.Entry<String, ArrayList<Object>> entry : sourceCsvInstancesList.entrySet()) { //if the table name of the instance is the same as the filename of the schema String instTableName = (String) entry.getValue().get(0); String schemaTableName = absoluteTablePath .substring(absoluteTablePath.lastIndexOf(File.separator) + 1); //exclude filename extension if (schemaTableName.indexOf(".") > 0) { schemaTableName = schemaTableName.substring(0, schemaTableName.lastIndexOf(".")); } if (instTableName.equals(schemaTableName)) { Element instanceCsvTable = new Element("instance"); instancesCsvTable.addContent(instanceCsvTable); Element pathInstanceCsvTable = new Element("path"); String relativeInstancePath = filePathTransformator.relativize(mappingTaskFilePath, entry.getKey()); pathInstanceCsvTable.setText(relativeInstancePath); Element colNamesCsvTable = new Element("column-names"); boolean inclColNames = (Boolean) entry.getValue().get(1); if (!inclColNames) { colNamesCsvTable.setText(SpicyEngineConstants.NOT_INCL_COL_NAMES); } else { colNamesCsvTable.setText(SpicyEngineConstants.INCL_COL_NAMES); } instanceCsvTable.addContent(pathInstanceCsvTable); instanceCsvTable.addContent(colNamesCsvTable); } } } } } return sourceCSV; }
From source file:com.wasteofplastic.askyblock.commands.Challenges.java
private void givePotion(Player player, List<ItemStack> rewardedItems, String[] element, int rewardQty) { ItemStack item = getPotion(element, rewardQty, "challenges.yml"); rewardedItems.add(item);/* www . j a v a 2 s . c o m*/ final HashMap<Integer, ItemStack> leftOvers = player.getInventory().addItem(item); if (!leftOvers.isEmpty()) { player.getWorld().dropItemNaturally(player.getLocation(), leftOvers.get(0)); } }
From source file:com.speed.ob.api.ClassStore.java
public void dump(File in, File out, Config config) throws IOException { if (in.isDirectory()) { for (ClassNode node : nodes()) { String[] parts = node.name.split("\\."); String dirName = node.name.substring(0, node.name.lastIndexOf(".")); dirName = dirName.replace(".", "/"); File dir = new File(out, dirName); if (!dir.exists()) { if (!dir.mkdirs()) throw new IOException("Could not make output dir: " + dir.getAbsolutePath()); }/*from w w w . ja v a 2s .c o m*/ ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); node.accept(writer); byte[] data = writer.toByteArray(); FileOutputStream fOut = new FileOutputStream( new File(dir, node.name.substring(node.name.lastIndexOf(".") + 1))); fOut.write(data); fOut.flush(); fOut.close(); } } else if (in.getName().endsWith(".jar")) { File output = new File(out, in.getName()); JarFile jf = new JarFile(in); HashMap<JarEntry, Object> existingData = new HashMap<>(); if (output.exists()) { try { JarInputStream jarIn = new JarInputStream(new FileInputStream(output)); JarEntry entry; while ((entry = jarIn.getNextJarEntry()) != null) { if (!entry.isDirectory()) { byte[] data = IOUtils.toByteArray(jarIn); existingData.put(entry, data); jarIn.closeEntry(); } } jarIn.close(); } catch (IOException e) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Could not read existing output file, overwriting", e); } } FileOutputStream fout = new FileOutputStream(output); Manifest manifest = null; if (jf.getManifest() != null) { manifest = jf.getManifest(); if (!config.getBoolean("ClassNameTransform.keep_packages") && config.getBoolean("ClassNameTransform.exclude_mains")) { manifest = new Manifest(manifest); if (manifest.getMainAttributes().getValue("Main-Class") != null) { String manifestName = manifest.getMainAttributes().getValue("Main-Class"); if (manifestName.contains(".")) { manifestName = manifestName.substring(manifestName.lastIndexOf(".") + 1); manifest.getMainAttributes().putValue("Main-Class", manifestName); } } } } jf.close(); JarOutputStream jarOut = manifest == null ? new JarOutputStream(fout) : new JarOutputStream(fout, manifest); Logger.getLogger(getClass().getName()).fine("Restoring " + existingData.size() + " existing files"); if (!existingData.isEmpty()) { for (Map.Entry<JarEntry, Object> entry : existingData.entrySet()) { Logger.getLogger(getClass().getName()).fine("Restoring " + entry.getKey().getName()); jarOut.putNextEntry(entry.getKey()); jarOut.write((byte[]) entry.getValue()); jarOut.closeEntry(); } } for (ClassNode node : nodes()) { ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); node.accept(writer); byte[] data = writer.toByteArray(); int index = node.name.lastIndexOf("/"); String fileName; if (index > 0) { fileName = node.name.substring(0, index + 1).replace(".", "/"); fileName += node.name.substring(index + 1).concat(".class"); } else { fileName = node.name.concat(".class"); } JarEntry entry = new JarEntry(fileName); jarOut.putNextEntry(entry); jarOut.write(data); jarOut.closeEntry(); } jarOut.close(); } else { if (nodes().size() == 1) { File outputFile = new File(out, in.getName()); ClassNode node = nodes().iterator().next(); ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); byte[] data = writer.toByteArray(); FileOutputStream stream = new FileOutputStream(outputFile); stream.write(data); stream.close(); } } }
From source file:at.becast.youploader.gui.FrmMain.java
public void loadAccounts() { int i = 0;/*from w ww . j a v a 2 s . c o m*/ HashMap<AccountType, Integer> accounts = accMng.load(); for (Entry<AccountType, Integer> entry : accounts.entrySet()) { getCmbAccount().addItem(entry.getKey()); AccListModel.addElement(entry.getKey()); JMenuItem rdoBtn = new JMenuItem(entry.getKey().toString()); if (entry.getValue() == 1) { rdoBtn.setSelected(true); getCmbAccount().setSelectedItem(entry.getKey()); } rdoBtn.setActionCommand(entry.getKey().toString()); rdoBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editAccount(e.getActionCommand()); } }); _accounts.put(i, rdoBtn); mnuAcc.add(rdoBtn); i++; } if (!accounts.isEmpty()) { btnAddToQueue.setEnabled(true); } }
From source file:org.kuali.ole.module.purap.document.service.impl.CreditMemoServiceImpl.java
/** * @see org.kuali.ole.module.purap.document.service.CreditMemoCreateService#populateDocumentAfterInit(org.kuali.ole.module.purap.document.CreditMemoDocument) *//* w w w . j a v a2 s . c o m*/ @Override public void populateDocumentAfterInit(VendorCreditMemoDocument cmDocument) { OleVendorCreditMemoDocument vendorCreditMemoDocument = (OleVendorCreditMemoDocument) cmDocument; // make a call to search for expired/closed accounts HashMap<String, ExpiredOrClosedAccountEntry> expiredOrClosedAccountList = accountsPayableService .getExpiredOrClosedAccountList(cmDocument); if (vendorCreditMemoDocument.isSourceDocumentPaymentRequest() && vendorCreditMemoDocument.getInvoiceIdentifier() == null) { populateDocumentFromPreq(vendorCreditMemoDocument, expiredOrClosedAccountList); } else if (vendorCreditMemoDocument.isSourceDocumentPurchaseOrder() && vendorCreditMemoDocument.getInvoiceIdentifier() == null) { populateDocumentFromPO(vendorCreditMemoDocument, expiredOrClosedAccountList); } else if (vendorCreditMemoDocument.getInvoiceIdentifier() != null) { populateDocumentFromVendor(vendorCreditMemoDocument); } populateDocumentDescription(vendorCreditMemoDocument); // write a note for expired/closed accounts if any exist and add a message stating there were expired/closed accounts at the // top of the document accountsPayableService.generateExpiredOrClosedAccountNote(cmDocument, expiredOrClosedAccountList); // set indicator so a message is displayed for accounts that were replaced due to expired/closed status if (ObjectUtils.isNotNull(expiredOrClosedAccountList) && !expiredOrClosedAccountList.isEmpty()) { cmDocument.setContinuationAccountIndicator(true); } }
From source file:com.foxykeep.datadroid.internal.network.NetworkConnectionImpl.java
/** * Call the webservice using the given parameters to construct the request and return the * result./*from ww w.j av a2 s . c o m*/ * * @param context The context to use for this operation. Used to generate the user agent if * needed. * @param urlValue The webservice URL. * @param method The request method to use. * @param parameterList The parameters to add to the request. * @param headerMap The headers to add to the request. * @param isGzipEnabled Whether the request will use gzip compression if available on the * server. * @param userAgent The user agent to set in the request. If null, a default Android one will be * created. * @param postText The POSTDATA text to add in the request. * @param credentials The credentials to use for authentication. * @param isSslValidationEnabled Whether the request will validate the SSL certificates. * @return The result of the webservice call. */ public static ConnectionResult execute(Context context, String urlValue, Method method, ArrayList<BasicNameValuePair> parameterList, HashMap<String, String> headerMap, boolean isGzipEnabled, String userAgent, String postText, UsernamePasswordCredentials credentials, boolean isSslValidationEnabled) throws ConnectionException { HttpURLConnection connection = null; try { // Prepare the request information if (userAgent == null) { userAgent = UserAgentUtils.get(context); } if (headerMap == null) { headerMap = new HashMap<String, String>(); } headerMap.put(HTTP.USER_AGENT, userAgent); if (isGzipEnabled) { headerMap.put(ACCEPT_ENCODING_HEADER, "gzip"); } headerMap.put(ACCEPT_CHARSET_HEADER, UTF8_CHARSET); if (credentials != null) { headerMap.put(AUTHORIZATION_HEADER, createAuthenticationHeader(credentials)); } StringBuilder paramBuilder = new StringBuilder(); if (parameterList != null && !parameterList.isEmpty()) { for (int i = 0, size = parameterList.size(); i < size; i++) { BasicNameValuePair parameter = parameterList.get(i); String name = parameter.getName(); String value = parameter.getValue(); if (TextUtils.isEmpty(name)) { // Empty parameter name. Check the next one. continue; } if (value == null) { value = ""; } paramBuilder.append(URLEncoder.encode(name, UTF8_CHARSET)); paramBuilder.append("="); paramBuilder.append(URLEncoder.encode(value, UTF8_CHARSET)); paramBuilder.append("&"); } } // Log the request if (DataDroidLog.canLog(Log.DEBUG)) { DataDroidLog.d(TAG, "Request url: " + urlValue); DataDroidLog.d(TAG, "Method: " + method.toString()); if (parameterList != null && !parameterList.isEmpty()) { DataDroidLog.d(TAG, "Parameters:"); for (int i = 0, size = parameterList.size(); i < size; i++) { BasicNameValuePair parameter = parameterList.get(i); String message = "- \"" + parameter.getName() + "\" = \"" + parameter.getValue() + "\""; DataDroidLog.d(TAG, message); } DataDroidLog.d(TAG, "Parameters String: \"" + paramBuilder.toString() + "\""); } if (postText != null) { DataDroidLog.d(TAG, "Post data: " + postText); } if (headerMap != null && !headerMap.isEmpty()) { DataDroidLog.d(TAG, "Headers:"); for (Entry<String, String> header : headerMap.entrySet()) { DataDroidLog.d(TAG, "- " + header.getKey() + " = " + header.getValue()); } } } // Create the connection object URL url = null; String outputText = null; switch (method) { case GET: case DELETE: String fullUrlValue = urlValue; if (paramBuilder.length() > 0) { fullUrlValue += "?" + paramBuilder.toString(); } url = new URL(fullUrlValue); connection = HttpUrlConnectionHelper.openUrlConnection(url); break; case PUT: case POST: url = new URL(urlValue); connection = HttpUrlConnectionHelper.openUrlConnection(url); connection.setDoOutput(true); if (paramBuilder.length() > 0) { outputText = paramBuilder.toString(); headerMap.put(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded"); headerMap.put(HTTP.CONTENT_LEN, String.valueOf(outputText.getBytes().length)); } else if (postText != null) { outputText = postText; } break; } // Set the request method connection.setRequestMethod(method.toString()); // If it's an HTTPS request and the SSL Validation is disabled if (url.getProtocol().equals("https") && !isSslValidationEnabled) { HttpsURLConnection httpsConnection = (HttpsURLConnection) connection; httpsConnection.setSSLSocketFactory(getAllHostsValidSocketFactory()); httpsConnection.setHostnameVerifier(getAllHostsValidVerifier()); } // Add the headers if (!headerMap.isEmpty()) { for (Entry<String, String> header : headerMap.entrySet()) { connection.addRequestProperty(header.getKey(), header.getValue()); } } // Set the connection and read timeout connection.setConnectTimeout(OPERATION_TIMEOUT); connection.setReadTimeout(OPERATION_TIMEOUT); // Set the outputStream content for POST and PUT requests if ((method == Method.POST || method == Method.PUT) && outputText != null) { OutputStream output = null; try { output = connection.getOutputStream(); output.write(outputText.getBytes()); } finally { if (output != null) { try { output.close(); } catch (IOException e) { // Already catching the first IOException so nothing to do here. } } } } String contentEncoding = connection.getHeaderField(HTTP.CONTENT_ENCODING); int responseCode = connection.getResponseCode(); boolean isGzip = contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip"); DataDroidLog.d(TAG, "Response code: " + responseCode); if (responseCode == HttpStatus.SC_MOVED_PERMANENTLY) { String redirectionUrl = connection.getHeaderField(LOCATION_HEADER); throw new ConnectionException("New location : " + redirectionUrl, redirectionUrl); } InputStream errorStream = connection.getErrorStream(); if (errorStream != null) { String error = convertStreamToString(errorStream, isGzip); throw new ConnectionException(error, responseCode); } String body = convertStreamToString(connection.getInputStream(), isGzip); if (DataDroidLog.canLog(Log.VERBOSE)) { DataDroidLog.v(TAG, "Response body: "); int pos = 0; int bodyLength = body.length(); while (pos < bodyLength) { DataDroidLog.v(TAG, body.substring(pos, Math.min(bodyLength - 1, pos + 200))); pos = pos + 200; } } return new ConnectionResult(connection.getHeaderFields(), body); } catch (IOException e) { DataDroidLog.e(TAG, "IOException", e); throw new ConnectionException(e); } catch (KeyManagementException e) { DataDroidLog.e(TAG, "KeyManagementException", e); throw new ConnectionException(e); } catch (NoSuchAlgorithmException e) { DataDroidLog.e(TAG, "NoSuchAlgorithmException", e); throw new ConnectionException(e); } finally { if (connection != null) { connection.disconnect(); } } }
From source file:org.apache.hadoop.hive.ql.parse.DDLSemanticAnalyzer.java
public static HashMap<String, String> getValidatedPartSpec(Table table, ASTNode astNode, HiveConf conf, boolean shouldBeFull) throws SemanticException { HashMap<String, String> partSpec = getPartSpec(astNode); if (partSpec != null && !partSpec.isEmpty()) { validatePartSpec(table, partSpec, astNode, conf, shouldBeFull); }/*www .j a v a 2s . c o m*/ return partSpec; }
From source file:org.kuali.student.enrollment.registration.client.service.impl.util.CourseRegistrationAndScheduleOfClassesUtil.java
private static List<CourseOfferingInfo> searchForCourseOfferingIdCreditsGradingByCourseCodeAndTerm( String courseCode, String atpId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, PermissionDeniedException, OperationFailedException { List<CourseOfferingInfo> resultList = new ArrayList<>(); HashMap<String, CourseOfferingInfo> hm = new HashMap<>(); SearchRequestInfo searchRequestInfo = new SearchRequestInfo( CourseOfferingManagementSearchImpl.CREDIT_REGGRADING_COID_BY_TERM_AND_COURSE_CODE_SEARCH_KEY); searchRequestInfo.addParam(CourseOfferingManagementSearchImpl.SearchParameters.COURSE_CODE, courseCode); searchRequestInfo.addParam(CourseOfferingManagementSearchImpl.SearchParameters.ATP_ID, atpId); SearchResultInfo searchResult = CourseRegistrationAndScheduleOfClassesUtil.getSearchService() .search(searchRequestInfo, contextInfo); for (SearchResultRowInfo row : searchResult.getRows()) { String courseOfferingId = "", resValGroupKey = ""; for (SearchResultCellInfo cellInfo : row.getCells()) { String value = StringUtils.EMPTY; if (cellInfo.getValue() != null) { value = cellInfo.getValue(); }//w w w . ja v a2 s . c om if (CourseOfferingManagementSearchImpl.SearchResultColumns.CO_ID.equals(cellInfo.getKey())) { courseOfferingId = value; } else if (CourseOfferingManagementSearchImpl.SearchResultColumns.RES_VAL_GROUP_KEY .equals(cellInfo.getKey())) { resValGroupKey = value; } } CourseOfferingInfo courseOfferingInfo = new CourseOfferingInfo(); if (!hm.containsKey(courseOfferingId)) { courseOfferingInfo.setId(courseOfferingId); courseOfferingInfo.setStudentRegistrationGradingOptions(new ArrayList<String>()); } else { courseOfferingInfo = hm.get(courseOfferingId); } if (resValGroupKey != null && resValGroupKey .startsWith(LrcServiceConstants.RESULT_GROUP_KEY_KUALI_CREDITTYPE_CREDIT_BASE)) { courseOfferingInfo.setCreditOptionId(resValGroupKey); } else if (resValGroupKey != null && (ArrayUtils.contains( CourseOfferingServiceConstants.ALL_STUDENT_REGISTRATION_OPTION_TYPE_KEYS, resValGroupKey) || ArrayUtils.contains(CourseOfferingServiceConstants.ALL_GRADING_OPTION_TYPE_KEYS, resValGroupKey))) { courseOfferingInfo.getStudentRegistrationGradingOptions().add(resValGroupKey); } hm.put(courseOfferingId, courseOfferingInfo); } if (!hm.isEmpty()) { for (Map.Entry<String, CourseOfferingInfo> pair : hm.entrySet()) { CourseOfferingInfo courseOfferingInfo = pair.getValue(); resultList.add(courseOfferingInfo); } } return resultList; }