List of usage examples for java.lang StringBuilder delete
@Override public StringBuilder delete(int start, int end)
From source file:com.impetus.client.rdbms.query.RDBMSEntityReader.java
/** * /*from ww w . j a v a 2 s . c o m*/ * @param entityMetadata * @param primaryKeys * @param aliasName * @param queryBuilder * @param entityType */ private void onCondition(EntityMetadata entityMetadata, MetamodelImpl metamodel, Set<String> primaryKeys, String aliasName, StringBuilder queryBuilder, EntityType entityType) { if (primaryKeys == null) { for (Object o : conditions) { if (o instanceof FilterClause) { FilterClause clause = ((FilterClause) o); Object value = clause.getValue().get(0); String propertyName = clause.getProperty(); String condition = clause.getCondition(); if (StringUtils.contains(propertyName, '.')) { int indexOf = propertyName.indexOf("."); String jpaColumnName = propertyName.substring(0, indexOf); String embeddedColumnName = propertyName.substring(indexOf + 1, propertyName.length()); String fieldName = entityMetadata.getFieldName(jpaColumnName); Attribute attribute = entityType.getAttribute(fieldName); EmbeddableType embeddedType = metamodel .embeddable(((AbstractAttribute) attribute).getBindableJavaType()); Attribute embeddedAttribute = embeddedType.getAttribute(embeddedColumnName); addClause(entityMetadata, aliasName, queryBuilder, entityType, value, condition, fieldName, embeddedAttribute); } else { String fieldName = entityMetadata.getFieldName(propertyName); Attribute attribute = entityType.getAttribute(fieldName); if (metamodel.isEmbeddable(((AbstractAttribute) attribute).getBindableJavaType())) { EmbeddableType embeddedType = metamodel .embeddable(((AbstractAttribute) attribute).getBindableJavaType()); Set<Attribute> attributes = embeddedType.getAttributes(); for (Attribute embeddedAttribute : attributes) { Object embeddedAttributevalue = PropertyAccessorHelper.getObject(value, (Field) embeddedAttribute.getJavaMember()); addClause(entityMetadata, aliasName, queryBuilder, entityType, embeddedAttributevalue, condition, propertyName, embeddedAttribute); queryBuilder.append(" and "); } queryBuilder.delete(queryBuilder.lastIndexOf("and"), queryBuilder.lastIndexOf("and") + 3); } else if (((AbstractAttribute) entityMetadata.getIdAttribute()).getJPAColumnName() .equals(propertyName)) { addClause(entityMetadata, aliasName, queryBuilder, entityType, value, condition, propertyName, entityMetadata.getIdAttribute()); } else { addClause(entityMetadata, aliasName, queryBuilder, entityType, value, condition, propertyName, attribute); } } } else { queryBuilder.append(" "); queryBuilder.append(o); queryBuilder.append(" "); } } } else { queryBuilder.append(aliasName); queryBuilder.append("."); queryBuilder.append(((AbstractAttribute) entityMetadata.getIdAttribute()).getJPAColumnName()); queryBuilder.append(" "); queryBuilder.append("IN("); int count = 0; Attribute col = entityMetadata.getIdAttribute(); boolean isString = isStringProperty(entityType, col); for (String key : primaryKeys) { appendStringPrefix(queryBuilder, isString); queryBuilder.append(key); appendStringPrefix(queryBuilder, isString); if (++count != primaryKeys.size()) { queryBuilder.append(","); } else { queryBuilder.append(")"); } } } }
From source file:com.impetus.client.cassandra.query.CassQuery.java
/** * Builds where Clause./*w w w . j a v a 2 s.c o m*/ * * @param kunderaQuery * the kundera query * @param metadata * the metadata * @param metaModel * the meta model * @param translator * the translator * @param builder * the builder */ private void buildWhereClause(KunderaQuery kunderaQuery, EntityMetadata metadata, MetamodelImpl metaModel, CQLTranslator translator, StringBuilder builder) { for (Object clause : kunderaQuery.getFilterClauseQueue()) { FilterClause filterClause = (FilterClause) clause; Field f = (Field) metaModel.entity(metadata.getEntityClazz()) .getAttribute(metadata.getFieldName(filterClause.getProperty())).getJavaMember(); String jpaColumnName = getColumnName(metadata, filterClause.getProperty()); if (metaModel.isEmbeddable(metadata.getIdAttribute().getBindableJavaType())) { Field[] fields = metadata.getIdAttribute().getBindableJavaType().getDeclaredFields(); EmbeddableType compoundKey = metaModel.embeddable(metadata.getIdAttribute().getBindableJavaType()); for (Field field : fields) { if (field != null && !Modifier.isStatic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers()) && !field.isAnnotationPresent(Transient.class)) { Attribute attribute = compoundKey.getAttribute(field.getName()); String columnName = ((AbstractAttribute) attribute).getJPAColumnName(); Object value = PropertyAccessorHelper.getObject(filterClause.getValue().get(0), field); // TODO translator.buildWhereClause(builder, field.getType(), columnName, value, filterClause.getCondition(), false); } } } else { translator.buildWhereClause(builder, f.getType(), jpaColumnName, filterClause.getValue().get(0), filterClause.getCondition(), false); } } builder.delete(builder.lastIndexOf(CQLTranslator.AND_CLAUSE), builder.length()); }
From source file:org.apache.hadoop.yarn.server.webapp.AppsBlock.java
protected void renderData(Block html) { TBODY<TABLE<Hamlet>> tbody = html.table("#apps").thead().tr().th(".id", "ID").th(".user", "User") .th(".name", "Name").th(".type", "Application Type").th(".queue", "Queue") .th(".priority", "Application Priority").th(".starttime", "StartTime") .th(".finishtime", "FinishTime").th(".state", "State").th(".finalstatus", "FinalStatus") .th(".progress", "Progress").th(".ui", "Tracking UI")._()._().tbody(); StringBuilder appsTableData = new StringBuilder("[\n"); for (ApplicationReport appReport : appReports) { // TODO: remove the following condition. It is still here because // the history side implementation of ApplicationBaseProtocol // hasn't filtering capability (YARN-1819). if (!reqAppStates.isEmpty() && !reqAppStates.contains(appReport.getYarnApplicationState())) { continue; }/*w w w.j a v a2 s. com*/ AppInfo app = new AppInfo(appReport); String percent = StringUtils.format("%.1f", app.getProgress()); appsTableData.append("[\"<a href='").append(url("app", app.getAppId())).append("'>") .append(app.getAppId()).append("</a>\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(app.getUser()))) .append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(app.getName()))) .append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(app.getType()))) .append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(app.getQueue()))) .append("\",\"").append(String.valueOf(app.getPriority())).append("\",\"") .append(app.getStartedTime()).append("\",\"").append(app.getFinishedTime()).append("\",\"") .append(app.getAppState() == null ? UNAVAILABLE : app.getAppState()).append("\",\"") .append(app.getFinalAppStatus()).append("\",\"") // Progress bar .append("<br title='").append(percent).append("'> <div class='").append(C_PROGRESSBAR) .append("' title='").append(join(percent, '%')).append("'> ").append("<div class='") .append(C_PROGRESSBAR_VALUE).append("' style='").append(join("width:", percent, '%')) .append("'> </div> </div>").append("\",\"<a "); String trackingURL = app.getTrackingUrl() == null || app.getTrackingUrl().equals(UNAVAILABLE) ? null : app.getTrackingUrl(); String trackingUI = app.getTrackingUrl() == null || app.getTrackingUrl().equals(UNAVAILABLE) ? "Unassigned" : app.getAppState() == YarnApplicationState.FINISHED || app.getAppState() == YarnApplicationState.FAILED || app.getAppState() == YarnApplicationState.KILLED ? "History" : "ApplicationMaster"; appsTableData.append(trackingURL == null ? "#" : "href='" + trackingURL).append("'>").append(trackingUI) .append("</a>\"],\n"); } if (appsTableData.charAt(appsTableData.length() - 2) == ',') { appsTableData.delete(appsTableData.length() - 2, appsTableData.length() - 1); } appsTableData.append("]"); html.script().$type("text/javascript")._("var appsTableData=" + appsTableData)._(); tbody._()._(); }
From source file:net.duckling.ddl.util.ResourceQuery.java
protected String getFileTypeString() { if (StringUtils.isNotEmpty(getFileType())) { if (LynxConstants.SEARCH_TYPE_PICTURE.equals(fileType)) { // StringBuilder sb = new StringBuilder(); String[] types = TeamQueryUtil.convertType(LynxConstants.SEARCH_TYPE_PICTURE); sb.append(" and ( " + getTableAlias() + "item_type = :item_type and "); params.put("item_type", types[0]); StringBuilder temp = new StringBuilder(); temp.append(" ("); for (int i = 1; i < types.length; i++) { temp.append(" " + getTableAlias() + "file_type = :file_type" + i + " or "); params.put("file_type" + i, types[i]); }/*from ww w. ja v a 2 s .c o m*/ String subStr = temp.toString(); subStr = subStr.substring(0, subStr.length() - "or ".length()); subStr = subStr + "))"; sb.append(subStr); return sb.toString(); } else if (LynxConstants.SEARCH_TYPE_EXCEPTFOLDER.equals(fileType)) { // params.put("itemTypeDPage", LynxConstants.TYPE_PAGE); params.put("itemTypeDFile", LynxConstants.TYPE_FILE); return " and (" + getTableAlias() + "item_type= :itemTypeDPage or " + getTableAlias() + "item_type= :itemTypeDFile) "; } else if (LynxConstants.TYPE_PAGE.equals(fileType)) { params.put("itemType", LynxConstants.TYPE_PAGE); return " and item_type=:itemType "; } else if (LynxConstants.SRERCH_TYPE_NOPAGE.equals(fileType)) { params.put("itemType", LynxConstants.TYPE_PAGE); return " and item_type!=:itemType "; } else { //??docpdf String[] types = TeamQueryUtil.convertType(fileType); if (types != null && types.length > 0) { StringBuilder sb = new StringBuilder(); sb.append(" and " + getTableAlias() + "item_type = '" + types[0] + "' "); if (types.length > 1) { sb.append(" and ("); for (int i = 1; i < types.length; i++) { sb.append("" + getTableAlias() + "file_type like '%" + types[i] + "%' or "); } //or sb.delete(sb.length() - 4, sb.length()); sb.append(") "); } return sb.toString(); } } } return ""; }
From source file:org.apache.hadoop.yarn.server.webapp.AppBlock.java
protected void generateApplicationTable(Block html, UserGroupInformation callerUGI, Collection<ApplicationAttemptReport> attempts) { // Application Attempt Table TBODY<TABLE<Hamlet>> tbody = html.table("#attempts").thead().tr().th(".id", "Attempt ID") .th(".started", "Started").th(".node", "Node").th(".logs", "Logs")._()._().tbody(); StringBuilder attemptsTableData = new StringBuilder("[\n"); for (final ApplicationAttemptReport appAttemptReport : attempts) { AppAttemptInfo appAttempt = new AppAttemptInfo(appAttemptReport); ContainerReport containerReport; try {/*from ww w. ja va2 s . c o m*/ final GetContainerReportRequest request = GetContainerReportRequest .newInstance(appAttemptReport.getAMContainerId()); if (callerUGI == null) { containerReport = appBaseProt.getContainerReport(request).getContainerReport(); } else { containerReport = callerUGI.doAs(new PrivilegedExceptionAction<ContainerReport>() { @Override public ContainerReport run() throws Exception { ContainerReport report = null; if (request.getContainerId() != null) { try { report = appBaseProt.getContainerReport(request).getContainerReport(); } catch (ContainerNotFoundException ex) { LOG.warn(ex.getMessage()); } } return report; } }); } } catch (Exception e) { String message = "Failed to read the AM container of the application attempt " + appAttemptReport.getApplicationAttemptId() + "."; LOG.error(message, e); html.p()._(message)._(); return; } long startTime = 0L; String logsLink = null; String nodeLink = null; if (containerReport != null) { ContainerInfo container = new ContainerInfo(containerReport); startTime = container.getStartedTime(); logsLink = containerReport.getLogUrl(); nodeLink = containerReport.getNodeHttpAddress(); } attemptsTableData.append("[\"<a href='").append(url("appattempt", appAttempt.getAppAttemptId())) .append("'>").append(appAttempt.getAppAttemptId()).append("</a>\",\"").append(startTime) .append("\",\"<a ").append(nodeLink == null ? "#" : "href='" + nodeLink).append("'>") .append(nodeLink == null ? "N/A" : StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(nodeLink))) .append("</a>\",\"<a ").append(logsLink == null ? "#" : "href='" + logsLink).append("'>") .append(logsLink == null ? "N/A" : "Logs").append("</a>\"],\n"); } if (attemptsTableData.charAt(attemptsTableData.length() - 2) == ',') { attemptsTableData.delete(attemptsTableData.length() - 2, attemptsTableData.length() - 1); } attemptsTableData.append("]"); html.script().$type("text/javascript")._("var attemptsTableData=" + attemptsTableData)._(); tbody._()._(); }
From source file:org.apache.hadoop.yarn.server.resourcemanager.webapp.FairSchedulerAppsBlock.java
@Override public void render(Block html) { TBODY<TABLE<Hamlet>> tbody = html.table("#apps").thead().tr().th(".id", "ID").th(".user", "User") .th(".name", "Name").th(".type", "Application Type").th(".queue", "Queue") .th(".fairshare", "Fair Share").th(".starttime", "StartTime").th(".finishtime", "FinishTime") .th(".state", "State").th(".finalstatus", "FinalStatus") .th(".runningcontainer", "Running Containers").th(".allocatedCpu", "Allocated CPU VCores") .th(".allocatedMemory", "Allocated Memory MB").th(".progress", "Progress").th(".ui", "Tracking UI") ._()._().tbody();/*from w ww . j a v a 2s .c om*/ Collection<YarnApplicationState> reqAppStates = null; String reqStateString = $(APP_STATE); if (reqStateString != null && !reqStateString.isEmpty()) { String[] appStateStrings = reqStateString.split(","); reqAppStates = new HashSet<YarnApplicationState>(appStateStrings.length); for (String stateString : appStateStrings) { reqAppStates.add(YarnApplicationState.valueOf(stateString)); } } StringBuilder appsTableData = new StringBuilder("[\n"); for (RMApp app : apps.values()) { if (reqAppStates != null && !reqAppStates.contains(app.createApplicationState())) { continue; } AppInfo appInfo = new AppInfo(rm, app, true, WebAppUtils.getHttpSchemePrefix(conf)); String percent = StringUtils.format("%.1f", appInfo.getProgress()); ApplicationAttemptId attemptId = app.getCurrentAppAttempt().getAppAttemptId(); long fairShare = fsinfo.getAppFairShare(attemptId); if (fairShare == FairSchedulerInfo.INVALID_FAIR_SHARE) { // FairScheduler#applications don't have the entry. Skip it. continue; } appsTableData.append("[\"<a href='").append(url("app", appInfo.getAppId())).append("'>") .append(appInfo.getAppId()).append("</a>\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(appInfo.getUser()))) .append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(appInfo.getName()))) .append("\",\"") .append(StringEscapeUtils .escapeJavaScript(StringEscapeUtils.escapeHtml(appInfo.getApplicationType()))) .append("\",\"") .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(appInfo.getQueue()))) .append("\",\"").append(fairShare).append("\",\"").append(appInfo.getStartTime()) .append("\",\"").append(appInfo.getFinishTime()).append("\",\"").append(appInfo.getState()) .append("\",\"").append(appInfo.getFinalStatus()).append("\",\"") .append(appInfo.getRunningContainers() == -1 ? "N/A" : String.valueOf(appInfo.getRunningContainers())) .append("\",\"") .append(appInfo.getAllocatedVCores() == -1 ? "N/A" : String.valueOf(appInfo.getAllocatedVCores())) .append("\",\"") .append(appInfo.getAllocatedMB() == -1 ? "N/A" : String.valueOf(appInfo.getAllocatedMB())) .append("\",\"") // Progress bar .append("<br title='").append(percent).append("'> <div class='").append(C_PROGRESSBAR) .append("' title='").append(join(percent, '%')).append("'> ").append("<div class='") .append(C_PROGRESSBAR_VALUE).append("' style='").append(join("width:", percent, '%')) .append("'> </div> </div>").append("\",\"<a href='"); String trackingURL = !appInfo.isTrackingUrlReady() ? "#" : appInfo.getTrackingUrlPretty(); appsTableData.append(trackingURL).append("'>").append(appInfo.getTrackingUI()).append("</a>\"],\n"); } if (appsTableData.charAt(appsTableData.length() - 2) == ',') { appsTableData.delete(appsTableData.length() - 2, appsTableData.length() - 1); } appsTableData.append("]"); html.script().$type("text/javascript")._("var appsTableData=" + appsTableData)._(); tbody._()._(); }
From source file:com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.java
/** * On cql3 create keyspace.//from w w w . j ava 2 s. co m * * @throws InvalidRequestException * the invalid request exception * @throws UnavailableException * the unavailable exception * @throws TimedOutException * the timed out exception * @throws SchemaDisagreementException * the schema disagreement exception * @throws TException * the t exception * @throws UnsupportedEncodingException * the unsupported encoding exception */ private void onCql3CreateKeyspace() throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException, UnsupportedEncodingException { String createKeyspace = CQLTranslator.CREATE_KEYSPACE; String placement_strategy = csmd.getPlacement_strategy(databaseName); String replication_conf = CQLTranslator.SIMPLE_REPLICATION; createKeyspace = createKeyspace.replace("$KEYSPACE", Constants.ESCAPE_QUOTE + databaseName + Constants.ESCAPE_QUOTE); Schema schema = CassandraPropertyReader.csmd.getSchema(databaseName); if (schema != null && schema.getName() != null && schema.getName().equalsIgnoreCase(databaseName) && schema.getSchemaProperties() != null) { Properties schemaProperties = schema.getSchemaProperties(); if (placement_strategy.equalsIgnoreCase(SimpleStrategy.class.getSimpleName()) || placement_strategy.equalsIgnoreCase(SimpleStrategy.class.getName())) { String replicationFactor = schemaProperties.getProperty(CassandraConstants.REPLICATION_FACTOR, CassandraConstants.DEFAULT_REPLICATION_FACTOR); replication_conf = replication_conf.replace("$REPLICATION_FACTOR", replicationFactor); createKeyspace = createKeyspace.replace("$CLASS", placement_strategy); } else if (placement_strategy.equalsIgnoreCase(NetworkTopologyStrategy.class.getSimpleName()) || placement_strategy.equalsIgnoreCase(NetworkTopologyStrategy.class.getName())) { if (schema.getDataCenters() != null && !schema.getDataCenters().isEmpty()) { StringBuilder builder = new StringBuilder(); for (DataCenter dc : schema.getDataCenters()) { builder.append(CQLTranslator.QUOTE_STR); builder.append(dc.getName()); builder.append(CQLTranslator.QUOTE_STR); builder.append(":"); builder.append(dc.getValue()); builder.append(CQLTranslator.COMMA_STR); } builder.delete(builder.lastIndexOf(CQLTranslator.COMMA_STR), builder.length()); replication_conf = builder.toString(); } } createKeyspace = createKeyspace.replace("$CLASS", placement_strategy); createKeyspace = createKeyspace.replace("$REPLICATION", replication_conf); boolean isDurableWrites = Boolean .parseBoolean(schemaProperties.getProperty(CassandraConstants.DURABLE_WRITES, "true")); createKeyspace = createKeyspace.replace("$DURABLE_WRITES", isDurableWrites + ""); } else { createKeyspace = createKeyspace.replace("$CLASS", placement_strategy); replication_conf = replication_conf.replace("$REPLICATION_FACTOR", CassandraConstants.DEFAULT_REPLICATION_FACTOR); createKeyspace = createKeyspace.replace("$REPLICATION", replication_conf); createKeyspace = createKeyspace.replace("$DURABLE_WRITES", "true"); } cassandra_client.execute_cql3_query(ByteBuffer.wrap(createKeyspace.getBytes(Constants.CHARSET_UTF8)), Compression.NONE, ConsistencyLevel.ONE); KunderaCoreUtils.printQuery(createKeyspace, showQuery); }
From source file:org.dasein.cloud.ibm.sce.compute.vm.SCEVirtualMachine.java
public String getRandomPassword(String username) { StringBuilder password = new StringBuilder(); ArrayList<String> invalidSubstrings = new ArrayList<String>(); final String[] invalidStrings = { username, "admin", "Administrator", "idcadmin" }; for (String invalidString : invalidStrings) { invalidSubstrings.addAll(generateThreeCharSubstrings(invalidString)); }/* w w w .ja va 2 s. c om*/ int rnd = random.nextInt(); int length = 16; if (rnd < 0) { rnd = -rnd; } length = length + (rnd % 8); while (password.length() < 1) { char c; rnd = random.nextInt(); if (rnd < 0) { rnd = -rnd; } c = (char) (rnd % 255); if (uppercaseAlphabet.contains(String.valueOf(c))) { password.append(c); } } while (password.length() < 2) { char c; rnd = random.nextInt(); if (rnd < 0) { rnd = -rnd; } c = (char) (rnd % 255); if (lowercaseAlphabet.contains(String.valueOf(c))) { password.append(c); } } while (password.length() < 3) { char c; rnd = random.nextInt(); if (rnd < 0) { rnd = -rnd; } c = (char) (rnd % 255); if (numbers.contains(String.valueOf(c))) { password.append(c); } } while (password.length() < 4) { char c; rnd = random.nextInt(); if (rnd < 0) { rnd = -rnd; } c = (char) (rnd % 255); if (symbols.contains(String.valueOf(c))) { password.append(c); } } while (password.length() < length) { char c; rnd = random.nextInt(); if (rnd < 0) { rnd = -rnd; } c = (char) (rnd % 255); if (allChars.contains(String.valueOf(c))) { password.append(c); } for (String invalidSubstring : invalidSubstrings) { if (password.toString().contains(invalidSubstring)) { password = password.delete(4, password.length()); break; } } } return password.toString(); }
From source file:com.flexive.shared.scripting.groovy.GroovyScriptExporterTools.java
/** * Write the script code to create a group assignment * * @param ga the FxGroupAssignment to be scripted * @param isDerived the Assignment is derived * @param differences the List of differences (map keys f. the builder) * @param defaultsOnly use only default settings provided by the GTB, no analysis of assignments will be performed * @param tabCount the number of tabs to be added to the code's left hand side * @param withoutDependencies true = do not create assignment:xpath code * @param differingDerivedAssignments the List of assignment ids for derived assignments differing from their base assignments * @return returns the partial script as a String *///w w w .j a v a 2 s. com public static String updateGroupAssignment(FxGroupAssignment ga, boolean isDerived, List<String> differences, boolean defaultsOnly, int tabCount, boolean withoutDependencies, List<Long> differingDerivedAssignments) { StringBuilder script = new StringBuilder(200); final FxGroup group = ga.getGroup(); // name = alias script.append(Indent.tabs(tabCount)); boolean createGroup = false; if (!isDerived || (isDerived && differingDerivedAssignments != null && !differingDerivedAssignments.contains(ga.getId())) || (isDerived && differences.size() > 0) || (isDerived && !withoutDependencies)) createGroup = true; if (createGroup) { // script.append("\n"); final String groupAlias = keyWordNameCheck(ga.getAlias().toUpperCase(), true); script.append(groupAlias).append("( "); // opening parenthesis + 1x \s } // ASSIGNMENT if (isDerived && !withoutDependencies || (isDerived && !withoutDependencies && differingDerivedAssignments != null && !differingDerivedAssignments.contains(ga.getId()))) { final String assignmentPath = CacheAdmin.getEnvironment().getAssignment(ga.getBaseAssignmentId()) .getXPath(); script.append("assignment: \"").append(assignmentPath).append("\","); } if (!defaultsOnly && differences.size() > 0) { tabCount++; script.append("\n"); // label and hint if (differences.contains("hint") || differences.contains("label")) script.append(getLabelAndHintStructure(group, differences.contains("label"), differences.contains("hint"), tabCount)); Map<String, String> sopts = new LinkedHashMap<String, String>(); if (differences.contains("defaultMultiplicity")) sopts.put("defaultMultiplicity", ga.getDefaultMultiplicity() + ""); if (differences.contains("multiplicity")) { if (group.mayOverrideBaseMultiplicity()) sopts.put("multiplicity", "new FxMultiplicity(" + ga.getMultiplicity().getMin() + "," + ga.getMultiplicity().getMax() + ")"); } if (differences.contains("groupMode")) sopts.put("groupMode", "GroupMode." + ga.getMode().name()); if (differences.contains("enabled")) sopts.put("enabled", ga.isEnabled() + ""); // FxStructureOptions via the GroovyOptionbuilder if (differences.contains("structureoptions")) script.append(getStructureOptions(ga, tabCount)); // append options to script for (String option : sopts.keySet()) { script.append(simpleOption(option, sopts.get(option), tabCount)); } script.trimToSize(); if (script.indexOf(",\n", script.length() - 2) != -1) script.delete(script.length() - 2, script.length()); } script.trimToSize(); if (script.indexOf(",", script.length() - 1) != -1) script.delete(script.length() - 1, script.length()); if (createGroup) script.append(") "); // closing parenthesis + 1x \s return script.toString(); }
From source file:module.mailtracking.presentationTier.MailTrackingAction.java
private String serializeAjaxFilterResponseForSentMail(String sEcho, Integer iTotalRecords, Integer iTotalDisplayRecords, java.util.List<CorrespondenceEntry> limitedEntries, HttpServletRequest request) {/* w w w . j a v a 2 s. c o m*/ StringBuilder stringBuilder = new StringBuilder("{"); stringBuilder.append("\"sEcho\": ").append(sEcho).append(", \n"); stringBuilder.append("\"iTotalRecords\": ").append(iTotalRecords).append(", \n"); stringBuilder.append("\"iTotalDisplayRecords\": ").append(iTotalDisplayRecords).append(", \n"); stringBuilder.append("\"aaData\": ").append("[ \n"); for (CorrespondenceEntry entry : limitedEntries) { stringBuilder.append("[ \"").append(entry.getReference()).append("\", "); stringBuilder.append("\"").append(escapeQuotes(entry.getWhenSent().toString("dd/MM/yyyy"))) .append("\", "); stringBuilder.append("\"").append(escapeQuotes(entry.getRecipient())).append("\", "); stringBuilder.append("\"").append(escapeQuotes(entry.getSubject())).append("\", "); stringBuilder.append("\"").append(escapeQuotes(entry.getSender())).append("\", "); stringBuilder.append("\"") .append(entry.isUserAbleToView(Authenticate.getUser()) ? generateLinkForCorrespondenceEntryView(request, entry) : "permission_not_granted") .append(","); stringBuilder.append(entry.isUserAbleToEdit(Authenticate.getUser()) && entry.isActive() ? generateLinkForCorrespondenceEntryEdition(request, entry) : "permission_not_granted").append(","); stringBuilder.append(entry.isUserAbleToDelete(Authenticate.getUser()) && entry.isActive() ? generateLinkForCorrespondenceEntryRemoval(request, entry) : "permission_not_granted").append(","); stringBuilder.append(entry.isUserAbleToViewMainDocument(Authenticate.getUser()) ? generateLinkForCorrespondenceEntryMainDocument(request, entry) : "permission_not_granted").append(","); stringBuilder.append(entry.isUserAbleToCopyEntry(Authenticate.getUser()) ? generateLinkForCorrespondenceEntryCopy(request, entry) : "permission_not_granted").append("\","); stringBuilder.append("\"").append(entry.isActive()).append("\" ], "); } stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length()); stringBuilder.append(" ]\n }"); return stringBuilder.toString(); }