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
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
import org.jboss.hal.core.CrudOperations;
import org.jboss.hal.core.finder.ColumnAction;
import org.jboss.hal.core.finder.ColumnActionFactory;
import org.jboss.hal.core.finder.DependentItemsProvider;
import org.jboss.hal.core.finder.Finder;
import org.jboss.hal.core.finder.FinderColumn;
import org.jboss.hal.core.finder.FinderPath;
import org.jboss.hal.core.finder.FinderSegment;
import org.jboss.hal.core.finder.ItemAction;
import org.jboss.hal.core.finder.ItemActionFactory;
import org.jboss.hal.core.finder.ItemDisplay;
Expand Down Expand Up @@ -64,7 +63,6 @@

import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.Collections.emptyList;
import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.toList;

Expand All @@ -91,12 +89,12 @@
SCATTERED_CACHE_ADDRESS }, recursive = false)
public class CacheColumn extends FinderColumn<Cache> {

private static String findCacheContainer(FinderPath path) {
FinderSegment<?> segment = path.findColumn(Ids.CACHE_CONTAINER);
if (segment != null) {
return Ids.extractCacheContainer(segment.getItemId());
}
return null;
private static String getCacheContainerId() {
return Ids.CACHE_CONTAINER;
}

private String findCacheContainer() {
return DependentItemsProvider.resolver(getCacheContainerId(), getFinder().getContext().getPath()).getName();
}

private static final String JGROUPS_ADDITION_STATUS = "jgrupsAdditionStatus";
Expand All @@ -123,28 +121,23 @@ public CacheColumn(Finder finder,
EventBus eventBus) {

super(new Builder<Cache>(finder, Ids.CACHE, Names.CACHE)
.itemsProvider(context -> new Promise<>((resolve, reject) -> {
String cacheContainer = findCacheContainer(context.getPath());
if (cacheContainer != null) {
CacheType[] cacheTypes = CacheType.values();
ResourceAddress address = CACHE_CONTAINER_TEMPLATE.resolve(statementContext, cacheContainer);
List<String> children = stream(cacheTypes).map(CacheType::resource).collect(toList());
crud.readChildren(address, children, 1, result -> {
List<Cache> caches = new ArrayList<>();
for (int i = 0; i < result.size(); i++) {
List<Property> properties = result.step(i).get(RESULT).asPropertyList();
for (Property property : properties) {
caches.add(new Cache(property.getName(), cacheTypes[i], property.getValue()));
.itemsProvider(new DependentItemsProvider<Cache>(
cacheContainer -> new Promise<>((resolve, reject) -> {
CacheType[] cacheTypes = CacheType.values();
ResourceAddress address = CACHE_CONTAINER_TEMPLATE.resolve(statementContext, cacheContainer);
List<String> children = stream(cacheTypes).map(CacheType::resource).collect(toList());
crud.readChildren(address, children, 1, result -> {
List<Cache> caches = new ArrayList<>();
for (int i = 0; i < result.size(); i++) {
List<Property> properties = result.step(i).get(RESULT).asPropertyList();
for (Property property : properties) {
caches.add(new Cache(property.getName(), cacheTypes[i], property.getValue()));
}
}
}
// Collections.sort(caches, (c1, c2) -> c1.getName().compareTo(c2.getName()));
caches.sort(comparing(NamedNode::getName));
resolve.onInvoke(caches);
});
} else {
resolve.onInvoke(emptyList());
}
}))
caches.sort(comparing(NamedNode::getName));
resolve.onInvoke(caches);
});
}), getCacheContainerId()))
.onPreview(CachePreview::new)
.pinnable()
.showCount()
Expand Down Expand Up @@ -203,7 +196,7 @@ public String getFilterData() {
@Override
public List<ItemAction<Cache>> actions() {
List<ItemAction<Cache>> actions = new ArrayList<>();
String cacheContainer = findCacheContainer(getFinder().getContext().getPath());
String cacheContainer = findCacheContainer();
if (cacheContainer != null) {
actions.add(itemActionFactory.viewAndMonitor(Ids.build(item.type().baseId, item.getName()),
places.selectedProfile(item.type().nameToken)
Expand Down Expand Up @@ -231,7 +224,7 @@ private void addCache(CacheType cacheType) {
AddResourceDialog dialog = new AddResourceDialog(Ids.build(cacheType.baseId, Ids.ADD),
resources.messages().addResourceTitle(cacheType.type), metadata,
(name, model) -> {
String cacheContainer = findCacheContainer(getFinder().getContext().getPath());
String cacheContainer = findCacheContainer();
ResourceAddress address = cacheType.template.resolve(statementContext, cacheContainer, name);

if (cacheType.equals(CacheType.LOCAL)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import javax.inject.Inject;

import org.jboss.hal.core.CrudOperations;
import org.jboss.hal.core.finder.DependentItemsProvider;
import org.jboss.hal.core.finder.Finder;
import org.jboss.hal.core.finder.FinderColumn;
import org.jboss.hal.core.finder.FinderSegment;
import org.jboss.hal.core.finder.ItemAction;
import org.jboss.hal.core.finder.ItemActionFactory;
import org.jboss.hal.core.finder.PreviewContent;
Expand Down Expand Up @@ -90,75 +90,70 @@ public ServerSettingsColumn(Finder finder,
this.dispatcher = dispatcher;
this.resources = resources;

setItemsProvider(context -> new Promise<>((resolve, reject) -> {
List<StaticItem> items = new ArrayList<>();
FinderSegment<?> segment = context.getPath().findColumn(Ids.MESSAGING_SERVER_CONFIGURATION);
if (segment != null) {
String server = segment.getItemTitle();
StatementContext serverStatementContext = new SelectionAwareStatementContext(statementContext,
() -> server);
ResourceAddress address = SELECTED_SERVER_TEMPLATE.resolve(serverStatementContext);
HaPolicy.readChildren(crud, address, 1, children -> {

items.add(new StaticItem.Builder(Names.DESTINATIONS)
.id(Ids.MESSAGING_SERVER_DESTINATION)
.action(itemActionFactory.view(
places.selectedProfile(NameTokens.MESSAGING_SERVER_DESTINATION)
.with(SERVER, server)
.build()))
.onPreview(new PreviewContent<>(Names.DESTINATIONS,
resources.previews().configurationMessagingDestinations()))
.build());
items.add(new StaticItem.Builder(Names.CONNECTIONS)
.id(Ids.MESSAGING_SERVER_CONNECTION)
.action(itemActionFactory.view(
places.selectedProfile(NameTokens.MESSAGING_SERVER_CONNECTION)
.with(SERVER, server)
.build()))
.onPreview(new PreviewContent<>(Names.CONNECTIONS,
resources.previews().configurationMessagingConnections()))
.build());
items.add(new StaticItem.Builder(Names.CLUSTERING)
.id(Ids.MESSAGING_SERVER_CLUSTERING)
.action(itemActionFactory.view(
places.selectedProfile(NameTokens.MESSAGING_SERVER_CLUSTERING)
.with(SERVER, server)
.build()))
.onPreview(new PreviewContent<>(Names.CLUSTERING,
resources.previews().configurationMessagingClustering()))
.build());

StaticItem.Builder builder = new StaticItem.Builder(Names.HA_POLICY)
.id(Ids.MESSAGING_SERVER_HA_POLICY);
if (children.isEmpty()) {
builder.action(resources.constants().add(), item -> addHaPolicy(serverStatementContext))
setItemsProvider(new DependentItemsProvider<StaticItem>(
parentNames -> new Promise<>((resolve, reject) -> {
List<StaticItem> items = new ArrayList<>();
String server = parentNames[0];
StatementContext serverStatementContext = new SelectionAwareStatementContext(statementContext,
() -> server);
ResourceAddress address = SELECTED_SERVER_TEMPLATE.resolve(serverStatementContext);
HaPolicy.readChildren(crud, address, 1, children -> {

items.add(new StaticItem.Builder(Names.DESTINATIONS)
.id(Ids.MESSAGING_SERVER_DESTINATION)
.action(itemActionFactory.view(
places.selectedProfile(NameTokens.MESSAGING_SERVER_HA_POLICY)
places.selectedProfile(NameTokens.MESSAGING_SERVER_DESTINATION)
.with(SERVER, server)
.build()))
.onPreview(new PreviewContent<>(Names.HA_POLICY,
resources.previews().configurationMessagingHaPolicy()));

} else {
Property child = children.get(0);
HaPolicy haPolicy = HaPolicy.fromResourceName(child.getName());
builder.action(itemActionFactory.view(
places.selectedProfile(NameTokens.MESSAGING_SERVER_HA_POLICY)
.with(SERVER, server)
.build()))
.action(resources.constants().remove(),
item -> removeHaPolicy(serverStatementContext, haPolicy))
.onPreview(new HaPolicyPreview(haPolicy, child.getValue()));
}
items.add(builder.build());

resolve.onInvoke(items);
});
.onPreview(new PreviewContent<>(Names.DESTINATIONS,
resources.previews().configurationMessagingDestinations()))
.build());
items.add(new StaticItem.Builder(Names.CONNECTIONS)
.id(Ids.MESSAGING_SERVER_CONNECTION)
.action(itemActionFactory.view(
places.selectedProfile(NameTokens.MESSAGING_SERVER_CONNECTION)
.with(SERVER, server)
.build()))
.onPreview(new PreviewContent<>(Names.CONNECTIONS,
resources.previews().configurationMessagingConnections()))
.build());
items.add(new StaticItem.Builder(Names.CLUSTERING)
.id(Ids.MESSAGING_SERVER_CLUSTERING)
.action(itemActionFactory.view(
places.selectedProfile(NameTokens.MESSAGING_SERVER_CLUSTERING)
.with(SERVER, server)
.build()))
.onPreview(new PreviewContent<>(Names.CLUSTERING,
resources.previews().configurationMessagingClustering()))
.build());

StaticItem.Builder builder = new StaticItem.Builder(Names.HA_POLICY)
.id(Ids.MESSAGING_SERVER_HA_POLICY);
if (children.isEmpty()) {
builder.action(resources.constants().add(), item -> addHaPolicy(serverStatementContext))
.action(itemActionFactory.view(
places.selectedProfile(NameTokens.MESSAGING_SERVER_HA_POLICY)
.with(SERVER, server)
.build()))
.onPreview(new PreviewContent<>(Names.HA_POLICY,
resources.previews().configurationMessagingHaPolicy()));

} else {
Property child = children.get(0);
HaPolicy haPolicy = HaPolicy.fromResourceName(child.getName());
builder.action(itemActionFactory.view(
places.selectedProfile(NameTokens.MESSAGING_SERVER_HA_POLICY)
.with(SERVER, server)
.build()))
.action(resources.constants().remove(),
item -> removeHaPolicy(serverStatementContext, haPolicy))
.onPreview(new HaPolicyPreview(haPolicy, child.getValue()));
}
items.add(builder.build());

} else {
resolve.onInvoke(items);
}
}));
resolve.onInvoke(items);
});
}), Ids.MESSAGING_SERVER_CONFIGURATION));
}

private void addHaPolicy(StatementContext statementContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

import org.jboss.hal.core.CrudOperations;
import org.jboss.hal.core.finder.ColumnActionFactory;
import org.jboss.hal.core.finder.DependentItemsProvider;
import org.jboss.hal.core.finder.Finder;
import org.jboss.hal.core.finder.FinderColumn;
import org.jboss.hal.core.finder.FinderSegment;
import org.jboss.hal.core.finder.ItemAction;
import org.jboss.hal.core.finder.ItemActionFactory;
import org.jboss.hal.core.finder.ItemDisplay;
Expand Down Expand Up @@ -149,10 +149,6 @@ private StatementContext selectionAwareStatementContext() {
}

private String findServer() {
FinderSegment<?> segment = getFinder().getContext().getPath().findColumn(Ids.UNDERTOW_SERVER);
if (segment != null) {
return Ids.extractUndertowServer(segment.getItemId());
}
return null;
return DependentItemsProvider.resolver(Ids.UNDERTOW_SERVER, getFinder().getContext().getPath()).getName();
}
}
Loading
Loading