<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=How_To_Create_An_Import_Process_With_Images</id>
	<title>How To Create An Import Process With Images - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=How_To_Create_An_Import_Process_With_Images"/>
	<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=How_To_Create_An_Import_Process_With_Images&amp;action=history"/>
	<updated>2026-04-06T21:44:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.infinite-erp.co.id/index.php?title=How_To_Create_An_Import_Process_With_Images&amp;diff=2788&amp;oldid=prev</id>
		<title>Wikiadmin: Created page with &quot;{{RatingArticle}} {{Languages | Documentation_Style_Guide}} == Objective == The objective of this article is to show you how to make a massive image importation process. Speci...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=How_To_Create_An_Import_Process_With_Images&amp;diff=2788&amp;oldid=prev"/>
		<updated>2021-12-16T03:33:58Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{RatingArticle}} {{Languages | Documentation_Style_Guide}} == Objective == The objective of this article is to show you how to make a massive image importation process. Speci...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{RatingArticle}}&lt;br /&gt;
{{Languages | Documentation_Style_Guide}}&lt;br /&gt;
== Objective ==&lt;br /&gt;
The objective of this article is to show you how to make a massive image importation process. Specificilly, we are going to import product images.&lt;br /&gt;
&lt;br /&gt;
== Execution Steps ==&lt;br /&gt;
We are going to create a [http://wiki.openbravo.com/wiki/ERP_2.50:Developers_Guide/How_to_Create_Your_Own_Import_Process_with_IDL custom importation process], using the '''Initial Data Load for Java''' module. We are going to use the java class SampleProductsProcess, included in this module...&lt;br /&gt;
For that we will use the java class '''SampleProductsProcess.java''' as the base that is included in the '''Initial Data Load Module for Java''', and through a series of single modifications we will include a new column within the import .csv that will allow us to specify the path of the image that is associated to the product.&lt;br /&gt;
=== Installing Required Modules ===&lt;br /&gt;
&lt;br /&gt;
* Activate the Professional subscription License.&lt;br /&gt;
* Go to General Setup -&amp;gt; Application -&amp;gt; Module Management -&amp;gt; Add Modules&lt;br /&gt;
* Search and install the following modules.&lt;br /&gt;
** Initial Data Load (Refer [[http://forge.openbravo.com/projects/xidl|here]])&lt;br /&gt;
** Initial Data Load Extension for Java (Refer[[http://forge.openbravo.com/projects/idljava|here]])&lt;br /&gt;
&lt;br /&gt;
=== Preparing SampleProductsProcess.java ===&lt;br /&gt;
The following modifications need to be made:&lt;br /&gt;
&lt;br /&gt;
*'''getEntityName''' method: We will simply return the name of our new entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dl&amp;gt;&amp;lt;dd&amp;gt;&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;public String getEntityName() {&lt;br /&gt;
    return &amp;quot;Simple Products With Image&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&amp;lt;/dl&amp;gt;&lt;br /&gt;
*'''getParameters''' method : We add a new parameter to localize our image. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;dl&amp;gt;&amp;lt;dd&amp;gt;&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;    ....&lt;br /&gt;
    new Parameter(&amp;quot;ImageLocation&amp;quot;, Parameter.STRING) };&lt;br /&gt;
    ....&lt;br /&gt;
&amp;lt;/source&amp;gt;&amp;lt;/dl&amp;gt;&lt;br /&gt;
*'''validateProcess''' method: We add a validator for our new field (for example: for the maximum length)&lt;br /&gt;
&amp;lt;dl&amp;gt;&amp;lt;dd&amp;gt;&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;    ....&lt;br /&gt;
    validator.checkString(values[21], 255);&lt;br /&gt;
    ....&lt;br /&gt;
&amp;lt;/source&amp;gt;&amp;lt;/dl&amp;gt;&lt;br /&gt;
*'''internalProcess''' method: We have to pass a parameter to the createProduct() method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dl&amp;gt;&amp;lt;dd&amp;gt;&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;public BaseOBObject internalProcess(Object... values) throws Exception {&lt;br /&gt;
    return createProduct((String) values[0], (String) values[1], (String) values[2],&lt;br /&gt;
        (String) values[3], (String) values[4], (String) values[5], (String) values[6],&lt;br /&gt;
        (String) values[7], (String) values[8], (String) values[9], (String) values[10],&lt;br /&gt;
        (String) values[11], (String) values[12], (String) values[13], (String) values[14],&lt;br /&gt;
        (String) values[15], (String) values[16], (String) values[17], (String) values[18],&lt;br /&gt;
        (String) values[19], (String) values[20], (String) values[21]);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&amp;lt;/dl&amp;gt;&lt;br /&gt;
*'''createProduct''' method: Additionally to receiving a new parameter (imagelocation), this method does contain the logic to import the image to the database from its physical location.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dl&amp;gt;&amp;lt;dd&amp;gt;&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;    ....&lt;br /&gt;
    File imageFile = new File(imagelocation);&lt;br /&gt;
    if (imageFile.exists()) {&lt;br /&gt;
      FileInputStream is = new FileInputStream(imageFile);&lt;br /&gt;
      long length = imageFile.length();&lt;br /&gt;
      byte[] bytes = new byte[(int) length];&lt;br /&gt;
      int offset = 0;&lt;br /&gt;
      int numRead = 0;&lt;br /&gt;
      while (offset &amp;lt; bytes.length &lt;br /&gt;
         &amp;amp;&amp;amp; (numRead = is.read(bytes, offset, bytes.length - offset)) &amp;gt;= 0) {&lt;br /&gt;
          offset += numRead;&lt;br /&gt;
      }&lt;br /&gt;
      is.close();&lt;br /&gt;
      ByteArrayInputStream bis = new ByteArrayInputStream(bytes);&lt;br /&gt;
      BufferedImage rImage = ImageIO.read(bis);&lt;br /&gt;
      Image productImage = OBProvider.getInstance().get(Image.class);&lt;br /&gt;
      productImage.setName(imageFile.getName());&lt;br /&gt;
      productImage.setBindaryData(bytes);&lt;br /&gt;
      productImage.setWidth(new Long(rImage.getWidth()));&lt;br /&gt;
      productImage.setHeight(new Long(rImage.getHeight()));&lt;br /&gt;
      productImage.setMimetype(tika.detect(bytes));&lt;br /&gt;
      OBDal.getInstance().save(productImage);&lt;br /&gt;
      OBDal.getInstance().flush();&lt;br /&gt;
      product.setImage(productImage);&lt;br /&gt;
    }&lt;br /&gt;
    ....&lt;br /&gt;
&amp;lt;/source&amp;gt;&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Registering the Process ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|-|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* Go to Master Data Management -&amp;gt; Initial Data Load  -&amp;gt; Setup  -&amp;gt; Entity Default Value&lt;br /&gt;
* Register your Java file here as shown in the screen shot.&lt;br /&gt;
&lt;br /&gt;
||[[Image:Entity Deafault Values.png|thumbnail|300px|View larger]]||&lt;br /&gt;
|}&lt;br /&gt;
=== Importing the Data ===&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|-|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
The .csv file that contains the data, must include the new column we have added, with the string '''&amp;quot;ImageLocation&amp;quot;''' in the header.&lt;br /&gt;
&lt;br /&gt;
||[[Image:imageLocation.png|thumbnail|right|300px|View larger]]||&lt;br /&gt;
|}&lt;br /&gt;
Pay special attention on the class name while adding the entity default value.&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|-|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* Import the data using import window&lt;br /&gt;
* Go to Master Data Management -&amp;gt; Initial Data Load -&amp;gt; Process -&amp;gt; Import&lt;br /&gt;
* Choose the input file&lt;br /&gt;
* Choose the entity as '''&amp;quot;Product With Image&amp;quot;'''&lt;br /&gt;
&lt;br /&gt;
||[[Image:importScreen.png|thumbnail|right|300px|View larger]]||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* Validate the input file. If the file has invalid data, it will show the invalid data in the log.Screen&lt;br /&gt;
&lt;br /&gt;
[[Image:importSuccessful.png|800px]]&lt;br /&gt;
&lt;br /&gt;
* Once the input values are validated, the data can be loaded into the actual table by clicking on the process.&lt;br /&gt;
* If there are any issues while processing the input data, appropriate messages will be logged in the message box provided under the Log header in the import screen.&lt;br /&gt;
&lt;br /&gt;
== Result ==&lt;br /&gt;
As the result, we have the product imported with its corresponding product image.&lt;br /&gt;
[[Image:Result.png|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
		
	</entry>
</feed>