Thursday, August 1, 2013

Hibernate

Hibernate is an object-relational mapping (ORM) library for the Java language, providing a framework for mapping an object-oriented domain modelto a traditional relational database. Hibernate solves object-relational impedance mismatch problems by replacing direct persistence-related database accesses with high-level object handling functions.
Hibernate is free software that is distributed under the GNU Lesser General Public License.
Hibernate's primary feature is mapping from Java classes to database tables (and from Java data types to SQL data types). Hibernate also provides data query and retrieval facilities. It generates SQL calls and relieves the developer from manual result set handling and object conversion. Applications using Hibernate are portable to supported SQL databases with little performance overhead

Relational Persistence for Java and .NET

Historically, Hibernate facilitated the storage and retrieval of Java domain objects via Object/Relational Mapping.  Today, Hibernate is a collection of related projects enabling developers to utilize POJO-style domain models in their applications in ways extending well beyond Object/Relational Mapping

Example of sample Mapping XML file 

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Aug 9, 2013 9:25:17 AM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>

<class name="core.classes.lab.TestDescription" table="lab_test_description">
<id name="testID" type="int" column="labTestDescription_TestID">
<generator class="increment" />
</id>
<property name="testName" column="labTestDescription_TestName"
type="string" />
<property name="testDescription" column="labTestDescription_TestDescription"
type="string" />
<property name="category" column="labTestDescription_Category"
type="string" />
<property name="testProcedure" column="labTestDescription_TestProcedure"
type="string" />
<property name="isSpecimenAvailable" column="labTestDescription_IsSpecimenAvailable"
type="boolean" />
<property name="specimenType" column="labTestDescription_SpecimenType"
type="string" />
<property name="testResultTableName" column="labTestDescription_TestResultTableName"
type="string" />
<property name="loincCode" column="labTestdescription_LoincCode"
type="string" />

<property name="createUser" column="labTestDescription_CreateUser"
type="int" />
<property name="lastUpdateUser" column="labTestDescription_LastUpdateUser"
type="int" />
<property name="createDate" column="labTestDescription_CreateDate"
type="java.util.Date" />
<property name="lastUpdate" column="labTestDescription_LastUpdate"
type="java.util.Date" />

</class>
</hibernate-mapping>

Wednesday, June 12, 2013

PHP Barcode Generator

PHP CLASS : BARCODE

Version : 2.0.3
Licence : GPL / Cecill
Date : 2013-01-06
Auteur: DEMONTE Jean-Baptiste, HOUREZ Jonathan

Download the class PHP Barcode 2.0.3

Barcode PHP Class installation

Like all class, juste include the source file.
  1. include('Barcode.php');  
These classes are included :
  • Barcode
  • BarcodeI25
  • BarcodeEAN
  • BarcodeMSI
  • Barcode11
  • Barcode39
  • Barcode93
  • Barcode128
  • BarcodeCodabar
  • BarcodeDatamatrix

Barcode PHP Class utilisation

To use this class, tow statics functions are available, one for GD ressource and second one for FPDF
  1. Barcode::gd($res$color$x$y$angle$type$datas$width = null, $height = null);  
  2. Barcode::fpdf($res$color$x$y$angle$type$datas$width = null, $height = null);  

$res

ressource gd or fpdf

Unit depends on ressource : pixel for GD and defined in the constructor for fpdf

$color

int, string

Descriptor of the color (int) for GD and hexadecimal string for fpdf (ie: "FF0000")

$x, $y

numeric

coordinate of barcode center

$angle

numeric

Rotation angle in degree

$datas

string

Value barcode (dependent on the type of barcode)
If barcode type include it, the presence of the checksum is not mandatory, it ise automatically recalculated
array
type : ean8, ean13, code11, code39, code128, codabar
memberType
codestring
type : std25, int25, code93
memberType
codestring
crcboolean
type : msi
memberType
codestring
crcboolean
arraycrc1 : string("mod10", "mod11")
crc2 : string("mod10", "mod11")
type : datamatrix
memberType
codestring
rectboolean (default : false)

type (string)

  • codabar
  • code11 (code 11)
  • code39 (code 39)
  • code93 (code 93)
  • code128 (code 128)
  • ean8 (ean 8)
  • ean13 (ean 13)
  • std25 (standard 2 of 5 - industrial 2 of 5)
  • int25 (interleaved 2 of 5)
  • msi
  • datamatrix (ASCII + extended)

$width, $height

numeric

width and height of an element, for 2D barcode (datamatrix), $height is not used

<< Returned value >>

Both methods return an array containing the dimensions of the barcode and the coordinates of its ends
  1. array(  
  2.         'width' => w,  
  3.         'height'=> h,  
  4.         'p1' => array('x' => x, 'y' => y),  
  5.         'p2' => array('x' => x, 'y' => y),  
  6.         'p3' => array('x' => x, 'y' => y),  
  7.         'p4' => array('x' => x, 'y' => y)  
  8.       );  
Example :
  1. $im     = imagecreatetruecolor(300, 300);  
  2. $black  = ImageColorAllocate($im,0x00,0x00,0x00);  
  3. $white  = ImageColorAllocate($im,0xff,0xff,0xff);  
  4. imagefilledrectangle($im, 0, 0, 300, 300, $white);  
  5. $data = Barcode::gd($im$black, 150, 150, 0, "code128""12345678", 2, 50);  
"rotate" function allow to calculate coordinate of rotated point, usefull to center the "hri" (human readable interpretation)
Example
  1. $box = imagettfbbox($fontSize, 0, $font$data['hri']);  
  2. $len = $box[2] - $box[0];  
  3. Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge$angle$xt$yt);  
  4. imagettftext($im$fontSize$angle$x + $xt$y + $yt$blue$font$data['hri']);  

Thursday, February 21, 2013

Wow there Is a Framework Call CodeIgniter

In the begin of this project the requirement was to developed a system to the government hospital laboratory system An we ask to use the php codeigniter as our front end, this is the first time i heard about the this php framework. First our group has look in to the framework and had to learn it from the scratch. I am my self take the responsibility to learn this and teach the others. Codeigniter was used to maintain the MVC architecture on PHP,

CodeIgniter is an open source rapid development web application framework, for use in building dynamic web sites with PHP. "Its goal is to enable [developers] to develop projects much faster than writing code from scratch, by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and logical structure to access these libraries."[1] The first public version of CodeIgniter was released on February 28, 2006, and the latest stable version 2.1.4 was released July 8, 2013.
CodeIgniter is loosely based on the popular Model-View-Controller development pattern. While view and controller classes are a necessary part of development under CodeIgniter, models are optional.
CodeIgniter is most often noted for its speed when compared to other PHP frameworks In a critical take on PHP frameworks in general, PHP creator Rasmus Lerdorf spoke at frOSCon in August 2008, noting that he liked CodeIgniter "because it is faster, lighter and the least like a framework."
CodeIgniter's source code is maintained at GitHuband as of the preview version 3.0-dev, is certified open source software licensed with the Open Software License ("OSL") v. 3.0. Versions of CodeIgniter prior to 3.0 are licensed under a proprietary Apache/BSD-style open source license.
The decision to switch to an OSL license sparked some community controversy, especially about the GPL incompatibility of the new license, to which EllisLab has responded with a series of articles entitled Software License Awareness Week.
On July 9th 2013, EllisLab announced that it is seeking a new owner for its CodeIgniter, stating lack of involvement as a reason. It is not clear whether or not CodeIgniter will remain the backbone of its ExpressionEngine software.
This is the definition on wiki about codeigniter. using this freame work we can directly archive the MVC very easy. just have to put our code in right folder, interfaces to the view and db conncetion to the models and the connecters to the controller. this frame work is so awesome when its come to work under the MVC