List of usage examples for java.util List toString
public String toString()
From source file:com.odoo.orm.OSyncHelper.java
/** * Model info.//from www . j a va 2 s . c o m * * @param models * the models * @return the list */ public List<OValues> modelInfo(List<String> models) { List<OValues> models_list = new ArrayList<OValues>(); try { ODomain domain = new ODomain(); domain.add("name", "in", new JSONArray(models.toString())); JSONObject result = mOdoo.search_read("ir.module.module", getFields(mModel), domain.get()); JSONArray records = result.getJSONArray("records"); for (int i = 0; i < records.length(); i++) { JSONObject record = records.getJSONObject(i); OValues values = createValueRow(mModel, mModel.getColumns(false), record); models_list.add(values); } } catch (Exception e) { e.printStackTrace(); } return models_list; }
From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditN3GeneratorVTwo.java
/** * This is the method to use to substitute in URIs into variables of target N3 strings. * This takes into account multiple values that would be returned from a select list. * subInUris should no longer be used.//from ww w.j a v a2 s. co m * * It's important that the map contain String to List<String> mapping. * * Before values are sent in, all of the values for a variable should be placed within an array. * * The List n3targets will be modified. */ public void subInMultiUris(Map<String, List<String>> varsToVals, List<String> n3targets) { if (varsToVals == null || varsToVals.isEmpty() || n3targets == null) return; //for (String target : n3targets) { for (int i = 0; i < n3targets.size(); i++) { String result = n3targets.get(i); if (result == null) continue; Set<String> keySet = varsToVals.keySet(); for (String key : keySet) { List<String> values = varsToVals.get(key); if (values == null) { log.debug("skipping var " + key + " because value List is null"); continue; } else if (containsNullOrEmpty(values)) { //bdc34: what should we do if the list contains nulls or empty strings? //for now we just skip the whole key/var. //Maybe it would be useful to strip the nulls+empties out of the list? log.debug("skipping var " + key + " because it contains nulls or empty strings"); continue; } log.debug("The original value String is " + values.toString()); String valueString = org.apache.commons.lang.StringUtils.join(values, ">, <"); valueString = "<" + valueString + ">"; log.debug("The multiUri value String is " + valueString); result = subInNonBracketedURIS(key, valueString, result); } n3targets.set(i, result); } }
From source file:morphy.command.ClearmessagesCommand.java
public void process(String arguments, UserSession userSession) { /* clearmessages *//from ww w . j a v a 2s . c om will delete all of your messages. clearmessages 2 will delete your message #2. clearmessages DAV will delete all of your messages from DAV. clearmessages 4-7 will delete your messages 4 through 7. */ /* clearmessage 38-40 Messages 38-40 cleared. */ /* clearmessages 37-40 You have no messages 37-40. */ /* You have 36 messages (1 unread). Use "messages u" to view unread messages and "clearmessages *" to clear all. */ arguments = arguments.trim(); if (arguments.equals("")) { userSession.send(getContext().getUsage()); return; } else { if (!UserService.getInstance().isRegistered(userSession.getUser().getUserName())) { userSession.send("Only registered players can use the clearmessages command."); return; } int numMessages = 0; String query = "SELECT COUNT(*) FROM `messages` WHERE `to_user_id` = '" + userSession.getUser().getDBID() + "';"; ResultSet rs = DatabaseConnectionService.getInstance().getDBConnection().executeQueryWithRS(query); try { if (rs.next()) { numMessages = rs.getInt(1); } } catch (SQLException e) { e.printStackTrace(System.err); } if (numMessages == 0) { userSession.send("You have no messages."); return; } if (arguments.equals("*")) { // delete all messages query = "DELETE FROM `messages` WHERE `to_user_id` = '" + userSession.getUser().getDBID() + "'"; boolean executed = DatabaseConnectionService.getInstance().getDBConnection().executeQuery(query); if (executed) { userSession.send("Messages cleared."); return; } } if (StringUtils.isNumeric(arguments)) { // delete this message arguments += "-" + arguments; //return; } if (StringUtils.isAlpha(arguments)) { // delete all messages from this user int id = UserService.getInstance().getDBID(arguments); if (id == 0) { /* something failed */ userSession.send("There is no player matching the name " + arguments + "."); return; } else { /* clearmessages outrunyou You have no messages from OUTRUNYOU. */ String username = UserService.getInstance().correctCapsUsername(arguments); query = "SELECT `id` FROM `messages` WHERE `from_user_id` = '" + id + "' ORDER BY `id` ASC"; rs = DatabaseConnectionService.getInstance().getDBConnection().executeQueryWithRS(query); try { List<Integer> ids = new ArrayList<Integer>(); while (rs.next()) { ids.add(new Integer(rs.getInt(1))); } if (ids.size() == 0) { userSession.send("You have no messages from " + username + "."); return; } else { query = "DELETE FROM `messages` WHERE " + MessagesCommand.formatIdListForQuery("id", ids); boolean executed = DatabaseConnectionService.getInstance().getDBConnection() .executeQuery(query); if (executed) { userSession.send("Messages from " + username + " cleared."); return; } } } catch (SQLException e) { e.printStackTrace(System.err); } } return; } if (arguments.matches("[0-9]+\\-[0-9]+")) { // delete this range of messages List<Integer> list = MessagesCommand.expandRange(arguments); java.util.Collections.sort(list); query = "SELECT m.`id`,u1.`username`,`message`,`timestamp`,`read` " + "FROM `messages` m INNER JOIN `users` u1 ON (u1.`id` = m.`from_user_id`) " + "WHERE m.to_user_id = '" + userSession.getUser().getDBID() + "'" + "ORDER BY m.`id` ASC"; rs = DatabaseConnectionService.getInstance().getDBConnection().executeQueryWithRS(query); try { // the "ids" variable contains the actual message ids as stored in the database // and NOT the psuedo message number as the user thinks. List<Integer> ids = new ArrayList<Integer>(); List<Integer> rownums = new ArrayList<Integer>(); int rownum = 0; while (rs.next()) { rownum++; if (list.contains(rownum)) { ids.add(rs.getInt(1)); rownums.add(rownum); } } if (ids.size() > 0) { query = "DELETE FROM `messages` WHERE " + MessagesCommand.formatIdListForQuery("id", ids); boolean executed = DatabaseConnectionService.getInstance().getDBConnection() .executeQuery(query); if (executed) { userSession.send((rownums.size() == 1 ? "Message" : "Messages") + " " + rownums.toString() + " cleared."); return; } } else { userSession.send("You have no message" + (rownums.size() > 1 ? "s" : "") + " " + rownums.toString() + "."); return; } } catch (SQLException e) { e.printStackTrace(System.err); } return; } // if we've reached this point, nothing has been deleted, so invalid arguments. userSession.send(getContext().getUsage()); return; } }
From source file:de.tudarmstadt.ukp.dkpro.core.stanfordnlp.StanfordParser.java
/** * Processes the given text using the StanfordParser. * * @param aJCas/*from www.ja va 2 s.com*/ * the {@link JCas} to process * @see org.apache.uima.analysis_component.JCasAnnotator_ImplBase#process(org.apache.uima.jcas.JCas) */ @Override public void process(JCas aJCas) throws AnalysisEngineProcessException { modelProvider.configure(aJCas.getCas()); posMappingProvider.configure(aJCas.getCas()); constituentMappingProvider.configure(aJCas.getCas()); Type typeToParse; if (annotationTypeToParse != null) { typeToParse = aJCas.getCas().getTypeSystem().getType(annotationTypeToParse); } else { typeToParse = JCasUtil.getType(aJCas, Sentence.class); } FSIterator<Annotation> typeToParseIterator = aJCas.getAnnotationIndex(typeToParse).iterator(); // Iterator each Sentence or whichever construct to parse while (typeToParseIterator.hasNext()) { Annotation currAnnotationToParse = typeToParseIterator.next(); if (StringUtils.isBlank(currAnnotationToParse.getCoveredText())) { continue; } List<HasWord> tokenizedSentence = new ArrayList<HasWord>(); List<Token> tokens = new ArrayList<Token>(); // Split sentence to tokens for annotating indexes for (Token token : JCasUtil.selectCovered(Token.class, currAnnotationToParse)) { tokenizedSentence.add(tokenToWord(token)); tokens.add(token); } getContext().getLogger().log(FINE, tokenizedSentence.toString()); ParserGrammar parser = modelProvider.getResource(); Tree parseTree; try { if (tokenizedSentence.size() > maxTokens) { continue; } if (ptb3Escaping) { tokenizedSentence = CoreNlpUtils.applyPtbEscaping(tokenizedSentence, quoteBegin, quoteEnd); } // Get parse ParserQuery query = parser.parserQuery(); query.parse(tokenizedSentence); parseTree = query.getBestParse(); } catch (Exception e) { throw new AnalysisEngineProcessException(e); } // Create new StanfordAnnotator object StanfordAnnotator sfAnnotator = null; try { sfAnnotator = new StanfordAnnotator(new TreeWithTokens(parseTree, tokens)); sfAnnotator.setPosMappingProvider(posMappingProvider); sfAnnotator.setConstituentMappingProvider(constituentMappingProvider); } catch (Exception e) { getLogger().error("Unable to parse [" + currAnnotationToParse.getCoveredText() + "]"); throw new AnalysisEngineProcessException(e); } // Create Penn bracketed structure annotations if (writePennTree) { sfAnnotator.createPennTreeAnnotation(currAnnotationToParse.getBegin(), currAnnotationToParse.getEnd()); } // Create dependency annotations if (writeDependency) { doCreateDependencyTags(parser, sfAnnotator, parseTree, tokens); } // Create constituent annotations if (writeConstituent) { sfAnnotator.createConstituentAnnotationFromTree(parser.getTLPParams().treebankLanguagePack(), writePos); } } }
From source file:com.hortonworks.streamline.streams.service.TopologyComponentBundleResource.java
/** * List all component bundles registered for a type(SOURCE, SINK, etc) or only the ones that match query params * <p>/*from ww w.j a v a 2s . c o m*/ * GET api/v1/catalog/streams/componentbundles/SOURCE?name=kafkaSpoutComponent * </p> */ @GET @Path("/componentbundles/{component}") @Timed public Response listTopologyComponentBundlesForTypeWithFilter( @PathParam("component") TopologyComponentBundle.TopologyComponentType componentType, @Context UriInfo uriInfo, @Context SecurityContext securityContext) { SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_TOPOLOGY_COMPONENT_BUNDLE_USER); List<QueryParam> queryParams; MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); queryParams = WSUtils.buildQueryParameters(params); Collection<TopologyComponentBundle> topologyComponentBundles = catalogService .listTopologyComponentBundlesForTypeWithFilter(componentType, queryParams); if (topologyComponentBundles != null) { return WSUtils.respondEntities(topologyComponentBundles, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
From source file:com.square.client.gwt.server.test.StringConverterTest.java
/** * Test de recuperation des criteres.//from w ww . j av a 2s.c o m */ @SuppressWarnings("unchecked") @Test public void testRecupererCriteres() { final SimpleDateFormat sdf = new SimpleDateFormat(Messages.getString("StringConverterTest.34")); final Map<String, String> map = new HashMap<String, String>(); map.put("adresse", "uneAdresse"); map.put("dateNaissance", sdf.format(Calendar.getInstance().getTime())); map.put("idAgences", "java.lang.Long:1;5;8"); map.put("rechercheStricte", "true"); map.put("listeSorts", Messages.getString("StringConverterTest.43")); resetConverter(); final RemotePagingCriteriasDto<PersonneCriteresRechercheDto> criteres = (RemotePagingCriteriasDto<PersonneCriteresRechercheDto>) recupererCriteres( map, new PersonneCriteresRechercheDto()); final Calendar date = Calendar.getInstance(); final Calendar dateCopie = Calendar.getInstance(); date.clear(); date.set(dateCopie.get(Calendar.YEAR), dateCopie.get(Calendar.MONTH), dateCopie.get(Calendar.DAY_OF_MONTH)); final List<Long> idsAgences = new ArrayList<Long>(); idsAgences.add(1L); idsAgences.add(5L); idsAgences.add(8L); final List<RemotePagingSort> listeSorts = new ArrayList<RemotePagingSort>(); listeSorts.add(new RemotePagingSort("nom", RemotePagingSort.REMOTE_PAGING_SORT_DESC)); listeSorts.add(new RemotePagingSort("dateFin", RemotePagingSort.REMOTE_PAGING_SORT_ASC)); assertEquals(Messages.getString("StringConverterTest.46"), Messages.getString("StringConverterTest.47"), criteres.getCriterias().getAdresse()); assertEquals(Messages.getString("StringConverterTest.48"), date, criteres.getCriterias().getDateNaissance()); assertEquals(Messages.getString("StringConverterTest.49"), true, criteres.getCriterias().isRechercheStricte()); assertEquals(Messages.getString("StringConverterTest.50"), idsAgences.toString(), criteres.getCriterias().getIdAgences().toString()); boolean existTriNom = false; boolean existTriDateFin = false; for (RemotePagingSort remotePagingSort : listeSorts) { if (remotePagingSort.getSortField().equals("nom")) { assertEquals(Messages.getString("StringConverterTest.52"), RemotePagingSort.REMOTE_PAGING_SORT_DESC, remotePagingSort.getSortAsc()); existTriNom = true; } else if (remotePagingSort.getSortField().equals("dateFin")) { assertEquals(Messages.getString("StringConverterTest.54"), RemotePagingSort.REMOTE_PAGING_SORT_ASC, remotePagingSort.getSortAsc()); existTriDateFin = true; } else { fail(Messages.getString("StringConverterTest.55") + remotePagingSort.getSortField()); } } assertTrue(Messages.getString("StringConverterTest.56"), existTriNom); assertTrue(Messages.getString("StringConverterTest.57"), existTriDateFin); }
From source file:com.pinterest.teletraan.worker.ClusterReplacer.java
/** * Step 4. COMPLETING state should clean up hosts launched in INIT state * If found failed deploy asg hosts, use non-asg host to replace it. * No more launch activity in this state * If previous state failed/timeout/abort, should come to this state to do final clean up *///from w w w .j ava 2 s .co m private void processCompletingState(ClusterUpgradeEventBean eventBean) throws Exception { String clusterName = eventBean.getCluster_name(); if (StringUtils.isEmpty(eventBean.getHost_ids())) { LOG.info("Successfully completed COMPLETING state, move to COMPLETED state"); ClusterUpgradeEventBean updateBean = new ClusterUpgradeEventBean(); // Do not set status, leave it updateBean.setState(ClusterUpgradeEventState.COMPLETED); transitionState(eventBean.getId(), updateBean); updateClusterState(clusterName); return; } List<String> nonAsgHosts = Arrays.asList(eventBean.getHost_ids().split(",")); List<String> activeNonAsgHosts = hostInfoDAO.getRunningInstances(new ArrayList<>(nonAsgHosts)); if (activeNonAsgHosts.size() != activeNonAsgHosts.size()) { updateHostsInClusterEvent(eventBean.getId(), activeNonAsgHosts); } Collection<String> failedHosts = hostDAO.getFailedHostIdsByGroup(clusterName); List<String> failedDeployNonAsgHosts = new ArrayList<>(); List<String> failedDeployAsgHosts = new ArrayList<>(); for (String failedHost : failedHosts) { if (activeNonAsgHosts.contains(failedHost)) { failedDeployNonAsgHosts.add(failedHost); } else { failedDeployAsgHosts.add(failedHost); } } if (!failedDeployNonAsgHosts.isEmpty()) { activeNonAsgHosts.removeAll(failedDeployNonAsgHosts); clusterManager.terminateHosts(clusterName, failedDeployAsgHosts, true); LOG.info(String.format("Successfully terminated %d failed deploy non-asg hosts for cluster %s: %s", failedDeployNonAsgHosts.size(), clusterName, failedDeployAsgHosts.toString())); } if (!failedDeployAsgHosts.isEmpty() && !activeNonAsgHosts.isEmpty()) { int num = Math.min(failedDeployAsgHosts.size(), activeNonAsgHosts.size()); List<String> hostsToAttach = new ArrayList<>(activeNonAsgHosts.subList(0, num)); autoScalingManager.addInstancesToAutoScalingGroup(hostsToAttach, clusterName); activeNonAsgHosts.removeAll(hostsToAttach); LOG.info(String.format("Successfully attached %d hosts to cluster %s: %s", num, clusterName, hostsToAttach.toString())); List<String> hostsToTerminate = new ArrayList<>(failedDeployAsgHosts.subList(0, num)); clusterManager.terminateHosts(clusterName, hostsToTerminate, false); LOG.info(String.format("Successfully terminated %d failed deploy asg hosts in cluster %s: %s", num, clusterName, hostsToTerminate.toString())); } if (!activeNonAsgHosts.isEmpty()) { clusterManager.terminateHosts(clusterName, activeNonAsgHosts, true); LOG.info(String.format("Successfully terminated %d non asg hosts for cluster %s: %s", activeNonAsgHosts.size(), clusterName, activeNonAsgHosts.toString())); } LOG.info("Successfully completed COMPLETING state, move to COMPLETED state"); ClusterUpgradeEventBean updateBean = new ClusterUpgradeEventBean(); updateBean.setHost_ids(""); // Do not set status, leave it updateBean.setState(ClusterUpgradeEventState.COMPLETED); updateBean.setLast_worked_on(System.currentTimeMillis()); transitionState(eventBean.getId(), updateBean); updateClusterState(clusterName); }
From source file:com.flexive.tests.embedded.WorkflowTest.java
/** * Do some tests that caching works with transaction rollbacks * * @throws FxApplicationException if an error occured *//*from w w w.ja v a 2s. c om*/ @Test public void updateWorkflowCaching() throws FxApplicationException { long workflowId = createTestWorkflow(); try { WorkflowEdit editWorkflow = new WorkflowEdit(getEnvironment().getWorkflow(workflowId)); // add two valid steps editWorkflow.getSteps().add(new StepEdit( new Step(-1, StepDefinition.EDIT_STEP_ID, editWorkflow.getId(), myWorkflowACL.getId()))); editWorkflow.getSteps().add(new StepEdit( new Step(-2, StepDefinition.LIVE_STEP_ID, editWorkflow.getId(), myWorkflowACL.getId()))); // ... and an invalid route (which will cause a rollback after the steps have been added) editWorkflow.getRoutes().add(new Route(-1, UserGroup.GROUP_EVERYONE, -1, -10)); List<Step> cachedSteps = getEnvironment().getSteps(); try { workflowEngine.update(editWorkflow); Assert.fail("Should not be able to successfully create workflows with invalid routes."); } catch (Exception e) { Assert.assertEquals(cachedSteps, getEnvironment().getSteps(), "Steps should have been rollbacked.\nSteps before update: " + cachedSteps.toString() + "\nEnvironment: " + getEnvironment().getSteps()); } } finally { workflowEngine.remove(workflowId); } }
From source file:com.esd.cs.settings.YearAuditParameterController.java
/** * //from ww w .j a va 2 s.com * * @param request * @return */ @RequestMapping(value = "/list") @ResponseBody public Map<String, Object> list(@RequestParam(value = "page") Integer page, @RequestParam(value = "rows") Integer rows, HttpServletRequest request) { Map<String, Object> entity = new HashMap<>(); String year = request.getParameter("year"); try { AuditParameter auditParameter = new AuditParameter(); if (StringUtils.isNotBlank(year)) { auditParameter.setYear(year); } PaginationRecordsAndNumber<AuditParameter, Number> query = null; query = auditParameterService.getPaginationRecords(auditParameter, page, rows); Integer total = query.getNumber().intValue();// ?? List<Map<String, Object>> list = new ArrayList<>(); for (Iterator<AuditParameter> iterator = query.getRecords().iterator(); iterator.hasNext();) { AuditParameter it = iterator.next(); Map<String, Object> map = new HashMap<>(); map.put("id", it.getId());// id map.put("year", it.getYear());// map.put("areaCode", it.getArea().getName());// map.put("averageSalary", it.getAverageSalary());// map.put("putScale", it.getPutScale());// String payCloseDate = CalendarUtil.dateFormat(it.getPayCloseDate()); map.put("payCloseDate", payCloseDate);// list.add(map); } entity.put("total", total); entity.put("rows", list); logger.debug("total:{},rows:{}", total, list.toString()); } catch (Exception e) { logger.error("error{}", e); } return entity; }
From source file:com.odoo.core.rpc.wrapper.OdooWrapper.java
private void permRead(String model, List<Integer> ids, IOdooResponse callback, OdooSyncResponse backResponse) { try {/*from www .j a v a 2 s. com*/ OArguments args = new OArguments(); args.add(new JSONArray(ids.toString())); callMethod(model, "perm_read", args, null, null, callback, backResponse); } catch (JSONException e) { OdooLog.e(e, e.getMessage()); } }