Wednesday, July 11, 2012

Introduction of JSF configuration and setup




Create jsf project using following bellow step....


Step0:      Create project --> new --> web --> dynamic web project.
Step1:      Right click project properties and then choose Project Facets or type in the box of properties.
Step2:      Choose dynamic web module, java, java persistence, java script toolkit. then apply --> ok
Step3: Persistance.xml file will be created into src folder. Now open Persistance.xml with persistence xml editor. There is
                a. name    : project name
                b. persistence provider and more.
NB: better to copy all contain from actual written Persistance.xml file. which is availabel into autojsfcode projec.

Actual persistance.xml file contains:


<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="autojsfcode">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <properties>
        <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
        <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/jsftest"/>
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
        <property name="hibernate.connection.username" value="root"/>
        <property name="hibernate.connection.password" value=""/>
        <property name="show_sql" value="true" />
     </properties>
</persistence-unit>
</persistence>

For understanding..
---> Name= "autojsfcode"  (project name)
---> Database name = jsftest

Step4:      Right click project properties and then choose java persistence or type in the box of properties.
Step5:      Choose connection: New Mysql --> choose Add connection --> Connection Profile Types: MySql --> click Next.

                a. Database    :         jsftest (database name)
                b. URL         :           jdbc:mysql://localhost:3306/jsftest
                c. User Name:          root
                d. Password: (type if you have)
                e. Click test connection button. (Ping Successfully message will be given)

We have to generate bean java file. For that …
Now we have to create hibernate.cfg.xml file and hibernate.reveng.xml file.

hibernate.cfg.xml

Step6: select right click on project à new à others à type hibernate à Hibernate configuration file.




Then click finish.

hibernate.cfg.xml (must contain)
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.bytecode.use_reflection_optimizer">false</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/jsftest</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.search.autoregister_listeners">false</property>
        <mapping class="generatedcode.Info" />
    </session-factory>
</hibernate-configuration>

Step6: select right click on project à new à others à type hibernate à Hibernate console Configuration. à do setting à Finish


Now go change mode (Example java, Hibernet, java Browsing, Debug). Right corner of springsource you get this. So select Hibernate. Then left side beside project explorer you will get Hibernate configuration. If does not come then window à reset prospective.

Example : check database

Step7: select right click on project à new à others à type hibernate à Hibernate Reverse Engineering file


Click include à Finish
hibernate.reveng.xml (must contain)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>
  <table-filter match-catalog="jsftest" match-name="info"/>
</hibernate-reverse-engineering>

Step8: make automatically generate code  for that click picture option and then choose Hibernate code generation configuration




……………..
Create new record just beside Red Cross symbol and do setting as per image.
Now run. Code will automatically generate.


After generating code you get error in java file.
For solving that error: keep your mouse on import package. Then

Then organize import click.
Again above class write this code @Entity
@Table(name = "info", catalog = "jsftest")

Change db : jsftest to your db and name info to your info

Date: 21-12-11
=============================== Done =====================================
















































 

Adempiere ERP Data import and export shell command

If you want to dump/Export your adempiere database from PostgreSQL then use bellow Linux shell command

pg_dump -U adempiere postgres | gzip > Desktop/adempiere1.gz
pg_dump -U postgres adempiere | gzip > u01/adempiere1.gz   // final
pg_dump -U adempiere | gzip > /adempiere1.gz
pg_dump -U postgres adempiere | gzip > Desktop/adempiere1.gz
pg_dump -U postgres adempiere1 | gzip > u01/adempiere1.gz
pg_dump -U postgres adempiere3 | gzip > u01/adempiere-20-7-11.gz

NB: adempiere is user,  Desktop/adempiere1.gz is location where .gz file will be generated.

If you want to Import your adempiere database from PostgreSQL then use bellow Linux shell command

gunzip -c Desktop/adempiere-8-6-11.gz | psql -U postgres -d adempiere2
gunzip -c u01/adempiere_25_06_11.gz | psql -U postgres -d adempiere3
gunzip -c u01/adempiere-06-09-11-dayend.gz | psql -U postgres -d adempiere3

NB:  Desktop/adempiere-8-6-11.gz is a location where .gz file is located and adempiere2 is a database name. postgres is a super user.

Import different format data into adempiere database

CSV or other file format data import to Adempiere database. Steps are bellow

Step1.
copy adempiere.C_Location_test from '/opt/PostgreSQL/8.4/C_Location.txt' delimiters ',' csv;

Description: 
adempiere: is schema,  
    C_Location_test: is table name. 
    '/opt/PostgreSQL/8.4/C_Location.txt' : location where csv, txt and other file format is located.

Step2:
truncate table adempiere.m_product cascade;   
Description:
This query is used to delete all record from all table which containing m_product_id of m_product table

Install Adempiere ERP and Database

Installing step of Adempiere ERP and database

First Install Database (Install Postgresql8.4)

install postgresql through net
Step1 . 
sudo apt-get install postgresql
Step2. 
After install postgresql path will be having postgrsql at 3 different location
            as per my system
            location1 : /var/lib/postgresql/8.4/
            location2 : /usr/share/postgresql/8.4
            location3 : /etc/postgresql/8.4/


Location1 : /usr/share/postgresql/8.4/x
no  pg_hba.conf.sample available

Location2 : /usr/share/postgresql/8.4/pg_hba.conf.sample  configuration has to check
@remove-line-for-nolocal@# "local" is for Unix domain socket connections only
@remove-line-for-nolocal@local   all         all                               @authmethod@
# IPv4 local connections:
#host    all         all         127.0.0.1/32          trust
host    postgres    postgres    127.0.0.1/32          trust
# IPv6 local connections:
host    all         all         ::1/128               @authmethod@

Location3 : /etc/postgresql/8.4/pg_hba.conf  configuration has to check
# Database administrative login by UNIX sockets
local   all         postgres                          trust

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               trust
# IPv4 local connections:
host    all         all         127.0.0.1/32          trust
host    adempiere         adempiere         127.0.0.1/32          trust

# IPv6 local connections:
host    all         all         ::1/128               md5

NB: Location3 is actual configuration file for pg_hba.conf

Step3: 
Now check postgresql.conf using location3
listen_addresses = 'localhost'              # what IP address(es) to listen on;
                                                            # comma-separated list of addresses;
                                                            # defaults to 'localhost', '*' = all
                                                            # (change requires restart)
port = 5432

NB: listen_addresses and post will be close by #. just remove # then  listen_addresses and post will be active.


Step4 : Now created user
            Command :     createuser -P -E -d adempiere
Step5 : Create Database
            command :      createdb -O adempiere adempiere

Step6 : now do Adempiere dump using flowing commad
            Commnd : psql -d adempiere < Adempiere.dmp

wait for few moment. Your database will be inserted.
-----------------------------------------------------------------------

Do host setting/ or check setting
path for host : /etc/host
192.168.52.101           debobrota-Compaq-Presario-C700-Notebook-PC      # Added by NetworkManager
127.0.0.1         localhost.localdomain localhost
::1        debobrota-Compaq-Presario-C700-Notebook-PC      localhost6.localdomain6         localhost6
127.0.1.1         debobrota-Compaq-Presario-C700-Notebook-PC

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

NB: this checking is required when you will do ./RUN_setup.sh (this is adempiere file)

Do profile or bash_profile  setting
path for host : /root/
then go to /view/show hidden file
----------------------------------------
export JAVA_HOME=/u01/jdk1.6.0_16
export ADEMPIERE_HOME=/u01/Adempiere

export PATH=$JAVA_HOME/bin:$PATH
export PATH
unset USERNAME

NB: Remember do the same path setting for each user login. Example when u will login using root then go to profile (if ubuntu) and .bash_profile(if fedora)
same way when you will login by other user then set same path in the file.



Important Link :
4.                  http://www.adempiere.com/index.php/Install_on_Ubuntu_8.10
5.                  http://ubuntuforums.org/archive/index.php/t-725933.html
8.                  http://www.adempiere.com/index.php/ADempiere_Install_Linux%26PostgreSQL