Class ODataClient

java.lang.Object
org.bgerp.plugin.inventoru.sync1c.service.ODataClient

public class ODataClient extends Object
PROTOTYPE client for the 1C standard OData interface (/odata/standard.odata). Unlike the HS protocol (Api1cClient), OData requires NO custom code on the 1C side — only publishing the infobase on a web server with the standard OData interface enabled. The trade-off: metadata object names (register, catalog, field names) differ between 1C configurations (УТ/УНФ/КА/ERP/БП), so they are passed in as parameters configured by the admin instead of being hard-coded into a 1C-side service. Reads stock balances in two requests: 1. GET {apiUrl}/{balancePath}?$format=json[&$filter={warehouseKeyField} eq guid'...'] — the accumulation register balance virtual table, e.g. AccumulationRegister_ЗапасыНаСкладах/Balance(). Rows carry item/warehouse GUIDs and the quantity, but no human-readable names. 2. GET {apiUrl}/{catalogPath}?$format=json&$select=Ref_Key,Description — the nomenclature catalog, to resolve item GUIDs to names. Errors are thrown (not swallowed into an empty list as in Api1cClient) — this client is called from the interactive admin preview where the admin must see what went wrong.
  • Constructor Details

  • Method Details

    • fetchStocks

      public List<Api1cStock> fetchStocks(String balancePath, String catalogPath, String itemKeyField, String qtyField, String warehouseKeyField, String warehouseGuid) throws Exception
      Fetches stock balances over OData and maps them to the protocol-agnostic Api1cStock shape consumed by ImportService.importFromRows(Sync1cConnector, EngineerWarehouse, List).
      Parameters:
      balancePath - resource path of the balance virtual table, e.g. AccumulationRegister_ЗапасыНаСкладах/Balance()
      catalogPath - resource path of the nomenclature catalog, e.g. Catalog_Номенклатура; empty = skip name resolution (product_name falls back to the GUID)
      itemKeyField - balance row field with the item GUID, e.g. Номенклатура_Key
      qtyField - balance row field with the quantity, e.g. КоличествоBalance
      warehouseKeyField - balance row field with the warehouse GUID, e.g. Склад_Key
      warehouseGuid - optional warehouse GUID to filter by ($filter); empty = all warehouses
      Throws:
      Exception
    • fetchBarcodes

      public Map<String,String> fetchBarcodes(String barcodePath, String codeField, String itemKeyField) throws Exception
      Fetches the nomenclature barcode register: barcode → item GUID. In typical configurations this is InformationRegister_ШтрихкодыНоменклатуры with fields Штрихкод and Номенклатура_Key (overridable per connector).
      Throws:
      Exception
    • testConnection

      public String testConnection(String balancePath)
      Tests the connection by fetching one row of the balance table.
      Parameters:
      balancePath - resource path of the balance virtual table
      Returns:
      null on success, human-readable error message on failure