本文整理汇总了Java中org.jboss.forge.addon.ui.result.Result类的典型用法代码示例。如果您正苦于以下问题:Java Result类的具体用法?Java Result怎么用?Java Result使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Result类属于org.jboss.forge.addon.ui.result包,在下文中一共展示了Result类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMessage
import org.jboss.forge.addon.ui.result.Result; //导入依赖的package包/类
/**
* Returns the result message handling composite results
*/
public static String getMessage(Result result) {
if (result == null) {
return null;
} else if (result instanceof CompositeResult) {
CompositeResult compositeResult = (CompositeResult) result;
StringBuilder builder = new StringBuilder();
List<Result> results = compositeResult.getResults();
for (Result child : results) {
String message = getMessage(child);
if (message != null && message.trim().length() > 0) {
if (builder.length() > 0) {
builder.append("\n");
}
builder.append(message);
}
}
return builder.toString();
}
return result.getMessage();
}
示例2: execute
import org.jboss.forge.addon.ui.result.Result; //导入依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
UIContext uiContext = context.getUIContext();
Map<Object, Object> attributeMap = uiContext.getAttributeMap();
List<GitClonedRepoDetails> clonedRepos = (List<GitClonedRepoDetails>) attributeMap.get(AttributeMapKeys.GIT_CLONED_REPOS);
if (clonedRepos != null) {
for (GitClonedRepoDetails clonedRepo : clonedRepos) {
Git git = clonedRepo.getGit();
String gitUrl = clonedRepo.getGitUrl();
UserDetails userDetails = clonedRepo.getUserDetails();
File basedir = clonedRepo.getDirectory();
String message = "Adding pipeline";
try {
LOG.info("Performing a git commit and push on URI " + gitUrl);
gitAddCommitAndPush(git, gitUrl, userDetails, basedir, message);
} catch (GitAPIException e) {
return Results.fail("Failed to commit and push repository " + clonedRepo.getGitRepoName() + " due to " + e, e);
} finally {
removeTemporaryFiles(basedir);
}
}
}
return Results.success();
}
示例3: execute
import org.jboss.forge.addon.ui.result.Result; //导入依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
final UIContext uiContext = context.getUIContext();
final Project project = helper.getProject(uiContext);
final Map<Object, Object> attributeMap = uiContext.getAttributeMap();
final JPADataSource dataSource = (JPADataSource) attributeMap.get(JPADataSource.class);
persistenceOperations.setup(SpringBootJPAFacet.PERSISTENCE_UNIT_NAME, project, dataSource, false);
// if we're using H2, Derby or HSQL embedded databases, we need to remove any previously set data
// source properties
if (!SpringBootPersistenceContainer.isNotEmbeddedDB(dataSource.getDatabase())) {
SpringBootHelper.removeSpringDataPropertiesFromApplication(project);
}
return null;
}
示例4: execute
import org.jboss.forge.addon.ui.result.Result; //导入依赖的package包/类
@Override
public Result execute(final UIExecutionContext context) throws Exception
{
final UIContext uiContext = context.getUIContext();
applyUIValues(uiContext);
// add driver dependency
final Project project = helper.getProject(uiContext);
final DatabaseType database = dbType.getValue();
final Coordinate driverCoordinate = database.getDriverCoordinate();
SpringBootHelper.addDependency(project, driverCoordinate.getGroupId(), driverCoordinate.getArtifactId())
.setScopeType("runtime");
SpringBootHelper.addSpringBootDependency(project, SpringBootFacet.SPRING_BOOT_STARTER_DATA_JPA_ARTIFACT)
.setScopeType("runtime");
return Results.success("Spring Boot JPA successfully set up!");
}
示例5: getResultMessage
import org.jboss.forge.addon.ui.result.Result; //导入依赖的package包/类
protected static String getResultMessage(Result result) {
if (result instanceof CompositeResult) {
CompositeResult compositeResult = (CompositeResult) result;
List<Result> results = compositeResult.getResults();
StringBuilder buffer = new StringBuilder();
for (Result childResult : results) {
String childResultMessage = getResultMessage(childResult);
if (Strings.isNotBlank(childResultMessage)) {
if (buffer.length() > 0) {
buffer.append("\n");
}
buffer.append(childResultMessage);
}
}
return buffer.toString();
} else if (result != null) {
return result.getMessage();
} else {
return null;
}
}
示例6: execute
import org.jboss.forge.addon.ui.result.Result; //导入依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
String buildConfigName = buildName.getValue();
Objects.assertNotNull(buildConfigName, "buildName");
Map<String, String> labels = BuildConfigs.createBuildLabels(buildConfigName);
String gitUrlText = getOrFindGitUrl(context, gitUri.getValue());
String imageText = image.getValue();
List<EnvVar> envVars = createEnvVars(buildConfigName, gitUrlText, mavenCommand.getValue());
BuildConfig buildConfig = BuildConfigs.createIntegrationTestBuildConfig(buildConfigName, labels, gitUrlText, imageText, envVars);
LOG.info("Generated BuildConfig: " + toJson(buildConfig));
ImageStream imageRepository = BuildConfigs.imageRepository(buildConfigName, labels);
Controller controller = createController();
controller.applyImageStream(imageRepository, "generated ImageStream: " + toJson(imageRepository));
controller.applyBuildConfig(buildConfig, "generated BuildConfig: " + toJson(buildConfig));
return Results.success("Added BuildConfig: " + Builds.getName(buildConfig) + " to OpenShift at master: " + getKubernetes().getMasterUrl());
}
示例7: getResultMessage
import org.jboss.forge.addon.ui.result.Result; //导入依赖的package包/类
public static String getResultMessage(Result result) {
if (result instanceof CompositeResult) {
CompositeResult compositeResult = (CompositeResult) result;
List<Result> results = compositeResult.getResults();
StringBuilder buffer = new StringBuilder();
for (Result childResult : results) {
String childResultMessage = getResultMessage(childResult);
if (Strings.isNotBlank(childResultMessage)) {
if (buffer.length() > 0) {
buffer.append("\n");
}
buffer.append(childResultMessage);
}
}
return buffer.toString();
} else if (result != null) {
return result.getMessage();
} else {
return null;
}
}
示例8: execute
import org.jboss.forge.addon.ui.result.Result; //导入依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
// only execute if we are last
if (last) {
Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap();
String kind = mandatoryAttributeValue(attributeMap, "kind");
if ("springboot".equals(kind)) {
return doExecuteSpringBoot(context);
} else {
return doExecuteJava(context);
}
} else {
return null;
}
}
示例9: ensureCamelArtifactIdAdded
import org.jboss.forge.addon.ui.result.Result; //导入依赖的package包/类
public static Result ensureCamelArtifactIdAdded(Project project, CamelComponentDetails details, DependencyInstaller dependencyInstaller) {
String groupId = details.getGroupId();
String artifactId = details.getArtifactId();
Dependency core = CamelProjectHelper.findCamelCoreDependency(project);
if (core == null) {
return Results.fail("The project does not include camel-core");
}
// we want to use same version as camel-core if its a camel component
// otherwise use the version from the dto
String version;
if ("org.apache.camel".equals(groupId)) {
version = core.getCoordinate().getVersion();
} else {
version = details.getVersion();
}
DependencyBuilder component = DependencyBuilder.create().setGroupId(groupId)
.setArtifactId(artifactId).setVersion(version);
// install the component
dependencyInstaller.install(project, component);
return null;
}
示例10: execute
import org.jboss.forge.addon.ui.result.Result; //导入依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap();
// only execute if we are last
if (last) {
String kind = mandatoryAttributeValue(attributeMap, "kind");
if ("xml".equals(kind)) {
return executeXml(context, attributeMap);
} else if ("java".equals(kind)) {
return executeJava(context, attributeMap);
} else {
return executeOther(context, attributeMap);
}
} else {
return null;
}
}
示例11: editEndpointXml
import org.jboss.forge.addon.ui.result.Result; //导入依赖的package包/类
private Result editEndpointXml(List<String> lines, String lineNumber, String endpointUrl, String uri, FileResource file, String xml) {
// the list is 0-based, and line number is 1-based
int idx = Integer.valueOf(lineNumber) - 1;
String line = lines.get(idx);
// replace uri with new value
line = StringHelper.replaceAll(line, endpointUrl, uri);
lines.set(idx, line);
LOG.info("Updating " + endpointUrl + " to " + uri + " at line " + lineNumber + " in file " + xml);
// and save the file back
String content = LineNumberHelper.linesToString(lines);
file.setContents(content);
return Results.success("Update endpoint uri: " + uri + " in file " + xml);
}
示例12: editEndpointOther
import org.jboss.forge.addon.ui.result.Result; //导入依赖的package包/类
protected Result editEndpointOther(Project project, ResourcesFacet facet, FileResource file, String uri, String endpointUrl,
String currentFile, String lineNumber) throws Exception {
List<String> lines = LineNumberHelper.readLines(file.getResourceInputStream());
// the list is 0-based, and line number is 1-based
int idx = Integer.valueOf(lineNumber) - 1;
String line = lines.get(idx);
// replace uri with new value
line = StringHelper.replaceAll(line, endpointUrl, uri);
lines.set(idx, line);
LOG.info("Updating " + endpointUrl + " to " + uri + " at line " + lineNumber + " in file " + currentFile);
// and save the file back
String content = LineNumberHelper.linesToString(lines);
file.setContents(content);
return Results.success("Update endpoint uri: " + uri + " in file " + currentFile);
}
示例13: execute
import org.jboss.forge.addon.ui.result.Result; //导入依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap();
// only execute if we are last
if (last) {
String kind = mandatoryAttributeValue(attributeMap, "kind");
if ("xml".equals(kind)) {
return executeXml(context, attributeMap);
} else {
throw new UnsupportedOperationException("Java not yet supported");
}
} else {
return null;
}
}
示例14: execute
import org.jboss.forge.addon.ui.result.Result; //导入依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
String scheme = name.getValue();
// maybe the connector has already been added to the catalog
String json = camelCatalog.componentJSonSchema(scheme);
if (json == null) {
// discover classpath and find all the connectors and add them to the catalog
Project project = getSelectedProjectOrNull(context.getUIContext());
if (project != null) {
discoverCustomCamelComponentsOnClasspathAndAddToCatalog(camelCatalog, project);
}
// load schema again
json = camelCatalog.componentJSonSchema(scheme);
}
if (json != null) {
return Results.success(json);
} else {
return Results.fail("Connector " + scheme + " not found");
}
}
示例15: testSomething
import org.jboss.forge.addon.ui.result.Result; //导入依赖的package包/类
@Test
public void testSomething() throws Exception {
File tempDir = OperatingSystemUtils.createTempDir();
try {
Project project = projectFactory.createTempProject();
Assert.assertNotNull("Should have created a project", project);
CommandController command = testHarness.createCommandController(CamelSetupCommand.class, project.getRoot());
command.initialize();
command.setValueFor("kind", "camel-spring");
Result result = command.execute();
Assert.assertFalse("Should setup Camel in the project", result instanceof Failed);
command = testHarness.createCommandController(CamelGetComponentsCommand.class, project.getRoot());
command.initialize();
result = command.execute();
Assert.assertFalse("Should not fail", result instanceof Failed);
String message = result.getMessage();
System.out.println(message);
} finally {
tempDir.delete();
}
}