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
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:
partNumberpartDomainId(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
PartyRoleDetailAndPartyDetailview for an existingPARTY_GROUPwith the exactpartDomainIdand the roleDOMAIN_PARTY. - Creation: If it doesn't exist, it uses the Entity Engine (
delegator.create()) to build a brand newParty,PartyGroup, andPartyRole.
3. Categorization (Line Codes)
A product must belong to a manufacturer's line code.
- storeLineCode: It constructs a unique
productCategoryIdusing the format[partyId]_[lineCode]and triggers thestoreLineCodeservice synchronously. - storeSubLineCode: If a
currentsublinewas 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 astdPartNumber(crucial for exact-match searching later). - storeProduct: It triggers the OFBiz
storeProductservice, which creates/updates theProducttable 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 likeASTorAppl eCat. - Attributes: It stores custom attributes like
CORE_FLAGandMOVEMENT_FLAGasProductAttributerecords.
5. Good Identifications & Packaging
A single part can have multiple barcodes depending on how it is packaged.
- Item Level (
stdupc): Creates aGoodIdentificationrecord for the primary UPC/EAN. - Package Level (
CAfor Case,PLfor Pallet): If case or pallet quantities/UPCs are provided, it creates/updatesProductPackagerecords. 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_DISTANCEandWARRANTY_TIME(along with their UOMs like miles/months) asProductFeatures. - Localized Content: It parses
warrantyWd(English),warrantyWdEs(Spanish), andwarrantyWdFr(French). For each translation, it creates anElectronicTextandDataResource, wraps it in aContentrecord, and links them viaContentAssocto 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 theirPartyRelationship) to determine the correctcurrencyUomId(falling back to USD). - Price Ingestion: It takes fields like
listprice,itemprice, and the 8 tier prices (currentprice1throughcurrentprice8) and inserts them into theProductPricetable. 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.