List of usage examples for java.util ArrayList remove
public boolean remove(Object o)
From source file:com.mindquarry.desktop.workspace.SVNHelper.java
public ChangePath[] getRemoteChanges() { LogMessage[] messages;/* w ww. ja v a 2s .c o m*/ // get local revision, path and log messages from here to HEAD int trimLength; Info info; try { info = client.info(localPath); trimLength = info.getUrl().length() - info.getRepository().length(); long revision = info.getRevision() + 1; Revision start = Revision.getInstance(revision); Revision head = Revision.HEAD; messages = client.logMessages(localPath, start, head, false, true, 0); } catch (ClientException e) { return new ChangePath[0]; } ArrayList<ChangePath> changePaths = new ArrayList<ChangePath>(); for (LogMessage message : messages) { long revision = message.getRevisionNumber(); ChangePath[] changes = message.getChangedPaths(); for (ChangePath change : changes) { String absPath = change.getPath(); String path = absPath; // truncate path to be relative to wc root if (absPath.length() > trimLength) { path = absPath.substring(trimLength + 1); } // get the items local revision String itemLocalPath = localPath + "/" + path; //$NON-NLS-1$ long itemRev = -1; try { Info itemInfo = client.info(itemLocalPath); /* // skip directories if (itemInfo.getNodeKind() != NodeKind.file) { continue; }*/ if (itemInfo != null) { itemRev = itemInfo.getLastChangedRevision(); } } catch (ClientException e) { } // couldn't get local rev, file is probably missing // so: skip if deleted on server if (itemRev == -1 && change.getAction() == 'D') { continue; } // if our copy of this item is newer that the log message, skip it // and wait for possibly newer log messages if (itemRev > revision) { continue; } // check if we already added this change to our list ChangePath existing = null; for (ChangePath oldChange : changePaths) { if (oldChange.getPath().equals(absPath)) { existing = oldChange; break; } } if (existing != null) { // remove it if it's been deleted if (change.getAction() == 'D') { changePaths.remove(existing); } continue; } // add the change path to the result array changePaths.add(change); } } return changePaths.toArray(new ChangePath[0]); }
From source file:com.notepadlite.NoteListFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void listNotes() { // Get number of files int numOfFiles = getNumOfNotes(getActivity().getFilesDir()); int numOfNotes = numOfFiles; // Get array of file names String[] listOfFiles = getListOfNotes(getActivity().getFilesDir()); ArrayList<String> listOfNotes = new ArrayList<>(); // Remove any files from the list that aren't notes for (int i = 0; i < numOfFiles; i++) { if (NumberUtils.isNumber(listOfFiles[i])) listOfNotes.add(listOfFiles[i]); else/*from ww w . ja v a 2s. c o m*/ numOfNotes--; } // Declare ListView final ListView listView = (ListView) getActivity().findViewById(R.id.listView1); // Create arrays of note lists String[] listOfNotesByDate = new String[numOfNotes]; String[] listOfNotesByName = new String[numOfNotes]; NoteListItem[] listOfTitlesByDate = new NoteListItem[numOfNotes]; NoteListItem[] listOfTitlesByName = new NoteListItem[numOfNotes]; ArrayList<NoteListItem> list = new ArrayList<>(numOfNotes); for (int i = 0; i < numOfNotes; i++) { listOfNotesByDate[i] = listOfNotes.get(i); } // If sort-by is "by date", sort in reverse order if (sortBy.equals("date")) Arrays.sort(listOfNotesByDate, Collections.reverseOrder()); // Get array of first lines of each note for (int i = 0; i < numOfNotes; i++) { try { String title = listener.loadNoteTitle(listOfNotesByDate[i]); String date = listener.loadNoteDate(listOfNotesByDate[i]); listOfTitlesByDate[i] = new NoteListItem(title, date); } catch (IOException e) { showToast(R.string.error_loading_list); } } // If sort-by is "by name", sort alphabetically if (sortBy.equals("name")) { // Copy titles array System.arraycopy(listOfTitlesByDate, 0, listOfTitlesByName, 0, numOfNotes); // Sort titles Arrays.sort(listOfTitlesByName, NoteListItem.NoteComparatorTitle); // Initialize notes array for (int i = 0; i < numOfNotes; i++) listOfNotesByName[i] = "new"; // Copy filenames array with new sort order of titles and nullify date arrays for (int i = 0; i < numOfNotes; i++) { for (int j = 0; j < numOfNotes; j++) { if (listOfTitlesByName[i].getNote().equals(listOfTitlesByDate[j].getNote()) && listOfNotesByName[i].equals("new")) { listOfNotesByName[i] = listOfNotesByDate[j]; listOfNotesByDate[j] = ""; listOfTitlesByDate[j] = new NoteListItem("", ""); } } } // Populate ArrayList with notes, showing name as first line of the notes list.addAll(Arrays.asList(listOfTitlesByName)); } else if (sortBy.equals("date")) list.addAll(Arrays.asList(listOfTitlesByDate)); // Create the custom adapters to bind the array to the ListView final NoteListDateAdapter dateAdapter = new NoteListDateAdapter(getActivity(), list); final NoteListAdapter adapter = new NoteListAdapter(getActivity(), list); // Display the ListView if (showDate) listView.setAdapter(dateAdapter); else listView.setAdapter(adapter); // Finalize arrays to prepare for handling clicked items final String[] finalListByDate = listOfNotesByDate; final String[] finalListByName = listOfNotesByName; // Make ListView handle clicked items listView.setClickable(true); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { if (sortBy.equals("date")) { if (directEdit) listener.editNote(finalListByDate[position]); else listener.viewNote(finalListByDate[position]); } else if (sortBy.equals("name")) { if (directEdit) listener.editNote(finalListByName[position]); else listener.viewNote(finalListByName[position]); } } }); // Make ListView handle contextual action bar final ArrayList<String> cab = new ArrayList<>(numOfNotes); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new MultiChoiceModeListener() { @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { // Respond to clicks on the actions in the CAB switch (item.getItemId()) { case R.id.action_export: mode.finish(); // Action picked, so close the CAB listener.exportNote(cab.toArray()); return true; case R.id.action_delete: mode.finish(); // Action picked, so close the CAB listener.deleteNote(cab.toArray()); return true; default: return false; } } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { listener.hideFab(); // Inflate the menu for the CAB MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.context_menu, menu); // Clear any old values from cab array cab.clear(); return true; } @Override public void onDestroyActionMode(ActionMode mode) { listener.showFab(); } @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { // Add/remove filenames to cab array as they are checked/unchecked if (checked) { if (sortBy.equals("date")) cab.add(finalListByDate[position]); if (sortBy.equals("name")) cab.add(finalListByName[position]); } else { if (sortBy.equals("date")) cab.remove(finalListByDate[position]); if (sortBy.equals("name")) cab.remove(finalListByName[position]); } // Update the title in CAB if (cab.size() == 0) mode.setTitle(""); else mode.setTitle(cab.size() + " " + listener.getCabString(cab.size())); } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } }); // If there are no saved notes, then display the empty view if (numOfNotes == 0) { TextView empty = (TextView) getActivity().findViewById(R.id.empty); listView.setEmptyView(empty); } }
From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobDAOImpl.java
public KwlReturnObject getConfigRecruitmentData(HashMap<String, Object> requestParams) { KwlReturnObject result = null;/*from w w w . j av a 2 s . c o m*/ try { ArrayList name = null; String hql = ""; ArrayList value = null; ArrayList orderby = null; ArrayList ordertype = null; String[] searchCol = null; hql = "from ConfigRecruitmentData "; if (requestParams.get("filter_names") != null && requestParams.get("filter_values") != null) { name = new ArrayList((List<String>) requestParams.get("filter_names")); value = new ArrayList((List<Object>) requestParams.get("filter_values")); hql += com.krawler.common.util.StringUtil.filterQuery(name, "where"); int ind = hql.indexOf("("); if (ind > -1) { int index = Integer.valueOf(hql.substring(ind + 1, ind + 2)); hql.replace("(" + index + ")", value.get(index).toString()); value.remove(index); } } if (requestParams.get("searchcol") != null && requestParams.get("ss") != null) { searchCol = (String[]) requestParams.get("searchcol"); hql += StringUtil.getSearchquery(requestParams.get("ss").toString(), searchCol, value); } if (requestParams.get("order_by") != null && requestParams.get("order_type") != null) { orderby = new ArrayList((List<String>) requestParams.get("order_by")); ordertype = new ArrayList((List<Object>) requestParams.get("order_type")); hql += com.krawler.common.util.StringUtil.orderQuery(orderby, ordertype); } result = StringUtil.getPagingquery(requestParams, searchCol, hibernateTemplate, hql, value); } catch (Exception ex) { result.setSuccessFlag(false); ex.printStackTrace(); } finally { return result; } }
From source file:eu.cassandra.utils.Utils.java
/** * This function is used in order to create clusters of points of interest * based on the active power difference they have. * /*from w w w. java2s . co m*/ * @param pois * The list of points of interest that will be clustered. * @return The newly created clusters with the points that are comprising * them. * @throws Exception */ public static ArrayList<ArrayList<PointOfInterest>> clusterPoints(ArrayList<PointOfInterest> pois, int bias) throws Exception { // Initialize the auxiliary variables ArrayList<ArrayList<PointOfInterest>> result = new ArrayList<ArrayList<PointOfInterest>>(); // Estimating the number of clusters that will be created int numberOfClusters = (int) (Math.ceil((double) pois.size() / (double) Constants.MAX_POINTS_OF_INTEREST)) + bias; log.info("Clusters: " + pois.size() + " / " + Constants.MAX_POINTS_OF_INTEREST + " + " + bias + " = " + numberOfClusters); // Create a new empty list of points for each cluster for (int i = 0; i < numberOfClusters; i++) result.add(new ArrayList<PointOfInterest>()); // Initializing auxiliary variables namely the attributes of the data set Attribute id = new Attribute("id"); Attribute pDiffRise = new Attribute("pDiff"); ArrayList<Attribute> attr = new ArrayList<Attribute>(); attr.add(id); attr.add(pDiffRise); Instances instances = new Instances("Points of Interest", attr, 0); // Each event is translated to an instance with the above attributes for (int i = 0; i < pois.size(); i++) { Instance inst = new DenseInstance(2); inst.setValue(id, i); inst.setValue(pDiffRise, Math.abs(pois.get(i).getPDiff())); instances.add(inst); } // System.out.println(instances.toString()); Instances newInst = null; log.debug("Instances: " + instances.toSummaryString()); // Create the addcluster filter of Weka and the set up the hierarchical // clusterer. AddCluster addcluster = new AddCluster(); SimpleKMeans kmeans = new SimpleKMeans(); kmeans.setSeed(numberOfClusters); // This is the important parameter to set kmeans.setPreserveInstancesOrder(true); kmeans.setNumClusters(numberOfClusters); kmeans.buildClusterer(instances); addcluster.setClusterer(kmeans); addcluster.setInputFormat(instances); addcluster.setIgnoredAttributeIndices("1"); // Cluster data set newInst = Filter.useFilter(instances, addcluster); // System.out.println(newInst.toString()); // Parse through the dataset to see where each point is placed in the // clusters. for (int i = 0; i < newInst.size(); i++) { String cluster = newInst.get(i).stringValue(newInst.attribute(2)); cluster = cluster.replace("cluster", ""); log.debug("Point of Interest: " + i + " Cluster: " + cluster); result.get(Integer.parseInt(cluster) - 1).add(pois.get(i)); } // Sorting the each cluster points by their minutes. for (int i = result.size() - 1; i >= 0; i--) { if (result.get(i).size() == 0) result.remove(i); else Collections.sort(result.get(i), Constants.comp); } // Sorting the all clusters by their active power. Collections.sort(result, Constants.comp5); return result; }
From source file:com.yuwang.pinju.web.module.shop.action.ShopSaveShopInfoAction.java
/** * ????// w w w . j av a 2s .c o m * @return statusError: iWillOpenShopAction.htm * @return baseInfoError: shopOpenFillCustomerBaseInfo.ftl * @return success: queryShopInfoAction.htm * @return not-allowed: notAllowError.ftl */ public String saveBusinessBrandInfo() { long userId = queryUserId(); ShopFlowInfoDO shopFlowInfoDO = shopOpenAO.queryFlowInfo(userId); if (shopFlowInfoDO != null && shopFlowInfoDO.getAuditStatus() != null && (shopFlowInfoDO.getAuditStatus().equals(ShopConstant.AUDIT_STATUS_OPEN_END) || shopFlowInfoDO.getAuditStatus().equals(ShopConstant.AUDIT_STATUS_PASS) || shopFlowInfoDO.getAuditStatus().equals(ShopConstant.AUDIT_STATUS_WAIT))) { return "statusError"; } List<ShopBusinessInfoDO> shopInfoList = shopOpenAO.queryShopBusinessInfo(userId); ShopBusinessInfoDO shopBInfo = null; if (shopInfoList != null && shopInfoList.size() > 0) { shopBInfo = shopInfoList.get(0); } ShopBusinessInfoDO shopB = new ShopBusinessInfoDO(); if (brandSaveType == 0 || brandSaveType == 1) { try { //?C? errorMessage = validateBrandInfo(shopBusinessInfoDO); //? if (null != errorMessage && !"".equals(errorMessage)) { return "brandInfoError"; } //??,??,?? String brandLogoPicNames[] = null; String brandCertificatePicNames[] = null; String qualityCertificatePicNames[] = null; if (shopBInfo != null) { if (brandLogo != null && brandLogo.length > 0) { brandLogoPicNames = saveFile(brandLogo, brandLogoFileName); if (brandLogoPicNames != null && brandLogoPicNames.length > 0) { // StringBuffer brandLogoPicNameBuffer = new // StringBuffer(); // for(String brandLogoPicName : brandLogoPicNames){ // brandLogoPicNameBuffer.append(brandLogoPicName).append(","); // } // String brandLogoPicNameStr = // brandLogoPicNameBuffer.substring(0, // brandLogoPicNameBuffer.length() - 1); String brandLogoPicNameStr = brandLogoPicNames[0]; String brandLogoDBStr = shopBInfo.getBrandLogo(); if (brandLogoDBStr != null && brandLogoDBStr.length() > 0) { String[] brandLogoArr = brandLogoDBStr.split("@!@"); ArrayList<String> arrayList = new ArrayList<String>(brandLogoArr.length + 1); for (String str : brandLogoArr) { arrayList.add(str); } arrayList.add(currentBrand, brandLogoPicNameStr); if (arrayList.size() > currentBrand + 1) { arrayList.remove(currentBrand + 1); } brandLogoPicNameStr = ""; for (String str : arrayList) { brandLogoPicNameStr += str + "@!@"; } // brandLogoPicNameStr = brandLogoPicNameStr.substring(0, brandLogoPicNameStr.length() - 1); } shopB.setBrandLogo(brandLogoPicNameStr); } } if (brandCertificate != null && brandCertificate.length > 0) { brandCertificatePicNames = saveFile(brandCertificate, brandCertificateFileName); if (brandCertificatePicNames != null && brandCertificatePicNames.length > 0) { // StringBuffer brandCertificatePicNameBuffer = new // StringBuffer(); // for(String brandCertificate : // brandCertificatePicNames){ // brandCertificatePicNameBuffer.append(brandCertificate).append(","); // } // String brandCertificatePicNameStr = // brandCertificatePicNameBuffer.substring(0, // brandCertificatePicNameBuffer.length() - 1); // shopBusinessInfoDO.setBrandCertificate(brandCertificatePicNameStr); String brandCertificatePicNameStr = brandCertificatePicNames[0]; String brandCertificateDBStr = shopBInfo.getBrandCertificate(); if (brandCertificateDBStr != null && brandCertificateDBStr.length() > 0) { String[] brandCertificateArr = brandCertificateDBStr.split("@!@"); ArrayList<String> arrayList = new ArrayList<String>(brandCertificateArr.length + 1); for (String str : brandCertificateArr) { arrayList.add(str); } arrayList.add(currentBrand, brandCertificatePicNameStr); if (arrayList.size() > currentBrand + 1) { arrayList.remove(currentBrand + 1); } brandCertificatePicNameStr = ""; for (String str : arrayList) { brandCertificatePicNameStr += str + "@!@"; } // brandCertificatePicNameStr = brandCertificatePicNameStr.substring(0, // brandCertificatePicNameStr.length() - 1); } shopB.setBrandCertificate(brandCertificatePicNameStr); } } if (qualityCertificate != null && qualityCertificate.length > 0) { qualityCertificatePicNames = saveFile(qualityCertificate, qualityCertificateFileName); if (qualityCertificatePicNames != null && qualityCertificatePicNames.length > 0) { // StringBuffer qualityCertificatePicNameBuffer = new // StringBuffer(); // for(String qualityCertificate : // qualityCertificatePicNames){ // qualityCertificatePicNameBuffer.append(qualityCertificate).append(","); // } // String qualityCertificatePicNameStr = // qualityCertificatePicNameBuffer.substring(0, // qualityCertificatePicNameBuffer.length() - 1); // shopBusinessInfoDO.setQualityCertificate(qualityCertificatePicNameStr); String qualityCertificatePicNameStr = qualityCertificatePicNames[0]; String qualityCertificateDBStr = shopBInfo.getQualityCertificate(); if (qualityCertificateDBStr != null && qualityCertificateDBStr.length() > 0) { String[] qualityCertificateArr = qualityCertificateDBStr.split("@!@"); ArrayList<String> arrayList = new ArrayList<String>( qualityCertificateArr.length + 1); for (String str : qualityCertificateArr) { arrayList.add(str); } arrayList.add(currentBrand, qualityCertificatePicNameStr); if (arrayList.size() > currentBrand + 1) { arrayList.remove(currentBrand + 1); } qualityCertificatePicNameStr = ""; for (String str : arrayList) { qualityCertificatePicNameStr += str + "@!@"; } // qualityCertificatePicNameStr = qualityCertificatePicNameStr.substring(0, // qualityCertificatePicNameStr.length() - 1); } shopB.setQualityCertificate(qualityCertificatePicNameStr); } } if (shopBusinessInfoDO.getBrandName() != null && shopBusinessInfoDO.getBrandName().length() > 0) { ArrayList<String> arrayList = null; if (shopBInfo.getBrandName() != null && shopBInfo.getBrandName().length() > 0) { String nameString = shopBInfo.getBrandName(); String[] brandNameArr = nameString.split("@!@"); arrayList = new ArrayList<String>(brandNameArr.length + 1); for (String str : brandNameArr) { arrayList.add(str); } arrayList.add(currentBrand, shopBusinessInfoDO.getBrandName()); if (arrayList.size() > currentBrand + 1) { arrayList.remove(currentBrand + 1); } } else { arrayList = new ArrayList<String>(1); arrayList.add(currentBrand, shopBusinessInfoDO.getBrandName()); } String brandNameStr = ""; for (String str : arrayList) { brandNameStr += str + "@!@"; } // brandNameStr = brandNameStr.substring(0, brandNameStr.length() - 1); shopB.setBrandName(brandNameStr); } String[] brandEnglishNameArr = null; ArrayList<String> list = null; if (shopBInfo.getBrandEnglishName() != null && shopBInfo.getBrandEnglishName().length() > 0) { brandEnglishNameArr = shopBInfo.getBrandEnglishName().split("@!@"); list = new ArrayList<String>(brandEnglishNameArr.length + 1); for (String str : brandEnglishNameArr) { list.add(str); } } else { list = new ArrayList<String>(1); } if (shopBusinessInfoDO.getBrandEnglishName() != null && shopBusinessInfoDO.getBrandEnglishName().length() > 0) { list.add(currentBrand, shopBusinessInfoDO.getBrandEnglishName()); } else { list.add(currentBrand, " "); } if (list.size() > 1 && list.size() > currentBrand + 1) { list.remove(currentBrand + 1); } String brandEnglishNameStr = ""; for (String str : list) { brandEnglishNameStr += str + "@!@"; } //brandEnglishNameStr = brandEnglishNameStr.substring(0, brandEnglishNameStr.length() - 1); shopB.setBrandEnglishName(brandEnglishNameStr); if (shopBusinessInfoDO.getBrandStory() != null && shopBusinessInfoDO.getBrandStory().length() > 0) { String[] brandStoryArr = null; ArrayList<String> arrayList = null; if (shopBInfo.getBrandStory() != null && shopBInfo.getBrandStory().length() > 0) { brandStoryArr = shopBInfo.getBrandStory().split("@!@"); arrayList = new ArrayList<String>(brandStoryArr.length + 1); for (String str : brandStoryArr) { arrayList.add(str); } arrayList.add(currentBrand, shopBusinessInfoDO.getBrandStory()); if (arrayList.size() > currentBrand + 1) { arrayList.remove(currentBrand + 1); } } else { arrayList = new ArrayList<String>(1); arrayList.add(currentBrand, shopBusinessInfoDO.getBrandStory()); } String brandStoryStr = ""; for (String str : arrayList) { brandStoryStr += str + "@!@"; } // brandStoryStr = brandStoryStr.substring(0, brandStoryStr.length() - 1); shopB.setBrandStory(brandStoryStr); } if (shopBusinessInfoDO.getTrademarkNumber() != null && shopBusinessInfoDO.getTrademarkNumber().length() > 0) { String[] trademarkNumberArr = null; ArrayList<String> arrayList = null; if (shopBInfo.getTrademarkNumber() != null && shopBInfo.getTrademarkNumber().length() > 0) { trademarkNumberArr = shopBInfo.getTrademarkNumber().split("@!@"); arrayList = new ArrayList<String>(trademarkNumberArr.length + 1); for (String str : trademarkNumberArr) { arrayList.add(str); } arrayList.add(currentBrand, shopBusinessInfoDO.getTrademarkNumber()); if (arrayList.size() > currentBrand + 1) { arrayList.remove(currentBrand + 1); } } else { arrayList = new ArrayList<String>(1); arrayList.add(currentBrand, shopBusinessInfoDO.getTrademarkNumber()); } String trademarkNumberStr = ""; for (String str : arrayList) { trademarkNumberStr += str + "@!@"; } // trademarkNumberStr = trademarkNumberStr.substring(0, trademarkNumberStr.length() - 1); shopB.setTrademarkNumber(trademarkNumberStr); } } //? shopB.setUserId(userId); shopOpenManager.updateShopBusinessInfo(shopB); //?? List<ShopOpenFlowDO> list = shopOpenAO.queryShopOpenFlow(userId); if (list != null && list.size() > 0) { ShopOpenFlowDO shopOpenFlowDO = list.get(0); shopOpenFlowDO.setUserId(userId); shopOpenFlowDO.setGmtModified(new Date()); Integer isFillInfo = shopOpenFlowDO.getIsFillInfo(); if (isFillInfo == null) { isFillInfo = ShopConstant.IS_FILL_SHOP_INFO_STEP3; shopOpenFlowDO.setIsFillInfo(isFillInfo); } else { if (isFillInfo.toString() .indexOf(String.valueOf(ShopConstant.IS_FILL_SHOP_INFO_STEP3)) == -1) { shopOpenFlowDO.setIsFillInfo(Integer.parseInt( isFillInfo.toString() + ShopConstant.IS_FILL_SHOP_INFO_STEP3.toString())); } } shopOpenManager.updateShopOpenFlow(shopOpenFlowDO); } //cookie PinjuCookieManager.clearShop2(); } catch (ManagerException e) { log.error(e.getMessage()); } } String returnString = ""; int newBrandSeq = 0; if (shopBInfo != null) { String brandNameString = shopBInfo.getBrandName(); if (brandNameString != null && brandNameString.length() > 0) { newBrandSeq = brandNameString.split("@!@").length; } } if (brandSaveType == 2) { returnString = "notSaveAndNew"; shopBusinessInfoDO = new ShopBusinessInfoDO(); if (currentBrand + 1 <= newBrandSeq) { brandSeq = currentBrand + 1; currentBrand = currentBrand + 1; } } else if (brandSaveType == 1) { returnString = "saveAndNew"; shopBusinessInfoDO = new ShopBusinessInfoDO(); if (currentBrand <= newBrandSeq) { brandSeq = currentBrand + 1; currentBrand = currentBrand + 1; } } else if (brandSaveType == 0) { returnString = "success"; } return returnString; }
From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobDAOImpl.java
public KwlReturnObject getConfigRecruitment(HashMap<String, Object> requestParams) { KwlReturnObject result = null;/* ww w . j av a2s . c o m*/ try { ArrayList name = null; String hql = ""; ArrayList value = null; ArrayList orderby = null; ArrayList ordertype = null; String[] searchCol = null; hql = "from ConfigRecruitment "; if (requestParams.get("filter_names") != null && requestParams.get("filter_values") != null) { name = new ArrayList((List<String>) requestParams.get("filter_names")); value = new ArrayList((List<Object>) requestParams.get("filter_values")); hql += com.krawler.common.util.StringUtil.filterQuery(name, "where"); int ind = hql.indexOf("("); if (ind > -1) { int index = Integer.valueOf(hql.substring(ind + 1, ind + 2)); hql = hql.replace("(" + index + ")", "(" + value.get(index).toString() + ")"); value.remove(index); } } if (requestParams.get("searchcol") != null && requestParams.get("ss") != null) { searchCol = (String[]) requestParams.get("searchcol"); hql += StringUtil.getSearchquery(requestParams.get("ss").toString(), searchCol, value); } if (requestParams.get("order_by") != null && requestParams.get("order_type") != null) { orderby = new ArrayList((List<String>) requestParams.get("order_by")); ordertype = new ArrayList((List<Object>) requestParams.get("order_type")); hql += com.krawler.common.util.StringUtil.orderQuery(orderby, ordertype); } result = StringUtil.getPagingquery(requestParams, searchCol, hibernateTemplate, hql, value); } catch (Exception ex) { result.setSuccessFlag(false); ex.printStackTrace(); } finally { return result; } }
From source file:com.krawler.spring.hrms.rec.job.hrmsRecJobDAOImpl.java
@Override public KwlReturnObject getConfigMaster(HashMap<String, Object> requestParams) { KwlReturnObject result = null;/*from w w w .ja v a 2 s .co m*/ try { ArrayList name = null; String hql = ""; ArrayList value = null; ArrayList orderby = null; ArrayList ordertype = null; String[] searchCol = null; hql = "from ConfigRecruitmentMaster "; if (requestParams.get("filter_names") != null && requestParams.get("filter_values") != null) { name = new ArrayList((List<String>) requestParams.get("filter_names")); value = new ArrayList((List<Object>) requestParams.get("filter_values")); hql += com.krawler.common.util.StringUtil.filterQuery(name, "where"); int ind = hql.indexOf("("); if (ind > -1) { int index = Integer.valueOf(hql.substring(ind + 1, ind + 2)); hql = hql.replace("(" + index + ")", "(" + value.get(index).toString() + ")"); value.remove(index); } } if (requestParams.get("searchcol") != null && requestParams.get("ss") != null) { searchCol = (String[]) requestParams.get("searchcol"); hql += StringUtil.getSearchquery(requestParams.get("ss").toString(), searchCol, value); } if (requestParams.get("order_by") != null && requestParams.get("order_type") != null) { orderby = new ArrayList((List<String>) requestParams.get("order_by")); ordertype = new ArrayList((List<Object>) requestParams.get("order_type")); hql += com.krawler.common.util.StringUtil.orderQuery(orderby, ordertype); } result = StringUtil.getPagingquery(requestParams, searchCol, hibernateTemplate, hql, value); } catch (Exception ex) { result.setSuccessFlag(false); ex.printStackTrace(); } finally { return result; } }
From source file:gdsc.smlm.ij.plugins.DriftCalculator.java
/** * Calculates drift using images from N consecutive frames aligned to the overall image. * // w w w . j a v a 2s . c o m * @param results * @param limits * @param reconstructionSize * @return the drift { dx[], dy[] } */ private double[][] calculateUsingFrames(MemoryPeakResults results, int[] limits, int reconstructionSize) { double[] dx = new double[limits[1] + 1]; double[] dy = new double[dx.length]; // Extract the localisations into blocks of N consecutive frames ArrayList<ArrayList<Localisation>> blocks = new ArrayList<ArrayList<Localisation>>(); results.sort(); List<PeakResult> peakResults = results.getResults(); int t = 0; ArrayList<Localisation> nextBlock = null; for (PeakResult r : peakResults) { if (r.peak > t) { while (r.peak > t) t += frames; // To avoid blocks without many results only create a new block if the min size has been met if (nextBlock == null || nextBlock.size() >= minimimLocalisations) nextBlock = new ArrayList<Localisation>(); blocks.add(nextBlock); } nextBlock.add(new Localisation(r.peak, r.getXPosition(), r.getYPosition(), r.getSignal())); } if (blocks.size() < 2) { tracker.log("ERROR : Require at least 2 images for drift calculation"); return null; } // Check the final block has enough localisations if (nextBlock.size() < minimimLocalisations) { blocks.remove(blocks.size() - 1); ArrayList<Localisation> combinedBlock = blocks.get(blocks.size() - 1); combinedBlock.addAll(nextBlock); if (blocks.size() < 2) { tracker.log("ERROR : Require at least 2 images for drift calculation"); return null; } } // Find the average time point for each block int[] blockT = new int[blocks.size()]; t = 0; for (ArrayList<Localisation> block : blocks) { long sum = 0; for (Localisation r : block) { sum += r.t; } blockT[t++] = (int) (sum / block.size()); } // Calculate a scale to use when constructing the images for alignment Rectangle bounds = results.getBounds(true); float scale = (reconstructionSize - 1f) / FastMath.max(bounds.width, bounds.height); threadPool = Executors.newFixedThreadPool(Prefs.getThreads()); double[] originalDriftTimePoints = getOriginalDriftTimePoints(dx, blockT); lastdx = null; double smoothing = updateSmoothingParameter(originalDriftTimePoints); double change = calculateDriftUsingFrames(blocks, blockT, bounds, scale, dx, dy, originalDriftTimePoints, smoothing, iterations); if (Double.isNaN(change) || tracker.isEnded()) return null; plotDrift(limits, dx, dy); Utils.log("Drift Calculator : Initial drift " + Utils.rounded(change)); for (int i = 1; i <= maxIterations; i++) { change = calculateDriftUsingFrames(blocks, blockT, bounds, scale, dx, dy, originalDriftTimePoints, smoothing, iterations); if (Double.isNaN(change)) return null; plotDrift(limits, dx, dy); if (converged(i, change, getTotalDrift(dx, dy, originalDriftTimePoints))) break; } if (tracker.isEnded()) return null; plotDrift(limits, dx, dy); return new double[][] { dx, dy }; }
From source file:org.mustard.android.provider.StatusNet.java
private long updateInner(String status, String in_reply_to, String lon, String lat, File media) throws MustardException, AuthException { ArrayList<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("status", status)); params.add(new BasicNameValuePair("source", MustardApplication.APPLICATION_NAME)); if (!in_reply_to.equals("") && !in_reply_to.equals("-1")) params.add(new BasicNameValuePair("in_reply_to_status_id", in_reply_to)); if (lon != null && !"".equals(lon)) params.add(new BasicNameValuePair("long", lon)); if (lat != null && !"".equals(lat)) params.add(new BasicNameValuePair("lat", lat)); String updateURL = mURL.toExternalForm() + (!isTwitter ? "/api" : "") + API_NOTICE_ADD; JSONObject json = null;/*w ww . j a va 2s . co m*/ long id = -1; try { if (media == null) { // String yfrogurl = ""; // if(isTwitter) { // yfrogurl = Yfrog.test(status,media); // Log.i(TAG, "Yfrog response: " + yfrogurl); // } json = mHttpManager.getJsonObject(updateURL, HttpManager.POST, params); } else { if (!isTwitter) json = mHttpManager.getJsonObject(updateURL, params, "media", media); else { try { String rr = Twitpic.upload(mContext, mHttpManager.getOAuthConsumer(), status, media); Log.d("Mustard", "twitpic id: " + rr); String newstatus = status + " " + rr; if (newstatus.length() > 140) { newstatus = status.substring(0, 136 - rr.length()) + "... " + rr; } params.remove(0); params.add(new BasicNameValuePair("status", newstatus)); json = mHttpManager.getJsonObject(updateURL, HttpManager.POST, params); } catch (Exception e) { e.printStackTrace(); } } } // System.out.println(json.toString(1)); Status s = StatusNetJSONUtil.getStatus(json); id = s.getNotice().getId(); } catch (AuthException e) { throw e; } catch (MustardException e) { if (MustardApplication.DEBUG) e.printStackTrace(); throw e; } catch (Exception e) { if (MustardApplication.DEBUG) e.printStackTrace(); throw new MustardException(e.getMessage()); } return id; }