Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions commons/src/main/java/org/apache/isis/commons/collections/Can.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
Expand Down Expand Up @@ -201,11 +202,26 @@ public static <T> Can<T> ofSingleton(T element) {
return Can_Singleton.of(element);
}

/**
* Var-arg version of {@link Can#ofArray(Object[])}.
* @param <T>
* @param array
* @return non-null
* @see Can#ofArray(Object[])
*/
@SafeVarargs
public static <T> Can<T> of(T ... array) {
return ofArray(array);
}

/**
* Returns either a {@code Can} with all the elements from given {@code array}
* or an empty {@code Can} if the {@code array} is {@code null}. Any elements
* equal to {@code null} are ignored and will not be contained in the resulting {@code Can}.
* @param <T>
* @param array
* @return non-null
*/
public static <T> Can<T> ofArray(@Nullable T[] array) {

if(_NullSafe.size(array)==0) {
Expand Down Expand Up @@ -273,6 +289,14 @@ public static <T> Can<T> ofCollection(@Nullable Collection<T> collection) {
return Can_Multiple.of(nonNullElements);
}

/**
* Returns either a {@code Can} with all the elements from given {@code iterable}
* or an empty {@code Can} if the {@code iterable} is {@code null}. Any elements
* equal to {@code null} are ignored and will not be contained in the resulting {@code Can}.
* @param <T>
* @param iterable
* @return non-null
*/
public static <T> Can<T> ofIterable(@Nullable Iterable<T> iterable) {

if(iterable==null) {
Expand All @@ -284,11 +308,36 @@ public static <T> Can<T> ofIterable(@Nullable Iterable<T> iterable) {

return ofCollection(elements);
}

/**
* Returns either a {@code Can} with all the elements from given {@code enumeration}
* or an empty {@code Can} if the {@code enumeration} is {@code null}. Any elements
* equal to {@code null} are ignored and will not be contained in the resulting {@code Can}.
* <p>
* As side-effect, consumes given {@code enumeration}.
* @param <T>
* @param enumeration
* @return non-null
*/
public static <T> Can<T> ofEnumeration(@Nullable Enumeration<T> enumeration) {

if(enumeration==null) {
return empty();
}

val elements = new ArrayList<T>();
while(enumeration.hasMoreElements()) {
elements.add(enumeration.nextElement());
}
return ofCollection(elements);
}

/**
* Returns either a {@code Can} with all the elements from given {@code stream}
* or an empty {@code Can} if the {@code stream} is {@code null}. Any elements
* equal to {@code null} are ignored and will not be contained in the resulting {@code Can}.
* <p>
* As side-effect, consumes given {@code stream}.
* @param <T>
* @param stream
* @return non-null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.function.ToIntFunction;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

import javax.annotation.Nullable;

import org.apache.isis.commons.collections.Can;
import org.apache.isis.commons.internal.assertions._Assert;
import org.apache.isis.commons.internal.collections._Lists;

import lombok.Getter;
import lombok.NonNull;
Expand Down Expand Up @@ -82,6 +85,15 @@ public static Can<String> getLines(final @Nullable String text){
return Can.ofStream(streamLines(text));
}

public static Can<String> breakLines(Can<String> lines, int maxChars) {
if(lines.isEmpty()) {
return lines;
}
return lines.stream()
.flatMap(line->breakLine(line, maxChars))
.collect(Can.toCan());
}

/**
* Reads content from given {@code input} into a {@link Can} of lines,
* removing new line characters {@code \n,\r} in the process.
Expand Down Expand Up @@ -338,5 +350,47 @@ private static ToIntFunction<String> indexAndlineToIntFunction(IndexAwareLineToI
return line->mapper.apply(indexRef[0]++, line);
}

private static Stream<String> breakLine(String line, final int maxChars) {
line = line.trim();
if(line.length()<=maxChars) {
return Stream.of(line);
}
val tokens = Can.ofEnumeration(new StringTokenizer(line, " .-:/", true))
.map(String.class::cast);

val constraintLines = _Lists.<String>newArrayList();
val partialSum = _Refs.intRef(0);
val partialCount = _Refs.intRef(0);

val tokenIterator = tokens.iterator();

tokens.stream()
.mapToInt(String::length)
.forEach(tokenLen->{

final int nextLen = partialSum.getValue() + tokenLen;
if(nextLen <= maxChars) {
partialSum.update(x->nextLen);
partialCount.inc();
} else {

constraintLines.add(
IntStream.range(0, partialCount.getValue())
.mapToObj(__->tokenIterator.next())
.collect(Collectors.joining()));

partialSum.update(x->tokenLen);
partialCount.setValue(1);
}
});

// add remaining
constraintLines.add(
IntStream.range(0, partialCount.getValue())
.mapToObj(__->tokenIterator.next())
.collect(Collectors.joining()));

return constraintLines.stream();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void exit(String from, String to) {
private final static int PARTICIPANT_PADDING_H = 8;
private final static int PARTICIPANT_PADDING_V = 3;
private final static int PARTICIPANT_LINEGAP = 0;
private final static int PARTICIPANT_MAX_CHAR_PER_LINE = 26;
private final static Optional<Font> PARTICIPANT_FONT = _Graphics.lookupFont("Verdana", 12.f);

private final static int CONNECTION_MARGIN_V = 5;
Expand Down Expand Up @@ -112,7 +113,8 @@ void layout(Graphics2D g, IntReference y_offset) {
val dim = textBlock.layout(g.getFontMetrics(),
CONNECTION_LABEL_PADDING_H,
CONNECTION_LABEL_PADDING_V,
CONNECTION_LABEL_LINEGAP);
CONNECTION_LABEL_LINEGAP,
Integer.MAX_VALUE);

height = dim.height;
y_bottom = y_top + height;
Expand Down Expand Up @@ -145,7 +147,8 @@ void layout(Graphics2D g, IntReference x_offset) {
val dim = textBlock.layout(g.getFontMetrics(),
PARTICIPANT_PADDING_H,
PARTICIPANT_PADDING_V,
PARTICIPANT_LINEGAP);
PARTICIPANT_LINEGAP,
PARTICIPANT_MAX_CHAR_PER_LINE);

width = dim.width;
x_right = x_left + width;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ static class TextBlock {
int lineDescent;
int lineHeight;

Dimension layout(FontMetrics metrics, int hPadding, int vPadding, int lineGap) {
Dimension layout(FontMetrics metrics, int hPadding, int vPadding, int lineGap, int maxCharsPerLine) {
this.hPadding = hPadding;
this.vPadding = vPadding;
this.lineGap = lineGap;
lines = _Text.getLines(label);
lines = _Text.breakLines(_Text.getLines(label), maxCharsPerLine);
if(lines.isEmpty()) {
return new Dimension(0, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.isis.core.config;

import java.util.Collections;
import java.util.Map;

import org.springframework.boot.context.properties.ConfigurationProperties;
Expand Down Expand Up @@ -63,12 +64,12 @@
})
public class IsisModuleCoreConfig {

@ConfigurationProperties(prefix = "")
@ConfigurationProperties(prefix = "", ignoreUnknownFields = true)
@Data
public static class ConfigProps {
private Map<String, String> isis;
private Map<String, String> resteasy;
private Map<String, String> datanucleus;
private Map<String, String> isis = Collections.emptyMap();
private Map<String, String> resteasy = Collections.emptyMap();
private Map<String, String> datanucleus = Collections.emptyMap();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ default Optional<ExecutionContext> currentExecutionContext() {

/** @return the unique id of the current top-level request- or test-scoped Interaction*/
Optional<UUID> getConversationId();

/** @return authentication-layer-stack size */
int getAuthenticationLayerCount();

// -- MESSAGE BROKER

Expand Down
6 changes: 3 additions & 3 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@
<npm.version>6.13.1</npm.version>

<objenesis.version>3.1</objenesis.version>
<ognl.version>3.2.18</ognl.version>
<ognl.version>3.2.19</ognl.version>

<pdfbox.version>2.0.22</pdfbox.version>
<pdfbox.version>2.0.23</pdfbox.version>
<picocontainer.version>2.15</picocontainer.version>
<poi.version>4.1.2</poi.version>

Expand All @@ -173,7 +173,7 @@
<shiro.version>1.7.1</shiro.version>
<simpleslackapi.version>1.3.0</simpleslackapi.version>
<slf4j-api.version>1.7.30</slf4j-api.version> <!-- as provided by spring-boot, needed to solve convergence issues -->
<spring-boot.version>2.4.3</spring-boot.version> <!-- has no effect here, needs to be set in isis-parent/pom.xml -->
<spring-boot.version>2.4.4</spring-boot.version> <!-- has no effect here, needs to be set in isis-parent/pom.xml -->
<summernote.version>0.8.11</summernote.version>
<swagger-core.version>1.6.2</swagger-core.version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
package org.apache.isis.core.runtime.events;

import org.apache.isis.applib.services.confview.ConfigurationViewService;
import org.apache.isis.commons.internal.debug._Probe;
import org.apache.isis.commons.internal.debug.xray.XrayDataModel;
import org.apache.isis.commons.internal.debug.xray.XrayModel;
import org.apache.isis.commons.internal.debug.xray.XrayUi;
import org.apache.isis.core.interaction.session.InteractionTracker;
import org.apache.isis.core.runtime.util.XrayUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ public static ThreadMemento currentThreadAsMemento() {
String.format("Thread-%d\n%s", ct.getId(), ct.getName()));
}

public static String nestedInteractionId(int authenticationStackSize) {
return "ia-" + (authenticationStackSize-1);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ public class MemberExecutorServiceDefault
private final @Getter ObjectManager objectManager;
private final @Getter ClockService clockService;
private final @Getter Provider<MetricsService> metricsService;
private final @Getter
InteractionDtoFactory interactionDtoFactory;
private final @Getter InteractionDtoFactory interactionDtoFactory;
private final @Getter Provider<ExecutionPublisher> executionPublisher;
private final @Getter MetamodelEventService metamodelEventService;
private final @Getter TransactionService transactionService;
Expand Down Expand Up @@ -120,7 +119,7 @@ public ManagedObject invokeAction(
CommandPublishingFacet.ifPublishingEnabledForCommand(
command, owningAction, facetHolder, ()->command.updater().setPublishingEnabled(true));

val xrayHandle = _Xray.enterInvocation(interaction);
val xrayHandle = _Xray.enterActionInvocation(interactionTracker, interaction, owningAction, head, argumentAdapters);

val actionId = owningAction.getIdentifier();
log.debug("about to invoke action {}", actionId);
Expand Down Expand Up @@ -202,7 +201,7 @@ public ManagedObject setOrClearProperty(
CommandPublishingFacet.ifPublishingEnabledForCommand(
command, owningProperty, facetHolder, ()->command.updater().setPublishingEnabled(true));

val xrayHandle = _Xray.enterInvocation(interaction);
val xrayHandle = _Xray.enterPropertyEdit(interactionTracker, interaction, owningProperty, head, newValueAdapter);

val propertyId = owningProperty.getIdentifier();

Expand Down
Loading