SNX_CUSTOM_DYNAMIC_FLEX_FIELDS_IMPORTER

Description: Limited to code that handles the import of data derived from dynamic flex fields. You can use a code extension of this type for the N4 entities listed below.

Abstract Base Class: DefaultCustomDynamicFlexFieldsImporter

Interface: ECustomDynamicFlexFieldsImporter

Module: Inventory

Version Added: 2.2

Requires Code Extension Name or Name Pattern: Yes

Code Extension Name or Name Pattern: <Entity Name>SnxImporter

For example, if the code extension pertains to the entity UnitFacilityVisit, you would name the code extension UnitFacilityVisitSnxImporter.

Where to specify code extensions of this type: SNX Importer code extensions are limited to the following entities: Operator, UnLocCode, EqComponent, LineDischargeList, EquipSerialRange, Railcar, LineLoadList, Vessel, VesselClass, EquipmentDeliveryOrder, SpeacialStow, RoutingPoint, Gate, TruckingCompany, ServiceOrder, Booking, EquipmentLoadoutOrder, CarrierVisitServiceOrder, Equipment, TrainVisit, Commodity, TruckDriver, CarrierItinerary, DocumentType, RailcarType, Truck, BillOfLading, Railroad, Unit, VesselVisitDetails.

System-Seeded Code Extensions Using this Type: None

 

Code example

The following code example addresses the SNX import of a dynamic flex field (unitCustomDFF_SNX_IMPORTER_TEST_FIELD) of the Unit entity from the UnitFacilityVisit entity.

import com.navis.argo.business.snx.DefaultCustomDynamicFlexFieldsImporter

import com.navis.framework.metafields.MetafieldId

import com.navis.framework.metafields.MetafieldIdFactory

import com.navis.framework.persistence.Entity

import org.jdom.Attribute

import org.jdom.Element

import org.jdom.Namespace

import com.navis.argo.business.snx.DefaultCustomDynamicFlexFieldsImporter

import com.navis.framework.metafields.MetafieldId

import com.navis.framework.metafields.MetafieldIdFactory

import com.navis.framework.persistence.Entity

import org.jdom.Attribute

import org.jdom.Element

import org.jdom.Namespace

import java.util.List;

 

class UnitSnxImporter  extends DefaultCustomDynamicFlexFieldsImporter {

    public void init(Entity inEntity) {

        if (inEntity != null) {

            _importEntity = inEntity;

        }

    }

    public void parseElement(Element inElement) {

        Namespace nm = inElement.getNamespace();

        Element dynamicFileds = inElement.getChild(DefaultCustomDynamicFlexFieldsImporter.CUSTOM_DYNAMIC_FLEX_FIELDS_ELEMENT, nm);

        if (dynamicFileds == null) {

            return;

        }

        List fields = dynamicFileds.getChildren(DefaultCustomDynamicFlexFieldsImporter.CUSTOM_DYNAMIC_FLEX_FIELD_ELEMENT,nm);

        if (fields == null) {

            return;

        }

        for (Element field : fields) {

            Attribute nameAttribute = field.getAttribute(DefaultCustomDynamicFlexFieldsImporter.NAME_ATTRIBUTE, nm);

            if (nameAttribute != null) {

                String name = nameAttribute.getValue();

                Attribute valueAttribute = field.getAttribute(DefaultCustomDynamicFlexFieldsImporter.VALUE_ATTRIBUTE, nm);

                if (valueAttribute != null) {

                    String value = valueAttribute.getValue();

                    MetafieldId fieldId = MetafieldIdFactory.valueOf(name);

                    _importEntity.setFieldValue(fieldId, value);

                }

            }

        }

    }

    private Entity _importEntity;

}