How can I insert common data into a temp table from disparate schemas?

前端 未结 2 1440
囚心锁ツ
囚心锁ツ 2021-01-25 21:22

I am not sure how to solve this problem:

We import order information from a variety of online vendors ( Amazon, Newegg etc ). Each vendor has their own specific termino

2条回答
  •  感情败类
    2021-01-25 21:48

    Sounds like you need to create an abstract class that will define the basics of interacting with the data, then derive a class per database schema you need to access. This will allow the core code to operate on a single object type, and each implementation can then specify the queries in a form specific to that database schema.

    Something like:

    public class Order
    {
        private String orderNumber;
        private BigDecimal orderTotal;
        ... etc ...
    }
    
    public abstract class AbstractOrderInformation
    {
      public abstract ArrayList getOrders();
      ...
    }
    

    with a Newegg class:

    public class NeweggOrderInformation extends AbstractOrderInformation
    {
       public ArrayList getOrders() {
          ... do the work of getting the newegg order
       }
     ...
    }
    

    Then you can have an arbitrarily large number of formats and when you need information, you can just iterate over all the implementations and get the Orders from each.

提交回复
热议问题