User:Mjeg15

From ADempiere ERP Wiki

Jump to: navigation, search
Name This user real name is : Michael Johnson Gendrala
Yahoo mail Yahoo email : nayrusoul@yahoo.com

Contents

About Me...


Hello Everyone! I am Michael, or you can call me Mikesz for short. :) I'm an Adempiere developer who is currently working in Makati, Philippines. I am currently known as Redhuan's apprentice here in the company and I will be documenting the things that I discover and as I go along with Adempiere. I hope this can be of help to anyone.


My Notes

  • Currently Using Eclipse Indigo 3.7.1
  • Operating System: OpenSUSE 11.4 64 Bit


Setting up iDempiere workspace

Followed the following manuals:


  • When I was following this [Kenai Workspace Setup] I have encountered this error, during import using the Buckminster plugin of Eclipse:
 ERROR   [0001] : No suitable provider for component org.adempiere.sdk:eclipse.feature was found in resourceMap file:/home/mike/Desktop/Adempiere-Kenai-Hengsin-Dev/hengsin~development/org.adempiere.sdk-feature/adempiere.rmap
 ERROR   [0001] : No suitable provider for component org.adempiere.sdk:eclipse.feature was found in searchPath workspace.bundle.project
   ERROR   [0001] : Rejecting provider local({0}/{1}[/home/mike/workspace/idempiere/org.adempiere.sdk]): Components of type eclipse.feature are not supported
 ERROR   [0001] : No suitable provider for component org.adempiere.sdk:eclipse.feature was found in searchPath workspace.feature.project
   ERROR   [0001] : Resolution attempt ended with exception: Provider local(/home/mike/workspace/idempiere/org.adempiere.sdk-feature): Missing CSpec source required by component type eclipse.feature
     ERROR   Provider local(/home/mike/workspace/idempiere/org.adempiere.sdk-feature): Missing CSpec source required by component type eclipse.feature
  • I had all the pre-requisites before this occurred and the solution for this was that the workspace project that I checked out isn't the workspace that I am currently using. I must use the workspace that I checked out, and make it the default workspace for it to work.
  • When doing the final step of the tutorial, which is when running the install.app from the run configurations, there were validation errors thus preventing me from proceeding.

File:Eclipse_validation_error.png‎

  • This was solved by going into the configurations of the install.app, going into the plug-ins tab and pressing Add Required Plug-ins button. Then I was able to proceed to running.
  • Another Error that I have encountered during the final stages of the setup was that when I was logging in as GardenAdmin the following error occured: nulljava.lang.ClassNotFoundException: org.eevolution.model.LiberoValidator global - This was because the database that I used was from the adempiere360. I was able to fix this using the database from this link. The database is inside the ExpDatOSGI.zip
Creating a new plug-in project and testing through eclipse

  • Follow the manual on how to create plug-in project.
  • On the MANIFEST.MF of the plug-in created, go to the Dependencies tab and add the necessary plug-ins to be able to use the classes of a separate project.
    • Might also need to add on the MANIFEST.MF tab the following line: Eclipse-RegisterBuddy: org.adempiere.base. So far from my tests, this line must be included.
  • Go to debug or run configurations and choose swingclient.product (server.product) for server, go into the Plug-ins tab and check the project that you will be testing and adding default values for the Start Level and Auto-Start columns, the clicking Apply. When running the idempiere, the plug-ins added will also be running.
Extending the iDempiere-Web Server

I am not yet very familiar on how p2 works, but on this section, I will show how I add a new bundle plug-in into iDempiere.

  • For organization of plugins to install, first we must create a dropins folder (or any other name, I just chose dropins because I am currently attempting to try on how to make use of dropins folder of equinox) on the root folder of our iDempiere installation (e.g. $IDEMPIERE_INSTALL_HOME/adempiere_server/dropins). This folder is where we will be storing the plug-in bundles that we create. Please look into this on how to create and export bundles.
  • After adding a new plug-in go to $IDEMPIERE_INSTALL_HOME/adempiere_server/configuration/org.eclipse.equinox.simpleconfigurator/ and edit the bundles.info
  • After opening the bundles.info we can not add a new line for our new bundle, add the new line in this format:
    • ($project_name),($version_name),dropins/($file_name).jar,4,false (e.g. org.idempiere.extend.callout,1.0.0.201202101334,dropins/org.idempiere.ioss.extend_1.0.0.201202101334.jar,4,false)
    • NOTE: For idempiere client side, the next steps are no longer necessary, just restart the client to make it work.
  • After adding the file into the bundles.info, we now have two options on installing the plugin.
  • First is when the server is not running. We can just setup iDempiere again through setup.sh and the plug-in should install right away.
  • The other is installing it via osgi console when the server is running. Just input the following commands:
  osgi> install file:$IDEMPIERE_INSTALL_HOME/adempiere_server/dropins/(file_name).jar
  • An output something like Bundle id is (some_number) should appear. Then input the following command
  osgi> start (some_number).
  • The bundle should now be working, and to see if it does type in ss into the console to see the list of bundles.
Modifying existing models through Eclipse

  • This is where I will be trying to modify existing models. And I will be using MRequisition as an example.
  • First is to copy the MRequisition class on the new plug-in and add update as you require.
  • Go to the MANIFEST.MF of the plug-in project.
  • Go to the Dependencies and add required plug-ins. (e.g. org.adempiere.base)
  • Go to the Overview Tab and click on the Extensions Link. This will enable the hidden extensions tab to appear.
  • Go to the Extensions tab and add the extension org.adempiere.base.IModelFactory
  • Right click on the newly created extension, go to new and create a new factory.
  • Add a priority which is greater than 0.

File:Extension_Point_Mjeg15.jpg

  • Go to the class link of the Extension Point Details to create a new class.
  • Once created a class with the following codes should appear
package org.idempiere.base;

import java.sql.ResultSet;

import org.adempiere.base.IModelFactory;
import org.compiere.model.PO;

public class ExampleModelFactory implements IModelFactory {

	public ExampleModelFactory() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public Class<?> getClass(String tableName) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public PO getPO(String tableName, int Record_ID, String trxName) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public PO getPO(String tableName, ResultSet rs, String trxName) {
		// TODO Auto-generated method stub
		return null;
	}

}
  • To make use of your own MRequisition class here is an example. (Credits to Low Heng Sin for the example)
public Class<?> getClass (String tableName) {
   if ("M_Requisition".equals(tableName)) {
     return com.abc.model.MRequisition.class;
   } else {
     return null;
   }

}

public PO getPO (String tableName, int Record_ID, String trxName) {
if ("M_Requisition".equals(tableName)) {
     return new com.abc.model.MRequisition(Env.getCtx(), Record_ID, trxName);
   } else {
     return null;
   }

} 
References

Setting up Eclipse Workspace Adempiere OpenBravo POS

Plugins Needed for Eclipse - MercurialEclipse


  • Cloning the project using eclipse (adempiere361)
    • Create a new workspace.
    • On you new and empty workspace go 'File' and 'Import'
    • On the import window choose the 'Mercurial Folder' and choose the 'Clone Existing Mercurial Repository' from the menu.
    • On the clone repository window in the 'URL' field. Paste the following: http://adempiere.hg.sourceforge.net:8000/hgroot/adempiere/adempiere361, name the Clone directory name as you wish and then press Next and wait for it to clone. Might take a while depending on the connection. The following is the screenshot on the clone repository window: Note that the following screen shot is not the same as the repository shown above. File:Adempiere361Clone-mjeg15.png
    • After cloning the repository, it is now time to add the download the ActiveMQ and Open Bravo source codes which is integrated unto ADempiere. The sources can be found here ,the repositories for ActiveMQ and Open Bravo can be found on page 33 of the document.


Adding a new button/process

  • After following the instructions on the openbravoiPOSGuide that was provided by Red1, we should now know how to use open bravo POS using adempiere. Since now that we have a working derby database for OpenBravo POS, we can now try to create a new button.
  • First is from your workspace, open the ActiveMQ_POS project. Go into the locales folder and open the pos_messages.properties.
  • This file, (I am guessing here) is a collection of variables that will be used to create warning messages and label names. In the Menu group, since I will be adding a new button for testing purposes, will add a new menu, similar to the custom ones created for ADempiere. (i.e. Menu.ERPCustomers = Customer Synchronization).
  • Next is I will be adding a new button. When running the Open Bravo through Eclipse, go to Maintenance -> Resources -> Menu.Root. In here we can add a menu item as we please, since there are already existing custom changes, I will just follow the format to create one. The following is a sample screen shot: File:MenuRoot.png


  • In the following screen shot below will show a new added button. Named Customer Synchronization. File:CustomerSynchronization.png




Creating Excel File using ADempiere Process and allowing to download


Requirements
  • Latest apache POI jar
  • Apache Server
Setup for Eclipse
  • Download Binary Distribution of Apache POI from here
  • Unzip the file to a folder, and take note of that there are several .jar files there. The one that we will be making use of is the poi-[version number].jar
  • Add the .jar file into the customization project, import it through java build path and import external jar. Please take note that ADempiere also has a POI installed in it, (currently using ADempiere 354a so my library of POI is outdated), so if the latest is newer than the current one, please make sure that on the Order and Export tab of the configure build path of eclipse, is that the POI is higher than the trunk for its use to be prioritized over the other.
Creating the Process using eclipse
  • Assuming that we already know how to create an ADempiere process using eclipse, it is pretty much the same (if not, please look into org.compiere.process of ADempiere source code for reference), except that we will be creating the file at a specific path, on the same unit as the where we will be setting up adempiere.
  • How to create file using POI, here is a Documentation from the creators: http://poi.apache.org/spreadsheet/quick-guide.html
  • After coding the process, create the process using the adempiere Report & Process window.
  • When running the process, an .xls file should be created on a folder specified.
Setting up ADempiere Web Server with POI to create text file and download using link
  • Copy the POI jar file into the ADempiere packages folder. (e.g. adempiere_home/packages/poi/lib) and setup the adempiere with customization on the lib folder.
  • Setup the adempiere server or use silent setup, and run the web server. If apache server is installed and running, we should be able to access the files from the folder specified depending on the settings.
  • Run the process to create an xls file using webui, and please take note, that on the return statement of the doIt() method of the process, don't forget to add an html link on the message so that there will be a link generated after the process is finished. Assuming the link is pointing to the file created, it should have a download prompt.

References

Personal tools