Search in sources :

Example 21 with TextStringBuilder

use of org.apache.commons.text.TextStringBuilder in project iaf by ibissource.

the class MessageStoreSender method sendMessage.

@Override
public Message sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException {
    try {
        Message messageToStore = message;
        if (sessionKeys != null) {
            List<String> list = new ArrayList<>();
            list.add(StringEscapeUtils.escapeCsv(message.asString()));
            StringTokenizer tokenizer = new StringTokenizer(sessionKeys, ",");
            while (tokenizer.hasMoreElements()) {
                String sessionKey = (String) tokenizer.nextElement();
                Message msg = session.getMessage(sessionKey);
                if (!msg.isEmpty()) {
                    list.add(StringEscapeUtils.escapeCsv(msg.asString()));
                }
            }
            TextStringBuilder sb = new TextStringBuilder();
            sb.appendWithSeparators(list, ",");
            messageToStore = Message.asMessage(sb.toString());
        }
        // the messageId to be inserted in the messageStore defaults to the messageId of the session
        String messageId = session.getMessageId();
        String correlationID = messageId;
        if (paramList != null && paramList.findParameter(PARAM_MESSAGEID) != null) {
            try {
                // the messageId to be inserted can also be specified via the parameter messageId
                messageId = paramList.getValues(message, session).get(PARAM_MESSAGEID).asStringValue();
            } catch (ParameterException e) {
                throw new SenderException("Could not resolve parameter messageId", e);
            }
        }
        return new Message(storeMessage(messageId, correlationID, new Date(), null, null, messageToStore.asString()));
    } catch (IOException e) {
        throw new SenderException(getLogPrefix(), e);
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) Message(nl.nn.adapterframework.stream.Message) ArrayList(java.util.ArrayList) ParameterException(nl.nn.adapterframework.core.ParameterException) IOException(java.io.IOException) SenderException(nl.nn.adapterframework.core.SenderException) TextStringBuilder(org.apache.commons.text.TextStringBuilder) Date(java.util.Date)

Example 22 with TextStringBuilder

use of org.apache.commons.text.TextStringBuilder in project incubator-gobblin by apache.

the class AutomaticTroubleshooterImpl method getIssueSummaryMessage.

@Override
public String getIssueSummaryMessage() throws TroubleshooterException {
    List<Issue> issues = issueRepository.getAll();
    TextStringBuilder sb = new TextStringBuilder();
    sb.appendln("");
    sb.appendln("vvvvv============= Issues (summary) =============vvvvv");
    for (int i = 0; i < issues.size(); i++) {
        Issue issue = issues.get(i);
        sb.appendln("%s) %s %s %s | source: %s", i + 1, issue.getSeverity().toString(), issue.getCode(), issue.getSummary(), issue.getSourceClass());
    }
    sb.append("^^^^^=============================================^^^^^");
    return sb.toString();
}
Also used : Issue(org.apache.gobblin.runtime.troubleshooter.Issue) TextStringBuilder(org.apache.commons.text.TextStringBuilder)

Example 23 with TextStringBuilder

use of org.apache.commons.text.TextStringBuilder in project incubator-gobblin by apache.

the class AutomaticTroubleshooterImpl method getIssueDetailsMessage.

@Override
public String getIssueDetailsMessage() throws TroubleshooterException {
    List<Issue> issues = issueRepository.getAll();
    TextStringBuilder sb = new TextStringBuilder();
    sb.appendln("");
    sb.appendln("vvvvv============= Issues (detailed) =============vvvvv");
    for (int i = 0; i < issues.size(); i++) {
        Issue issue = issues.get(i);
        sb.appendln("%s) %s %s %s", i + 1, issue.getSeverity().toString(), issue.getCode(), issue.getSummary());
        sb.appendln("\tsource: %s", issue.getSourceClass());
        if (issue.getDetails() != null) {
            sb.appendln("\t" + issue.getDetails().replaceAll(System.lineSeparator(), System.lineSeparator() + "\t"));
        }
        if (issue.getProperties() != null) {
            issue.getProperties().forEach((key, value) -> {
                sb.appendln("\t%s: %s", key, value);
            });
        }
    }
    sb.append("^^^^^================================================^^^^^");
    return sb.toString();
}
Also used : Issue(org.apache.gobblin.runtime.troubleshooter.Issue) TextStringBuilder(org.apache.commons.text.TextStringBuilder)

Example 24 with TextStringBuilder

use of org.apache.commons.text.TextStringBuilder in project Plan by plan-player-analytics.

the class BukkitPartBuilder method hover.

@Override
public MessageBuilder hover(Collection<String> lines) {
    ComponentBuilder hoverMsg = new ComponentBuilder("");
    hoverMsg.append(new TextStringBuilder().appendWithSeparators(lines, "\n").build());
    part.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverMsg.create()));
    return this;
}
Also used : HoverEvent(net.md_5.bungee.api.chat.HoverEvent) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder) TextStringBuilder(org.apache.commons.text.TextStringBuilder)

Example 25 with TextStringBuilder

use of org.apache.commons.text.TextStringBuilder in project Plan by plan-player-analytics.

the class ItemNameFormatter method apply.

@Override
public String apply(String name) {
    String[] parts = StringUtils.split(name, '_');
    TextStringBuilder builder = new TextStringBuilder();
    builder.appendWithSeparators(Arrays.stream(parts).map(StringUtils::lowerCase).map(StringUtils::capitalize).iterator(), " ");
    return builder.toString();
}
Also used : StringUtils(org.apache.commons.lang3.StringUtils) TextStringBuilder(org.apache.commons.text.TextStringBuilder)

Aggregations

TextStringBuilder (org.apache.commons.text.TextStringBuilder)37 PreparedStatement (java.sql.PreparedStatement)4 ResultSet (java.sql.ResultSet)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Issue (org.apache.gobblin.runtime.troubleshooter.Issue)4 QueryStatement (com.djrapitops.plan.storage.database.queries.QueryStatement)3 Nullable (javax.annotation.Nullable)3 StringTokenizer (org.apache.commons.text.StringTokenizer)3 Test (org.junit.jupiter.api.Test)3 ServerUUID (com.djrapitops.plan.identification.ServerUUID)2 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)2 SecurityJpqlGenerator (com.haulmont.cuba.core.global.filter.SecurityJpqlGenerator)2 ConditionsTree (com.haulmont.cuba.gui.components.filter.ConditionsTree)2 FakeFilterSupport (com.haulmont.cuba.gui.components.filter.FakeFilterSupport)2 FilterParser (com.haulmont.cuba.gui.components.filter.FilterParser)2 FilterEditor (com.haulmont.cuba.gui.components.filter.edit.FilterEditor)2 FilterEntity (com.haulmont.cuba.security.entity.FilterEntity)2 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)2 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)2