Skip to main content
Back to AutoCore Hub

Detailed Analysis: importMemberProduct

The importMemberProduct service (located in DataImportServices.java) is the central workhorse of the AutoCore data import pipeline. While the wrappers and multi-threaded engines handle file parsing, thread safety, and batching, importMemberProduct is exclusively responsible for translating a single row of CSV data into the complex, highly-normalized entity graph of Apache OFBiz.


High-Level Architecture Flow

Service Execution FlowUse mouse wheel to zoom, drag to pan • Pull bottom edge to resize

Detailed Execution Phases

1. Context Unpacking & Validation

The service receives a heavily populated Map<String, Object> context. It begins by unpacking over 40 potential fields (e.g., part, mfg, listprice, stdupc, qtyminorder) and converting them from standard strings into strongly typed Java objects (like BigDecimal for prices and Timestamp for dates).

Validation Gate: The service immediately halts and returns an error (mandatoryFieldMissing = TRUE) if any of the following critical fields are empty:

  • partNumber
  • partDomainId (Member ID)
  • lineCode (Manufacturer Code)

2. Domain Party Setup

In OFBiz, every member or data provider must be represented as a Party.

  • Query: It searches the PartyRoleDetailAndPartyDetail view for an existing PARTY_GROUP with the exact partDomainId and the role DOMAIN_PARTY.
  • Creation: If it doesn't exist, it uses the Entity Engine (delegator.create()) to build a brand new Party, PartyGroup, and PartyRole.

3. Categorization (Line Codes)

A product must belong to a manufacturer's line code.

  • storeLineCode: It constructs a unique productCategoryId using the format [partyId]_[lineCode] and triggers the storeLineCode service synchronously.
  • storeSubLineCode: If a currentsubline was provided in the CSV, it repeats this process to build the sub-line hierarchy ([lineCodeId]_[subLineCode]).

4. Core Product Orchestration

This is where the actual part number is registered.

  • Normalization: It calls ProductServices.compressString(partNumber) to strip out hyphens and special characters, creating a stdPartNumber (crucial for exact-match searching later).
  • storeProduct: It triggers the OFBiz storeProduct service, which creates/updates the Product table and establishes the foreign key relationships linking this part to the previously created Domain Party and Line Code Category.

4.5. Global Brand Mapping & Product Attributes

After the core product is created, the service enriches it with industry-standard mappings:

  • LegacyBrandMapping: It checks if the member's line code maps to an AAIA/AutoCare standard brand ID. If so, it flags the product (isBrandMapExist, isGTINMapExist) and stores features like AST or Appl eCat.
  • Attributes: It stores custom attributes like CORE_FLAG and MOVEMENT_FLAG as ProductAttribute records.

5. Good Identifications & Packaging

A single part can have multiple barcodes depending on how it is packaged.

  • Item Level (stdupc): Creates a GoodIdentification record for the primary UPC/EAN.
  • Package Level (CA for Case, PL for Pallet): If case or pallet quantities/UPCs are provided, it creates/updates ProductPackage records. This robustly stores the exact weight, height, width, and depth metrics for pallets and cases directly against the product.

6. Warranties & Localized Content

The AutoCore feed supports complex warranty data.

  • Features: It stores WARRANTY_DISTANCE and WARRANTY_TIME (along with their UOMs like miles/months) as ProductFeatures.
  • Localized Content: It parses warrantyWd (English), warrantyWdEs (Spanish), and warrantyWdFr (French). For each translation, it creates an ElectronicText and DataResource, wraps it in a Content record, and links them via ContentAssoc to support multi-lingual storefronts.

7. Pricing Tiers & Currency Overrides

The AutoCore data feed contains massive pricing matrices.

  • Currency Resolution: It dynamically looks up the Member's ProductStore (via their PartyRelationship) to determine the correct currencyUomId (falling back to USD).
  • Price Ingestion: It takes fields like listprice, itemprice, and the 8 tier prices (currentprice1 through currentprice8) and inserts them into the ProductPrice table. Crucially, if the currency changes, it gracefully expires the old price records (thruDate = now) before inserting the new ones.

8. Solr Search Indexing

At the very top of the execution block, the service initializes an HttpSolrClient connected to the memberproduct core. After successfully writing all the highly-normalized data to the relational SQL database, it takes the flattened product representation and pushes it to Apache Solr. This ensures that the moment the import row completes, the product is immediately searchable via the storefront UI without waiting for a nightly batch job.


Entity Relationship Sequence

Entity Ingestion SequenceUse mouse wheel to zoom, drag to pan • Pull bottom edge to resize