本文整理汇总了Java中com.rallydev.rest.util.Fetch类的典型用法代码示例。如果您正苦于以下问题:Java Fetch类的具体用法?Java Fetch怎么用?Java Fetch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Fetch类属于com.rallydev.rest.util包,在下文中一共展示了Fetch类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTimeEntryItem
import com.rallydev.rest.util.Fetch; //导入依赖的package包/类
private String createTimeEntryItem(String projectId, String workProductId,
Optional<String> taskId, TimeEntry entry) throws IOException {
ZonedDateTime weekStartDate = weekStartDateUtc(entry.getDay());
TimeEntryItem item = taskId
.map(_taskId -> new TimeEntryItem(projectId, workProductId, _taskId, user, weekStartDate))
.orElse(new TimeEntryItem(projectId, workProductId, user, weekStartDate));
CreateRequest newTimeEntryItem = new CreateRequest("timeentryitem", item.toJson());
newTimeEntryItem.setFetch(new Fetch(OBJECT_ID));
CreateResponse response = rally.create(newTimeEntryItem);
if (!response.wasSuccessful()) {
throw new ChroniclerException("Failed to create time entry item: "
+ Arrays.toString(response.getErrors()));
}
return response.getObject()
.get(OBJECT_ID)
.getAsString();
}
示例2: taskIdByNameAndWorkProduct
import com.rallydev.rest.util.Fetch; //导入依赖的package包/类
private String taskIdByNameAndWorkProduct(String taskName, String workProductId, String workspaceRef) {
TaskKey taskKey = new TaskKey(taskName, workProductId, workspaceRef);
return taskIdCache.computeIfAbsent(taskKey, task -> {
QueryRequest forTask = new QueryRequest("task");
QueryFilter byName = new QueryFilter("Name", "=", taskName);
QueryFilter byWorkProduct = new QueryFilter("WorkProduct.ObjectID", "=", workProductId);
forTask.setQueryFilter(byName.and(byWorkProduct));
forTask.setWorkspace(workspaceRef);
forTask.setFetch(new Fetch(OBJECT_ID));
QueryResponse result = queryRally(forTask);
if (result.getTotalResultCount() == 0) {
throw new ChroniclerException("No tasks found for task name, " + taskName + ", and work product "
+ "id, " + workProductId);
}
return result.getResults()
.get(0)
.getAsJsonObject()
.get(OBJECT_ID)
.getAsString();
});
}
示例3: firstSubscriptionId
import com.rallydev.rest.util.Fetch; //导入依赖的package包/类
private String firstSubscriptionId() throws IOException {
QueryRequest subscription = new QueryRequest("subscription");
subscription.setFetch(new Fetch(OBJECT_ID));
QueryResponse subscriptionResult = rally.query(subscription);
if (subscriptionResult.getTotalResultCount() == 0) {
throw new ChroniclerException("Account has no subscriptions?");
}
if (subscriptionResult.getTotalResultCount() > 1) {
throw new ChroniclerException("Got more than one subscription associated with account. "
+ "Provide a subscription name.");
}
return subscriptionResult.getResults()
.get(0)
.getAsJsonObject()
.get(OBJECT_ID)
.getAsString();
}
示例4: getRallySubscription
import com.rallydev.rest.util.Fetch; //导入依赖的package包/类
private JsonObject getRallySubscription() throws Exception {
try {
LOG.info("Getting Subscription data from Rally.");
QueryRequest request = new QueryRequest("Subscription");
request.setFetch(new Fetch("Workspaces,Name,Projects,BuildDefinitions"));
QueryResponse response = getRallyInstance().query(request);
if (response.wasSuccessful()) {
LOG.info("Obtained Subscription Data: Response Count=" + response.getTotalResultCount());
return response.getResults().get(0).getAsJsonObject();
} else {
LOG.error("Could not obtain subscription information from Rally.");
LOG.error(response.getErrors().toString());
throw new ConnectionException("Could not connect to Rally and get Subscription data.");
}
} catch (Exception e) {
LOG.error("Could not obtain subscription information from Rally.");
LOG.error(e);
throw new ConnectionException("Could not connect to Rally and get Subscription data.");
}
}
示例5: FindChangeSet
import com.rallydev.rest.util.Fetch; //导入依赖的package包/类
public String FindChangeSet(String scmName, String revision) {
LOG.info("Looking for change set: " + scmName + ":" + revision);
try {
RallyRepository repository = getSubscription().FindRepository(scmName);
if (repository != null) {
QueryRequest request = new QueryRequest("ChangeSet");
QueryFilter filter = new QueryFilter("SCMRepository", "=", repository.getRef()).and(new QueryFilter("Revision", "=", revision));
request.setFetch(new Fetch("Name,Revision"));
request.setQueryFilter(filter);
QueryResponse response = getRallyInstance().query(request);
if (response.wasSuccessful() && response.getTotalResultCount() > 0) {
LOG.info("Found change set. Response Count=" + response.getTotalResultCount());
return response.getResults().get(0).getAsJsonObject().get("_ref").getAsString();
} else {
LOG.info("Could not obtain ChangeSet data for: " + scmName + " : " + revision);
LOG.info(response.getErrors().toString());
}
}
} catch (Exception e) {
LOG.error("Error finding change set. ");
LOG.error(e);
}
return null;
}
示例6: Get
import com.rallydev.rest.util.Fetch; //导入依赖的package包/类
public JsonObject Get(String ref, String[] fields) {
LOG.info("Getting: " + ref);
try {
GetRequest request = new GetRequest(ref);
if (fields != null && fields.length > 0) request.setFetch(new Fetch(fields));
GetResponse response = getRallyInstance().get(request);
if (!response.wasSuccessful()) {
LOG.error("Could not get object: " + ref);
logErrors(response.getErrors());
logWarnings(response.getWarnings());
}
return response.getObject();
} catch (Exception e) {
LOG.error("Could not get object: " + ref, e);
}
return null;
}
示例7: findAllowedAttributeValues
import com.rallydev.rest.util.Fetch; //导入依赖的package包/类
private List<AllowedAttributeValue> findAllowedAttributeValues(RallyRestApi restApi, AttributeDefinition attributeDefinition)
throws IOException {
QueryRequest allowedValuesRequest = new QueryRequest((JsonObject) gson.toJsonTree(attributeDefinition.getAllowedValue()));
allowedValuesRequest.setFetch(new Fetch(STRING_VALUE));
QueryResponse allowedValuesResponse = restApi.query(allowedValuesRequest);
return gson.fromJson(allowedValuesResponse.getResults(), new TypeToken<List<AllowedAttributeValue>>() {
}.getType());
}
示例8: findDefectAttributeDefinitions
import com.rallydev.rest.util.Fetch; //导入依赖的package包/类
private List<AttributeDefinition> findDefectAttributeDefinitions(RallyRestApi restApi) throws IOException {
QueryRequest typeDefRequest = new QueryRequest(TYPE_DEFINITION);
typeDefRequest.setFetch(new Fetch(OBJECT_ID, ATTRIBUTES));
typeDefRequest.setQueryFilter(new QueryFilter(NAME, "=", DEFECT));
QueryResponse typeDefQueryResponse = restApi.query(typeDefRequest);
JsonObject typeDefJsonObject = typeDefQueryResponse.getResults().get(0).getAsJsonObject();
QueryRequest attributeRequest = new QueryRequest(
(JsonObject) gson.toJsonTree(gson.fromJson(typeDefJsonObject, TypeDefinition.class).getAttributeDefinition()));
attributeRequest.setFetch(new Fetch(ALLOWED_VALUES, ELEMENT_NAME, NAME, REQUIRED, TYPE, OBJECT_ID, READ_ONLY));
QueryResponse attributesQueryResponse = restApi.query(attributeRequest);
return gson.fromJson(attributesQueryResponse.getResults(), new TypeToken<List<AttributeDefinition>>() {
}.getType());
}
示例9: projectIdByName
import com.rallydev.rest.util.Fetch; //导入依赖的package包/类
private String projectIdByName(String projectName, String workspaceRef) {
ProjectKey projectKey = new ProjectKey(projectName, workspaceRef);
return projectIdCache.computeIfAbsent(projectKey, project -> {
QueryRequest forProject = new QueryRequest("project");
QueryFilter byName = new QueryFilter("Name", "=", projectName);
forProject.setQueryFilter(byName);
forProject.setWorkspace(workspaceRef);
forProject.setFetch(new Fetch(OBJECT_ID));
QueryResponse result = queryRally(forProject);
if (result.getTotalResultCount() == 0) {
throw new ChroniclerException("No projects found for name, " + projectName);
}
if (result.getTotalResultCount() > 1) {
throw new ChroniclerException("Multiple projects found for name, " + projectName + ". I'm "
+ "afraid I may record something in the wrong place.");
}
return result.getResults()
.get(0)
.getAsJsonObject()
.get(OBJECT_ID)
.getAsString();
});
}
示例10: workspaceRefByName
import com.rallydev.rest.util.Fetch; //导入依赖的package包/类
private String workspaceRefByName(String workspace) throws IOException {
String subscriptionId = firstSubscriptionId();
QueryRequest forWorkspace = new QueryRequest("subscription/" + subscriptionId + "/workspaces");
QueryFilter byName = new QueryFilter("Name", "=", workspace);
forWorkspace.setQueryFilter(byName);
forWorkspace.setFetch(new Fetch("_ref"));
QueryResponse response = rally.query(forWorkspace);
if (response.getTotalResultCount() == 0) {
throw new ChroniclerException("No workspaces found for subscription, " + subscriptionId + ", "
+ "with name, " + workspace + ".");
}
if (response.getTotalResultCount() > 1) {
throw new ChroniclerException("Multiple workspaces found for subscription, " + subscriptionId
+ ", with name, " + workspace + ".");
}
return response.getResults()
.get(0)
.getAsJsonObject()
.get("_ref")
.getAsString();
}
示例11: getSCMRepositories
import com.rallydev.rest.util.Fetch; //导入依赖的package包/类
private JsonArray getSCMRepositories() throws Exception {
LOG.info("Getting SCM Repository Data from Rally.");
QueryRequest request = new QueryRequest("SCMRepository");
request.setFetch(new Fetch("Name,Description,SCMType,Projects"));
QueryResponse response = getRallyInstance().query(request);
if (response.wasSuccessful()) {
LOG.info("Obtained Repository Data: Response Count=" + response.getTotalResultCount());
return response.getResults();
} else {
LOG.error("Could not obtain SCMRepository information from Rally.");
LOG.error(response.getErrors().toString());
throw new ConnectionException("Could not connect to Rally and get SCMRepository data.");
}
}
示例12: workProductIdByNameAndProject
import com.rallydev.rest.util.Fetch; //导入依赖的package包/类
private String workProductIdByNameAndProject(String workProductName, String projectId,
String workspaceRef, ZonedDateTime day) {
WorkProductKey workProductKey = new WorkProductKey(workProductName, projectId, workspaceRef);
List<IdAndDate> products = workProductIdCache.computeIfAbsent(workProductKey, workProduct -> {
QueryRequest forWorkProduct = new QueryRequest("artifact");
QueryFilter byName = new QueryFilter("Name", "=", workProductName);
QueryFilter byProject = new QueryFilter("Project.ObjectID", "=", projectId);
forWorkProduct.setQueryFilter(byName.and(byProject));
forWorkProduct.setWorkspace(workspaceRef);
forWorkProduct.setFetch(new Fetch(OBJECT_ID, "CreationDate"));
forWorkProduct.setOrder("CreationDate DESC");
QueryResponse result = queryRally(forWorkProduct);
if (result.getTotalResultCount() == 0) {
throw new ChroniclerException("No work products found for name, " + workProductName);
}
if (result.getTotalResultCount() > 1) {
logger.warning("Multiple results for work product found for name, " + workProductName +
". Will choose latest one that is created before entry entered.");
}
List<IdAndDate> results = new ArrayList<>(result.getTotalResultCount());
for (JsonElement product : result.getResults()) {
JsonObject productObj = product.getAsJsonObject();
ZonedDateTime creationDate = RallyExternalTimeSheet.ISO_8601_UTC
.parse(productObj.get("CreationDate").getAsString(), LocalDateTime::from)
.atZone(RallyExternalTimeSheet.ISO_8601_UTC.getZone());
String id = productObj.get(OBJECT_ID).getAsString();
results.add(new IdAndDate(id, creationDate));
}
return results;
});
if (products.size() == 1) {
return products.get(0).id;
}
return products.stream()
.filter(p -> !p.date.isAfter(day))
.findFirst()
.map(p -> p.id)
.orElse(products.get(0).id);
}