Skip to end of banner
Go to start of banner

GOBI - Overriding default Mapping

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »


Overview

mod-gobi receives request from edge-orders and maps the XML received from GOBI to an order format the mod-orders supports.

Currently mod-gobi supports below order types:

  1. Listed Electronic Monograph
  2. Listed Electronic serial
  3. Listed Print Monograph
  4. Listed Print Serial
  5. Unlisted Print Monograph
  6. UnlistedPrint Serial

The fields received from GOBI need to be mapped to proper fields in orders. By default there are few fields supported by each order type and the mapping for each type is listed here:
https://github.com/folio-org/mod-gobi/tree/master/src/main/resources

Methods and fields to translate the specified type

Supported fields

Defined in the https://github.com/folio-org/mod-gobi/blob/master/src/main/resources/mapping.jsonproperties.field

How to use

 {
	"field": "APPROVED",
	"dataSource": {
		"default": "true",
		"translation": "toBoolean",
		"translateDefault": true
	}
}

The body of the request could look like below with 

  1. field:  one of the defined field from https://github.com/folio-org/mod-gobi/blob/master/src/main/resources/mapping.jsonproperties.field
  2. dataSource.default: default value
  3. datasource.translation: defined and implemented method from https://github.com/folio-org/mod-gobi/blob/master/src/main/resources/mapping.jsonproperties.dataSource.properties.translation

Supported methods

Defined in the https://github.com/folio-org/mod-gobi/blob/master/src/main/resources/mapping.jsonproperties.dataSource.properties.translation

How to use

Update mapping for "Listed Print Monograph" → https://github.com/folio-org/mod-gobi/blob/master/src/main/resources/ListedPrintMonograph.json

Insert mapping configuration in the "mappings" of the https://github.com/folio-org/mod-gobi/blob/master/src/main/resources/ListedPrintMonograph.json

 {
	"field": "EXPENSE_CLASS",
	"dataSource": {
		"from": "//LocalData[Description='LocalData4']/Value",
		"translation": "lookupExpenseClassId",
	}
}

The body of the request could look like below with 

  1. field:  one of the defined field from https://github.com/folio-org/mod-gobi/blob/master/src/main/resources/mapping.jsonproperties.field
  2. dataSource.from: XPath to the valuse from GOBI order
  3. datasource.translation: defined and implemented method from https://github.com/folio-org/mod-gobi/blob/master/src/main/resources/mapping.jsonproperties.dataSource.properties.translation

Customize order mappings

However, there are scenario when the library wants to specify their own mapping or default values for certain fields , instead of those specified in the module.

This can be achieved by specifying a custom mapping in mod-configuration. 


Example Request

The body of the request could look like below with 

  1. code: "gobi.order.{orderType}" : orderType can be one of the 6 listed above
  2. module: must be "GOBI"
  3. configName: mist be "orderMapping"
  4. value: the mapping that must be used instead of the default mapping 
{
    "module" : "GOBI",
    "configName" : "orderMappings",
    "code" : "gobi.order.ListedElectronicMonograph",
    "description" : "GOBI order mappings",
    "enabled" : true,
    "value" : "{\"orderType\":\"ListedElectronicMonograph\",\"mappings\":[{\"field\":\"CURRENCY\",\"dataSource\":{\"from\":\"//ListPrice/Currency\",\"default\":\"USD\"}},{\"field\":\"TITLE\",\"dataSource\":{\"from\":\"//datafield[@tag='245']/*\",\"combinator\":\"concat\"}},{\"field\":\"LIST_UNIT_PRICE_ELECTRONIC\",\"dataSource\":{\"from\":\"//ListPrice/Amount\",\"default\":\"0\",\"translation\": \"toDouble\"}},{\"field\":\"PO_LINE_ESTIMATED_PRICE\",\"dataSource\":{\"from\":\"//NetPrice/Amount\",\"defaultMapping\": { \"dataSource\":{ \"from\": \"//ListPrice/Amount//EstPrice\",\"default\":\"15.0\",\"translation\": \"toDouble\",\"combinator\" : \"multiply\"}},\"translation\": \"toDouble\"}}]}"
}



Request to be sent to mod-configuration:

curl  --request POST 'https://{okapiURL}/configurations/entries' \
--header 'Content-Type: application/json' \
--header 'x-okapi-token: {x-okapi-token}\
--data-raw '{
"module": "GOBI",
"configName": "orderMappings",
"code": "gobi.order.ListedPrintMonograph",
"description": "GOBI order mappings",
"enabled": true,
"value": "{\n \"orderType\": \"ListedPrintMonograph\",\n \"mappings\": [\n {\n \"field\": \"ACQUISITION_METHOD\",\n \"dataSource\": {\n \"default\": \"Purchase At Vendor System\"\n }\n },\n {\n \"field\": \"APPROVED\",\n \"dataSource\": {\n \"default\": \"true\",\n \"translation\": \"toBoolean\",\n \"translateDefault\": true\n }\n },\n {\n \"field\": \"CLAIMED\",\n \"dataSource\": {\n \"default\": \"true\",\n \"translation\": \"toBoolean\",\n \"translateDefault\": true\n }\n },\n {\n \"field\": \"COLLECTION\",\n \"dataSource\": {\n \"default\": \"false\",\n \"translation\": \"toBoolean\",\n \"translateDefault\": true\n }\n },\n {\n \"field\": \"CONTRIBUTOR\",\n \"dataSource\": {\n \"from\": \"//datafield[@tag='100']/*\",\n \"combinator\": \"concat\"\n }\n },\n {\n \"field\": \"CONTRIBUTOR_NAME_TYPE\",\n \"dataSource\": {\n \"default\": \"Personal name\",\n \"translation\": \"lookupContributorNameTypeId\",\n \"translateDefault\": true\n }\n },\n {\n \"field\": \"CURRENCY\",\n \"dataSource\": {\n \"from\": \"//ListPrice/Currency\",\n \"default\": \"USD\"\n }\n },\n {\n \"field\": \"DATE_ORDERED\",\n \"dataSource\": {\n \"from\": \"//OrderPlaced\",\n \"translation\": \"toDate\"\n }\n },\n {\n \"field\": \"EXPENSE_CLASS\",\n \"dataSource\": {\n \"from\": \"//LocalData[Description='LocalData4']/Value\",\n \"translation\": \"lookupExpenseClassId\"\n }\n },\n {\n \"field\": \"FUND_ID\",\n \"dataSource\": {\n \"from\": \"//FundCode\",\n \"translation\": \"lookupFundId\"\n }\n },\n {\n \"field\": \"FUND_CODE\",\n \"dataSource\": {\n \"from\": \"//FundCode\"\n }\n },\n {\n \"field\": \"FUND_PERCENTAGE\",\n \"dataSource\": {\n \"default\": \"100\",\n \"translation\": \"toDouble\",\n \"translateDefault\": true\n }\n },\n {\n \"field\": \"VENDOR_INSTRUCTIONS\",\n \"dataSource\": {\n \"from\": \"//OrderNotes\",\n \"default\" : \"N/A\"\n }\n },\n {\n \"field\": \"LIST_UNIT_PRICE\",\n \"dataSource\": {\n \"from\": \"//ListPrice/Amount\",\n \"default\": \"0\",\n \"translation\": \"toDouble\",\n \"translateDefault\": true\n }\n },\n {\n \"field\": \"LOCATION\",\n \"dataSource\": {\n \"from\": \"//Location\",\n \"default\": \"*\",\n \"translation\": \"lookupLocationId\",\n \"translateDefault\": true\n }\n },\n {\n \"field\": \"MANUAL_PO\",\n \"dataSource\": {\n \"default\": \"false\",\n \"translation\": \"toBoolean\",\n \"translateDefault\": true\n }\n },\n {\n \"field\": \"MATERIAL_TYPE\",\n \"dataSource\": {\n \"from\": \"//LocalData[Description='LocalData1']/Value\",\n \"default\" : \"unspecified\",\n \"translation\": \"lookupMaterialTypeId\",\n \"translateDefault\": true\n }\n },\n {\n \"field\": \"ORDER_TYPE\",\n \"dataSource\": {\n \"default\": \"One-Time\"\n }\n },\n {\n \"field\": \"PO_LINE_ORDER_FORMAT\",\n \"dataSource\": {\n \"default\": \"Physical Resource\"\n }\n },\n {\n \"field\": \"PO_LINE_PAYMENT_STATUS\",\n \"dataSource\": {\n \"default\": \"Awaiting Payment\"\n }\n },\n {\n \"field\": \"PO_LINE_RECEIPT_STATUS\",\n \"dataSource\": {\n \"default\": \"Awaiting Receipt\"\n }\n },\n {\n \"field\": \"PRODUCT_ID\",\n \"dataSource\": {\n \"from\": \"//datafield[@tag='020']/subfield[@code='a']\",\n \"translation\": \"truncateISBNQualifier\"\n }\n },\n {\n \"field\": \"PRODUCT_ID_TYPE\",\n \"dataSource\": {\n \"default\": \"ISBN\",\n \"translation\": \"lookupProductIdType\",\n \"translateDefault\": true\n }\n },\n {\n \"field\": \"PRODUCT_QUALIFIER\",\n \"dataSource\": {\n \"from\": \"//datafield[@tag='020']/subfield[@code='q']\",\n \"defaultMapping\": {\n \"dataSource\": {\n \"from\": \"//datafield[@tag='020']/subfield[@code='a']\",\n \"translation\": \"separateISBNQualifier\"\n }\n }\n }\n },\n {\n \"field\": \"PUBLICATION_DATE\",\n \"dataSource\": {\n \"from\": \"//datafield[@tag='260']/subfield[@code='c']\"\n }\n },\n {\n \"field\": \"PUBLISHER\",\n \"dataSource\": {\n \"from\": \"//datafield[@tag='260']/subfield[@code='b']\"\n }\n },\n {\n \"field\": \"QUANTITY_PHYSICAL\",\n \"dataSource\": {\n \"from\": \"//Quantity\",\n \"default\": \"1\",\n \"translation\": \"toInteger\"\n }\n },\n {\n \"field\": \"RECEIVING_NOTE\",\n \"dataSource\": {\n \"from\": \"//LocalData[Description='LocalData2']/Value\"\n }\n },\n {\n \"field\": \"REQUESTER\",\n \"dataSource\": {\n \"from\": \"//LocalData[Description='LocalData3']/Value\"\n }\n },\n {\n \"field\": \"SOURCE\",\n \"dataSource\": {\n \"default\": \"API\"\n }\n },\n {\n \"field\": \"TAGS\",\n \"dataSource\": {\n \"from\": \"//LocalData[Description='LocalData4']/Value\"\n }\n },\n {\n \"field\": \"TITLE\",\n \"dataSource\": {\n \"from\": \"//datafield[@tag='245']/*\",\n \"combinator\": \"concat\"\n }\n },\n {\n \"field\": \"VENDOR\",\n \"dataSource\": {\n \"default\": \"GOBI\",\n \"translation\": \"lookupOrganization\",\n \"translateDefault\": true\n }\n },\n {\n \"field\": \"VENDOR_ACCOUNT\",\n \"dataSource\": {\n \"from\": \"//SubAccount\",\n \"default\": \"0\"\n }\n },\n {\n \"field\": \"VENDOR_REF_NO\",\n \"dataSource\": {\n \"from\": \"//YBPOrderKey\"\n }\n },\n {\n \"field\": \"VENDOR_REF_NO_TYPE\",\n \"dataSource\": {\n \"default\": \"Vendor order reference number\"\n }\n },\n {\n \"field\": \"WORKFLOW_STATUS\",\n \"dataSource\": {\n \"default\": \"Open\"\n }\n }\n ]\n }\n"
}
'


Other points to note:

  1. By default there is no entry in mod-configuration, the default values used are stored inside the mod-gobi module
  2. No entry is necessary in mod-configuration if the default values are acceptable
  3. There should be one entry for each order type in order to override values
  4. If mod-configuration is not reachable for any reason while an order is being placed, the default rules are used to proceed with placing the order



  • No labels