List of usage examples for java.util ArrayList addAll
public boolean addAll(Collection<? extends E> c)
From source file:com.viseur.control.MoreTailoredIdeas.java
/** * Handles the HTTP <code>GET</code> method. * * @param request servlet request/*from ww w. j a v a2 s . c om*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { JSONObject json = new JSONObject(); int last = Integer.valueOf(request.getParameter("last")); ArrayList<Idea> suggested = new ArrayList<>(); String htmlContent = ""; HttpSession session = request.getSession(); User reg = (User) session.getAttribute("user"); suggested.addAll(new Developer(reg).getRelativeIdeas(last)); for (Idea ideaN : suggested) { String tags = ""; if (!ideaN.oSys.isEmpty()) { for (int key : ideaN.oSys.keySet()) { tags += "<label class='label label-info'>" + ideaN.oSys.get(key) + "</label> "; } } if (!ideaN.langs.isEmpty()) { for (int key : ideaN.langs.keySet()) { tags += "<label class='label label-default'> " + ideaN.langs.get(key) + "</label> "; } } if (!ideaN.platforms.isEmpty()) { for (int key : ideaN.platforms.keySet()) { tags += "<label class='label label-primary'>" + ideaN.platforms.get(key) + "</label> "; } } htmlContent += "<div class='col-sm-6 col-md-4'><div class='thumbnail'><h6><span class='label label-default pull-right'>" + ideaN.ideaStatus + "</span></h6><div class='caption'><div class='row'>" + "<div class='col-md-12 col-xs-12 idea_title'><h3>" + ideaN.title + "</h3></div></div>" + "<p class='idea_desc'>" + ideaN.itemShortDesc + "</p><div class='row'><div class='col-md-6'><h6 class=''>" + "<span class='glyphicon glyphicon-eye-open'></span>" + ideaN.visted + "VIEWS</h6></div>" + "<div class='col-md-6'><h6 class=''><span class='glyphicon glyphicon-fire'></span>" + ideaN.buzzedTimes + "BUZZES</h6></div></div><div class='row'><div class='col-md-12'>" + tags + "</div></div></div><a href='" + VHost.ROOT + "/viewidea.jsp?idea=" + ideaN.itemId + "' class='btn btn-primary btn-block'>" + " View</a></div></div>"; } json.put("last", last + suggested.size()); json.put("htmlContent", htmlContent); try (PrintWriter out = response.getWriter()) { out.println(json); out.flush(); } }
From source file:org.hbird.business.navigation.processors.orekit.OrekitContactPredictor.java
@Handler public ContactPredictionRequest<ContactData> predict(ContactPredictionRequest<ContactData> request) throws OrekitException { Propagator propagator = propagatorProvider.getPropagator(request); ContactPredictionConfiguration conf = request.getConfiguration(); List<GroundStation> gsList = request.getGroundStations(); TleOrbitalParameters tleParameters = request.getTleParameters(); String satelliteId = conf.getSatelliteId(); Frame inertrialFrame = frameProvider.getInertialFrame(); for (GroundStation gs : gsList) { String gsId = gs.getID(); String gsName = gs.getName(); int elevation = 0; // TODO - 16.05.2013, kimmell - make it configurable GeoLocation location = gs.getGeoLocation(); GeodeticPoint point = NavigationUtilities.toGeodeticPoint(location); TopocentricFrame frame = new TopocentricFrame(Constants.earth, point, gsName); EventDetector detector = new ContactEventCollector(issuerId, elevation, frame, satelliteId, gsId, tleParameters, publisher, inertrialFrame); propagator.addEventDetector(detector); }//from w w w .ja v a 2 s . co m long start = request.getStartTime(); long end = request.getEndTime(); AbsoluteDate startDate = new AbsoluteDate(new Date(start), TimeScalesFactory.getUTC()); AbsoluteDate endDate = new AbsoluteDate(new Date(end), TimeScalesFactory.getUTC()); LOG.debug("Predicting contacts for satelliteId '{}' and {} ground stations", satelliteId, gsList.size()); long startPredcition = System.currentTimeMillis(); propagator.propagate(startDate, endDate); long endPredcition = System.currentTimeMillis(); ArrayList<ContactData> result = new ArrayList<ContactData>(); for (EventDetector ed : propagator.getEventsDetectors()) { ContactEventCollector cec = (ContactEventCollector) ed; result.addAll(cec.getDataSet()); } LOG.debug("Prediciont completed in {} ms; calculated {} LocationContactEvents", (endPredcition - startPredcition), result.size()); request.setPredictedEvents(result); return request; }
From source file:ch.puzzle.itc.mobiliar.business.generator.control.extracted.templates.TemplateProcessorBaseTest.java
protected int getGeneratedTemplateSize() { ArrayList<GeneratedTemplate> templates = new ArrayList<GeneratedTemplate>(); for (GenerationUnitGenerationResult result : generationResults) { templates.addAll(result.getGeneratedTemplates()); }/*from w w w . j av a 2 s .c om*/ return templates.size(); }
From source file:com.blackducksoftware.integration.hub.detect.workflow.codelocation.CodeLocationNameGenerator.java
private String createCommonName(final String prefix, final List<String> namePieces, final String suffix, final List<String> endPieces) { final ArrayList<String> commonNamePieces = new ArrayList<>(); if (StringUtils.isNotBlank(prefix)) { commonNamePieces.add(prefix);/* w w w. j a va 2s. c o m*/ } commonNamePieces.addAll(namePieces); if (StringUtils.isNotBlank(suffix)) { commonNamePieces.add(suffix); } final String name = StringUtils.join(commonNamePieces, "/"); final String endPiece = StringUtils.join(endPieces, "/"); return String.format("%s %s", name, endPiece); }
From source file:FileGameAccess.java
@SuppressWarnings("unchecked") @Override//ww w .ja v a2 s .c o m public Collection<ICommand> getAllCommands(int gameId) { ArrayList<ICommand> commands = new ArrayList<>(); Collection<ICommand> o = (Collection<ICommand>) this.loadSerializable(gameId + ".commands"); if (o != null) commands.addAll(o); return commands; }
From source file:flink.iso8583.MessageFactory.java
/** Sets a map with the fields that are to be expected when parsing a certain type of * message.//from w ww.j a va 2 s. co m * @param type The message type. * @param map A map of FieldParseInfo instances, each of which define what type and length * of field to expect. The keys will be the field numbers. */ public void setParseMap(Integer type, Map map) { parseMap.put(type, map); ArrayList index = new ArrayList(); index.addAll(map.keySet()); Collections.sort(index); log.trace("Adding parse map for type " + Integer.toHexString(type.intValue()) + " with fields " + index); parseOrder.put(type, index); }
From source file:org.openmrs.module.openhmis.inventory.api.impl.StockroomDataServiceImpl.java
@Override protected Collection<? extends OpenmrsObject> getRelatedObjects(Stockroom entity) { ArrayList<OpenmrsObject> results = new ArrayList<OpenmrsObject>(); results.addAll(entity.getOperations()); results.addAll(entity.getItems());// w w w.ja va 2 s . c o m return results; }
From source file:cn.vlabs.duckling.vwb.service.config.impl.DomainServiceImpl.java
private Properties compact(Map<String, String> domains) { Properties prop = new Properties(); ArrayList<String> keys = new ArrayList<String>(); keys.addAll(domains.keySet()); Collections.sort(keys);/*from w ww .j av a 2 s .c o m*/ int id = 0; HashSet<String> valueSet = new HashSet<String>(); for (String key : keys) { String value = domains.get(key); if (!valueSet.contains(value) && isValidDomain(value)) { if (id == 0) { prop.put(KeyConstants.SITE_DOMAIN_KEY, value); } else { prop.put(KeyConstants.SITE_DOMAIN_KEY + "." + id, value); } id++; valueSet.add(value); } } return prop; }
From source file:eu.itesla_project.online.tools.ListForecastErrorsAnalysisTool.java
@Override public void run(CommandLine line) throws Exception { ForecastErrorsAnalysisConfig config = ForecastErrorsAnalysisConfig.load(); ForecastErrorsDataStorage feDataStorage = config.getForecastErrorsDataStorageFactoryClass().newInstance() .create();//ww w.j ava 2s . com List<ForecastErrorsAnalysisDetails> analysisList = feDataStorage.listAnalysis(); DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); Table table = new Table(5, BorderStyle.CLASSIC_WIDE); table.addCell("ID", new CellStyle(CellStyle.HorizontalAlign.center)); table.addCell("Date", new CellStyle(CellStyle.HorizontalAlign.center)); table.addCell("Errors Models", new CellStyle(CellStyle.HorizontalAlign.center)); table.addCell("Statistics", new CellStyle(CellStyle.HorizontalAlign.center)); table.addCell("Parameters", new CellStyle(CellStyle.HorizontalAlign.center)); for (ForecastErrorsAnalysisDetails analysis : analysisList) { ArrayList<TimeHorizon> mergedList = new ArrayList<TimeHorizon>(analysis.getForecastErrorsDataList()); mergedList.removeAll(analysis.getForecastErrorsStatisticsList()); mergedList.addAll(analysis.getForecastErrorsStatisticsList()); for (TimeHorizon timeHorizon : mergedList) { table.addCell(analysis.getAnalysisId()); table.addCell(formatter.print(analysis.getAnalysisDate())); if (analysis.getForecastErrorsDataList().contains(timeHorizon)) table.addCell(timeHorizon.getName()); else table.addCell("-"); if (analysis.getForecastErrorsStatisticsList().contains(timeHorizon)) table.addCell(timeHorizon.getName()); else table.addCell("-"); ForecastErrorsAnalyzerParameters parameters = feDataStorage.getParameters(analysis.getAnalysisId(), timeHorizon); if (parameters != null) { //table.addCell(parameters.toString().substring(32)); String value = parameters.toString().substring(32); while (value.length() > COLUMN_LENGTH) { table.addCell(value.substring(0, COLUMN_LENGTH), new CellStyle(CellStyle.HorizontalAlign.left)); table.addCell(" ", new CellStyle(CellStyle.HorizontalAlign.left)); table.addCell(" ", new CellStyle(CellStyle.HorizontalAlign.left)); table.addCell(" ", new CellStyle(CellStyle.HorizontalAlign.left)); table.addCell(" ", new CellStyle(CellStyle.HorizontalAlign.left)); value = value.substring(COLUMN_LENGTH); } table.addCell(value, new CellStyle(CellStyle.HorizontalAlign.left)); } else table.addCell("-"); } } System.out.println(table.render()); }
From source file:com.logicmonitor.ft.jxmtop.JMXTopMain.java
/** * @param args : arguments array/* w w w . j av a2 s .co m*/ * @return Run Parameter */ private static RunParameter ARGSAnalyser(String[] args) { Options options = new Options(); options.addOption(new Option("h", "help", false, "show this help message")) .addOption(new Option("u", true, "User name for remote process")) .addOption(new Option("p", true, "Password for remote process")) .addOption(new Option("f", true, "Path to the configure file")) .addOption(new Option("i", true, "Interval between two scan tasks, unit is second")) .addOption(new Option("a", false, "Show alias names instead of jmx paths")); CommandLineParser parser = new BasicParser(); RunParameter runParameter = new RunParameter(); ArrayList<JMXInPath> inputtedPaths = new ArrayList<JMXInPath>(); try { CommandLine cli = parser.parse(options, args); if (args.length == 0 || cli.hasOption('h')) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("jmxtop jmxURL [jmx path lists]", "To view statuses of jmx paths:", options, "[Use 'Esc' or 'q' or 'Ctrl-c' to exit top console]\n[Use Key UP and Key DOWN to change pages]\n@Support by LogicMonitor", true); exit(0); } runParameter.setValid(true); if (cli.hasOption('a')) { runParameter.setShowAliasTitle(true); } if (cli.hasOption('f')) { List<JMXInPath> paths_from_file = getPathsFromFile(cli.getOptionValue('f')); inputtedPaths.addAll(paths_from_file); } if (cli.hasOption('u')) { runParameter.setUsername(cli.getOptionValue('u')); } if (cli.hasOption('p')) { runParameter.setPassword(cli.getOptionValue('p')); } if (cli.hasOption('i')) { try { int interval = Integer.valueOf(cli.getOptionValue('i')); if (interval < 0) System.err.println("The interval value is negative! Using default set!"); else { runParameter.setInterval(interval); } } catch (Exception e) { runParameter.setValid(false); runParameter.setValidInfo( runParameter.getValidInfo() + "Argument after <-i> should be an integer\n"); } } List<String> others = cli.getArgList(); boolean jmxurl_found = false; for (String other : others) { if (other.toLowerCase().startsWith("service:jmx:")) { if (jmxurl_found) { runParameter.setValid(false); runParameter.setValidInfo(runParameter.getValidInfo() + "multiple jmxurl found\n"); return runParameter; } else { jmxurl_found = true; runParameter.setSurl(other.toLowerCase()); } } else { inputtedPaths.add(new JMXInPath(other)); } } if (!jmxurl_found) { runParameter.setValid(false); runParameter.setValidInfo(runParameter.getValidInfo() + "No jmxurl found. The jmxurl should start with \"service:jmx:\" \n"); } } catch (ParseException e) { e.printStackTrace(); runParameter.setValid(false); runParameter.setValidInfo(runParameter.getValidInfo() + "Exception caught while parse arguments!\n"); } if (inputtedPaths.isEmpty()) { runParameter.setValid(false); runParameter.setValidInfo(runParameter.getValidInfo() + "No jmx paths inputted"); } else { runParameter.setPaths(inputtedPaths); } return runParameter; }