當前位置: 首頁>>代碼示例>>Java>>正文


Java Fetch類代碼示例

本文整理匯總了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();
}
 
開發者ID:alechenninger,項目名稱:chronicler,代碼行數:23,代碼來源:RallyExternalTimeSheet.java

示例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();
  });
}
 
開發者ID:alechenninger,項目名稱:chronicler,代碼行數:27,代碼來源:RallyExternalTimeSheet.java

示例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();
}
 
開發者ID:alechenninger,項目名稱:chronicler,代碼行數:21,代碼來源:RallyExternalTimeSheet.java

示例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.");
    }
}
 
開發者ID:trevleyb,項目名稱:TeamCityRallyIntegration,代碼行數:21,代碼來源:RallyConnector.java

示例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;
}
 
開發者ID:trevleyb,項目名稱:TeamCityRallyIntegration,代碼行數:25,代碼來源:RallyConnector.java

示例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;
}
 
開發者ID:trevleyb,項目名稱:TeamCityRallyIntegration,代碼行數:18,代碼來源:RallyConnector.java

示例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());
}
 
開發者ID:reportportal,項目名稱:service-rally,代碼行數:9,代碼來源:RallyStrategy.java

示例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());
}
 
開發者ID:reportportal,項目名稱:service-rally,代碼行數:14,代碼來源:RallyStrategy.java

示例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();
  });
}
 
開發者ID:alechenninger,項目名稱:chronicler,代碼行數:30,代碼來源:RallyExternalTimeSheet.java

示例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();
}
 
開發者ID:alechenninger,項目名稱:chronicler,代碼行數:28,代碼來源:RallyExternalTimeSheet.java

示例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.");
    }
}
 
開發者ID:trevleyb,項目名稱:TeamCityRallyIntegration,代碼行數:15,代碼來源:RallyConnector.java

示例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);
}
 
開發者ID:alechenninger,項目名稱:chronicler,代碼行數:49,代碼來源:RallyExternalTimeSheet.java


注:本文中的com.rallydev.rest.util.Fetch類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。