List of usage examples for java.util LinkedHashMap get
public V get(Object key)
From source file:citation_prediction.CitationCore.java
/** * This function will take a list of WSB solutions and graph them. You can add solutions to the graph by saving * the return of the function the first time and passing it back in on the next call as the 'plot'. * /* w w w .j a va2s . c o m*/ * * @param data_in_days The citation data distributed mostly even in days (call fixdata function if data is in years). * @param m The average number of new references in each new paper for a journal. * @param plot The plot you would like the WSB solution plotted to. * @param graphTitle The title to display on the JPanel. * @param lineLegend The title of this curve. * @param wsbSolutions The list of WSB solutions to graph. * @param showGraph Display the graph to the user (generally called once all curves have been added.) * @param frame The frame to display the graph in. * @return A Panel containing the graph. */ public Plot2DPanel graphWSB(double[][] data_in_days, double m, Plot2DPanel plot, String graphTitle, String lineLegend, ArrayList<LinkedHashMap<String, Double>> wsbSolutions, boolean showGraph, JFrame frame) { //source of library: http://code.google.com/p/jmathplot/ int plotLength = data_in_days.length + (365 * 3); double[][] data_in_years = new double[plotLength][2]; //Translate the data into years instead of days for (int i = 0; i < data_in_days.length; i++) { data_in_years[i][0] = data_in_days[i][0] / 365; data_in_years[i][1] = data_in_days[i][1]; } for (int i = data_in_days.length; i < plotLength; i++) { data_in_years[i][0] = data_in_years[i - 1][0] + .025; data_in_years[i][1] = data_in_years[data_in_days.length - 1][1]; } if (plot == null) { plot = new Plot2DPanel(); plot.addScatterPlot("Actual Citations", data_in_years); //Plot the data } //Extract the timevalue column RealMatrix mdata = MatrixUtils.createRealMatrix(data_in_years); double[] tvalues = mdata.getColumn(0); double[] cvalues = new double[plotLength]; for (LinkedHashMap<String, Double> s : wsbSolutions) { //calculate their fitted y values for (int i = 0; i < plotLength; i++) { cvalues[i] = m * (Math.exp( s.get("lambda") * pnorm((Math.log(365 * tvalues[i]) - s.get("mu")) / s.get("sigma"))) - 1); } //Calculate the Ultimate Impact double c_impact = m * (Math.exp(s.get("lambda")) - 1); //plot the fit plot.addLinePlot("Ultimate Impact=" + c_impact + " :: " + lineLegend, tvalues, cvalues); } // put the PlotPanel in a JFrame, as a JPanel if (showGraph) { plot.setAxisLabel(0, "Time in Years"); plot.setAxisLabel(1, "Cumulative Citations"); //Uncomment these if you wish to have fixed axis. //plot.setFixedBounds(1, 0, 500); //plot.setFixedBounds(0, 0, 60); // Add the file Title BaseLabel filetitle = new BaseLabel(graphTitle, Color.GRAY, 0.5, 1.1); filetitle.setFont(new Font("Courier", Font.BOLD, 13)); plot.addPlotable(filetitle); plot.addLegend("SOUTH"); //JFrame frame = new JFrame(graphTitle); frame.setTitle(graphTitle); frame.setContentPane(plot); frame.setBounds(0, 0, 1000, 800); frame.setVisible(true); frame.repaint(); } return plot; }
From source file:com.example.rachid.myapplication.MyMeteor.java
public User getUserWithFacebook(String facebook_id) { // Get Database Database database = mMeteor.getDatabase(); // Get Collection name is "Users" Collection collection = database.getCollection(Users); Log.i(TAG, "ENTRO A MyMeteor:getUserWithFacebook:Collection: " + collection); // Get of Collection "Users" where Age of all users is equal to 30 Query query = collection.whereEqual("facebook_id", facebook_id); Document document = query.findOne(); Log.i(TAG, "ENTRO A MyMeteor:getUserWithFacebook:Document: " + document); // ---------------------------------------------------------------------------------------- String id = document.getId(); ArrayList emails = (ArrayList) document.getField("emails");//ArrayList de {LinkedHashMap} LinkedHashMap email_complete = (LinkedHashMap) emails.get(0); // email_complete = LinkedHashMap = {(String)address (boolean)verified} String email = (String) email_complete.get("address"); String user_name = (String) document.getField("username"); String password = null; //(String) document.getField("password"); String name = (String) document.getField("name"); String surname = (String) document.getField("surname"); String gender = (String) document.getField("gender"); String birthday = (String) document.getField("birthday"); String place = (String) document.getField("place"); String music_style = (String) document.getField("music_style"); String image = (String) document.getField("image"); String google_id = null; //(String) document.getField("google_id"); //String facebook_id = null; //(String) document.getField("facebook_id"); ArrayList<String> festivals_created = (ArrayList<String>) document.getField("festivals_created"); ArrayList<String> festivals_assisted = (ArrayList<String>) document.getField("festivals_assisted"); String location = MyState.getUser().getLocation(); String language = MyState.getUser().getLanguage(); // ---------------------------------------------------------------------------------------- return new User(id, email, user_name, password, name, surname, gender, birthday, place, music_style, image, google_id, facebook_id, festivals_created, festivals_assisted, location, language); }
From source file:com.example.rachid.myapplication.MyMeteor.java
public User getUserWithGoogle(String google_id) { // Get Database Database database = mMeteor.getDatabase(); // Get Collection name is "Users" Collection collection = database.getCollection(Users); Log.i(TAG, "ENTRO A MyMeteor:getUserWithGoogle:Collection: " + collection); // Get of Collection "Users" where Age of all users is equal to 30 Query query = collection.whereEqual("google_id", google_id); Document document = query.findOne(); Log.i(TAG, "ENTRO A MyMeteor:getUserWithGoogle:Document: " + document); // ---------------------------------------------------------------------------------------- String id = document.getId(); ArrayList emails = (ArrayList) document.getField("emails");//ArrayList de {LinkedHashMap} LinkedHashMap email_complete = (LinkedHashMap) emails.get(0); // email_complete = LinkedHashMap = {(String)address (boolean)verified} String email = (String) email_complete.get("address"); String user_name = (String) document.getField("username"); String password = null; //(String) document.getField("password"); String name = (String) document.getField("name"); String surname = (String) document.getField("surname"); String gender = (String) document.getField("gender"); String birthday = (String) document.getField("birthday"); String place = (String) document.getField("place"); String music_style = (String) document.getField("music_style"); String image = (String) document.getField("image"); //String google_id = null; //(String) document.getField("google_id"); String facebook_id = null; //(String) document.getField("facebook_id"); ArrayList<String> festivals_created = (ArrayList<String>) document.getField("festivals_created"); ArrayList<String> festivals_assisted = (ArrayList<String>) document.getField("festivals_assisted"); String location = MyState.getUser().getLocation(); String language = MyState.getUser().getLanguage(); // ---------------------------------------------------------------------------------------- return new User(id, email, user_name, password, name, surname, gender, birthday, place, music_style, image, google_id, facebook_id, festivals_created, festivals_assisted, location, language); }
From source file:aldenjava.opticalmapping.data.mappingresult.OptMapResultNode.java
public void trimResult(int step, LinkedHashMap<String, DataNode> optrefmap) { this.trimResult(step, optrefmap.get(mappedRegion.ref)); }
From source file:com.example.rachid.myapplication.MyMeteor.java
public User getUserWithId(String id) { // Get Database Database database = mMeteor.getDatabase(); // Get Collection name is "Users" Collection collection = database.getCollection(Users); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:Collection: " + collection); // Get of Collection "Users" where Age of all users is equal to 30 Document document = collection.getDocument(id); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:Document: " + document); //String email = (String) document.getField("email"); ArrayList emails = (ArrayList) document.getField("emails");//ArrayList de {LinkedHashMap} LinkedHashMap email_complete = (LinkedHashMap) emails.get(0); // email_complete = LinkedHashMap = {(String)address (boolean)verified} String email = (String) email_complete.get("address"); String user_name = (String) document.getField("username"); String password = null; //(String) document.getField("password"); String name = (String) document.getField("name"); String surname = (String) document.getField("surname"); String gender = (String) document.getField("gender"); String birthday = (String) document.getField("birthday"); String place = (String) document.getField("place"); String music_style = (String) document.getField("music_style"); String image = (String) document.getField("image"); String google_id = null; //(String) document.getField("google_id"); String facebook_id = null; //(String) document.getField("facebook_id"); ArrayList<String> festivals_created = (ArrayList<String>) document.getField("festivals_created"); ArrayList<String> festivals_assisted = (ArrayList<String>) document.getField("festivals_assisted"); String location = MyState.getUser().getLocation(); String language = MyState.getUser().getLanguage(); // IMPRIMIR LOS VALORES RECOGIDOS DE LA DB DEL SERVIDOR // ---------------------------------------------------------------------------------------- /*/*from w ww. j ava2 s.c o m*/ Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:ID: " + id); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:EMAIL: " + email); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:USER_NAME: " + user_name); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:PASSWORD: " + password); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:NAME: " + name); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:SURNAME: " + surname); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:GENDER: " + gender); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:BIRTHDAY: " + birthday); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:PLACE: " + place); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:MUSIC_STYLE: " + music_style); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:IMAGE: " + image); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:GOOGLE_ID: " + google_id); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:FACEBOOK_ID: " + facebook_id); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:FESTIVALS_CREATED: " + festivals_created); Log.i(TAG, "ENTRO A MyMeteor:getUserWithId:FESTIVALS_ASSISTED: " + festivals_assisted); */ // ---------------------------------------------------------------------------------------- return new User(id, email, user_name, password, name, surname, gender, birthday, place, music_style, image, google_id, facebook_id, festivals_created, festivals_assisted, location, language); }
From source file:jp.co.iidev.subartifact1.divider1.mojo.ArtifactDividerMojo.java
public void execute() throws MojoExecutionException { Artifact projArt = project.getArtifact(); Map<Dependency, Artifact> artifactsForDep = Maps.newHashMap(); projArt = project.getArtifact();/*from w w w. j a va 2 s. com*/ { List<Dependency> dep = project.getDependencies(); Set<Artifact> arts = project.getDependencyArtifacts(); for (Dependency dx : dep) { String grpid = dx.getGroupId(); String artid = dx.getArtifactId(); String clsf = dx.getClassifier(); for (Artifact art : arts) { boolean a = StringUtils.equals(art.getArtifactId(), artid); boolean g = StringUtils.equals(art.getGroupId(), grpid); boolean c = StringUtils.equals(art.getClassifier(), clsf); if (a && g && c) { artifactsForDep.put(dx, art); } } } } { String version = project.getVersion(); String groupId = project.getGroupId(); LinkedHashMap<File, Dependency> compiletimeClasspath = Maps.newLinkedHashMap(); File rtjar = Paths.get(System.getProperty("java.home"), "lib", "rt.jar").toFile(); Dependency rtjar_dummyDep = new Dependency(); { rtjar_dummyDep.setGroupId(SystemUtils.JAVA_VENDOR.replace(" ", ".")); rtjar_dummyDep.setVersion(SystemUtils.JAVA_RUNTIME_VERSION); rtjar_dummyDep.setArtifactId(SystemUtils.JAVA_RUNTIME_NAME); } File targetJar = project.getArtifact().getFile(); Dependency targetJarDep = new Dependency(); { targetJarDep.setArtifactId(project.getArtifactId()); targetJarDep.setGroupId(project.getGroupId()); targetJarDep.setVersion(project.getVersion()); targetJarDep.setClassifier(projArt.getClassifier()); } compiletimeClasspath.put(rtjar, rtjar_dummyDep); compiletimeClasspath.put(targetJar, targetJarDep); artifactsForDep.forEach((d, a) -> { compiletimeClasspath.put(a.getFile(), d); }); LoggableFactory lf = new LoggableFactory() { @Override public Loggable createLoggable(Class cx) { return new Loggable() { Logger l = LoggerFactory.getLogger(cx); @Override public void warn(String text) { l.warn(text); } @Override public void info(String text) { l.info(text); } @Override public void error(String text) { l.error(text); } @Override public void debug(String text) { l.debug(text); } }; } }; try { LinkedHashMap<SubArtifactDefinition, SubArtifactDeployment> buildPlan = new DivisionExecutor( lf.createLoggable(DivisionExecutor.class)).planDivision(targetJar, rootSubArtifactId, Arrays.asList(subartifacts == null ? new SubArtifact[0] : subartifacts), compiletimeClasspath, not(in(ImmutableSet.of(rtjar, targetJar))), defaultRootTransitivePropagations, defaultRootSourceReferencePropagations, defaultSubartifactSourceReferencePropagations, globalReferencePropagations, lf); Set<File> usableJar = Sets.newLinkedHashSet(compiletimeClasspath.keySet()); usableJar.remove(targetJar); usableJar.remove(rtjar); int ix = 0; for (SubArtifact s : subartifacts) { for (Dependency d : s.getExtraDependencies()) { buildPlan.get(s).getJarDeps().put(new File("x_xx_xyx_duMmy" + (ix++) + ".jar"), d); } } new PomSetGenerator(project.getBasedir().toPath().resolve("pom.xml"), outputDirectory.toPath(), templateOutputDirectory.toPath(), lf).generate(groupId, version, this.subArtifactsParentArtifactId, buildPlan); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new MojoExecutionException("division process error", e); } } }
From source file:com.thingsee.tracker.MainActivity.java
private void loadTrackers() { Log.d("Tracker", "loadTrackers()"); new KiiQueryTrackersAsyncTask(new KiiQueryTrackersAsyncTask.AsyncResponseQueryTrackers() { @Override//from w ww. java 2s. c o m public void processFinish(LinkedHashMap<String, TrackerModel> trackers) { for (String key : trackers.keySet()) { TrackerModel trackerModel = trackers.get(key); addTracker(trackerModel); Log.d("Tracker", "added Tracker, key:" + key + " name:" + trackerModel.getName() + " token:" + trackerModel.getThing().getCurrentAccessToken()); } trackersLoaded = true; } }, CommonConstants.KII_CLOUD_APP_ID, CommonConstants.KII_CLOUD_APP_KEY, getCurrentAccountAccessToken()) .execute(); }
From source file:de.helmholtz_muenchen.ibis.utils.abstractNodes.BinaryWrapperNode.BinaryWrapperNodeModel.java
/** * Returns the parameters which were set by the parameter file and the additional parameter field * and by the GUI. // www .j av a 2s . c o m * Override levels: GUI parameter -> additional parameter -> default parameter file * @param inData Input data tables * @return */ protected ArrayList<String> getSetParameters(final BufferedDataTable[] inData) { LinkedHashMap<String, String> pars = new LinkedHashMap<String, String>(); // merged parameter set // LinkedHashMap<String, String> parsFile = getParametersFromParameterFile(); // get parameter from file // LinkedHashMap<String, String> parsAdditional = getAdditionalParameter(); // get parameter from input field LinkedHashMap<String, String> parsGUI = getGUIParameters(inData); // get parameter from GUI // merge them all together // pars.putAll(parsFile); // pars.putAll(parsAdditional); pars.putAll(parsGUI); // build the command list ArrayList<String> commands = new ArrayList<String>(); for (Iterator<String> it = pars.keySet().iterator(); it.hasNext();) { // add parameter name String key = it.next(); if (key.length() > 0) { // add value, if some is set String value = pars.get(key); if (value.length() != 0) commands.add(key + " " + value); else commands.add(key); } } // return the commands return commands; }
From source file:org.openmeetings.app.installation.ImportInitvalues.java
/** * Loading initial Language from xml Files into database *//*from w ww.ja v a2s.co m*/ // ------------------------------------------------------------------------------ public void loadInitLanguages(String filePath) throws Exception { loadCountriesFiles(filePath); loadTimeZoneFiles(filePath); LinkedHashMap<Integer, LinkedHashMap<String, Object>> listlanguages = this.getLanguageFiles(filePath); boolean langFieldIdIsInited = false; /** Read all languages files */ for (Iterator<Integer> itLang = listlanguages.keySet().iterator(); itLang.hasNext();) { Integer langId = itLang.next(); LinkedHashMap<String, Object> lang = listlanguages.get(langId); log.debug("loadInitLanguages lang: " + lang); String langName = (String) lang.get("name"); String rtl = (String) lang.get("rtl"); String code = (String) lang.get("code"); log.debug("loadInitLanguages rtl from xml: " + rtl); Boolean langRtl = false; if (rtl != null && rtl.equals("true")) langRtl = true; Long languages_id = fieldLanguageDaoImpl.addLanguage(langName, langRtl, code); SAXReader reader = new SAXReader(); Document document = reader.read(new File(filePath, langName + ".xml")); Element root = document.getRootElement(); for (@SuppressWarnings("rawtypes") Iterator it = root.elementIterator("string"); it.hasNext();) { Element item = (Element) it.next(); // log.error(item.getName()); Long id = Long.valueOf(item.attributeValue("id")).longValue(); String name = item.attributeValue("name"); String value = ""; for (@SuppressWarnings("rawtypes") Iterator t2 = item.elementIterator("value"); t2.hasNext();) { Element val = (Element) t2.next(); value = val.getText(); } // log.error("result: "+langFieldIdIsInited+" "+id+" "+name+" "+value); Fieldvalues fv = null; // Only do that for the first field-set if (!langFieldIdIsInited) { fv = fieldmanagment.addFieldById(name, id); } else { fv = fieldmanagment.getFieldvaluesById(id); } fieldmanagment.addFieldValueByFieldAndLanguage(fv, languages_id, value); } log.debug("Lang ADDED: " + lang); if (!langFieldIdIsInited) langFieldIdIsInited = true; } }
From source file:com.baidu.rigel.biplatform.tesseract.isservice.search.service.impl.CallbackSearchServiceImpl.java
/** * @param context ?//from w w w. ja v a2 s .co m * @param query ? * @return * @throws IndexAndSearchException exception occurred when */ public SearchIndexResultSet query(QueryContext context, QueryRequest query) throws IndexAndSearchException { LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_BEGIN, "callbackquery", "[callbackquery:" + query + "]")); if (query == null || context == null || StringUtils.isEmpty(query.getCubeId())) { LOGGER.error(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_EXCEPTION, "callbackquery", "[callbackquery:" + query + "]")); throw new IndexAndSearchException( TesseractExceptionUtils.getExceptionMessage(IndexAndSearchException.QUERYEXCEPTION_MESSAGE, IndexAndSearchExceptionType.ILLEGALARGUMENT_EXCEPTION), IndexAndSearchExceptionType.ILLEGALARGUMENT_EXCEPTION); } // TODO ??? if (query.getGroupBy() == null || query.getSelect() == null) { return null; } Map<String, String> requestParams = ((QueryContextAdapter) context).getQuestionModel().getRequestParams(); // Build query target map Map<String, List<MiniCubeMeasure>> callbackMeasures = context.getQueryMeasures().stream() .filter(m -> m.getType().equals(MeasureType.CALLBACK)).map(m -> { CallbackMeasure tmp = (CallbackMeasure) m; for (Map.Entry<String, String> entry : tmp.getCallbackParams().entrySet()) { if (requestParams.containsKey(entry.getKey())) { tmp.getCallbackParams().put(entry.getKey(), requestParams.get(entry.getKey())); } } return m; }).collect(Collectors.groupingBy(c -> ((CallbackMeasure) c).getCallbackUrl(), Collectors.toList())); if (callbackMeasures == null || callbackMeasures.isEmpty()) { LOGGER.error(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_EXCEPTION, "Empty callback measure", "[callbackquery:" + query + "]")); throw new IndexAndSearchException( TesseractExceptionUtils.getExceptionMessage(IndexAndSearchException.QUERYEXCEPTION_MESSAGE, IndexAndSearchExceptionType.ILLEGALARGUMENT_EXCEPTION), IndexAndSearchExceptionType.ILLEGALARGUMENT_EXCEPTION); } LOGGER.info("Find callback targets " + callbackMeasures); // Keep group-by sequence. List<String> groupby = new ArrayList<String>(query.getGroupBy().getGroups()); LinkedHashMap<String, List<String>> groupbyParams = new LinkedHashMap<String, List<String>>(groupby.size()); for (String g : groupby) { groupbyParams.put(g, new ArrayList<String>()); } LinkedHashMap<String, List<String>> whereParams = new LinkedHashMap<String, List<String>>(); for (Expression e : query.getWhere().getAndList()) { List<String> l = e.getQueryValues().stream().filter(v -> !StringUtils.isEmpty(v.getValue())) .map(v -> v.getValue()).collect(Collectors.toList()); if (groupbyParams.containsKey(e.getProperties())) { // if not contains SUMMARY_KEY, add it into group by list if (!l.contains(TesseractConstant.SUMMARY_KEY)) { l.add(TesseractConstant.SUMMARY_KEY); } // Put it into group by field groupbyParams.get(e.getProperties()).addAll(l); } else { // Put it into filter field if (CollectionUtils.isEmpty(l)) { List<Set<String>> tmp = e.getQueryValues().stream().map(v -> v.getLeafValues()) .collect(Collectors.toList()); List<String> values = Lists.newArrayList(); tmp.forEach(t -> values.addAll(t)); whereParams.put(e.getProperties(), values); } else { whereParams.put(e.getProperties(), new ArrayList<String>(l)); } } } // Prepare query tools // CountDownLatch latch = new CountDownLatch(response.size()); // List<Future<CallbackResponse>> results = Lists.newArrayList(); Map<CallbackExecutor, Future<CallbackResponse>> results = Maps.newHashMap(); ExecutorCompletionService<CallbackResponse> service = new ExecutorCompletionService<CallbackResponse>( taskExecutor); StringBuilder callbackMeasureNames = new StringBuilder(); for (Entry<String, List<MiniCubeMeasure>> e : callbackMeasures.entrySet()) { CallbackExecutor ce = new CallbackExecutor(e, groupbyParams, whereParams); results.put(ce, service.submit(ce)); e.getValue().forEach(m -> { callbackMeasureNames.append(" " + m.getCaption() + " "); }); } // } Map<CallbackExecutor, CallbackResponse> response = new ConcurrentHashMap<CallbackExecutor, CallbackResponse>( callbackMeasures.size()); StringBuffer sb = new StringBuffer(); results.forEach((k, v) -> { try { response.put(k, v.get()); } catch (Exception e1) { LOGGER.error(e1.getMessage(), e1); sb.append(": " + callbackMeasureNames.toString() + " ??, ?"); } }); if (!StringUtils.isEmpty(sb.toString())) { if (ThreadLocalPlaceholder.getProperty(ThreadLocalPlaceholder.ERROR_MSG_KEY) != null) { ThreadLocalPlaceholder.unbindProperty(ThreadLocalPlaceholder.ERROR_MSG_KEY); } ThreadLocalPlaceholder.bindProperty(ThreadLocalPlaceholder.ERROR_MSG_KEY, sb.toString()); } // Package result SqlQuery sqlQuery = QueryRequestUtil.transQueryRequest2SqlQuery(query); SearchIndexResultSet result = null; if (!response.isEmpty()) { result = packageResultRecords(query, sqlQuery, response); } else { result = new SearchIndexResultSet(new Meta(query.getGroupBy().getGroups().toArray(new String[0])), 0); } LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_END, "query", "[query:" + query + "]")); return result; }