List of usage examples for java.util Vector addAll
public boolean addAll(Collection<? extends E> c)
From source file:edu.uga.cs.fluxbuster.clustering.ClusterGenerator.java
/** * Compute a distance matrix from a list of candidate flux domains with * a maximum number of calculation threads. * * @param cfds the list of candidate flux domains * @param maxnumthreads the thread ceiling * @return the vector of values in the distance matrix in row major * order/* w w w. j av a2 s .c o m*/ */ private Vector<Float> computeDistanceMatrixMultiThreaded(List<CandidateFluxDomain> cfds, int maxnumthreads) { Vector<Float> retval = new Vector<Float>(); ThreadFactory tf = Executors.defaultThreadFactory(); double gamma = Double.parseDouble(localprops.getProperty(GAMMAKEY)); ArrayList<Thread> threads = new ArrayList<Thread>(); ArrayList<HashSet<Integer>> threadrows = new ArrayList<HashSet<Integer>>(); int interval = (int) Math.ceil((cfds.size() - 1) / (double) maxnumthreads); int left = 0; int right = cfds.size() - 2; HashSet<Integer> curset = null; boolean addLeftFirst = true; while (left <= right) { if (curset == null) { curset = new HashSet<Integer>(); } if (curset.size() == interval) { threadrows.add(curset); curset = null; } else { if (addLeftFirst) { curset.add(left++); } else { curset.add(right--); } addLeftFirst = !addLeftFirst; if (curset.size() == interval) { continue; } if (addLeftFirst) { curset.add(left++); } else { curset.add(right--); } } } if (curset != null && curset.size() > 0) { threadrows.add(curset); } ArrayList<Vector<Float>> resultsList = new ArrayList<Vector<Float>>(cfds.size()); // this is necessary to make sure that the proper indexes exist in // resultsList before being accessed by the threads for (int i = 0; i < cfds.size() - 1; i++) { resultsList.add(null); } for (int i = 0; i < threadrows.size(); i++) { Thread t = tf.newThread(new DistanceMatrixCalculator(gamma, threadrows.get(i), cfds, resultsList)); threads.add(t); } for (Thread t : threads) { t.start(); } for (Thread t : threads) { try { t.join(); } catch (InterruptedException e) { e.printStackTrace(); } } for (int i = 0; i < resultsList.size(); i++) { retval.addAll(resultsList.get(i)); } return retval; }
From source file:com.symbian.driver.core.controller.tasks.TEFTask.java
private Vector<String> loadServerNames(String aScript) { Vector<String> lResults = null; String lUserHome = System.getProperty("user.home"); File lTempDir = new File(lUserHome, "temp"); if (!lTempDir.exists()) lTempDir.mkdirs();// w w w . j av a2 s . co m File lTempFile = null; try { lTempFile = File.createTempFile("testdriver_", ".script", lTempDir); LOGGER.fine("retrieve script file from " + aScript + " to " + lTempFile.getAbsolutePath()); if (!DeviceUtils.retrieveFile(aScript, lTempFile.getAbsolutePath(), false, null)) { LOGGER.warning("Unable to retrieve TEF script file: " + aScript); return null; } } catch (IOException e) { LOGGER.warning("Unable to create temporary storage! Server name loading skipped!"); return null; } //parse script file try { BufferedReader lScriptInput = new BufferedReader(new FileReader(lTempFile)); String lScriptLine = null; //prepare regular expression Pattern lSuitePattern = Pattern.compile("LOAD_SUITE\\s*(.*)"); Pattern lScriptPattern = Pattern.compile("RUN_SCRIPT\\s*(.*)"); Matcher lMatcher = null; while ((lScriptLine = lScriptInput.readLine()) != null) { lMatcher = lSuitePattern.matcher(lScriptLine); if (lMatcher.matches()) { //LOAD_SUITE found, get server name if (lResults == null) lResults = new Vector<String>(); String lServerName = lMatcher.group(1); int lIndex = lServerName.indexOf(" "); if (lIndex > -1) lServerName = lServerName.substring(0, lIndex); lResults.add("c:\\sys\\bin\\" + lServerName + ".exe"); } else { lMatcher = lScriptPattern.matcher(lScriptLine); if (lMatcher.matches()) { //RUN_SCRIPT found, retrieve it and recursively call loading String lScriptFile = lMatcher.group(1); Vector<String> lNames = loadServerNames(lScriptFile); if (lResults == null) lResults = new Vector<String>(); lResults.addAll(lNames); } } } } catch (IOException e) { LOGGER.log(Level.SEVERE, "Can't open script file for reading!"); } return lResults; }
From source file:org.unitime.timetable.solver.course.ui.ClassInfoModel.java
public Collection<ClassAssignment> getAllTimes() { Vector<ClassAssignment> times = new Vector<ClassAssignment>(); Class_ clazz = getClazz().getClazz(); DatePattern datePattern = clazz.effectiveDatePattern(); if (datePattern == null) return times; if (datePattern.getType() == DatePattern.sTypePatternSet) { Set<DatePatternPref> datePatternPrefs = (Set<DatePatternPref>) clazz .effectivePreferences(DatePatternPref.class); boolean hasReq = false; for (DatePatternPref p : datePatternPrefs) { if (PreferenceLevel.sRequired.equals(p.getPrefLevel().getPrefProlog())) { hasReq = true;/* ww w . ja va 2s . com*/ break; } } for (DatePattern child : datePattern.findChildren()) { String pr = PreferenceLevel.sNeutral; for (DatePatternPref p : datePatternPrefs) { if (p.getDatePattern().equals(child)) pr = p.getPrefLevel().getPrefProlog(); } int prVal = 0; if (!PreferenceLevel.sNeutral.equals(pr) && !PreferenceLevel.sRequired.equals(pr)) { prVal = PreferenceLevel.prolog2int(pr); } if (hasReq && !PreferenceLevel.sRequired.equals(pr)) prVal += 100; if (PreferenceLevel.sProhibited.equals(pr)) prVal += 100; times.addAll(getTimes(new ClassDateInfo(child.getUniqueId(), clazz.getUniqueId(), child.getName(), child.getPatternBitSet(), prVal))); } } else { times.addAll(getTimes(new ClassDateInfo(datePattern.getUniqueId(), clazz.getUniqueId(), datePattern.getName(), datePattern.getPatternBitSet(), PreferenceLevel.sIntLevelNeutral))); } return times; }
From source file:edu.ku.brc.ui.FeedBackSender.java
/** * Creates an array of POST method parameters to send with the version checking / usage tracking connection. * //from ww w . j ava 2 s. c om * @param item the item to fill * @return an array of POST parameters */ protected NameValuePair[] createPostParameters(final FeedBackSenderItem item) { Vector<NameValuePair> postParams = new Vector<NameValuePair>(); try { postParams.add(new NameValuePair("bug", item.getBug())); //$NON-NLS-1$ postParams.add(new NameValuePair("class_name", item.getClassName())); //$NON-NLS-1$ postParams.add(new NameValuePair("comments", item.getComments())); //$NON-NLS-1$ postParams.add(new NameValuePair("stack_trace", item.getStackTrace())); //$NON-NLS-1$ postParams.add(new NameValuePair("task_name", item.getTaskName())); //$NON-NLS-1$ postParams.add(new NameValuePair("title", item.getTitle())); //$NON-NLS-1$ // get the install ID String installID = UsageTracker.getInstallId(); postParams.add(new NameValuePair("id", installID)); //$NON-NLS-1$ Runtime runtime = Runtime.getRuntime(); Long usedMemory = runtime.maxMemory() - (runtime.totalMemory() + runtime.freeMemory()); Long maxMemory = runtime.maxMemory(); // get the OS name and version postParams.add(new NameValuePair("os_name", System.getProperty("os.name"))); //$NON-NLS-1$ //$NON-NLS-2$ postParams.add(new NameValuePair("os_version", System.getProperty("os.version"))); //$NON-NLS-1$ //$NON-NLS-2$ postParams.add(new NameValuePair("java_version", System.getProperty("java.version"))); //$NON-NLS-1$ //$NON-NLS-2$ postParams.add(new NameValuePair("java_vendor", System.getProperty("java.vendor"))); //$NON-NLS-1$ //$NON-NLS-2$ postParams.add(new NameValuePair("max_memory", maxMemory.toString())); //$NON-NLS-1$ postParams.add(new NameValuePair("used_memory", usedMemory.toString())); //$NON-NLS-1$ Properties props = item.getProps(); if (props != null) { for (Object key : props.keySet()) { postParams.add(new NameValuePair(key.toString(), props.getProperty(key.toString()))); //$NON-NLS-1$ } } //if (!UIRegistry.isRelease()) // For Testing Only { postParams.add(new NameValuePair("user_name", System.getProperty("user.name"))); //$NON-NLS-1$ try { postParams.add(new NameValuePair("ip", InetAddress.getLocalHost().getHostAddress())); //$NON-NLS-1$ } catch (UnknownHostException e) { } } String resAppVersion = UIRegistry.getAppVersion(); if (StringUtils.isEmpty(resAppVersion)) { resAppVersion = "Unknown"; } postParams.add(new NameValuePair("app_version", resAppVersion)); //$NON-NLS-1$ Vector<NameValuePair> extraStats = collectionSecondaryInfo(item); if (extraStats != null) { postParams.addAll(extraStats); } // create an array from the params NameValuePair[] paramArray = new NameValuePair[postParams.size()]; for (int i = 0; i < paramArray.length; ++i) { paramArray[i] = postParams.get(i); } return paramArray; } catch (Exception ex) { ex.printStackTrace(); } return null; }
From source file:com.yahoo.ycsb.db.couchbase2.Couchbase2Client.java
/** * Performs the {@link #scan(String, String, int, Set, Vector)} operation, optimized for all fields. * * Since the full document bodies need to be loaded anyways, it makes sense to just grab the document IDs * from N1QL and then perform the bulk loading via KV for better performance. This is a usual pattern with * Couchbase and shows the benefits of using both N1QL and KV together. * * @param table The name of the table// ww w. j a va2s. co m * @param startkey The record key of the first record to read. * @param recordcount The number of records to read * @param result A Vector of HashMaps, where each HashMap is a set field/value pairs for one record * @return The result of the operation. */ private Status scanAllFields(final String table, final String startkey, final int recordcount, final Vector<HashMap<String, ByteIterator>> result) { final List<HashMap<String, ByteIterator>> data = new ArrayList<HashMap<String, ByteIterator>>(recordcount); bucket.async() .query(N1qlQuery.parameterized(scanAllQuery, JsonArray.from(formatId(table, startkey), recordcount), N1qlParams.build().adhoc(adhoc).maxParallelism(maxParallelism))) .doOnNext(new Action1<AsyncN1qlQueryResult>() { @Override public void call(AsyncN1qlQueryResult result) { if (!result.parseSuccess()) { throw new RuntimeException("Error while parsing N1QL Result. Query: " + scanAllQuery + ", Errors: " + result.errors()); } } }).flatMap(new Func1<AsyncN1qlQueryResult, Observable<AsyncN1qlQueryRow>>() { @Override public Observable<AsyncN1qlQueryRow> call(AsyncN1qlQueryResult result) { return result.rows(); } }).flatMap(new Func1<AsyncN1qlQueryRow, Observable<RawJsonDocument>>() { @Override public Observable<RawJsonDocument> call(AsyncN1qlQueryRow row) { String id = new String(row.byteValue()).trim(); return bucket.async().get(id.substring(1, id.length() - 1), RawJsonDocument.class); } }).map(new Func1<RawJsonDocument, HashMap<String, ByteIterator>>() { @Override public HashMap<String, ByteIterator> call(RawJsonDocument document) { HashMap<String, ByteIterator> tuple = new HashMap<String, ByteIterator>(); decode(document.content(), null, tuple); return tuple; } }).toBlocking().forEach(new Action1<HashMap<String, ByteIterator>>() { @Override public void call(HashMap<String, ByteIterator> tuple) { data.add(tuple); } }); result.addAll(data); return Status.OK; }
From source file:it.acubelab.smaph.learn.TuneModel.java
private static Pair<Vector<ModelConfigurationResult>, ModelConfigurationResult> trainIterative( BinaryExampleGatherer trainGatherer, BinaryExampleGatherer develGatherer, double editDistanceThreshold, OptimizaionProfiles optProfile, double optProfileThreshold, double gamma, double C) { Vector<ModelConfigurationResult> globalScoreboard = new Vector<>(); Vector<Integer> allFtrs = SmaphUtils.getAllFtrVect(trainGatherer.getFtrCount()); double bestwPos; double bestwNeg; double broadwPosMin = 0.1; double broadwPosMax = 50.0; double broadwNegMin = 1.0; double broadwNegMax = 1.0; double broadkPos = 0.2; int broadSteps = 10; int fineSteps = 5; int iterations = 3; // broad tune weights (all ftr) try {//from w ww . j a v a2 s . co m Pair<Double, Double> bestBroadWeights = new WeightSelector(broadwPosMin, broadwPosMax, broadkPos, broadwNegMin, broadwNegMax, 1.0, gamma, C, broadSteps, editDistanceThreshold, allFtrs, trainGatherer, develGatherer, optProfile, globalScoreboard).call(); bestwPos = bestBroadWeights.first; bestwNeg = bestBroadWeights.second; } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(); } System.err.println("Done broad weighting."); int bestIterPos = WeightSelector.weightToIter(bestwPos, broadwPosMax, broadwPosMin, broadkPos, broadSteps); double finewPosMin = WeightSelector.computeWeight(broadwPosMax, broadwPosMin, broadkPos, bestIterPos - 1, broadSteps); double finewPosMax = WeightSelector.computeWeight(broadwPosMax, broadwPosMin, broadkPos, bestIterPos + 1, broadSteps); double finewNegMin = 0.5; double finewNegMax = 2.0; ModelConfigurationResult bestResult = ModelConfigurationResult.findBest(globalScoreboard, optProfile, optProfileThreshold); ; for (int iteration = 0; iteration < iterations; iteration++) { // Do feature selection /* * ModelConfigurationResult bestFtr; { * Vector<ModelConfigurationResult> scoreboardFtrSelection = new * Vector<>(); new AblationFeatureSelector(bestwPos, bestwNeg, * editDistanceThreshold, trainGatherer, develGatherer, optProfile, * optProfileThreshold, scoreboardFtrSelection) .run(); bestFtr = * ModelConfigurationResult .findBest(scoreboardFtrSelection, * optProfile, optProfileThreshold); * globalScoreboard.addAll(scoreboardFtrSelection); * System.err.printf("Done feature selection (iteration %d).%n", * iteration); } Vector<Integer> bestFeatures = * bestFtr.getFeatures(); */ Vector<Integer> bestFeatures = allFtrs; { // Fine-tune weights Vector<ModelConfigurationResult> scoreboardWeightsTuning = new Vector<>(); Pair<Double, Double> weights; try { weights = new WeightSelector(finewPosMin, finewPosMax, -1, finewNegMin, finewNegMax, -1, gamma, C, fineSteps, editDistanceThreshold, bestFeatures, trainGatherer, develGatherer, optProfile, scoreboardWeightsTuning).call(); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(); } bestwPos = weights.first; bestwNeg = weights.second; finewPosMin = bestwPos * 0.5; finewPosMax = bestwPos * 2.0; finewNegMin = bestwNeg * 0.5; finewNegMax = bestwNeg * 2.0; globalScoreboard.addAll(scoreboardWeightsTuning); System.err.printf("Done weights tuning (iteration %d).%n", iteration); } ModelConfigurationResult newBest = ModelConfigurationResult.findBest(globalScoreboard, optProfile, optProfileThreshold); if (bestResult != null && newBest.equalResult(bestResult, optProfile, optProfileThreshold)) { System.err.printf("Not improving, stopping on iteration %d.%n", iteration); break; } bestResult = newBest; } return new Pair<Vector<ModelConfigurationResult>, ModelConfigurationResult>(globalScoreboard, ModelConfigurationResult.findBest(globalScoreboard, optProfile, optProfileThreshold)); }
From source file:com.globalsight.everest.usermgr.UserManagerLocal.java
/** * Get users matched the specified criteria * /*from ww w . ja va2 s .co m*/ * @param p_userAttrs * - Arrtibute array contains the User entry attributes * @param p_roleAttrs * - Attribute array contains the Role entry attributes * @param p_project * @return a Vector of User objects * @exception UserManagerException * - Component related exception. * @exception java.rmi.RemoteException * - Network related exception. */ public Vector getUsers(UserSearchParams p_searchParams, Project p_project) throws RemoteException, UserManagerException { Session session = HibernateUtil.getSession(); boolean filterUser = false; Vector<UserImpl> us = new Vector<UserImpl>(); Criteria c = session.createCriteria(UserImpl.class); String userId = p_searchParams.getIdName(); if (userId != null && userId.length() > 0) { filterUser = true; c.add(Restrictions.or(Restrictions.ilike("userId", "%" + userId + "%"), Restrictions.ilike("userName", "%" + userId + "%"))); } String firstName = p_searchParams.getFirstName(); if (firstName != null && firstName.length() > 0) { filterUser = true; c.add(Restrictions.eq("firstName", firstName)); } String lastName = p_searchParams.getLastName(); if (lastName != null && lastName.length() > 0) { filterUser = true; c.add(Restrictions.eq("lastName", lastName)); } String email = p_searchParams.getEmail(); if (email != null && email.length() > 0) { filterUser = true; c.add(Restrictions.eq("email", email)); } if (filterUser) { us.addAll(c.list()); } boolean filterRole = false; Criteria cc = session.createCriteria(ContainerRoleImpl.class); Criteria uc = session.createCriteria(UserRoleImpl.class); String sourceLocale = p_searchParams.getSourceLocaleParam(); if (sourceLocale != null && sourceLocale.length() > 0) { filterRole = true; cc.add(Restrictions.eq("sourceLocale", sourceLocale)); uc.add(Restrictions.eq("sourceLocale", sourceLocale)); } String targetLocale = p_searchParams.getTargetLocaleParam(); if (targetLocale != null && targetLocale.length() > 0) { filterRole = true; cc.add(Restrictions.eq("targetLocale", targetLocale)); uc.add(Restrictions.eq("targetLocale", targetLocale)); } if (filterRole) { List uids = new ArrayList(); cc.add(Restrictions.eq("state", User.State.ACTIVE)); uc.add(Restrictions.eq("state", User.State.ACTIVE)); List<ContainerRoleImpl> crs = cc.list(); List<UserRoleImpl> urs = uc.list(); for (ContainerRoleImpl cr : crs) { uids.addAll(cr.getUserIds()); } for (UserRoleImpl ur : urs) { uids.add(ur.getUser()); } if (uids.size() > 0) { c = session.createCriteria(UserImpl.class); c.add(Restrictions.in("userId", uids)); us.addAll(c.list()); } } return us; // return getUsers(p_userAttrs, p_roleAttrs, null, p_project); }
From source file:edu.ku.brc.specify.utilapps.RegProcessor.java
/** * @return/*from w w w. ja v a 2 s . com*/ */ public List<Pair<String, String>> getAllKeyDescPairs() { Vector<Pair<String, String>> list = new Vector<Pair<String, String>>(); list.add(new Pair<String, String>("num_co", "Collections")); list.add(new Pair<String, String>("num_tx", "Taxon Records")); list.add(new Pair<String, String>("num_txu", "Taxon Records Used")); list.add(new Pair<String, String>("num_geo", "Geography Records")); list.add(new Pair<String, String>("num_geou", "Geography Records Used")); list.add(new Pair<String, String>("num_loc", "Locality Records")); list.add(new Pair<String, String>("num_locgr", "Locality Records Used")); list.add(new Pair<String, String>("num_preps", "Preparations Records")); list.add(new Pair<String, String>("num_prpcnt", "Count of Preparations")); list.add(new Pair<String, String>("num_litho", "Lithostratigraphy Records")); list.add(new Pair<String, String>("num_lithou", "Lithostratigraphy Records Used")); list.add(new Pair<String, String>("num_gtp", "Chronostratigraphy Records")); list.add(new Pair<String, String>("num_gtpu", "Chronostratigraphy Records Used")); list.add(new Pair<String, String>("Phone", "Phone")); list.add(new Pair<String, String>("Address", "Address")); list.add(new Pair<String, String>("Institution_number", "Institution Number")); list.add(new Pair<String, String>("Institution_name", "Institution")); list.add(new Pair<String, String>("Division_number", "Division Number")); list.add(new Pair<String, String>("Division_name", "Division")); list.add(new Pair<String, String>("Discipline_number", "Discipline Number")); list.add(new Pair<String, String>("Discipline_type", "Discipline")); list.add(new Pair<String, String>("Collection_name", "Collection Name")); list.add(new Pair<String, String>("Collection_number", "Collection Number")); list.add(new Pair<String, String>("Collection_estsize", "Collection Estimated Size")); list.add(new Pair<String, String>("reg_number", "Registration Number")); list.add(new Pair<String, String>("id", "Id")); list.add(new Pair<String, String>("last_used_date", "Last Opened Date")); list.add(new Pair<String, String>("hostname", "Host Name")); list.addAll(getRegKeyDescPairs()); list.addAll(getTrackKeyDescPairs()); return list; }
From source file:com.geminimobile.web.SearchController.java
@Override protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException arg3) throws Exception { SearchCommand cmd = (SearchCommand) command; ModelAndView mav = new ModelAndView(getSuccessView()); CDRDataAccess cdrAccess = new CDRDataAccess(); Date toDate = SearchCommand.m_sdf.parse(cmd.getToDate()); long maxTimestamp = toDate.getTime(); Date fromDate = SearchCommand.m_sdf.parse(cmd.getFromDate()); long minTimestamp = fromDate.getTime(); String msisdn = cmd.getMsisdn(); String action = cmd.getAction(); Vector<CDREntry> cdrs; if (action.compareToIgnoreCase("downloadcsv") == 0) { if (msisdn != null && msisdn.length() > 0) { cdrs = cdrAccess.getCDRsByMSISDN(cmd.getMsisdn(), minTimestamp, maxTimestamp, cmd.getMarket(), cmd.getMessageType(), 100000); // 100,000 entries max } else {/*ww w .j a v a 2s.co m*/ cdrs = cdrAccess.getCDRsByHour(minTimestamp, maxTimestamp, cmd.getMarket(), cmd.getMessageType(), MAX_ENTRIES_PER_PAGE); } StringBuffer sb = new StringBuffer(); // Write column headers sb.append("Date/Time,Market,Type,MSISDN,MO IP address,MT IP Address,Sender Domain,Recipient Domain\n"); for (CDREntry entry : cdrs) { sb.append(entry.getDisplayTimestamp() + "," + entry.getMarket() + "," + entry.getType() + "," + entry.getMsisdn() + "," + entry.getMoIPAddress() + "," + entry.getMtIPAddress() + "," + entry.getSenderDomain() + "," + entry.getRecipientDomain() + "\n"); } String csvString = sb.toString(); response.setBufferSize(sb.length()); response.setContentLength(sb.length()); response.setContentType("text/plain; charset=UTF-8"); //response.setContentType( "text/csv" ); //response.setContentType("application/ms-excel"); //response.setHeader("Content-disposition", "attachment;filename=cdrResults.csv"); response.setHeader("Content-Disposition", "attachment; filename=" + "cdrResults.csv" + ";"); ServletOutputStream os = response.getOutputStream(); os.write(csvString.getBytes()); os.flush(); os.close(); return null; } else if (action.compareToIgnoreCase("graph") == 0) { cmd.setGraph(true); List<ChartSeries> chartData; if (msisdn != null && msisdn.length() > 0) { chartData = cdrAccess.getChartDataByMSISDN(cmd.getMsisdn(), minTimestamp, maxTimestamp, cmd.getMarket(), cmd.getMessageType(), 100000); } else { chartData = cdrAccess.getChartDataByHour(minTimestamp, maxTimestamp, cmd.getMarket(), cmd.getMessageType(), 100000); } request.getSession().setAttribute("chartData", chartData); } else if (action.compareToIgnoreCase("getmore") == 0) { cdrs = (Vector<CDREntry>) request.getSession().getAttribute("currentcdrs"); int numCDRs = cdrs.size(); CDREntry lastCDR = cdrs.get(numCDRs - 1); long lastCDRTime = Long.parseLong(lastCDR.getTimestamp()); if (msisdn != null && msisdn.length() > 0) { Vector<CDREntry> moreCDRs = cdrAccess.getCDRsByMSISDN(cmd.getMsisdn(), lastCDRTime, maxTimestamp, cmd.getMarket(), cmd.getMessageType(), MAX_ENTRIES_PER_PAGE); cdrs.addAll(moreCDRs); } else { Vector<CDREntry> moreCDRs = cdrAccess.getCDRsByHour(lastCDRTime, maxTimestamp, cmd.getMarket(), cmd.getMessageType(), MAX_ENTRIES_PER_PAGE); cdrs.addAll(moreCDRs); } request.getSession().setAttribute("currentcdrs", cdrs); mav.addObject("cdrs", cdrs); } else { // Normal search if (msisdn != null && msisdn.length() > 0) { cdrs = cdrAccess.getCDRsByMSISDN(cmd.getMsisdn(), minTimestamp, maxTimestamp, cmd.getMarket(), cmd.getMessageType(), MAX_ENTRIES_PER_PAGE); } else { cdrs = cdrAccess.getCDRsByHour(minTimestamp, maxTimestamp, cmd.getMarket(), cmd.getMessageType(), MAX_ENTRIES_PER_PAGE); } request.getSession().setAttribute("currentcdrs", cdrs); mav.addObject("cdrs", cdrs); } mav.addObject("searchCmd", cmd); List<Option> msgOptions = getMessageOptions(); mav.addObject("msgTypes", msgOptions); List<Option> marketOptions = getMarketOptions(); mav.addObject("marketTypes", marketOptions); return mav; }
From source file:org.openbravo.erpCommon.modules.ImportModule.java
/** * Returns all the modules and dependencies described within the obx file (as InputStream) * /*ww w. j ava 2s.com*/ * Used to check dependencies in local installation * * @param dModulesToInstall * @param dDependencies * @param obx * @param merges * (output param) It contains all the merges defines in the obx as * (MergedModuleId,MergedBy) * @throws Exception */ private void getModulesFromObx(Vector<DynaBean> dModulesToInstall, Vector<DynaBean> dDependencies, Vector<DynaBean> dDBprefix, InputStream obx, Map<String, String> merges) throws Exception { final ZipInputStream obxInputStream = new ZipInputStream(obx); ZipEntry entry = null; boolean foundAll = false; boolean foundModule = false; boolean foundDependency = false; boolean foundPrefix = false; boolean foundMerge = false; while (((entry = obxInputStream.getNextEntry()) != null) && !foundAll) { if (entry.getName().endsWith(".obx")) { // If it is a new module, install it final ByteArrayInputStream ba = getCurrentEntryStream(obxInputStream); obxInputStream.closeEntry(); getModulesFromObx(dModulesToInstall, dDependencies, dDBprefix, ba, merges); } else if (entry.getName().replace("\\", "/").endsWith("src-db/database/sourcedata/AD_MODULE.xml")) { final Vector<DynaBean> module = getEntryDynaBeans(getBytesCurrentEntryStream(obxInputStream)); boolean isPackage = false; if (module != null && module.size() > 0) { isPackage = !((String) module.get(0).get("TYPE")).equals("M"); } dModulesToInstall.addAll(module); obxInputStream.closeEntry(); foundModule = true && !isPackage; } else if (entry.getName().replace("\\", "/") .endsWith("src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml")) { dDependencies.addAll(getEntryDynaBeans(getBytesCurrentEntryStream(obxInputStream))); obxInputStream.closeEntry(); foundDependency = true; } else if (entry.getName().replace("\\", "/") .endsWith("src-db/database/sourcedata/AD_MODULE_DBPREFIX.xml")) { dDBprefix.addAll(getEntryDynaBeans(getBytesCurrentEntryStream(obxInputStream))); obxInputStream.closeEntry(); foundPrefix = true; } else if (entry.getName().replace("\\", "/") .endsWith("/src-db/database/sourcedata/AD_MODULE_MERGE.xml")) { Vector<DynaBean> dynMerges = getEntryDynaBeans(getBytesCurrentEntryStream(obxInputStream)); for (DynaBean merge : dynMerges) { merges.put((String) merge.get("MERGED_MODULE_UUID"), (String) merge.get("AD_MODULE_ID")); } obxInputStream.closeEntry(); foundMerge = true; } else { obxInputStream.closeEntry(); } foundAll = foundModule && foundDependency && foundPrefix && foundMerge; } obxInputStream.close(); }