All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gov.nasa.pds.registry.common.connection.es.BulkImpl Maven / Gradle / Ivy

The newest version!
package gov.nasa.pds.registry.common.connection.es;


import java.util.Collection;
import gov.nasa.pds.registry.common.Request;
import gov.nasa.pds.registry.common.Request.Bulk;

class BulkImpl implements Request.Bulk {
  private String index = null;
  private String refresh = null;
  String json = "";
  //@Override
  public void add(String statement) {
    this.json += statement + "\n";
  }
  @Override
  public void add(String statement, String document) {
    this.json += statement + "\n";
    this.json += document + "\n";
  }
  @Override
  public Request.Bulk buildUpdateStatus(Collection lidvids, String status) {
    this.json = JsonHelper.buildUpdateStatusJson(lidvids, status);
    return this;
  }
  @Override
  public Bulk setIndex(String name) {
    this.index = name;
    return this;
  }
  @Override
  public Bulk setRefresh(Refresh type) {
    switch (type) {
      case False:
        this.refresh = "false";
        break;
      case True:
        this.refresh = "true";
        break;
      case WaitFor:
        this.refresh = "wait_for";
        break;
    }
    return this;
  }
  @Override
  public String toString() {
    return (this.index == null ? "" : "/" + this.index) + "/_bulk" + (this.refresh == null ? "" : "?refresh=" + this.refresh);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy