mardi 5 février 2019

How to be generic when creating an XML for different suppliers

I try to explain my problem. I have a Order database. Each Order have orderlines. Each orderline has a product. These products can be ordered at different suppliers. Suppose we have this order:

ORDER
.......
Hamer 1x Supplier:supplier1
chair 1x Supplier:supplier1
door  1x Supplier:supplier8

So we have three orderlines which are ordered at two different suppliers, 1 and 8. Now supplier 1 and 8 can receive the orderline as XML. The difference is that the XML structure of 1 and 8 are both different. I am thinking about a tool to create which combines the orderlines when the supplier is the same and eventually sends the orderline(s) as an XML order to the supplier.

The way how I wanted to do this is like this:

enter image description here

So we have a order class and a supplier class:

enter image description here

When the code wants to create the xml it first creates the supplier object for example it creates an object for supplier1. Then it takes the elements and creates a XML from it. What I want to know, is this a correct way of doing this? Or are there also any design patterns for this?

Aucun commentaire:

Enregistrer un commentaire