DefaultIBizImporter.java

  1. /*
  2.  * #%L
  3.  * *********************************************************************************************************************
  4.  *
  5.  * blueHour
  6.  * http://bluehour.tidalwave.it - git clone git@bitbucket.org:tidalwave/bluehour-src.git
  7.  * %%
  8.  * Copyright (C) 2013 - 2023 Tidalwave s.a.s. (http://tidalwave.it)
  9.  * %%
  10.  * *********************************************************************************************************************
  11.  *
  12.  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  13.  * the License. You may obtain a copy of the License at
  14.  *
  15.  *     http://www.apache.org/licenses/LICENSE-2.0
  16.  *
  17.  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  18.  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
  19.  * specific language governing permissions and limitations under the License.
  20.  *
  21.  * *********************************************************************************************************************
  22.  *
  23.  *
  24.  * *********************************************************************************************************************
  25.  * #L%
  26.  */
  27. package it.tidalwave.accounting.importer.ibiz.impl;

  28. import javax.annotation.Nonnull;
  29. import java.io.IOException;
  30. import java.nio.file.Path;
  31. import it.tidalwave.accounting.model.Accounting;
  32. import it.tidalwave.accounting.importer.ibiz.IBizImporter;
  33. import lombok.experimental.Delegate;

  34. /***********************************************************************************************************************
  35.  *
  36.  * @author  Fabrizio Giudici
  37.  *
  38.  **********************************************************************************************************************/
  39. public class DefaultIBizImporter implements IBizImporter
  40.   {
  41. //    @Delegate
  42. //    private final As asSupport = new AsSupport(this);
  43.    
  44.     @Delegate
  45.     private final Accounting accounting = Accounting.createNew();

  46.     @Nonnull
  47.     private final Path path;

  48.     /*******************************************************************************************************************
  49.      *
  50.      * @return    a builder
  51.      *
  52.      ******************************************************************************************************************/
  53.     @Nonnull
  54.     public static IBizImporter.Builder builder()
  55.       {
  56.         return new DefaultIBizImporter.Builder(null); // FIXME: null
  57.       }

  58.     /*******************************************************************************************************************
  59.      *
  60.      * @param   builder
  61.      *
  62.      ******************************************************************************************************************/
  63.     public DefaultIBizImporter (@Nonnull final IBizImporter.Builder builder) // FIXME: protected
  64.       {
  65.         this.path = builder.getPath();
  66.       }

  67.     /*******************************************************************************************************************
  68.      *
  69.      * {@inheritDoc}
  70.      *
  71.      ******************************************************************************************************************/    
  72.     @Override
  73.     public void importAll()
  74.       throws IOException
  75.       {
  76.         new DefaultIBizCustomerImporter(getCustomerRegistry(), path).importCustomers();
  77.         new DefaultIBizProjectImporter(getCustomerRegistry(), getProjectRegistry(), path).importProjects();
  78.         new DefaultIBizInvoiceImporter(getInvoiceRegistry(), getProjectRegistry(), path).importInvoices();
  79.       }
  80.   }