List of usage examples for java.util Map.Entry get
V get(Object key);
From source file:com.rbsoftware.pfm.personalfinancemanager.MainActivity.java
/** * Creates navigation drawer// ww w. j av a 2 s. co m * * @param savedInstanceState of activity * @param toolbar of activity * @param intent received after login */ private void setupNavigationDrawer(final Bundle savedInstanceState, Toolbar toolbar, Intent intent) { AccountDocument accountDocument = financeDocumentModel .getAccountDocument(AccountDocument.ACCOUNT_DOCUMENT_ID + getUserId()); if (accountDocument == null) { HashMap<String, List<String>> values = new HashMap<>(); List<String> mainAccount = new ArrayList<>(); mainAccount.add(getString(R.string.main_wallet)); values.put(FinanceDocument.MAIN_ACCOUNT, mainAccount); accountDocument = new AccountDocument(MainActivity.getUserId(), values); MainActivity.financeDocumentModel.createDocument(accountDocument); } final HashMap<String, List<String>> accountsMap = accountDocument.getAccountsMap(); ArrayList<ProfileDrawerItem> profiles = new ArrayList<>(); for (Map.Entry<String, List<String>> entry : accountsMap.entrySet()) { ProfileDrawerItem profileDrawerItem; if (intent.getStringExtra("photoURL") != null) { profileDrawerItem = new ProfileDrawerItem().withName(intent.getStringExtra("name")) .withEmail(entry.getValue().get(0)).withIcon(intent.getStringExtra("photoURL")); } else { profileDrawerItem = new ProfileDrawerItem().withName(intent.getStringExtra("name")) .withEmail(entry.getValue().get(0)); } profiles.add(profileDrawerItem); } //Set up image loading through Picasso DrawerImageLoader.init(new AbstractDrawerImageLoader() { @Override public void set(ImageView imageView, Uri uri, Drawable placeholder) { if (uri != null) { Picasso.with(imageView.getContext()).load(uri).placeholder(placeholder).into(imageView); } } @Override public void cancel(ImageView imageView) { Picasso.with(imageView.getContext()).cancelRequest(imageView); } }); // Create the AccountHeader drawerAccountHeader = new AccountHeaderBuilder().withActivity(this) .withHeaderBackground(R.drawable.account_header_background) .addProfiles(profiles.toArray(new ProfileDrawerItem[profiles.size()])) .withOnlyMainProfileImageVisible(true).withProfileImagesClickable(false) .withSavedInstance(savedInstanceState) .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() { @Override public boolean onProfileChanged(View view, IProfile profile, boolean current) { for (Map.Entry<String, List<String>> entry : getAccountsMap().entrySet()) { if (entry.getValue().get(0).equals(profile.getEmail().toString())) { mActiveAccountId = entry.getKey(); break; } } //checking if orientation has been changed //if not reload data int prevState = orientationState; if (savedInstanceState != null) { prevState = savedInstanceState.getInt("screenOrientation"); savedInstanceState.putInt("screenOrientation", getResources().getConfiguration().orientation); } if (!Utils.isOrientationChanged(getApplicationContext(), prevState)) { reloadFragmentData(); } return false; } }).build(); //Setting default account for (IProfile profile : profiles) { String accountName = getString(R.string.main_wallet); if (savedInstanceState != null) { accountName = savedInstanceState.getString("activeAccountName"); } if (profile.getEmail().getText().equals(accountName)) { drawerAccountHeader.setActiveProfile(profile, true); } } //Build navigation drawer DrawerBuilder drawerBuilder = new DrawerBuilder().withActivity(this).withToolbar(toolbar) .withAccountHeader(drawerAccountHeader).withDelayDrawerClickEvent(0) .addDrawerItems( new PrimaryDrawerItem().withName(getResources().getStringArray(R.array.drawer_menu)[0]) .withIcon(GoogleMaterial.Icon.gmd_dashboard), new PrimaryDrawerItem().withName(getResources().getStringArray(R.array.drawer_menu)[1]) .withIcon(GoogleMaterial.Icon.gmd_book), new PrimaryDrawerItem().withName(getResources().getStringArray(R.array.drawer_menu)[2]) .withIcon(GoogleMaterial.Icon.gmd_monetization_on), new PrimaryDrawerItem().withName(getResources().getStringArray(R.array.drawer_menu)[3]) .withIcon(GoogleMaterial.Icon.gmd_pie_chart), new PrimaryDrawerItem().withName(getResources().getStringArray(R.array.drawer_menu)[4]) .withIcon(GoogleMaterial.Icon.gmd_credit_card), new PrimaryDrawerItem().withName(getResources().getStringArray(R.array.drawer_menu)[5]) .withIcon(GoogleMaterial.Icon.gmd_history), new DividerDrawerItem(), new PrimaryDrawerItem().withName(getResources().getStringArray(R.array.drawer_menu)[6]) .withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_star), new PrimaryDrawerItem().withName(getResources().getStringArray(R.array.drawer_menu)[7]) .withIcon(GoogleMaterial.Icon.gmd_add_circle), new PrimaryDrawerItem().withName(getResources().getStringArray(R.array.drawer_menu)[8]) .withIcon(GoogleMaterial.Icon.gmd_account_balance_wallet), new PrimaryDrawerItem().withName(getResources().getStringArray(R.array.drawer_menu)[9]) .withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_settings), new PrimaryDrawerItem().withName(getResources().getStringArray(R.array.drawer_menu)[10]) .withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_exit_to_app)) .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { if (position == 11) { Intent i = new Intent(MainActivity.this, SettingsActivity.class); startActivityForResult(i, MainActivity.RESULT_OK); return true; } else if (position == 8) { recommendToFriend(); } else if (position == 12) { signout(); return true; } else { openFragment(position); } return false; } }) .withSavedInstance(savedInstanceState); //make multipane layout for tablets in landscape orientation if (Utils.isTablet(this) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { drawerBuilder.withTranslucentStatusBar(false).withTranslucentNavigationBar(false); mMaterialDrawer = drawerBuilder.buildView(); ((ViewGroup) findViewById(R.id.nav_tablet)).addView(mMaterialDrawer.getSlider()); } else { mMaterialDrawer = drawerBuilder.build(); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(false); mMaterialDrawer.getActionBarDrawerToggle().setDrawerIndicatorEnabled(true); } } }
From source file:com.aliyun.openservices.odps.console.mapreduce.runtime.MapReduceJob.java
private void addTempResources() throws ODPSConsoleException, OdpsException { Map<String, List<String>> tempResources = mrCmd.getTempResources(); if (!tempResources.isEmpty()) { for (Map.Entry<String, List<String>> entry : tempResources.entrySet()) { String resAlias = entry.getKey(); List<String> resInfo = entry.getValue(); Type type = Type.valueOf(resInfo.get(0).toUpperCase()); FileResource resource = null; switch (type) { case PY: resource = new PyResource(); break; case JAR: resource = new JarResource(); break; case ARCHIVE: resource = new ArchiveResource(); break; case FILE: resource = new FileResource(); break; }/*from w ww. ja v a2 s .c o m*/ resource.setIsTempResource(true); // append uuid to file name String resName = UUID.randomUUID().toString() + "_" + resAlias; resource.setName(resName); // upload resource File resFile = new File(entry.getValue().get(1)); FileInputStream inputStream = null; try { inputStream = new FileInputStream(resFile); odps.resources().create(resource, inputStream); } catch (IOException ex) { throw new ODPSConsoleException(ODPSConsoleConstants.FILE_UPLOAD_FAIL, ex); } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException ex) { } } } // replace file path using resource name, for alias and drop resInfo.set(1, resName); } } }
From source file:Admin.products.ProductSaveS.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from ww w . ja va 2s. c o m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { try { String brand_id = null; String category_1_id = null; String category_2_id = null; String category_3_id = null; String product_name = null; String description = null; String specifications_name = null; //[] String specifications_value = null;//[] String specifications_unit = null;//[] String purchase_date = null; String MFD = null; String EXP = null; String purchase_price = null; // String old_price = null; String discount = null; String selling_price = null; String w_years = null; String w_months = null; String w_dates = null; String QTY = null; String pickup = null; String delivery_pond = null; String delivery_days = null; String delivery_area = null;//[] String images = null;//[] String rurl = "04_admin/product/product_save.jsp?"; Collecter01.i = 0; // ilagata sepe collect karanna kalin Collecter01.specifications.clear(); Collecter01.delivery_areas = ""; Collecter01.product_images.clear(); FileItemFactory item = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(item); List<FileItem> list = upload.parseRequest(request); for (FileItem fileItem : list) { if (fileItem.isFormField()) { //form field switch (fileItem.getFieldName()) { case "sel01n": System.out.println("BRAND_ID-------------:" + fileItem.getString()); brand_id = fileItem.getString(); if (checkDigit(brand_id.trim())) { } else { response.sendRedirect(rurl + "msg=Please select the brand"); } break; case "sel02n": System.out.println("CATEGORY1_ID---------:" + fileItem.getString()); category_1_id = fileItem.getString(); if (checkDigit(category_1_id.trim())) { } else { response.sendRedirect(rurl + "msg=Please select the category 1"); } break; case "sel03n": System.out.println("CATEGORY2_ID---------:" + fileItem.getString()); category_2_id = fileItem.getString(); if (checkDigit(category_2_id.trim())) { } else { response.sendRedirect(rurl + "msg=Please select the category 2"); } break; case "sel04n": System.out.println("CATEGORY3_ID---------:" + fileItem.getString()); category_3_id = fileItem.getString(); if (checkDigit(category_3_id.trim())) { } else { response.sendRedirect(rurl + "msg=Please select the category 3"); } break; case "txf01n": System.out.println("PRODUCT_NAME---------:" + fileItem.getString()); product_name = fileItem.getString(); if (checkString(product_name.trim())) { } else { response.sendRedirect(rurl + "msg=Please enter the product name"); } break; case "txa01n": System.out.println("DESCRIPTION----------:" + fileItem.getString()); description = fileItem.getString(); if (checkString(description.trim())) { } else { response.sendRedirect(rurl + "msg=Please enter the description"); } break; case "spe01n": System.out.println("SPECIFICATION_NAME----------:" + fileItem.getString()); specifications_name = fileItem.getString(); if (checkString(specifications_name.trim())) { Collecter01.collectSpec(specifications_name.trim()); } else { response.sendRedirect(rurl + "msg=Please enter the specifications name"); } break; case "spe02n": System.out.println("SPECIFICATION_VALUE---------:" + fileItem.getString()); specifications_value = fileItem.getString(); if (checkString(specifications_value.trim())) { Collecter01.collectSpec(specifications_value.trim()); } else { response.sendRedirect(rurl + "msg=Please enter the specifications value"); } break; case "spe03n": System.out.println("SPECIFICATION_UNIT----------:" + fileItem.getString()); specifications_unit = fileItem.getString(); if (specifications_unit == null || specifications_unit.equals("")) { specifications_unit = ""; } else { Collecter01.collectSpec(specifications_unit.trim()); } break; case "dat01n": System.out.println("PURCHASE_DATE--------:" + fileItem.getString()); purchase_date = fileItem.getString(); if (checkString(purchase_date)) { } else { response.sendRedirect(rurl + "msg=Please select the purchase date"); } break; case "dat02n": System.out.println("MFD------------------:" + fileItem.getString()); MFD = fileItem.getString(); if (checkString(MFD)) { } else { response.sendRedirect(rurl + "msg=Please select the MFD"); } break; case "dat03n": System.out.println("EXP------------------:" + fileItem.getString()); EXP = fileItem.getString(); if (checkString(EXP)) { } else { response.sendRedirect(rurl + "msg=Please enter the EXP"); } break; case "num01n": System.out.println("PURCHASE_price-------:" + fileItem.getString()); purchase_price = fileItem.getString(); if (checkDigit(purchase_price)) { } else { response.sendRedirect(rurl + "msg=Please enter the purchase price"); } break; case "num03n": System.out.println("DISCOUNT-------------:" + fileItem.getString() + " %"); discount = fileItem.getString(); if (checkDigit(discount)) { } else { response.sendRedirect(rurl + "msg=Please enter the discount"); } break; case "num04n": System.out.println("SELLING_PRICE--------:" + fileItem.getString()); selling_price = fileItem.getString(); if (checkDigit(selling_price)) { } else { response.sendRedirect(rurl + "msg=Please enter the selling price value"); } break; case "num05n": System.out.println("W_YEARS--------------:" + fileItem.getString()); w_years = fileItem.getString(); if (checkDigit(w_years)) { } else { response.sendRedirect(rurl + "msg=Please enter the warrenty years"); } break; case "num06n": System.out.println("W_MONTS--------------:" + fileItem.getString()); w_months = fileItem.getString(); if (checkDigit(w_months)) { } else { response.sendRedirect(rurl + "msg=Please enter the warrenty months"); } break; case "num07n": System.out.println("W_DATES--------------:" + fileItem.getString()); w_dates = fileItem.getString(); if (checkDigit(w_dates)) { } else { response.sendRedirect(rurl + "msg=Please enter th warrenty dates"); } break; case "num08n": System.out.println("QTY------------------:" + fileItem.getString()); QTY = fileItem.getString(); if (checkDigit(QTY)) { } else { response.sendRedirect(rurl + "msg=Please enter the QTY"); } break; case "sel05n": System.out.println("PICKUP---------------:" + fileItem.getString()); pickup = fileItem.getString(); if (checkString(pickup)) { } else { response.sendRedirect(rurl + "msg=Please select the pickup"); } break; case "sel06n": System.out.println("DELIVERY_POND--------:" + fileItem.getString()); delivery_pond = fileItem.getString(); if (checkString(delivery_pond)) { } else { response.sendRedirect(rurl + "msg=Please select the pay on delivery"); } break; case "num09n": System.out.println("DELIVERY_DAYS--------:" + fileItem.getString()); if (delivery_pond.trim().equals("Yes")) { delivery_days = fileItem.getString(); if (checkDigit(delivery_days)) { } else { response.sendRedirect(rurl + "msg=Please add the delivery dates"); } } else { } break; case "sel07n": System.out.println("DELIVERY_AREA--------:" + fileItem.getString());//[] if (delivery_pond.trim().equals("Yes")) { delivery_area = fileItem.getString(); if (checkString(delivery_area)) { // Collecter01.collectDeliveryArea(delivery_area.trim()); } else { response.sendRedirect(rurl + "msg=Please select the delivery areas"); } } else { delivery_area = fileItem.getString(); } break; default: break; } } else { images = fileItem.getName(); System.out.println(images); if (checkString(images)) { Long time = System.currentTimeMillis(); System.out.println("IMAGES_name----------:" + time); String apath = request.getServletContext().getRealPath("/04_admin/product/img/") + "\\" + time + ".jpg"; System.out.println("IMAGES_AP------------:" + apath); String rpath = "04_admin\\product\\img\\" + time + ".jpg"; System.out.println("IMAGES_RP------------:" + rpath); fileItem.write(new File(apath)); Collecter01.collectImages(rpath); } else { response.sendRedirect(rurl + "msg=Please select images"); } } } // if (checkDigit(brand_id)) { // // } else { System.out.println(checkDigit(brand_id)); System.out.println(checkString(category_1_id)); System.out.println(checkString(category_2_id)); System.out.println(checkString(category_3_id)); // System.out.println(specifications_name); //null // System.out.println(specifications_value); //null // System.out.println(specifications_unit); //null System.out.println(checkString(purchase_date)); System.out.println(checkString(MFD)); System.out.println(checkString(EXP)); System.out.println(checkDigit(purchase_price)); System.out.println(checkDigit(selling_price)); System.out.println(checkDigit(discount)); System.out.println(checkDigit(w_years)); System.out.println(checkDigit(w_months)); System.out.println(checkDigit(w_dates)); System.out.println(checkDigit(QTY)); System.out.println(checkString(pickup)); System.out.println(checkString(delivery_pond)); System.out.println(delivery_pond.trim().equals("Yes") ? checkDigit(delivery_days) : true); System.out.println(delivery_pond.trim().equals("Yes") ? checkString(delivery_area) : true); System.out.println(checkString(images)); if (checkDigit(brand_id) && checkString(category_1_id) && checkString(category_2_id) && checkString(category_3_id) && checkString(purchase_date) && checkString(MFD) && checkString(EXP) && checkDigit(purchase_price) && checkDigit(selling_price) && checkDigit(discount) && checkDigit(w_years) && checkDigit(w_months) && checkDigit(w_dates) && checkDigit(QTY) && checkString(pickup) && checkString(delivery_pond) && delivery_pond.trim().equals("Yes") ? checkDigit(delivery_days) : true && delivery_pond.trim().equals("Yes") ? checkString(delivery_area) : true && checkString(images)) { System.out.println( "VALIDATION OK---------------------------------------------------------------------"); // try { // String sql0 = "SELECT * FROM product WHERE name=?"; // PreparedStatement ps0 = Controller.DB.con().prepareStatement(sql0); // ps0.setString(1, product_name); // System.out.println(ps0); // ResultSet rs0 = ps0.executeQuery(); // // if (rs0.first()) { // response.sendRedirect(rurl + "msg=Can't save This product allready in data base&color=red"); // } else { // System.out.println("product eka na"); try { String sql1 = "INSERT INTO product VALUES (null,?,?,?,?)"; PreparedStatement ps1 = Controller.DB.con().prepareStatement(sql1); ps1.setString(1, product_name); ps1.setString(2, description); ps1.setInt(3, Integer.parseInt(brand_id)); ps1.setInt(4, Integer.parseInt(category_3_id)); System.out.println(ps1); ps1.executeUpdate(); try { String sql2 = "SELECT MAX(idproduct) FROM product WHERE name=?"; PreparedStatement ps2 = Controller.DB.con().prepareStatement(sql2); ps2.setString(1, product_name); System.out.println(ps2); ResultSet rs2 = ps2.executeQuery(); while (rs2.next()) { System.out.println(rs2.getInt(1)); //--------------------------------STOCK------------------------------- try { String sql3 = "INSERT INTO stock VALUES (null,?,?,?,?,?,?,?,?,?,?)"; PreparedStatement ps3 = Controller.DB.con().prepareStatement(sql3); ps3.setString(1, purchase_date); ps3.setInt(2, Integer.parseInt(purchase_price)); // ps3.setInt(3, Integer.parseInt(old_price)); ps3.setInt(3, Integer.parseInt(discount)); ps3.setInt(4, Integer.parseInt(selling_price)); ps3.setString(5, w_years + "," + w_months + "," + w_dates); ps3.setInt(6, Integer.parseInt(QTY)); ps3.setString(7, pickup); ps3.setString(8, MFD); ps3.setString(9, EXP); ps3.setInt(10, rs2.getInt(1)); System.out.println(ps3); ps3.executeUpdate(); //----------------------------------IMAGES-------------------------------------------------------------- try { for (String img_path : Collecter01.product_images) { String sql4 = "INSERT INTO image VALUES (?,?)"; PreparedStatement ps4 = Controller.DB.con().prepareStatement(sql4); ps4.setInt(1, rs2.getInt(1)); ps4.setString(2, img_path); System.out.println(ps4); ps4.executeUpdate(); } //----------------------------------DELIVERY------------------------------------------------------------ try { String sql5 = "INSERT INTO delivery VALUES (?,?,?,?)"; PreparedStatement ps5 = Controller.DB.con().prepareStatement(sql5); ps5.setInt(1, rs2.getInt(1)); if (delivery_pond.equals("Yes")) { System.out.println("delivery pay yes"); ps5.setString(2, delivery_pond); ps5.setInt(3, Integer.parseInt(delivery_days)); ps5.setString(4, Collecter01.delivery_areas.substring(1)); System.out.println(ps5); ps5.executeUpdate(); } else { System.out.println("delivery info na save karanna"); ps5.setString(2, delivery_pond); ps5.setInt(3, 0); ps5.setString(4, "No"); System.out.println(ps5); ps5.executeUpdate(); } //----------------------------------SPECIFICATIONS------------------------------------------------------------ try { String sql6 = "SELECT idSpecifications FROM specifications WHERE name=?"; PreparedStatement ps6 = Controller.DB.con().prepareStatement(sql6); for (Map.Entry<String, List> entry : Collecter01.specifications .entrySet()) { System.out.println( entry.getKey() + "---" + entry.getValue().get(0) + "---" + entry.getValue().get(1)); ps6.setString(1, entry.getKey()); System.out.println(ps6); ResultSet rs6 = ps6.executeQuery(); int idSpecifications = 0; try { if (rs6.first()) { System.out.println("Specifications name/id ata____1"); idSpecifications = rs6.getInt(1); } else { System.out.println("Specifications name/id na____2"); try { String sql7 = "INSERT INTO specifications VALUES (null,?)"; PreparedStatement ps7 = Controller.DB.con() .prepareStatement(sql7); ps7.setString(1, entry.getKey()); System.out.println(ps7); ps7.executeUpdate(); System.out.println( "Specifications new add karanawa____2-1"); try { String sql8 = "SELECT idSpecifications FROM specifications WHERE name=?"; PreparedStatement ps8 = Controller.DB.con() .prepareStatement(sql8); ps8.setString(1, entry.getKey()); System.out.println(ps8); ResultSet rs8 = ps8.executeQuery(); if (rs8.first()) { System.out.println( "new Specifications name/id ata____3-1"); idSpecifications = rs8.getInt(1); } else { } } catch (Exception e9) { System.out.println( "new Specifications name/id na____3-2"); } } catch (Exception e8) { System.out.println( "Specifications new add fail____2-2"); } } } catch (Exception e7) { } finally { try { String sql9 = "INSERT INTO product_has_specifications VALUES (?,?,?,?)"; PreparedStatement ps9 = Controller.DB.con() .prepareStatement(sql9); ps9.setInt(1, rs2.getInt(1)); ps9.setInt(2, idSpecifications); ps9.setString(3, (String) entry.getValue().get(0)); ps9.setString(4, (String) entry.getValue().get(1)); System.out.println(ps9); ps9.executeUpdate(); System.out.println("spec value save kara"); } catch (Exception e10) { System.out.println("spec value save fail"); } } } } catch (Exception e6) { System.out.println("specifications id load fail fail"); } finally { response.sendRedirect( rurl + "msg=product successfully saved !&cl=00bf6f"); System.out.println( "SAVE COMPLETE---------------------------------------------------------------------"); } //----------------------------------SPECIFICATIONS------------------------------------------------------------ } catch (Exception e5) { System.out.println("delivery info save fail"); } //----------------------------------DELIVERY------------------------------------------------------------ } catch (Exception e4) { System.out.println("images data save fail"); } //----------------------------------IMAGES-------------------------------------------------------------- } catch (Exception e3) { System.out.println("stock eke data save fail"); } //----------------------------------STOCK--------------------------------------------------------------- } } catch (Exception e2) { System.out.println("product eke id eka load fail"); } } catch (Exception e1) { System.out.println("product ekata data save fail"); } // }// // } catch (Exception e) {// // // }// } else { System.out.println( "VALIDATION FAIL---------------------------------------------------------------------"); } // } } catch (Exception e) { throw new ServletException(e); } } }
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 w w. java 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.eucalyptus.tests.awssdk.S3ListMpuTests.java
@Test public void keyMarkerUploadIdMarker() throws Exception { testInfo(this.getClass().getSimpleName() + " - keyMarkerUploadIdMarker"); try {/*www . ja va 2 s.co m*/ int numKeys = 3 + random.nextInt(3); // 3-5 keys int numUploads = 3 + random.nextInt(3); // 3-5 uploads print("Number of keys: " + numKeys); print("Number of uploads per key: " + numUploads); // Generate some mpus TreeMap<String, List<String>> keyUploadIdMap = initiateMpusForMultipleKeys(s3ClientA, accountA, numKeys, numUploads, new String()); // Starting with every key and upload ID in the ascending order, list the mpus using the pair and verify that the results. for (Map.Entry<String, List<String>> mapEntry : keyUploadIdMap.entrySet()) { // Compute what the sorted mpus should look like NavigableMap<String, List<String>> tailMap = keyUploadIdMap.tailMap(mapEntry.getKey(), false); for (int i = 0; i < numUploads; i++) { // Compute what the sorted uploadIds should look like this key List<String> tailList = mapEntry.getValue().subList(i + 1, numUploads); // List mpus using the key marker and upload ID marker and verify MultipartUploadListing listing = listMpu(s3ClientA, accountA, bucketName, mapEntry.getKey(), mapEntry.getValue().get(i), null, null, null, false); assertTrue( "Expected " + ((tailMap.size() * numUploads) + (numUploads - i - 1)) + " mpu listings, but got " + listing.getMultipartUploads().size(), ((tailMap.size() * numUploads) + (numUploads - i - 1)) == listing.getMultipartUploads() .size()); Iterator<MultipartUpload> mpuIterator = listing.getMultipartUploads().iterator(); for (String uploadId : tailList) { MultipartUpload mpu = mpuIterator.next(); assertTrue("Expected key to be " + mapEntry.getKey() + ", but got " + mpu.getKey(), mpu.getKey().equals(mapEntry.getKey())); assertTrue("Expected upload ID to be " + uploadId + ", but got " + mpu.getUploadId(), mpu.getUploadId().equals(uploadId)); verifyCommonElements(mpu); } for (Entry<String, List<String>> tailMapEntry : tailMap.entrySet()) { for (String uploadId : tailMapEntry.getValue()) { MultipartUpload mpu = mpuIterator.next(); assertTrue("Expected key to be " + tailMapEntry.getKey() + ", but got " + mpu.getKey(), mpu.getKey().equals(tailMapEntry.getKey())); assertTrue("Expected upload ID to be " + uploadId + ", but got " + mpu.getUploadId(), mpu.getUploadId().equals(uploadId)); verifyCommonElements(mpu); } } assertTrue("Expected mpu iterator to be empty", !mpuIterator.hasNext()); } } } catch (AmazonServiceException ase) { printException(ase); assertThat(false, "Failed to run keyMarkerUploadIdMarker"); } }
From source file:org.apache.cxf.jaxrs.openapi.OpenApiCustomizer.java
public void customize(final OpenAPI oas) { if (replaceTags || javadocProvider != null) { Map<String, ClassResourceInfo> operations = new HashMap<>(); Map<Pair<String, String>, OperationResourceInfo> methods = new HashMap<>(); cris.forEach(cri -> {//from ww w .j ava 2 s.c om cri.getMethodDispatcher().getOperationResourceInfos().forEach(ori -> { String normalizedPath = getNormalizedPath(cri.getURITemplate().getValue(), ori.getURITemplate().getValue()); operations.put(normalizedPath, cri); methods.put(Pair.of(ori.getHttpMethod(), normalizedPath), ori); }); }); List<Tag> tags = new ArrayList<>(); oas.getPaths().forEach((pathKey, pathItem) -> { Tag tag = null; if (replaceTags && operations.containsKey(pathKey)) { ClassResourceInfo cri = operations.get(pathKey); tag = new Tag(); tag.setName(cri.getURITemplate().getValue().replaceAll("/", "_")); if (javadocProvider != null) { tag.setDescription(javadocProvider.getClassDoc(cri)); } if (!tags.contains(tag)) { tags.add(tag); } } for (Map.Entry<HttpMethod, Operation> subentry : pathItem.readOperationsMap().entrySet()) { if (replaceTags && tag != null) { subentry.getValue().setTags(Collections.singletonList(tag.getName())); } Pair<String, String> key = Pair.of(subentry.getKey().name(), pathKey); if (methods.containsKey(key) && javadocProvider != null) { OperationResourceInfo ori = methods.get(key); if (StringUtils.isBlank(subentry.getValue().getSummary())) { subentry.getValue().setSummary(javadocProvider.getMethodDoc(ori)); } if (subentry.getValue().getParameters() == null) { List<Parameter> parameters = new ArrayList<>(); addParameters(parameters); subentry.getValue().setParameters(parameters); } else { for (int i = 0; i < subentry.getValue().getParameters().size(); i++) { if (StringUtils .isBlank(subentry.getValue().getParameters().get(i).getDescription())) { subentry.getValue().getParameters().get(i) .setDescription(javadocProvider.getMethodParameterDoc(ori, i)); } } addParameters(subentry.getValue().getParameters()); } customizeResponses(subentry.getValue(), ori); } } }); if (replaceTags && oas.getTags() != null) { oas.setTags(tags); } } }
From source file:org.roda.core.plugins.plugins.PluginHelper.java
public static void fixParents(IndexService index, ModelService model, Optional<String> jobId, Optional<String> computedSearchScope) throws GenericException, RequestNotValidException, AuthorizationDeniedException, NotFoundException { // collect all ghost ids Map<String, List<String>> aipIdToGhost = new HashMap<>(); Map<String, List<String>> sipIdToGhost = new HashMap<>(); Filter ghostsFilter = new Filter( new SimpleFilterParameter(RodaConstants.AIP_GHOST, Boolean.TRUE.toString())); jobId.ifPresent(id -> ghostsFilter.add(new SimpleFilterParameter(RodaConstants.INGEST_JOB_ID, id))); IterableIndexResult<IndexedAIP> ghosts = index.findAll(IndexedAIP.class, ghostsFilter, Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.INGEST_SIP_IDS)); for (IndexedAIP aip : ghosts) { if (aip.getIngestSIPIds() != null && !aip.getIngestSIPIds().isEmpty()) { List<String> temp = new ArrayList<>(); String firstIngestSIPId = aip.getIngestSIPIds().get(0); if (sipIdToGhost.containsKey(firstIngestSIPId)) { temp = sipIdToGhost.get(firstIngestSIPId); }//from w w w . j a v a2 s .c o m temp.add(aip.getId()); sipIdToGhost.put(firstIngestSIPId, temp); } else { List<String> temp = new ArrayList<>(); if (aipIdToGhost.containsKey(aip.getId())) { temp = aipIdToGhost.get(aip.getId()); } temp.add(aip.getId()); aipIdToGhost.put(aip.getId(), temp); } } for (Map.Entry<String, List<String>> entry : sipIdToGhost.entrySet()) { Filter nonGhostsFilter = new Filter( new OneOfManyFilterParameter(RodaConstants.INGEST_SIP_IDS, Arrays.asList(entry.getKey())), new SimpleFilterParameter(RodaConstants.AIP_GHOST, Boolean.FALSE.toString())); computedSearchScope.ifPresent( id -> nonGhostsFilter.add(new SimpleFilterParameter(RodaConstants.AIP_ANCESTORS, id))); IndexResult<IndexedAIP> result = index.find(IndexedAIP.class, nonGhostsFilter, Sorter.NONE, new Sublist(0, 1), Arrays.asList(RodaConstants.INDEX_UUID)); if (result.getTotalCount() > 1) { LOGGER.debug("Couldn't find non-ghost AIP with ingest SIP ids {}", entry.getKey()); } else if (result.getTotalCount() == 1) { IndexedAIP newParentIAIP = result.getResults().get(0); for (String id : entry.getValue()) { moveChildrenAIPsAndDelete(index, model, id, newParentIAIP.getId(), computedSearchScope); } } else if (result.getTotalCount() == 0) { String ghostIdToKeep = entry.getValue().get(0); AIP ghostToKeep = model.retrieveAIP(ghostIdToKeep); ghostToKeep.setGhost(false); model.updateAIP(ghostToKeep, "test"); if (entry.getValue().size() > 1) { for (int i = 1; i < entry.getValue().size(); i++) { updateParent(index, model, entry.getValue().get(i), ghostIdToKeep, computedSearchScope); } } } } }
From source file:Admin.products.ProductUpdateS.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w .j ava2 s . co m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { try { String product_id = null; String product_name = null; String description = null; String specifications_name = null; //[] String specifications_value = null;//[] String specifications_unit = null;//[] String purchase_date = null; String MFD = null; String EXP = null; String purchase_price = null; // String old_price = null; String discount = null; String selling_price = null; String w_years = null; String w_months = null; String w_dates = null; String QTY = null; String pickup = null; String delivery_pond = null; String delivery_days = null; String delivery_area = null;//[] String images0 = null; String images = null;//[] String rurl = null; Collecter01.i = 0; // ilagata sepe collect karanna kalin Collecter01.specifications.clear(); Collecter01.delivery_areas = ""; Collecter01.product_images.clear(); FileItemFactory item = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(item); List<FileItem> list = upload.parseRequest(request); for (FileItem fileItem : list) { if (fileItem.isFormField()) { //form field switch (fileItem.getFieldName()) { case "hid01n": System.out.println("PRODUCT_ID---------:" + fileItem.getString()); product_id = fileItem.getString(); if (checkDigit(product_id)) { rurl = "04_admin/product/product_update.jsp?upd01n=" + product_id + "&"; } else { rurl = "04_admin/product/product_update.jsp?upd01n=" + product_id + "&"; response.sendRedirect(rurl + "msg=Please enter the product id"); } break; case "txf01n": System.out.println("PRODUCT_NAME---------:" + fileItem.getString()); product_name = fileItem.getString(); if (checkString(product_name.trim())) { } else { response.sendRedirect(rurl + "msg=Please enter the product name"); } break; case "txa01n": System.out.println("DESCRIPTION----------:" + fileItem.getString()); description = fileItem.getString(); if (checkString(description.trim())) { } else { response.sendRedirect(rurl + "msg=Please enter the description"); } break; case "spe01n": System.out.println("SPECIFICATION_NAME----------:" + fileItem.getString()); specifications_name = fileItem.getString(); if (checkString(specifications_name.trim())) { Collecter01.collectSpec(specifications_name.trim()); } else { response.sendRedirect(rurl + "msg=Please enter the specifications name"); } break; case "spe02n": System.out.println("SPECIFICATION_VALUE---------:" + fileItem.getString()); specifications_value = fileItem.getString(); if (checkString(specifications_value.trim())) { Collecter01.collectSpec(specifications_value.trim()); } else { response.sendRedirect(rurl + "msg=Please enter the specifications value"); } break; case "spe03n": System.out.println("SPECIFICATION_UNIT----------:" + fileItem.getString()); specifications_unit = fileItem.getString(); if (specifications_unit == null || specifications_unit.equals("")) { specifications_unit = ""; } else { Collecter01.collectSpec(specifications_unit.trim()); } break; case "dat01n": System.out.println("PURCHASE_DATE--------:" + fileItem.getString()); purchase_date = fileItem.getString(); if (checkString(purchase_date)) { } else { response.sendRedirect(rurl + "msg=Please select the purchase date"); } break; case "dat02n": System.out.println("MFD------------------:" + fileItem.getString()); MFD = fileItem.getString(); if (checkString(MFD)) { } else { response.sendRedirect(rurl + "msg=Please select the MFD"); } break; case "dat03n": System.out.println("EXP------------------:" + fileItem.getString()); EXP = fileItem.getString(); if (checkString(EXP)) { } else { response.sendRedirect(rurl + "msg=Please enter the EXP"); } break; case "num01n": System.out.println("PURCHASE_price-------:" + fileItem.getString()); purchase_price = fileItem.getString(); if (checkDigit(purchase_price)) { } else { response.sendRedirect(rurl + "msg=Please enter the purchase price"); } break; case "num03n": System.out.println("DISCOUNT-------------:" + fileItem.getString() + " %"); discount = fileItem.getString(); if (checkDigit(discount)) { } else { response.sendRedirect(rurl + "msg=Please enter the discount"); } break; case "num04n": System.out.println("SELLING_PRICE--------:" + fileItem.getString()); selling_price = fileItem.getString(); if (checkDigit(selling_price)) { } else { response.sendRedirect(rurl + "msg=Please enter the selling price value"); } break; case "num05n": System.out.println("W_YEARS--------------:" + fileItem.getString()); w_years = fileItem.getString(); if (checkDigit(w_years)) { } else { response.sendRedirect(rurl + "msg=Please enter the warrenty years"); } break; case "num06n": System.out.println("W_MONTS--------------:" + fileItem.getString()); w_months = fileItem.getString(); if (checkDigit(w_months)) { } else { response.sendRedirect(rurl + "msg=Please enter the warrenty months"); } break; case "num07n": System.out.println("W_DATES--------------:" + fileItem.getString()); w_dates = fileItem.getString(); if (checkDigit(w_dates)) { } else { response.sendRedirect(rurl + "msg=Please enter th warrenty dates"); } break; case "num08n": System.out.println("QTY------------------:" + fileItem.getString()); QTY = fileItem.getString(); if (checkDigit(QTY)) { } else { response.sendRedirect(rurl + "msg=Please enter the QTY"); } break; case "sel05n": System.out.println("PICKUP---------------:" + fileItem.getString()); pickup = fileItem.getString(); if (checkString(pickup)) { } else { response.sendRedirect(rurl + "msg=Please select the pickup"); } break; case "sel06n": System.out.println("DELIVERY_POND--------:" + fileItem.getString()); delivery_pond = fileItem.getString(); if (checkString(delivery_pond)) { } else { response.sendRedirect(rurl + "msg=Please select the pay on delivery"); } break; case "num09n": System.out.println("DELIVERY_DAYS--------:" + fileItem.getString()); if (delivery_pond.trim().equals("Yes")) { delivery_days = fileItem.getString(); if (checkDigit(delivery_days)) { } else { response.sendRedirect(rurl + "msg=Please add the delivery dates"); } } else { } break; case "sel07n": System.out.println("DELIVERY_AREA--------:" + fileItem.getString());//[] if (delivery_pond.trim().equals("Yes")) { delivery_area = fileItem.getString(); if (checkString(delivery_area)) { // Collecter01.collectDeliveryArea(delivery_area.trim()); } else { response.sendRedirect(rurl + "msg=Please select the delivery areas"); } } else { } break; case "hid02n": System.out.println("DELETE--------:" + fileItem.getString()); images0 = fileItem.getString(); if (checkString(images0)) { for (String imn : images0.split(">")) { System.out.println(imn); } } else { System.out.println("delete natha"); // response.sendRedirect(rurl + "msg=Please select the pay on delivery"); } break; default: break; } } else { images = fileItem.getName(); System.out.println(images); if (checkString(images)) { Long time = System.currentTimeMillis(); System.out.println("IMAGES_name----------:" + time); String apath = request.getServletContext().getRealPath("/04_admin/product/img/") + "\\" + time + ".jpg"; System.out.println("IMAGES_AP------------:" + apath); String rpath = "04_admin\\product\\img\\" + time + ".jpg"; System.out.println("IMAGES_RP------------:" + rpath); fileItem.write(new File(apath)); Collecter01.collectImages(rpath); } else { // response.sendRedirect(rurl + "msg=Please select images"); } } } System.out.println(checkString(product_id)); System.out.println(checkString(product_name)); System.out.println(checkString(description)); // System.out.println(specifications_name); //null // System.out.println(specifications_value); //null // System.out.println(specifications_unit); //null System.out.println(checkString(purchase_date)); System.out.println(checkString(MFD)); System.out.println(checkString(EXP)); System.out.println(checkDigit(purchase_price)); System.out.println(checkDigit(selling_price)); System.out.println(checkDigit(discount)); System.out.println(checkDigit(w_years)); System.out.println(checkDigit(w_months)); System.out.println(checkDigit(w_dates)); System.out.println(checkDigit(QTY)); System.out.println(checkString(pickup)); System.out.println(checkString(delivery_pond)); System.out.println(delivery_pond.trim().equals("Yes") ? checkDigit(delivery_days) : true); System.out.println(delivery_pond.trim().equals("Yes") ? checkString(delivery_area) : true); System.out.println(checkString(images)); if (checkDigit(product_id) && checkString(product_name) && checkString(description) && checkString(purchase_date) && checkString(MFD) && checkString(EXP) && checkDigit(purchase_price) && checkDigit(selling_price) && checkDigit(discount) && checkDigit(w_years) && checkDigit(w_months) && checkDigit(w_dates) && checkDigit(QTY) && checkString(pickup) && checkString(delivery_pond) && delivery_pond.trim().equals("Yes") ? checkDigit(delivery_days) : true && delivery_pond.trim().equals("Yes") ? checkString(delivery_area) : true) { System.out.println( "UPDATE VALIDATION OK---------------------------------------------------------------------"); try { String sql00 = "UPDATE product SET name=?, description=? WHERE idproduct=?"; PreparedStatement ps00 = Controller.DB.con().prepareStatement(sql00); ps00.setString(1, product_name); ps00.setString(2, description); ps00.setInt(3, Integer.parseInt(product_id)); System.out.println(ps00); int x = ps00.executeUpdate(); if (x == 1) { try { String sql01 = "UPDATE stock SET purchase_date=?, purchase_price=?, discount=?, selling_price=?, warranty=?, QTY=?, pickup=?, MFD=?, EXP=? WHERE product_idproduct=?"; PreparedStatement ps01 = Controller.DB.con().prepareStatement(sql01); ps01.setString(1, purchase_date); ps01.setInt(2, Integer.parseInt(purchase_price)); ps01.setInt(3, Integer.parseInt(discount)); ps01.setInt(4, Integer.parseInt(selling_price)); ps01.setString(5, w_years + "," + w_months + "," + w_dates); ps01.setInt(6, Integer.parseInt(QTY)); ps01.setString(7, pickup); ps01.setInt(6, Integer.parseInt(QTY)); ps01.setString(7, pickup); ps01.setString(8, MFD); ps01.setString(9, EXP); ps01.setInt(10, Integer.parseInt(product_id)); System.out.println(ps01); int x1 = ps01.executeUpdate(); if (x1 == 1) { try { String sql04 = "SELECT * FROM delivery WHERE product_idproduct=?"; PreparedStatement ps04 = Controller.DB.con().prepareStatement(sql04); ps04.setInt(1, Integer.parseInt(product_id)); System.out.println(ps04); ResultSet rs04 = ps04.executeQuery(); if (rs04.next()) { System.out.println("update karanna delivery id ata"); try { String sql02 = "UPDATE delivery SET pay_on_delivery=?, days=?, area=? WHERE product_idproduct=?"; PreparedStatement ps02 = Controller.DB.con() .prepareStatement(sql02); try { if (delivery_pond.equals("Yes")) { ps02.setString(1, delivery_pond); ps02.setInt(2, Integer.parseInt(delivery_days)); ps02.setString(3, Collecter01.delivery_areas.substring(1)); ps02.setInt(4, Integer.parseInt(product_id)); } else { ps02.setString(1, "No"); ps02.setInt(2, 0); ps02.setString(3, "No"); ps02.setInt(4, Integer.parseInt(product_id)); } System.out.println(ps02); ps02.executeUpdate(); } catch (Exception e) { } finally { try { for (String imn : images0.split(">")) { if (imn.trim().equals("")) { } else { String sql5 = "DELETE FROM image WHERE path LIKE ?;"; PreparedStatement ps5 = Controller.DB.con() .prepareStatement(sql5); ps5.setString(1, "%" + imn + "%"); System.out.println(ps5); ps5.executeUpdate(); } } for (String img_path : Collecter01.product_images) { String sql4 = "INSERT INTO image VALUES (?,?)"; PreparedStatement ps4 = Controller.DB.con() .prepareStatement(sql4); ps4.setInt(1, Integer.parseInt(product_id)); ps4.setString(2, img_path); System.out.println(ps4); ps4.executeUpdate(); } } catch (Exception e) { } finally { try { String sql5 = "SELECT idSpecifications FROM specifications WHERE name=?"; PreparedStatement ps5 = Controller.DB.con() .prepareStatement(sql5); for (Map.Entry<String, List> entry : Collecter01.specifications .entrySet()) { System.out.println(entry.getKey() + "---" + entry.getValue().get(0) + "---" + entry.getValue().get(1)); ps5.setString(1, entry.getKey()); System.out.println(ps5); ResultSet rs5 = ps5.executeQuery(); // int idSpecifications = 0; try { if (rs5.first()) { System.out.println( "Specifications name/id ata____1"); // idSpecifications = rs5.getInt(1); } else { try { System.out.println( "Specifications name/id na____2"); String sql6 = "INSERT INTO specifications VALUES (null,?)"; PreparedStatement ps6 = Controller.DB .con().prepareStatement(sql6); ps6.setString(1, entry.getKey()); System.out.println(ps6); ps6.executeUpdate(); System.out.println( "Specifications new add karanawa____2-1"); try { String sql7 = "SELECT idSpecifications FROM specifications WHERE name=?"; PreparedStatement ps7 = Controller.DB .con() .prepareStatement(sql7); ps7.setString(1, entry.getKey()); System.out.println(ps7); ResultSet rs7 = ps7.executeQuery(); if (rs7.first()) { System.out.println( "new Specifications name/id ata____3-1"); // idSpecifications = rs7.getInt(1); } else { } } catch (Exception e9) { System.out.println( "new Specifications name/id na____3-2"); } } catch (Exception e8) { System.out.println( "Specifications new add fail____2-2"); } } } catch (Exception e7) { } finally { try { String sql8 = "DELETE FROM product_has_specifications WHERE product_idproduct=?;"; PreparedStatement ps8 = Controller.DB.con() .prepareStatement(sql8); ps8.setInt(1, Integer.parseInt(product_id)); System.out.println(ps8); ps8.executeUpdate(); } catch (Exception e) { } } } try { for (Map.Entry<String, List> entry : Collecter01.specifications .entrySet()) { // System.out.println(product_id); // System.out.println(entry.getKey()); // System.out.println(entry.getValue().get(0)); // System.out.println(entry.getValue().get(1)); int idSpecifications = 0; try { String sql9 = "SELECT idSpecifications FROM specifications WHERE name=?"; PreparedStatement ps9 = Controller.DB.con() .prepareStatement(sql9); ps9.setString(1, entry.getKey()); // System.out.println(ps7); ResultSet rs9 = ps9.executeQuery(); if (rs9.first()) { // System.out.println("new Specifications name/id ata____3-1"); idSpecifications = rs9.getInt(1); } else { } } catch (Exception e) { } // System.out.println(product_id); // System.out.println(idSpecifications); // System.out.println(entry.getValue().get(0)); // System.out.println(entry.getValue().get(1)); try { String sql10 = "INSERT INTO product_has_specifications VALUES (?,?,?,?)"; PreparedStatement ps10 = Controller.DB.con() .prepareStatement(sql10); ps10.setInt(1, Integer.parseInt(product_id)); ps10.setInt(2, idSpecifications); ps10.setString(3, (String) entry.getValue().get(0)); ps10.setString(4, (String) entry.getValue().get(1)); System.out.println(ps10); ps10.executeUpdate(); System.out.println("spec value save kara"); } catch (Exception e) { System.out.println("spec value save fail"); } } } catch (Exception e) { } } catch (Exception e) { } finally { String xv = rurl + "msg=Product update successful&cl=00bf6f"; response.sendRedirect(xv); } } } } catch (Exception e) { e.printStackTrace(); } } else { System.out.println("update karanna delivery id eka na"); } } catch (Exception e) { } } else { System.out.println("stock update fail"); } } catch (Exception e) { } } else { System.out.println("product update fail"); } } catch (Exception e) { } } else { } } catch (Exception e) { } } }
From source file:org.sakaiproject.rubrics.logic.RubricsServiceImpl.java
private String createCriterionJsonPayload(String associatedItemId, String evaluatedItemId, Map<String, String> formPostParameters, Resource<ToolItemRubricAssociation> association) throws Exception { Map<String, Map<String, String>> criterionDataMap = extractCriterionDataFromParams(formPostParameters); String criterionJsonData = ""; int index = 0; boolean pointsAdjusted = false; String points = null;/*from ww w .j a v a 2 s. c o m*/ String selectedRatingId = null; String inlineRubricUri = String.format("%s?%s", association.getLink("rubric").getHref(), "projection=inlineRubric"); RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); headers.add("Authorization", String.format("Bearer %s", generateJsonWebToken(association.getContent().getToolId()))); HttpEntity<?> requestEntity = new HttpEntity<>(headers); ResponseEntity<Rubric> rubricEntity = restTemplate.exchange(inlineRubricUri, HttpMethod.GET, requestEntity, Rubric.class); Map<String, Criterion> criterions = new HashMap<>(); for (Criterion criterion : rubricEntity.getBody().getCriterions()) { criterions.put(String.valueOf(criterion.getId()), criterion); } for (Map.Entry<String, Map<String, String>> criterionData : criterionDataMap.entrySet()) { if (index > 0) { criterionJsonData += ", "; } index++; final String selectedRatingPoints = criterionData.getValue() .get(RubricsConstants.RBCS_PREFIX + evaluatedItemId + "-" + associatedItemId + "-criterion"); if (StringUtils.isNotBlank(criterionData.getValue().get(RubricsConstants.RBCS_PREFIX + evaluatedItemId + "-" + associatedItemId + "-criterion-override"))) { pointsAdjusted = true; points = criterionData.getValue().get(RubricsConstants.RBCS_PREFIX + evaluatedItemId + "-" + associatedItemId + "-criterion-override"); } else { pointsAdjusted = false; points = selectedRatingPoints; } Criterion criterion = criterions.get(criterionData.getKey()); Optional<Rating> rating = criterion.getRatings().stream() .filter(c -> String.valueOf(c.getPoints()).equals(selectedRatingPoints)).findFirst(); if (rating.isPresent()) { selectedRatingId = String.valueOf(rating.get().getId()); } if (StringUtils.isEmpty(points)) { points = "0"; } criterionJsonData += String .format("{ \"criterionId\" : \"%s\", \"points\" : \"%s\", " + "\"comments\" : \"%s\", \"pointsAdjusted\" : %b, \"selectedRatingId\" : \"%s\" }", criterionData.getKey(), points, StringEscapeUtils .escapeJson(criterionData.getValue() .get(RubricsConstants.RBCS_PREFIX + evaluatedItemId + "-" + associatedItemId + "-criterion-comment")), pointsAdjusted, selectedRatingId); } return criterionJsonData; }