19 package org.turro.dossier.issue.parser;
21 import java.util.Collections;
22 import java.util.List;
23 import java.util.StringJoiner;
24 import java.util.regex.Matcher;
25 import java.util.regex.Pattern;
26 import java.util.stream.Collectors;
27 import org.turro.string.Strings;
28 import org.turro.elephant.context.Application;
36 private final StringJoiner changes, comment, participants, attachments, relations,
37 endBlock, upload, description, priority, type, grouping, dossier,
38 version, publishable, control, delivery, startDate, status,
39 resolution, duplicated, hours, expenses, price, prevision;
40 private final String text, proppart, attachpart;
49 endBlock =
new StringJoiner(
"|");
50 endBlock.merge(changes)
74 attachpart =
getText(attachments);
82 String block =
getText(participants);
83 if(!Strings.isBlank(block)) {
84 return Pattern.compile(
"\\R*(.+)\\s*:\\s*(.+)(\\R|$)")
87 .map((m) ->
new PairValue(m.group(1), m.group(2)))
88 .collect(Collectors.toList());
90 return Collections.EMPTY_LIST;
94 return Strings.isBlank(attachpart) ? null : Pattern.compile(
"\\R(" + upload +
")\\s*\\[\\s*(.+)\\](\\R|$)")
97 .map((m) -> m.group(2))
98 .collect(Collectors.toList());
178 int idxStart = 0, idxEnd;
179 Pattern pstart = Pattern.compile(
"(\\R|^)(" + block +
")\\R");
180 Matcher mstart = pstart.matcher(text);
182 idxStart = mstart.end() - 1;
185 Pattern pend = Pattern.compile(
"\\R((" + endBlock +
")\\R|$)");
186 Matcher mend = pend.matcher(text);
187 if(mend.find(idxStart + 1)) {
188 idxEnd = mend.start();
190 idxEnd = text.length();
192 if(idxEnd > idxStart) {
193 return text.substring(idxStart, idxEnd);
200 if(!Strings.isBlank(proppart)) {
201 Pattern pattern = Pattern.compile(
"\\R(" + options +
")\\s*:\\s*(.+)(\\R|$)");
202 Matcher matcher = pattern.matcher(proppart);
204 return matcher.group(2);
211 if(!Strings.isBlank(proppart)) {
212 Pattern pattern = Pattern.compile(
"\\R(" + options +
")\\s*\\[\\s*(.*)\\s*\\]:\\h*(.*)(\\R|$)");
213 Matcher matcher = pattern.matcher(proppart);
215 return new PairValue(matcher.group(2), matcher.group(3));
222 if(!Strings.isBlank(proppart)) {
223 Pattern pattern = Pattern.compile(
"\\R((" + prefix +
")" + separator +
"(" + options +
"))\\s*\\[\\s*(.*)\\s*\\]:\\h*(.*)(\\R|$)");
224 Matcher matcher = pattern.matcher(proppart);
226 return new PairValue(matcher.group(4), matcher.group(5));
232 private StringJoiner toRegExp(List<String> opts) {
233 StringJoiner sj =
new StringJoiner(
"|");
234 opts.forEach((opt) -> {
static List< String > getAllLocales(String key)