Package org.sonar.wsclient.services

Examples of org.sonar.wsclient.services.WSUtils


*/
public class ManualMeasureUnmarshaller extends AbstractUnmarshaller<ManualMeasure> {

  @Override
  protected ManualMeasure parse(Object json) {
    WSUtils utils = WSUtils.getINSTANCE();
    return new ManualMeasure()
        .setId(utils.getLong(json, "id"))
        .setMetricKey(utils.getString(json, "metric"))
        .setResourceKey(utils.getString(json, "resource"))
        .setCreatedAt(utils.getDateTime(json, "created_at"))
        .setUpdatedAt(utils.getDateTime(json, "updated_at"))
        .setUserLogin(utils.getString(json, "login"))
        .setUsername(utils.getString(json, "username"))
        .setValue(utils.getDouble(json, "val"))
        .setTextValue(utils.getString(json, "text"));
  }
View Full Code Here


* @since 2.9
*/
public class ServerSetupUnmarshaller implements Unmarshaller<ServerSetup> {
  @Override
  public ServerSetup toModel(String json) {
    WSUtils utils = WSUtils.getINSTANCE();
    Object map = utils.parse(json);
    return new ServerSetup()
      .setStatus(utils.getString(map, "status"))
      .setMessage(utils.getString(map, "msg"));
  }
View Full Code Here

public class AuthenticationUnmarshaller implements Unmarshaller<Authentication> {

  @Override
  public Authentication toModel(String json) {
    WSUtils utils = WSUtils.getINSTANCE();
    Object map = utils.parse(json);

    Boolean validJson = utils.getBoolean(map, "valid");
    return new Authentication().setValid(validJson != null ? validJson : false);
  }
View Full Code Here

public class DependencyUnmarshaller extends AbstractUnmarshaller<Dependency> {

  @Override
  protected Dependency parse(Object json) {
    WSUtils utils = WSUtils.getINSTANCE();
    return new Dependency()
        .setId(utils.getString(json, "id"))
        .setFromId(utils.getLong(json, "fi"))
        .setToId(utils.getLong(json, "ti"))
        .setFromKey(utils.getString(json, "fk"))
        .setToKey(utils.getString(json, "tk"))
        .setUsage(utils.getString(json, "u"))
        .setWeight(utils.getInteger(json, "w"))
        .setFromName(utils.getString(json, "fn"))
        .setFromQualifier(utils.getString(json, "fq"))
        .setToName(utils.getString(json, "tn"))
        .setToQualifier(utils.getString(json, "tq"));
  }
View Full Code Here

import java.util.List;

public class DependencyTreeUnmarshaller extends AbstractUnmarshaller<DependencyTree> {
  @Override
  protected DependencyTree parse(Object json) {
    WSUtils utils = WSUtils.getINSTANCE();
    DependencyTree tree = new DependencyTree()
        .setDepId(utils.getString(json, "did"))
        .setResourceId(utils.getString(json, "rid"))
        .setResourceKey(utils.getString(json, "k"))
        .setResourceName(utils.getString(json, "n"))
        .setResourceScope(utils.getString(json, "s"))
        .setResourceQualifier(utils.getString(json, "q"))
        .setResourceVersion(utils.getString(json, "v"))
        .setUsage(utils.getString(json, "u"))
        .setWeight(utils.getInteger(json, "w"));

    List<DependencyTree> to = new ArrayList<DependencyTree>();
    tree.setTo(to);

    Object toJson = utils.getField(json, "to");
    if (toJson != null) {
      for (int i = 0; i < utils.getArraySize(toJson); i++) {
        to.add(parse(utils.getArrayElement(toJson, i)));
      }
    }
    return tree;
  }
View Full Code Here

*/
public class ResourceSearchUnmarshaller extends AbstractUnmarshaller<ResourceSearchResult> {

  @Override
  protected ResourceSearchResult parse(Object json) {
    WSUtils utils = WSUtils.getINSTANCE();
    ResourceSearchResult result = new ResourceSearchResult();
    result.setPage(utils.getInteger(json, "page"));
    result.setPageSize(utils.getInteger(json, "page_size"));
    result.setTotal(utils.getInteger(json, "total"));

    List<ResourceSearchResult.Resource> resources = new ArrayList<ResourceSearchResult.Resource>();
    JSONArray dataJson = JsonUtils.getArray((JSONObject) json, "data");
    if (dataJson != null) {
      for (Object jsonResource : dataJson) {
View Full Code Here

    }
    return result;
  }

  private TimeMachineCell[] toCells(Object cells) {
    WSUtils utils = WSUtils.getINSTANCE();
    int size = utils.getArraySize(cells);
    TimeMachineCell[] result = new TimeMachineCell[size];
    for (int i = 0; i < size; i++) {
      Object cellJson = utils.getArrayElement(cells, i);
      Object valuesJson = utils.getField(cellJson, "v");
      if (valuesJson != null) {
        Object[] resultValues = new Object[utils.getArraySize(valuesJson)];
        for (int indexValue = 0; indexValue < utils.getArraySize(valuesJson); indexValue++) {
          Object value = utils.getArrayElement(valuesJson, indexValue);
          resultValues[indexValue] = value;
        }
        result[i] = new TimeMachineCell(utils.getDateTime(cellJson, "d"), resultValues);
      }
    }
    return result;
  }
View Full Code Here

public class ProfileUnmarshaller extends AbstractUnmarshaller<Profile> {

  @Override
  protected Profile parse(Object json) {
    WSUtils utils = WSUtils.getINSTANCE();
    Profile profile = new Profile();
    Boolean defaultProfile = utils.getBoolean(json, "default");
    profile
        .setLanguage(utils.getString(json, "language"))
        .setName(utils.getString(json, "name"))
        .setDefaultProfile(defaultProfile != null ? defaultProfile : false)
        .setParentName(utils.getString(json, "parent"));

    parseRules(utils, profile, json);
    return profile;
  }
View Full Code Here

* @author Evgeny Mandrikov
*/
public class ServerUnmarshaller implements Unmarshaller<Server> {
  @Override
  public Server toModel(String json) {
    WSUtils utils = WSUtils.getINSTANCE();
    Object map = utils.parse(json);
    Server server = new Server()
        .setId(utils.getString(map, "id"))
        .setVersion(utils.getString(map, "version"))
        .setStatusMessage(utils.getString(map, "status_msg"));
    String status = utils.getString(map, "status");
    if (status != null) {
      server.setStatus(Server.Status.valueOf(status));
    }
    return server;
  }
View Full Code Here

public class PropertyUnmarshaller extends AbstractUnmarshaller<Property> {

  @Override
  protected Property parse(Object json) {
    WSUtils utils = WSUtils.getINSTANCE();
    return new Property()
        .setKey(utils.getString(json, "key"))
        .setValue(utils.getString(json, "value"));
  }
View Full Code Here

TOP

Related Classes of org.sonar.wsclient.services.WSUtils

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.