use of org.springframework.shell.core.annotation.CliAvailabilityIndicator in project incubator-rya by apache.
the class RyaAdminCommands method arePeriodicPCJCommandsAvailable.
/**
* Enables commands that are available when the Shell is connected to a Rya Instance that supports PCJ Indexing.
*/
@CliAvailabilityIndicator({ CREATE_PERIODIC_PCJ_CMD, DELETE_PERIODIC_PCJ_CMD, LIST_INCREMENTAL_QUERIES })
public boolean arePeriodicPCJCommandsAvailable() {
// The PCJ commands are only available if the Shell is connected to an instance of Rya
// that is new enough to use the RyaDetailsRepository and is configured to maintain PCJs.
final ShellState shellState = state.getShellState();
if (shellState.getConnectionState() == ConnectionState.CONNECTED_TO_INSTANCE && shellState.getStorageType().get() == StorageType.ACCUMULO) {
final GetInstanceDetails getInstanceDetails = shellState.getConnectedCommands().get().getGetInstanceDetails();
final String ryaInstanceName = state.getShellState().getRyaInstanceName().get();
try {
final Optional<RyaDetails> instanceDetails = getInstanceDetails.getDetails(ryaInstanceName);
if (instanceDetails.isPresent()) {
return instanceDetails.get().getPCJIndexDetails().isEnabled();
}
} catch (final RyaClientException e) {
return false;
}
}
return false;
}
use of org.springframework.shell.core.annotation.CliAvailabilityIndicator in project geode by apache.
the class CommandManager method add.
/**
* Method to add new Commands to the parser
*
* @param commandMarker
*/
void add(CommandMarker commandMarker) {
if (CommandManagerAware.class.isAssignableFrom(commandMarker.getClass())) {
((CommandManagerAware) commandMarker).setCommandManager(this);
}
commandMarkers.add(commandMarker);
for (Method method : commandMarker.getClass().getMethods()) {
CliCommand cliCommand = method.getAnnotation(CliCommand.class);
CliAvailabilityIndicator availability = method.getAnnotation(CliAvailabilityIndicator.class);
if (cliCommand == null && availability == null) {
continue;
}
if (cliCommand != null) {
helper.addCommand(cliCommand, method);
}
if (availability != null) {
helper.addAvailabilityIndicator(availability, new MethodTarget(method, commandMarker));
}
}
}
use of org.springframework.shell.core.annotation.CliAvailabilityIndicator in project incubator-rya by apache.
the class RyaAdminCommands method arePCJCommandsAvailable.
/**
* Enables commands that are available when the Shell is connected to a Rya Instance that supports PCJ Indexing.
*/
@CliAvailabilityIndicator({ CREATE_PCJ_CMD, DELETE_PCJ_CMD })
public boolean arePCJCommandsAvailable() {
// The PCJ commands are only available if the Shell is connected to an instance of Rya
// that is new enough to use the RyaDetailsRepository and is configured to maintain PCJs.
final ShellState shellState = state.getShellState();
if (shellState.getConnectionState() == ConnectionState.CONNECTED_TO_INSTANCE) {
final GetInstanceDetails getInstanceDetails = shellState.getConnectedCommands().get().getGetInstanceDetails();
final String ryaInstanceName = state.getShellState().getRyaInstanceName().get();
try {
final Optional<RyaDetails> instanceDetails = getInstanceDetails.getDetails(ryaInstanceName);
if (instanceDetails.isPresent()) {
return instanceDetails.get().getPCJIndexDetails().isEnabled();
}
} catch (final RyaClientException e) {
return false;
}
}
return false;
}
Aggregations