List of usage examples for java.lang StringBuffer delete
@Override public synchronized StringBuffer delete(int start, int end)
From source file:org.malaguna.cmdit.service.reflection.ReflectionUtils.java
private String buildChangeMessage(PropertyDescriptor desc, String atributo, Object oldValue, Object newValue, String msgContext) {//from w w w .j a va 2s. c o m String result = null; if (msgContext != null) atributo = msgContext + atributo; if (Collection.class.isAssignableFrom(desc.getPropertyType())) { StringBuffer msgBuff = null; Collection<?> oldSetAux = (Collection<?>) oldValue; Collection<?> newSetAux = (Collection<?>) newValue; if ((oldSetAux != null && !oldSetAux.isEmpty()) || (newSetAux != null && !newSetAux.isEmpty())) { msgBuff = new StringBuffer("{" + atributo + "}"); } if (oldSetAux != null && newSetAux != null) { Collection<?> intersection = CollectionUtils.intersection(oldSetAux, newSetAux); Collection<?> nuevos = CollectionUtils.removeAll(newSetAux, intersection); Collection<?> borrados = CollectionUtils.removeAll(oldSetAux, intersection); if (nuevos != null && !nuevos.isEmpty()) { msgBuff.append("+++: "); for (Object element : nuevos) msgBuff.append(String.format("[%s], ", element.toString())); msgBuff.delete(msgBuff.length() - 2, msgBuff.length()); } if (borrados != null && !borrados.isEmpty()) { msgBuff.append("---: "); for (Object element : borrados) msgBuff.append(String.format("[%s], ", element.toString())); msgBuff.delete(msgBuff.length() - 2, msgBuff.length()); } } else if (oldSetAux != null && newSetAux == null) { if (!oldSetAux.isEmpty()) { msgBuff.append("+++: "); for (Object element : oldSetAux) msgBuff.append(String.format("[%s], ", element.toString())); msgBuff.delete(msgBuff.length() - 2, msgBuff.length()); } } else if (oldSetAux == null && newSetAux != null) { if (!newSetAux.isEmpty()) { msgBuff.append("---: "); for (Object element : newSetAux) msgBuff.append(String.format("[%s], ", element.toString())); msgBuff.delete(msgBuff.length() - 2, msgBuff.length()); } } if (msgBuff != null) result = msgBuff.toString(); } else { String format = "['%s' :: (%s) -> (%s)]"; result = String.format(format, atributo, (oldValue != null) ? oldValue.toString() : "null", (newValue != null) ? newValue.toString() : "null"); } return result; }
From source file:org.mulesoft.restx.clientapi.RestxServer.java
/** * Used to send requests to the server. The right headers are assembled and a * suitable HTTP method will be selected if not specified by the caller. * // ww w. j a va2 s .c o m * @param url The URL on the server to which the request should be sent. Since * this relies on an established server connection, the URL here is * just the path component of the URL (including possible query * parameters), starting with '/'. * @param data Any data we want to send with the request (in case of PUT or * POST). If data is specified, but no method is given, then the * method will default to POST. If a method is specified as well then * it must be POST or PUT. If no data should be sent then this should * be 'null'. * @param method The desired HTTP method of the request. * @param status The expected status. If the HTTP status from the server is * different than the expected status, an exception will be thrown. If * no status check should be performed then set this to 'null'. * @param headers A {@link HashMap<String, String>} in which any additional * request headers should be specified. For example: { "Accept" : * "application/json" }. The hash map will not be modified by this * method. * @return A {@link HttpResult} object with status and data that was returned by * the server. * @throws RestxClientException */ public HttpResult send(String url, String data, HttpMethod method, Integer status, HashMap<String, String> headers) throws RestxClientException { // Set default values for the method if nothing was specified. Depends on // whether we want to send data or not. if (method == null) { if (data == null) { method = HttpMethod.GET; } else { method = HttpMethod.POST; } } // Combine default headers with any additional headers if (headers == null) { headers = DEFAULT_REQ_HEADERS; } else { final HashMap<String, String> hm = new HashMap<String, String>(headers); for (final String name : DEFAULT_REQ_HEADERS.keySet()) { hm.put(name, DEFAULT_REQ_HEADERS.get(name)); } headers = hm; } URL fullUrl = null; HttpURLConnection conn = null; try { if (!url.startsWith("/")) { url = "/" + url; } fullUrl = new URL(serverUri + url); conn = (HttpURLConnection) fullUrl.openConnection(); // Set the request headers for (final Entry<String, String> header : headers.entrySet()) { conn.setRequestProperty(header.getKey(), header.getValue()); } // Set the request method conn.setRequestMethod(HttpMethod.toString(method)); // Send the message body if (data != null) { conn.setDoOutput(true); final OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); try { wr.write(data); } finally { wr.close(); } } // Get the response final BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; final StringBuffer buf = new StringBuffer(); while ((line = rd.readLine()) != null) { // For now we do nothing particularly efficient. We just assemble all // the data we get into a big string. buf.append(line); } rd.close(); final int respStatus = conn.getResponseCode(); if (status != null) { if (status != respStatus) { if (buf.length() > 256) { buf.delete(256, buf.length()); } throw new RestxClientException("Status code " + status + " was expected for request to '" + fullUrl + "'. Instead we received " + respStatus + " " + buf); } } return new HttpResult(conn.getResponseCode(), buf.toString()); } catch (final IOException e) { if (conn != null) { // This exception was thrown after we started to connect to the // server int code; String msg; try { // We may even have an initialised response already, in which // case // we are passing that information back to the caller. code = conn.getResponseCode(); msg = conn.getResponseMessage(); } catch (final IOException e1) { // The problem occurred before the response status in the HTTP // connection was initialised. code = HttpURLConnection.HTTP_INTERNAL_ERROR; msg = e.getMessage(); } if (status != null) { if (status != code) { throw new RestxClientException("Status code " + status + " was expected for request to '" + fullUrl + "'. Instead we received " + code); } } return new HttpResult(code, msg); } // The exception was thrown before we even initialised our connection throw new RestxClientException("Cannot connect with URI '" + fullUrl + "': " + e.getMessage()); } }
From source file:com.qut.middleware.delegator.openid.authn.impl.AuthnProcessorImpl.java
private void verifyOpenIDAuthnResponse(AuthnProcessorData processorData, List<AttributeType> esoeAttributes) throws OpenIDException, NoSuchAlgorithmException { ParameterList response;//w w w. ja v a 2 s . c o m DiscoveryInformation discovered; StringBuffer receivingURL; String queryString; VerificationResult verification; Identifier verified; AuthSuccess authSuccess; response = new ParameterList(processorData.getHttpRequest().getParameterMap()); /* Retrieve the stored discovery information */ discovered = (DiscoveryInformation) processorData.getHttpRequest().getSession() .getAttribute(ConfigurationConstants.OPENID_USER_SESSION_IDENTIFIER); /* Extract the receiving URL from the HTTP request */ receivingURL = processorData.getHttpRequest().getRequestURL(); /* * If a Layer 7 type device is offloading https change the recievingURL accordingly to ensure * correct verification */ if (httpsOffload) { receivingURL.delete(0, 4); receivingURL.insert(0, "https"); } queryString = processorData.getHttpRequest().getQueryString(); if (queryString != null && queryString.length() > 0) receivingURL.append("?").append(processorData.getHttpRequest().getQueryString()); /* Verify the response */ this.logger.debug("About to verify response, accepted at receivingURL of " + receivingURL + " server set return to as " + response.toString()); verification = manager.verify(receivingURL.toString(), response, discovered); verified = verification.getVerifiedId(); if (verified != null) { AttributeType esoeAttribute; MessageDigest algorithm; byte messageDigest[]; authSuccess = (AuthSuccess) verification.getAuthResponse(); /* * Merge verified ID to ESOE view, OpenID identifiers aren't really compatible with most applications as an * identifier, so we'll md5 hash them for presentation as uid */ algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); algorithm.update(verification.getVerifiedId().getIdentifier().getBytes()); messageDigest = algorithm.digest(); esoeAttribute = new AttributeType(); esoeAttribute.setNameFormat(AttributeFormatConstants.basic); esoeAttribute.setName(this.userIdentifier); esoeAttribute.getAttributeValues() .add(new String(Hex.encodeHex(messageDigest)) + ConfigurationConstants.OPENID_NAMESPACE); esoeAttributes.add(esoeAttribute); /* * Store openID identifier in attributes for use by applications */ esoeAttribute = new AttributeType(); esoeAttribute.setNameFormat(AttributeFormatConstants.basic); esoeAttribute.setName(ConfigurationConstants.OPENID_IDENTIFIER_ATTRIBUTE); esoeAttribute.getAttributeValues().add(verification.getVerifiedId().getIdentifier()); esoeAttributes.add(esoeAttribute); /* * Retrieve requested attributes (if provided, given low deployments of attribute exchange currently we * don't fail when this isn't presented) */ if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) { FetchResponse fetchResp = (FetchResponse) authSuccess.getExtension(AxMessage.OPENID_NS_AX); for (OpenIDAttribute attribute : this.requestedAttributes) { List<String> values = fetchResp.getAttributeValues(attribute.getLabel()); /* Merge to ESOE view */ esoeAttribute = new AttributeType(); esoeAttribute.setNameFormat(AttributeFormatConstants.basic); esoeAttribute.setName(attribute.getEsoeAttributeName()); for (String value : values) { esoeAttribute.getAttributeValues().add(attribute.getValuePrepend() + value); } esoeAttributes.add(esoeAttribute); } } } else { throw new OpenIDException("Attempt by manager to verify result returned null"); } }
From source file:analytics.storage.store2csv.java
@Override public void storeElementData(HashMap<String, Double> data, String metricName, String dataProvider, String analysisType, String headerColumn, Boolean fed) { // TODO Auto-generated method stub String sFileName = dataProvider + analysisType + ".csv"; Properties props = new Properties(); try {//from w w w . ja v a 2 s.c om props.load(new FileInputStream("configure.properties")); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); System.exit(-1); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); System.exit(-1); } File anls = new File(props.getProperty(AnalyticsConstants.resultsPath) + "Analysis_Results"); if (!anls.exists()) anls.mkdir(); File dir = new File(anls, dataProvider); if (!dir.exists()) dir.mkdir(); File file = new File(dir, sFileName); this.setElementDataFilePath(file.getAbsolutePath()); FileWriter writer = null; BufferedWriter bw = null; BufferedReader reader = null; try { if (file.exists() && isAppendData() == false) { if (fed == false) file.delete(); setAppend(true); } else if (!file.exists() && isAppendData() == false) setAppend(true); if (!file.exists() && isAppendData() == true) { writer = new FileWriter(file); bw = new BufferedWriter(writer); createHeaders(bw, metricName, headerColumn); Set<String> keySet = data.keySet(); Iterator<String> iterator = keySet.iterator(); StringBuffer key = new StringBuffer(); while (iterator.hasNext()) { // String key = iterator.next(); key.append(iterator.next()); // System.out.println(key); bw.append(key.toString()); bw.append(','); Double value = data.get(key.toString()); bw.append(String.valueOf(value)); bw.newLine(); key.delete(0, key.length()); } bw.close(); writer.close(); } else if (file.exists() && isAppendData() == true) { reader = new BufferedReader(new FileReader(file)); File temp = new File(dir, "temp.csv"); writer = new FileWriter(temp); bw = new BufferedWriter(writer); String line; int counter = 0; // Set<String> keySet = data.keySet(); // Iterator<String> iterator = keySet.iterator(); StringBuffer key = new StringBuffer(); while ((line = reader.readLine()) != null) { String[] split = line.split(","); // String key = split[0]; key.append(split[0]); if (counter == 0) { line = line + "," + metricName; bw.append(line); bw.newLine(); } else { Double value = data.get(key.toString()); // System.out.println("Appending key:" + key + // " value:" // + value); line = line + "," + value; // /System.out.println("Appending line:" + line); bw.append(line); bw.newLine(); } counter += 1; key.delete(0, key.length()); } bw.close(); writer.close(); FileUtils.copyFile(temp, file); temp.delete(); reader.close(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { if (bw != null) bw.close(); if (reader != null) reader.close(); if (writer != null) writer.close(); } catch (IOException ex) { ex.printStackTrace(); } } }
From source file:com.sfs.whichdoctor.dao.SavedSearchDAOImpl.java
/** * Used to get a Collection of SearchBean details for a public. * * @param filter the filter/*from w w w .j av a2s.c o m*/ * @param subtype the subtype * @param username the username * @return the collection * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final Collection<SearchBean> load(final String filter, final String subtype, final String username) throws WhichDoctorDaoException { final StringBuffer loadSearch = new StringBuffer(); ArrayList<Object> parameters = new ArrayList<Object>(); if (StringUtils.isNotBlank(filter)) { loadSearch.append(" AND (savedsearch.Name LIKE ? OR savedsearch.Description LIKE ?)"); parameters.add("%" + filter + "%"); parameters.add("%" + filter + "%"); } if (StringUtils.isNotBlank(subtype)) { loadSearch.append(" AND Type = ?"); parameters.add(subtype); } if (StringUtils.isNotBlank(username)) { loadSearch.append(" AND (savedsearch.UserDn = ? OR savedsearch.PublicSearch = true)"); parameters.add(username); } else { loadSearch.append(" AND savedsearch.publicSearch = true"); } if (loadSearch.length() > 0) { /* Delete the AND from the beginning of the search if defined */ final int subtract = 5; loadSearch.delete(0, subtract); loadSearch.insert(0, " WHERE "); } loadSearch.insert(0, this.getSQL().getValue("search/load")); loadSearch.append(" ORDER BY savedsearch.Name"); dataLogger.info("Retrieving saved public searches"); Collection<SearchBean> savedsearches = new ArrayList<SearchBean>(); try { savedsearches = this.getJdbcTemplateReader().query(loadSearch.toString(), parameters.toArray(), new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadSearch(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for search: " + ie.getMessage()); } return savedsearches; }
From source file:com.chinamobile.bcbsp.graph.GraphDataForDisk.java
@Override public void saveAllVertices(RecordWriter output) throws IOException, InterruptedException { for (int i = 0; i < sizeForAll(); i++) { Vertex<?, ?, Edge> vertex = getForAll(i); StringBuffer outEdges = new StringBuffer(); for (Edge edge : vertex.getAllEdges()) { outEdges.append(edge.getVertexID() + Constants.SPLIT_FLAG + edge.getEdgeValue() + Constants.SPACE_SPLIT_FLAG); }//from w w w . ja va 2 s .c o m if (outEdges.length() > 0) { int j = outEdges.length(); outEdges.delete(j - 1, j - 1); } output.write(new Text(vertex.getVertexID() + Constants.SPLIT_FLAG + vertex.getVertexValue()), new Text(outEdges.toString())); } }
From source file:org.apache.axis.transport.http.SimpleAxisWorker.java
/** * Read all mime headers, returning the value of Content-Length and * SOAPAction./*w w w . j a v a2 s . com*/ * @param is InputStream to read from * @param contentType The content type. * @param contentLocation The content location * @param soapAction StringBuffer to return the soapAction into * @param httpRequest StringBuffer for GET / POST * @param cookie first cookie header (if doSessions) * @param cookie2 second cookie header (if doSessions) * @param headers HTTP headers to transfer to MIME headers * @return Content-Length */ private int parseHeaders(NonBlockingBufferedInputStream is, byte buf[], StringBuffer contentType, StringBuffer contentLocation, StringBuffer soapAction, StringBuffer httpRequest, StringBuffer fileName, StringBuffer cookie, StringBuffer cookie2, StringBuffer authInfo, MimeHeaders headers) throws java.io.IOException { int n; int len = 0; // parse first line as GET or POST n = this.readLine(is, buf, 0, buf.length); if (n < 0) { // nothing! throw new java.io.IOException(Messages.getMessage("unexpectedEOS00")); } // which does it begin with? httpRequest.delete(0, httpRequest.length()); fileName.delete(0, fileName.length()); contentType.delete(0, contentType.length()); contentLocation.delete(0, contentLocation.length()); if (buf[0] == getHeader[0]) { httpRequest.append("GET"); for (int i = 0; i < n - 5; i++) { char c = (char) (buf[i + 5] & 0x7f); if (c == ' ') break; fileName.append(c); } log.debug(Messages.getMessage("filename01", "SimpleAxisServer", fileName.toString())); return 0; } else if (buf[0] == postHeader[0]) { httpRequest.append("POST"); for (int i = 0; i < n - 6; i++) { char c = (char) (buf[i + 6] & 0x7f); if (c == ' ') break; fileName.append(c); } log.debug(Messages.getMessage("filename01", "SimpleAxisServer", fileName.toString())); } else { throw new java.io.IOException(Messages.getMessage("badRequest00")); } while ((n = readLine(is, buf, 0, buf.length)) > 0) { if ((n <= 2) && (buf[0] == '\n' || buf[0] == '\r') && (len > 0)) break; // RobJ gutted the previous logic; it was too hard to extend for more headers. // Now, all it does is search forwards for ": " in the buf, // then do a length / byte compare. // Hopefully this is still somewhat efficient (Sam is watching!). // First, search forwards for ": " int endHeaderIndex = 0; while (endHeaderIndex < n && toLower[buf[endHeaderIndex]] != headerEnder[0]) { endHeaderIndex++; } endHeaderIndex += 2; // endHeaderIndex now points _just past_ the ": ", and is // comparable to the various lenLen, actionLen, etc. values // convenience; i gets pre-incremented, so initialize it to one less int i = endHeaderIndex - 1; // which header did we find? if (endHeaderIndex == lenLen && matches(buf, lenHeader)) { // parse content length while ((++i < n) && (buf[i] >= '0') && (buf[i] <= '9')) { len = (len * 10) + (buf[i] - '0'); } headers.addHeader(HTTPConstants.HEADER_CONTENT_LENGTH, String.valueOf(len)); } else if (endHeaderIndex == actionLen && matches(buf, actionHeader)) { soapAction.delete(0, soapAction.length()); // skip initial '"' i++; while ((++i < n) && (buf[i] != '"')) { soapAction.append((char) (buf[i] & 0x7f)); } headers.addHeader(HTTPConstants.HEADER_SOAP_ACTION, "\"" + soapAction.toString() + "\""); } else if (server.isSessionUsed() && endHeaderIndex == cookieLen && matches(buf, cookieHeader)) { // keep everything up to first ; while ((++i < n) && (buf[i] != ';') && (buf[i] != '\r') && (buf[i] != '\n')) { cookie.append((char) (buf[i] & 0x7f)); } headers.addHeader("Set-Cookie", cookie.toString()); } else if (server.isSessionUsed() && endHeaderIndex == cookie2Len && matches(buf, cookie2Header)) { // keep everything up to first ; while ((++i < n) && (buf[i] != ';') && (buf[i] != '\r') && (buf[i] != '\n')) { cookie2.append((char) (buf[i] & 0x7f)); } headers.addHeader("Set-Cookie2", cookie.toString()); } else if (endHeaderIndex == authLen && matches(buf, authHeader)) { if (matches(buf, endHeaderIndex, basicAuth)) { i += basicAuth.length; while (++i < n && (buf[i] != '\r') && (buf[i] != '\n')) { if (buf[i] == ' ') continue; authInfo.append((char) (buf[i] & 0x7f)); } headers.addHeader(HTTPConstants.HEADER_AUTHORIZATION, new String(basicAuth) + authInfo.toString()); } else { throw new java.io.IOException(Messages.getMessage("badAuth00")); } } else if (endHeaderIndex == locationLen && matches(buf, locationHeader)) { while (++i < n && (buf[i] != '\r') && (buf[i] != '\n')) { if (buf[i] == ' ') continue; contentLocation.append((char) (buf[i] & 0x7f)); } headers.addHeader(HTTPConstants.HEADER_CONTENT_LOCATION, contentLocation.toString()); } else if (endHeaderIndex == typeLen && matches(buf, typeHeader)) { while (++i < n && (buf[i] != '\r') && (buf[i] != '\n')) { if (buf[i] == ' ') continue; contentType.append((char) (buf[i] & 0x7f)); } headers.addHeader(HTTPConstants.HEADER_CONTENT_TYPE, contentLocation.toString()); } else { String customHeaderName = new String(buf, 0, endHeaderIndex - 2); StringBuffer customHeaderValue = new StringBuffer(); while (++i < n && (buf[i] != '\r') && (buf[i] != '\n')) { if (buf[i] == ' ') continue; customHeaderValue.append((char) (buf[i] & 0x7f)); } headers.addHeader(customHeaderName, customHeaderValue.toString()); } } return len; }
From source file:org.ourbeehive.mbp.util.JavaFormatter.java
public static String getDbStyle(String javaPhrase) { // The return value. StringBuffer javaWord = new StringBuffer(); StringBuffer dbPhrase = new StringBuffer(); String dbWord = null;// w ww .ja v a 2 s .com // Get "javaNameToDbName" cache from ctxCache. // Hashtable<String, String> javaNameToDbNameCache = CtxCacheFacade.getJavaNameToDbNameCache(); int len = javaPhrase.length(); char c = 0; for (int i = 0; i < len; i++) { c = javaPhrase.charAt(i); // Java Bean????"_" if (String.valueOf(c).equals(MapperElm.UNDER_LINE) == true) { continue; } if (Character.isLowerCase(c) == true || Character.isDigit(c) == true) { javaWord.append(c); if (i < len - 1) { continue; } } if (javaWord.length() != 0) { // Find corresponding dbWord with previous javaWord. // dbWord = javaNameToDbNameCache.get(javaWord.toString().toLowerCase()); dbWord = javaWord.toString().toUpperCase(); // if (dbWord != null) { if (dbPhrase.length() != 0) { dbPhrase.append(MapperElm.UNDER_LINE); } dbPhrase.append(dbWord); } // else { // // No need to look up others. // logger.warn("NO DB WORD: Fail to find corresponding DB word for " + "Java word '" + javaWord + "' in Java phrase '" + javaPhrase // + "'"); // return null; // } // Begin a new javaWord. javaWord.delete(0, javaWord.length()); if (Character.isUpperCase(c) == true) { javaWord.append(c); } } // javaWord.append(c); // Processing the last javaWord. // if (javaWord.length() != 0) { // // // Find corresponding dbWord with the last javaWord. // dbWord = fullNameToAbbrCache.get(javaWord.toString().toLowerCase()); // if (dbWord != null) { // if (dbPhrase.length() != 0) { // dbPhrase.append(MapperElm.UNDER_LINE); // } // dbPhrase.append(dbWord); // } else { // // No need to look up others. // logger.warn("NO DB WORD: Fail to find corresponding DB word for " + "Java word '" + javaWord + "' in Java phrase '" + javaPhrase // + "'"); // return null; // } // } return dbPhrase.toString(); }
From source file:com.gst.organisation.teller.service.TellerManagementReadPlatformServiceImpl.java
private String getTellerCriteria(final String sqlSearch, final Long tellerId) { final StringBuffer extraCriteria = new StringBuffer(200); if (sqlSearch != null) { extraCriteria.append(" and (").append(sqlSearch).append(")"); }// w w w . jav a 2 s . co m if (tellerId != null) { extraCriteria.append(" and teller_id = ").append(tellerId).append(" "); } // remove begin four letter including a space from the string. if (StringUtils.isNotBlank(extraCriteria.toString())) { extraCriteria.delete(0, 4); } return extraCriteria.toString(); }
From source file:com.glaf.report.web.springmvc.MxReportController.java
@RequestMapping("/edit") public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Map<String, Object> params = RequestUtils.getParameterMap(request); String reportId = ParamUtils.getString(params, "reportId"); Report report = null;//from w ww. ja v a2s . co m if (StringUtils.isNotEmpty(reportId)) { report = reportService.getReport(reportId); request.setAttribute("report", report); if (StringUtils.isNotEmpty(report.getChartIds())) { StringBuffer sb01 = new StringBuffer(); StringBuffer sb02 = new StringBuffer(); List<Chart> selecteds = new java.util.ArrayList<Chart>(); ChartQuery query = new ChartQuery(); List<Chart> list = chartService.list(query); request.setAttribute("unselecteds", list); List<String> selected = StringTools.split(report.getChartIds()); for (Chart c : list) { if (selected.contains(c.getId())) { selecteds.add(c); sb01.append(c.getId()).append(","); sb02.append(c.getSubject()).append(","); } } if (sb01.toString().endsWith(",")) { sb01.delete(sb01.length() - 1, sb01.length()); } if (sb02.toString().endsWith(",")) { sb02.delete(sb02.length() - 1, sb02.length()); } request.setAttribute("selecteds", selecteds); request.setAttribute("chartIds", sb01.toString()); request.setAttribute("chartNames", sb02.toString()); } if (StringUtils.isNotEmpty(report.getQueryIds())) { List<String> queryIds = StringTools.split(report.getQueryIds()); StringBuffer sb01 = new StringBuffer(); StringBuffer sb02 = new StringBuffer(); for (String queryId : queryIds) { QueryDefinition queryDefinition = queryDefinitionService.getQueryDefinition(queryId); if (queryDefinition != null) { sb01.append(queryDefinition.getId()).append(","); sb02.append(queryDefinition.getTitle()).append("[").append(queryDefinition.getId()) .append("],"); } } if (sb01.toString().endsWith(",")) { sb01.delete(sb01.length() - 1, sb01.length()); } if (sb02.toString().endsWith(",")) { sb02.delete(sb02.length() - 1, sb02.length()); } request.setAttribute("queryIds", sb01.toString()); request.setAttribute("queryNames", sb02.toString()); } } String view = request.getParameter("view"); if (StringUtils.isNotEmpty(view)) { return new ModelAndView(view, modelMap); } String x_view = ViewProperties.getString("report.edit"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/bi/report/edit", modelMap); }