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

com.xlenc.party.client.PartyClient Maven / Gradle / Ivy

The newest version!
package com.xlenc.party.client;

import com.shapestone.rest.jersey.hystrix.rx.HystrixRxCommand;
import com.shapestone.rest.jersey.hystrix.rx.HystrixRxMethod;
import com.xlenc.party.domain.data.*;
import com.xlenc.party.domain.data.System;
import org.glassfish.jersey.client.rx.rxjava.RxObservable;
import rx.Observable;

import javax.ws.rs.client.Client;
import javax.ws.rs.core.GenericType;

import java.util.List;

import static java.util.Arrays.asList;
import static java.util.UUID.randomUUID;
import static javax.ws.rs.client.Entity.entity;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;

import com.shapestone.result.Result;

/**
 * Name: Michael Williams
 * Date: 9/18/16.
 */
public class PartyClient {

  private PartyClientData partyClientData;
  private Client client;

  public PartyClient(PartyClientData partyClientData, Client client) {
    this.partyClientData = partyClientData;
    this.client = client;
  }

  public Observable addPerson(Person person) {
    return this.addPerson(person, null);
  }

  public Observable addPerson(Person person, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/persons")
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .post(entity(person, APPLICATION_JSON), Person.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addPerson").observe();
  }

  public Observable> getPersonsByIds(String... partyIds) {
    return getPersonsByIds(null, partyIds);
  }

  public Observable> getPersonsByIds(String correlationId, String... partyIds) {
    return getPersonsByIds(asList(partyIds), correlationId);
  }

  public Observable> getPersonsByIds(List partyIds) {
    return getPersonsByIds(partyIds, null);
  }

  public Observable> getPersonsByIds(List partyIds, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/persons")
        .queryParam("partyIds", partyIds.toArray())
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(new GenericType>(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getPersonsByIds").observe();
  }

  public Observable getPersonById(String partyId) {
    return this.getPersonById(partyId, null);
  }

  public Observable getPersonById(String partyId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/persons/{partyId}")
        .resolveTemplate("partyId", partyId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(Person.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getPersonById").observe();
  }

  public Observable addOrganization(Organization organization) {
    return this.addOrganization(organization, null);
  }

  public Observable addOrganization(Organization organization, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/organizations")
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .post(entity(organization, APPLICATION_JSON), Organization.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addOrganization").observe();
  }

  public Observable getOrganizationById(String partyId) {
    return this.getOrganizationById(partyId, null);
  }

  public Observable getOrganizationById(String partyId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/organizations/{partyId}")
        .resolveTemplate("partyId", partyId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(Organization.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getOrganizationById").observe();
  }

  public Observable> getOrganizationsByIds(List partyIds) {
    return this.getOrganizationsByIds(partyIds, null);
  }

  public Observable> getOrganizationsByIds(String... partyIds) {
    return getOrganizationsByIds(null, partyIds);
  }

  public Observable> getOrganizationsByIds(String correlationId, String... partyIds) {
    return getOrganizationsByIds(asList(partyIds), correlationId);
  }

  public Observable> getOrganizationsByIds(List partyIds, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
        RxObservable.from(client.target(partyClientData.getUrl()))
            .path("/parties/organizations")
            .queryParam("partyIds", partyIds.toArray())
            .request()
            .header("correlationId", determineCorrelationId(correlationId))
            .rx()
            .get(new GenericType>(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getOrganizationsByIds").observe();
  }

  public Observable addSystem(System system) {
    return this.addSystem(system, null);
  }

  public Observable addSystem(System system, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/systems")
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .post(entity(system, APPLICATION_JSON), System.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addSystem").observe();
  }



  public Observable getSystemById(String partyId) {
    return this.getSystemById(partyId, null);
  }

  public Observable getSystemById(String partyId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/systems/{partyId}")
        .resolveTemplate("partyId", partyId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(System.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getSystemById").observe();
  }

  public Observable> getSystemsByIds(String... partyIds) {
    return getSystemsByIds(null, partyIds);
  }

  public Observable> getSystemsByIds(String correlationId, String... partyIds) {
    return getSystemsByIds(asList(partyIds), correlationId);
  }

  public Observable> getSystemsByIds(List partyIds) {
    return getSystemsByIds(partyIds, null);
  }

  public Observable> getSystemsByIds(List partyIds, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/systems")
        .queryParam("partyIds", partyIds.toArray())
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(new GenericType>(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getSystemsByIds").observe();
  }

  public Observable addPartyRelationship(PartyRelationship partyRelationship) {
    return this.addPartyRelationship(partyRelationship, null);
  }

  public Observable addPartyRelationship(PartyRelationship partyRelationship, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/relationships")
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .post(entity(partyRelationship, APPLICATION_JSON), PartyRelationship.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addPartyRelationship").observe();
  }

  public Observable> addPartyRelationships(List partyRelationships) {
    return this.addPartyRelationships(partyRelationships, null);
  }

  public Observable> addPartyRelationships(List partyRelationships, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/relationships/batch")
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .post(entity(partyRelationships, APPLICATION_JSON), new GenericType>(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addPartyRelationships").observe();
  }

  public Observable getPartyRelationship(String partyId) {
    return this.getPartyRelationship(partyId, null);
  }

  public Observable getPartyRelationship(String partyRelationshipId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/relationships/{partyRelationshipId}")
        .resolveTemplate("partyRelationshipId", partyRelationshipId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(PartyRelationship.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getPartyRelationship").observe();
  }

  public Observable> getPartyRelationships(List partyRelationshipIds) {
    return this.getPartyRelationships(partyRelationshipIds, null);
  }

  public Observable> getPartyRelationships(List partyRelationshipIds, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/relationships")
        .queryParam("partyRelationshipIds", partyRelationshipIds.toArray())
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(new GenericType>(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getPartyRelationships").observe();
  }

  public Observable getSecurityGroupTree(String partyId, String relationshipTypeId) {
    return this.getSecurityGroupTree(partyId, relationshipTypeId, null);
  }

  public Observable getSecurityGroupTree(String partyId, String relationshipTypeId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/{partyId}/security-group-tree")
        .resolveTemplate("ownerPartyId", partyId)
        .queryParam("partyRelationshipTypeId", relationshipTypeId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(new GenericType(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getSecurityGroupTree").observe();
  }

  public Observable addVendorSystem(VendorSystem vendorSystem) {
    return this.addVendorSystem(vendorSystem, null);
  }

  public Observable addVendorSystem(VendorSystem vendorSystem, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/vendors/systems/relationships")
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .post(entity(vendorSystem, APPLICATION_JSON), VendorSystem.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addVendorSystem").observe();
  }

  public Observable>> addVendorSystems(List vendorSystems, String correlationId) {
    final HystrixRxMethod>>> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/vendors/systems/relationships/batch")
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .post(entity(vendorSystems, APPLICATION_JSON), new GenericType>>(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addVendorSystems").observe();
  }

  public Observable> getVendorSystems(String... relationshipIds) {
    return getVendorSystems(null, relationshipIds);
  }

  public Observable> getVendorSystems(String correlationId, String... relationshipIds) {
    return getVendorSystems(asList(relationshipIds), correlationId);
  }

  public Observable> getVendorSystems(List relationshipIds) {
    return getVendorSystems(relationshipIds, null);
  }

  public Observable> getVendorSystems(List relationshipIds, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
        RxObservable.from(client.target(partyClientData.getUrl()))
            .path("/parties/vendors/systems/relationships")
            .queryParam("relationshipIds", relationshipIds.toArray())
            .request()
            .header("correlationId", determineCorrelationId(correlationId))
            .rx()
            .get(new GenericType>(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getVendorSystems").observe();
  }

  public Observable getVendorSystem(String relationshipId) {
    return this.getVendorSystem(relationshipId, null);
  }

  public Observable getVendorSystem(String relationshipId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/vendors/systems/relationships/{relationshipId}")
        .resolveTemplate("relationshipId", relationshipId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(VendorSystem.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getVendorSystem").observe();
  }

  public Observable> getSystemGroups(String... relationshipIds) {
    return getSystemGroups(null, relationshipIds);
  }

  public Observable> getSystemGroups(String correlationId, String... relationshipIds) {
    return getSystemGroups(asList(relationshipIds), correlationId);
  }

  public Observable> getSystemGroups(List relationshipIds) {
    return getSystemGroups(relationshipIds, null);
  }

  public Observable> getSystemGroups(List relationshipIds, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
        RxObservable.from(client.target(partyClientData.getUrl()))
            .path("/parties/systems/groups/relationships")
            .queryParam("relationshipIds", relationshipIds.toArray())
            .request()
            .header("correlationId", determineCorrelationId(correlationId))
            .rx()
            .get(new GenericType>(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getSystemGroups").observe();
  }

  public Observable getSystemGroup(String relationshipId) {
    return this.getSystemGroup(relationshipId, null);
  }

  public Observable getSystemGroup(String relationshipId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/systems/groups/relationships/{relationshipId}")
        .resolveTemplate("relationshipId", relationshipId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(SystemGroup.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getSystemGroup").observe();
  }

  public Observable addSystemGroup(SystemGroup systemGroup) {
    return this.addSystemGroup(systemGroup, null);
  }

  public Observable addSystemGroup(SystemGroup systemGroup, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/systems/groups/relationships")
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .post(entity(systemGroup, APPLICATION_JSON), SystemGroup.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addSystemGroup").observe();
  }

  public Observable> getSystemCustomers(String... relationshipIds) {
    return getSystemCustomers(asList(relationshipIds));
  }

  public Observable> getSystemCustomers(String correlationId, String... relationshipIds) {
    return getSystemCustomers(asList(relationshipIds), correlationId);
  }

  public Observable> getSystemCustomers(List relationshipIds) {
    return getSystemCustomers(relationshipIds, null);
  }

  public Observable> getSystemCustomers(List relationshipIds, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
        RxObservable.from(client.target(partyClientData.getUrl()))
            .path("/parties/systems/customers/relationships")
            .queryParam("relationshipIds", relationshipIds.toArray())
            .request()
            .header("correlationId", determineCorrelationId(correlationId))
            .rx()
            .get(new GenericType>(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getSystemCustomers").observe();
  }

  public Observable getSystemCustomer(String relationshipId) {
    return this.getSystemCustomer(relationshipId, null);
  }

  public Observable getSystemCustomer(String relationshipId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/systems/customers/relationships/{relationshipId}")
        .resolveTemplate("relationshipId", relationshipId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(SystemCustomer.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getSystemCustomer").observe();
  }

  public Observable getSystemCustomerByFromPartyAndTypeId(String fromPartyId, String relationshipTypeId) {
    return getSystemCustomerByFromPartyAndTypeId(fromPartyId, relationshipTypeId, null);
  }

  public Observable getSystemCustomerByFromPartyAndTypeId(String fromPartyId, String relationshipTypeId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/systems/{fromPartyId}/customers/relationships/relationship-types/{relationshipTypeId}")
        .resolveTemplate("fromPartyId", fromPartyId)
        .resolveTemplate("relationshipTypeId", relationshipTypeId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(SystemCustomer.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getSystemCustomerByFromPartyAndTypeId").observe();
  }

  public Observable getSystemCustomerByToPartyId(String toPartyId) {
    return this.getSystemCustomerByToPartyId(toPartyId, null);
  }


  public Observable getSystemCustomerByToPartyId(String toPartyId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/systems/customers/{toPartyId}/relationships")
        .resolveTemplate("toPartyId", toPartyId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(SystemCustomer.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getSystemCustomerByToPartyId").observe();
  }

  public Observable getSystemCustomerByToPartyAndTypeId(String toPartyId, String relationshipTypeId) {
    return getSystemCustomerByToPartyAndTypeId(toPartyId, relationshipTypeId, null);
  }

  public Observable getSystemCustomerByToPartyAndTypeId(String toPartyId, String relationshipTypeId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/systems/customers/{toPartyId}/relationships/relationship-types/{relationshipTypeId}")
        .resolveTemplate("toPartyId", toPartyId)
        .resolveTemplate("relationshipTypeId", relationshipTypeId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(SystemCustomer.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getSystemCustomerByToPartyId").observe();
  }

  public Observable getSystemCustomerByFromPartyToPartyAndTypeId(String fromPartyId, String toPartyId, String relationshipTypeId) {
    return getSystemCustomerByFromPartyToPartyAndTypeId(fromPartyId, toPartyId, relationshipTypeId, null);
  }

  public Observable getSystemCustomerByFromPartyToPartyAndTypeId(String fromPartyId, String toPartyId, String relationshipTypeId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/systems/{fromPartyId}/customers/{toPartyId}/relationships/relationship-types/{relationshipTypeId}")
        .resolveTemplate("fromPartyId", fromPartyId)
        .resolveTemplate("toPartyId", toPartyId)
        .resolveTemplate("relationshipTypeId", relationshipTypeId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(SystemCustomer.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getSystemCustomerByFromPartyToPartyAndTypeId").observe();
  }

  public Observable addSystemCustomer(SystemCustomer systemCustomer) {
    return this.addSystemCustomer(systemCustomer, null);
  }

  public Observable addSystemCustomer(SystemCustomer systemCustomer, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/systems/customers/relationships")
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .post(entity(systemCustomer, APPLICATION_JSON), SystemCustomer.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addSystemCustomer").observe();
  }

  public Observable>> addSystemGroups(List systemGroups) {
    return this.addSystemGroups(systemGroups, null);
  }

  public Observable>> addSystemGroups(List systemGroups, String correlationId) {
    final HystrixRxMethod>>> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/vendors/groups/relationships/batch")
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .post(entity(systemGroups, APPLICATION_JSON), new GenericType>>(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addSystemGroups").observe();
  }

  public Observable> getCustomerGroups(String... relationshipIds) {
    return getCustomerGroups(null, relationshipIds);
  }

  public Observable> getCustomerGroups(String correlationId, String... relationshipIds) {
    return getCustomerGroups(asList(relationshipIds), correlationId);
  }

  public Observable> getCustomerGroups(List relationshipIds) {
    return getCustomerGroups(relationshipIds, null);
  }

  public Observable> getCustomerGroups(List relationshipIds, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
        RxObservable.from(client.target(partyClientData.getUrl()))
            .path("/parties/customers/groups/relationships")
            .queryParam("relationshipIds", relationshipIds.toArray())
            .request()
            .header("correlationId", determineCorrelationId(correlationId))
            .rx()
            .get(new GenericType>(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getCustomerGroup").observe();
  }

  public Observable getCustomerGroup(String relationshipId) {
    return this.getCustomerGroup(relationshipId, null);
  }

  public Observable getCustomerGroup(String relationshipId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/customers/groups/relationships/{relationshipId}")
        .resolveTemplate("relationshipId", relationshipId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(CustomerGroup.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getCustomerGroup").observe();
  }

  public Observable getCustomerGroupByFromPartyId(String fromPartyId, String relationshipTypeId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/customers/{fromPartyId}/groups/relationships/relationship-types/{relationshipTypeId}")
        .resolveTemplate("fromPartyId", fromPartyId)
        .resolveTemplate("relationshipTypeId", relationshipTypeId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(CustomerGroup.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getCustomerGroupByFromPartyId").observe();
  }

  public Observable getCustomerGroupByToPartyId(String toPartyId, String relationshipTypeId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/customers/groups/{toPartyId}/relationships/relationship-types/{relationshipTypeId}")
        .resolveTemplate("toPartyId", toPartyId)
        .resolveTemplate("relationshipTypeId", relationshipTypeId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(CustomerGroup.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getCustomerGroupByToPartyId").observe();
  }

  public Observable getCustomerGroupByFromPartyToPartyAndTypeId(String fromPartyId, String toPartyId, String relationshipTypeId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/customers/{fromPartyId}/groups/{toPartyId}/relationships/relationship-types/{relationshipTypeId}")
        .resolveTemplate("fromPartyId", fromPartyId)
        .resolveTemplate("toPartyId", toPartyId)
        .resolveTemplate("relationshipTypeId", relationshipTypeId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(CustomerGroup.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getCustomerGroupByFromPartyToPartyAndTypeId").observe();

  }

  public Observable addCustomerGroup(CustomerGroup customerGroup) {
    return this.addCustomerGroup(customerGroup, null);
  }

  public Observable addCustomerGroup(CustomerGroup customerGroup, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/customers/groups/relationships")
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .post(entity(customerGroup, APPLICATION_JSON), CustomerGroup.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addCustomerGroup").observe();
  }

  public Observable>> addCustomerGroups(List customerGroups) {
    return this.addCustomerGroups(customerGroups, null);
  }

  public Observable>> addCustomerGroups(List customerGroups, String correlationId) {
    final HystrixRxMethod>>> hystrixMethod = () ->
        RxObservable.from(client.target(partyClientData.getUrl()))
            .path("/parties/customers/groups/relationships/batch")
            .request()
            .header("correlationId", determineCorrelationId(correlationId))
            .rx()
            .post(entity(customerGroups, APPLICATION_JSON), new GenericType>>() {});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addCustomerGroups").observe();
  }

  public Observable getCustomer(String fromPartyId, String toPartyId) {
    return this.getCustomer(fromPartyId, toPartyId, null);
  }

  public Observable getCustomer(String fromPartyId, String toPartyId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/systems/{systemPartyId}/customers/{customerPartyId}")
        .resolveTemplate("systemPartyId", fromPartyId)
        .resolveTemplate("customerPartyId", toPartyId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(new GenericType(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getCustomer").observe();
  }

  public Observable getCustomerById(String partyId) {
    return this.getCustomerById(partyId, null);
  }

  public Observable getCustomerById(String partyId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/customers/{partyId}")
        .resolveTemplate("partyId", partyId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(new GenericType(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getCustomerById").observe();
  }

  public Observable addCustomer(Customer customer) {
    return this.addCustomer(customer, null);
  }

  public Observable addCustomer(Customer customer, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/customers")
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .post(entity(customer, APPLICATION_JSON), new GenericType(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addCustomer").observe();
  }

  public Observable getGroup(String partyId) {
    return this.getGroup(partyId, null);
  }

  public Observable getGroup(String partyId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/organizations/groups/{partyId}")
        .resolveTemplate("partyId", partyId)
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(new GenericType(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getGroup").observe();
  }

  public Observable> getGroupsByIds(List partyIds) {
    return this.getGroupsByIds(partyIds, null);
  }

  public Observable> getGroupsByIds(List partyIds, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/organizations/groups")
        .queryParam("partyIds", partyIds.toArray())
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(new GenericType>(){});
      return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getGroupsByIds").observe();
  }

  public Observable addGroup(Group group) {
    return this.addGroup(group, null);
  }

  public Observable addGroup(Group group, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/organizations/groups")
        .request()
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .post(entity(group, APPLICATION_JSON), new GenericType(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addGroup").observe();
  }

  public Observable addGroups(GroupList groups) {
    return this.addGroups(groups, null);
  }

  public Observable addGroups(GroupList groups, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
        RxObservable.from(client.target(partyClientData.getUrl()))
            .path("/parties/organizations/groups/batch")
            .request()
            .header("correlationId", determineCorrelationId(correlationId))
            .rx()
            .post(entity(groups, APPLICATION_JSON), GroupResultList.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addGroups").observe();
  }

  public Observable>> addGroupMembers(List groupMembers) {
    return this.addGroupMembers(groupMembers, null);
  }

  public Observable>> addGroupMembers(List groupMembers, String correlationId) {
    final HystrixRxMethod>>> hystrixMethod = () ->
        RxObservable.from(client.target(partyClientData.getUrl()))
            .path("/parties/groups/members/relationships/batch")
            .request()
            .header("correlationId", determineCorrelationId(correlationId))
            .rx()
            .post(entity(groupMembers, APPLICATION_JSON), new GenericType>>(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addGroupMembers").observe();
  }

  public Observable addGroupMember(GroupMember groupMember) {
    return this.addGroupMember(groupMember, null);
  }

  public Observable addGroupMember(GroupMember groupMember, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
        RxObservable.from(client.target(partyClientData.getUrl()))
            .path("/parties/groups/members/relationships")
            .request()
            .header("correlationId", determineCorrelationId(correlationId))
            .rx()
            .post(entity(groupMember, APPLICATION_JSON), GroupMember.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "addGroupMember").observe();
  }

  public Observable> getGroupMembers(String... relationshipIds) {
    return getGroupMembers(asList(relationshipIds));
  }

  public Observable> getGroupMembers(String correlationId, String... relationshipIds) {
    return getGroupMembers(asList(relationshipIds), correlationId);
  }

  public Observable> getGroupMembers(List relationshipIds) {
    return getGroupMembers(relationshipIds, null);
  }

  public Observable> getGroupMembers(List relationshipIds, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
        RxObservable.from(client.target(partyClientData.getUrl()))
            .path("/parties/groups/members/relationships")
            .queryParam("relationshipIds", relationshipIds.toArray())
            .request()
            .header("correlationId", determineCorrelationId(correlationId))
            .rx()
            .get(new GenericType>(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getGroupMembers").observe();
  }

  public Observable getGroupMember(String relationshipId) {
    return this.getGroupMember(relationshipId, null);
  }

  public Observable getGroupMember(String relationshipId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
        RxObservable.from(client.target(partyClientData.getUrl()))
            .path("/parties/groups/members/relationships/{relationshipId}")
            .resolveTemplate("relationshipId", relationshipId)
            .request()
            .header("correlationId", determineCorrelationId(correlationId))
            .rx()
            .get(GroupMember.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getGroupMember").observe();
  }

  public Observable> getGroupMembersByToPartyId(String partyId, String customerPartyId) {
    return getGroupMembersByToPartyId(partyId, customerPartyId);
  }

  public Observable> getGroupMembersByToPartyId(String toPartyId, String customerPartyId, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
        RxObservable.from(client.target(partyClientData.getUrl()))
            .path("/parties/groups/members/{partyId}/relationships")
            .resolveTemplate("partyId", toPartyId)
            .request()
            .header("customerPartyId", customerPartyId)
            .header("correlationId", determineCorrelationId(correlationId))
            .rx()
            .get(new GenericType>(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getGroupMembersByToPartyId").observe();
  }
  
  public Observable> getGroupMembersByFromPartyIds(List fromPartyIds, String ownerPartyId, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
          .path("/parties/groups/members/relationships/find-by-party-ids")
          .queryParam("partyIds", fromPartyIds.toArray())
          .request()
          .header("ownerPartyId", ownerPartyId)
          .header("correlationId", determineCorrelationId(correlationId))
          .rx()
          .get(new GenericType>(){});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getGroupMembersByFromPartyIds").observe();
  }  
  
  public Observable deletePersonByPartyId(String partyId, String customerPartyId) {
    return deletePersonByPartyId(partyId, customerPartyId, null);
  }

  public Observable deletePersonByPartyId(String partyId, String customerPartyId, String correlationId) {
    final HystrixRxMethod> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/persons/{partyId}")
        .resolveTemplate("partyId", partyId)
        .request()
        .header("customerPartyId", customerPartyId)
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .delete(Boolean.class);
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "deletePersonByPartyId").observe();
  }

  public Observable> deleteGroupMemberByToPartyId(String partyId, String customerPartyId) {
    return deleteGroupMemberByToPartyId(partyId, customerPartyId, null);
  }

  public Observable> deleteGroupMemberByToPartyId(String partyId, String customerPartyId, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/groups/members/{partyId}/relationships")
        .resolveTemplate("partyId", partyId)
        .request()
        .header("customerPartyId", customerPartyId)
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .delete(new GenericType>() {});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "deleteGroupMemberByToPartyId").observe();
  }

  public Observable> getAdministratorGroups(String ownerPartyId, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
        RxObservable.from(client.target(partyClientData.getUrl()))
            .path("/parties/customers/groups/parties/{ownerPartyId}")
            .resolveTemplate("ownerPartyId", ownerPartyId)
            .request()
            .header("ownerPartyId", ownerPartyId)
            .header("correlationId", determineCorrelationId(correlationId))
            .rx()
            .get(new GenericType>() {});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getAdministratorGroups").observe();
  }

  public Observable> getGroupsByNames(List groupNames, String ownerPartyId, String correlationId) {
    final HystrixRxMethod>> hystrixMethod = () ->
      RxObservable.from(client.target(partyClientData.getUrl()))
        .path("/parties/organizations/groups/find-by-names")
        .queryParam("groupNames", groupNames.toArray())
        .request()
        .header("ownerPartyId", ownerPartyId)
        .header("correlationId", determineCorrelationId(correlationId))
        .rx()
        .get(new GenericType>() {});
    return new HystrixRxCommand<>(partyClientData, hystrixMethod, "getGroupsByNames").observe();
  }

  private String determineCorrelationId(String correlationId) {
    return correlationId != null ? correlationId : randomUUID().toString();
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy