当前位置: 首页>>代码示例>>Java>>正文


Java QueryRequest类代码示例

本文整理汇总了Java中com.rallydev.rest.request.QueryRequest的典型用法代码示例。如果您正苦于以下问题:Java QueryRequest类的具体用法?Java QueryRequest怎么用?Java QueryRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


QueryRequest类属于com.rallydev.rest.request包,在下文中一共展示了QueryRequest类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: taskIdByNameAndWorkProduct

import com.rallydev.rest.request.QueryRequest; //导入依赖的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();
  });
}
 
开发者ID:alechenninger,项目名称:chronicler,代码行数:27,代码来源:RallyExternalTimeSheet.java

示例2: firstSubscriptionId

import com.rallydev.rest.request.QueryRequest; //导入依赖的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();
}
 
开发者ID:alechenninger,项目名称:chronicler,代码行数:21,代码来源:RallyExternalTimeSheet.java

示例3: checkConnection

import com.rallydev.rest.request.QueryRequest; //导入依赖的package包/类
@Override
public boolean checkConnection(ExternalSystem externalSystem) {
	try (RallyRestApi rallyRestApi = getRallyRestApi(new URI(externalSystem.getUrl()), externalSystem.getAccessKey())) {
		QueryRequest defectRequest = new QueryRequest(DEFECT);
		defectRequest.setPageSize(1);
		defectRequest.setLimit(1);
		return rallyRestApi.query(defectRequest).wasSuccessful();
	} catch (Exception e) {
		LOGGER.error(e.getMessage(), e);
		return false;
	}
}
 
开发者ID:reportportal,项目名称:service-rally,代码行数:13,代码来源:RallyStrategy.java

示例4: findAllowedAttributeValues

import com.rallydev.rest.request.QueryRequest; //导入依赖的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());
}
 
开发者ID:reportportal,项目名称:service-rally,代码行数:9,代码来源:RallyStrategy.java

示例5: findDefectAttributeDefinitions

import com.rallydev.rest.request.QueryRequest; //导入依赖的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());
}
 
开发者ID:reportportal,项目名称:service-rally,代码行数:14,代码来源:RallyStrategy.java

示例6: findDefect

import com.rallydev.rest.request.QueryRequest; //导入依赖的package包/类
private Optional<Defect> findDefect(RallyRestApi restApi, String ticketId) throws IOException {
	QueryRequest defectRequest = new QueryRequest(DEFECT);
	defectRequest.setQueryFilter(new QueryFilter(FORMATTED_ID, "=", ticketId));
	QueryResponse query = restApi.query(defectRequest);
	if (!query.wasSuccessful())
		return Optional.empty();
	List<Defect> defects = gson.fromJson(query.getResults(), new TypeToken<List<Defect>>() {
	}.getType());
	return defects.stream().findAny();
}
 
开发者ID:reportportal,项目名称:service-rally,代码行数:11,代码来源:RallyStrategy.java

示例7: getLastRecordedEntryTime

import com.rallydev.rest.request.QueryRequest; //导入依赖的package包/类
@Override
public Optional<ZonedDateTime> getLastRecordedEntryTime() {
  try {
    QueryRequest forMostRecentValue = new QueryRequest("timeentryvalue");
    QueryFilter byUser = new QueryFilter("TimeEntryItem.User", "=", user);
    String workspaceRef = workspaceRefByName(workspaceName);

    forMostRecentValue.setWorkspace(workspaceRef);
    forMostRecentValue.setOrder("DateVal desc");
    forMostRecentValue.setLimit(1);
    forMostRecentValue.setQueryFilter(byUser);
    forMostRecentValue.setPageSize(1);

    QueryResponse response = rally.query(forMostRecentValue);

    if (!response.wasSuccessful()) {
      throw new ChroniclerException("Failed to find most recent time entry value: "
          + Arrays.toString(response.getErrors()));
    }

    if (response.getTotalResultCount() == 0) {
      return Optional.empty();
    }

    TimeEntryValue value = TimeEntryValue.fromJson(response.getResults()
        .get(0)
        .getAsJsonObject());

    // Move to system time zone since Rally's precision is really only the day here.
    return Optional.of(value.getDateVal().withZoneSameLocal(ZoneId.systemDefault()));
  } catch (IOException | ParseException e) {
    throw new ChroniclerException(e);
  }
}
 
开发者ID:alechenninger,项目名称:chronicler,代码行数:35,代码来源:RallyExternalTimeSheet.java

示例8: queryRally

import com.rallydev.rest.request.QueryRequest; //导入依赖的package包/类
private QueryResponse queryRally(QueryRequest request) {
  try {
    return rally.query(request);
  } catch (IOException e) {
    throw new ChroniclerException(e);
  }
}
 
开发者ID:alechenninger,项目名称:chronicler,代码行数:8,代码来源:RallyExternalTimeSheet.java

示例9: projectIdByName

import com.rallydev.rest.request.QueryRequest; //导入依赖的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();
  });
}
 
开发者ID:alechenninger,项目名称:chronicler,代码行数:30,代码来源:RallyExternalTimeSheet.java

示例10: workspaceRefByName

import com.rallydev.rest.request.QueryRequest; //导入依赖的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();
}
 
开发者ID:alechenninger,项目名称:chronicler,代码行数:28,代码来源:RallyExternalTimeSheet.java

示例11: getTimeEntryItem

import com.rallydev.rest.request.QueryRequest; //导入依赖的package包/类
private Optional<String> getTimeEntryItem(String workspaceRef, String projectId,
    String workProductId, Optional<String> taskId, TimeEntry entry) throws IOException {
  QueryRequest forTimeEntryItem = new QueryRequest("timeentryitem");

  forTimeEntryItem.setWorkspace(workspaceRef);

  QueryFilter byProject = new QueryFilter("Project.ObjectID", "=", projectId);
  QueryFilter byWorkProduct = new QueryFilter("WorkProduct.ObjectID", "=", workProductId);
  QueryFilter byUserName = new QueryFilter("User.UserName", "=", user);
  QueryFilter byWeekStartDate = new QueryFilter("WeekStartDate", "=",
      ISO_8601_UTC.format(weekStartDateUtc(entry.getDay())));

  if (taskId.isPresent()) {
    QueryFilter byTask = new QueryFilter("Task.ObjectID", "=", taskId.get());

    forTimeEntryItem.setQueryFilter(byUserName.and(byWeekStartDate).and(byProject)
        .and(byWorkProduct).and(byTask));
  } else {
    forTimeEntryItem.setQueryFilter(byUserName.and(byWeekStartDate).and(byProject)
        .and(byWorkProduct));
  }

  QueryResponse response = rally.query(forTimeEntryItem);

  if (!response.wasSuccessful()) {
    throw new ChroniclerException("Failed to find existing time entry item (if any) for entry, "
        + entry + ": " + Arrays.toString(response.getErrors()));
  }

  if (response.getTotalResultCount() == 0) {
    return Optional.empty();
  }

  if (response.getTotalResultCount() > 1) {
    throw new ChroniclerException("Found multiple time entry items... somethings not right.\n"
        + "Query was: " + forTimeEntryItem.getQueryFilter() + "\n"
        + "Results were: " + response.getResults());
  }

  return Optional.of(response.getResults()
      .get(0)
      .getAsJsonObject()
      .get(OBJECT_ID)
      .getAsString());
}
 
开发者ID:alechenninger,项目名称:chronicler,代码行数:46,代码来源:RallyExternalTimeSheet.java

示例12: workProductIdByNameAndProject

import com.rallydev.rest.request.QueryRequest; //导入依赖的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);
}
 
开发者ID:alechenninger,项目名称:chronicler,代码行数:49,代码来源:RallyExternalTimeSheet.java


注:本文中的com.rallydev.rest.request.QueryRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。