Thursday, 31 March 2016

Hybris build targets over view....!!!



Purpose of build Tool:
Build tools are programs that automate the creation of executable applications from source code.

It is the act of scripting or automating a wide variety of tasks that software developers do in their day-to-day activities like:

1.   Compiling source code into binary code.
2.   Packaging that binary code.
3.   Running tests.
4.   Deployment to production systems.
Various build tools available in java are Ant, Maven, Gradle.

In Ant we have targets each target has its own purpose and usage to perform some task. These targets are present in build.xml file. To execute any target first we have to complete the following steps.
1.   Download the ant
2.   Install ant in your system
3.   Set ANT path in environmental variables.

In hybris we use Ant build tool. So before going to run any target go to platform folder open command window run the setantenv.bat file to set Ant environment then run your target to perform particular task. Without setting Ant environment your build will fail.
The following are the targets present in your build.xml file and what is their purpose is explained below:
Targetname = "build"  description="Builds all extensions"
 Targetname = "deploy"  description="Deploys platform to bundled server. Will copy files of config/tomcat or config/tcServer to config folder of configured bundled server.">
 Targetname = "ear" description="Builds ear file"
 Targetname = "all" depends="build,server" description="executes ant build and ant server  
 Targetname = "clean" description="Cleans platform and all extensions"
  Targetname = "cleanear" description="Cleans ear file"
      
    Targetname = "dist" description="Creates a distribution"
   Targetname = "pmd" description="Tests the source code with the pmd rules."
    Targetname = "sonar" description="Executes sonar to check all projects with the sonar rules.
    Targetname = "sonarsingle" description="Executes sonar to check a single project with the sonar rules."
    Targetname = "classpathgen" description="Creates a standard platform .classpath file"
    Targetname = "sourcezip" description="Creates a sourcezip"
    Targetname = "extgen" description="Runs extgen"
    Targetname = "modulegen" description="Runs modulegen"
    Targetname = "initialize" depends="build,server"
    Targetname = "droptypesystem"  description="Drops type system tables."
     Targetname = "createtypesystem"  description="Creates type system tables."
      Targetname = "server" description="Configures hybris Server and restart if running"
    Targetname = "updatesystem"
                                      description="Runs an update system of the specified tenant in stand-alone mode, using hybris Administration Console default settings. Syntax: ant updatesystem [-Dtenant=tenantID -DdryRun=true|false -DtypeSystemOnly=true|false]">
 Targetname = "webservice_nature" description="Provides webservice nature to selected extension"
Targetname = "yunitinit" description="Initializes JUnit tenant"
 Targetname = "yunitupdate" description="Update JUnit tenant"
 Targetname = "apidoc" description="build javadoc for all current extensions"

Architecture of hybris



Architecture of Hybris Commerce Suite:
The hybris Commerce Suite organizes data like product information to be propagated using multiple communication channels in a consistent and efficient way. This enables businesses to sell products across multiple distribution channels.
The hybris Commerce Suite is highly flexible and modular software which uses plug and play concept. The flexibility comes from several layers of abstraction and functionality.
·         Basic Architecture
·         Layer Architecture
Basic Architecture:


From a business point of view, the hybris Commerce Suite is divided into individual packages, such as Commerce, Content, Channel, and Orders.
Each package holds bundles of functionality assembled for a certain range of business functionality.
All these packages will rely on the main basic functionality provide by hybris Platform.
Note :
The hybris Platform can run without any package, no package can run without the hybris Platform.
Platform:
Platform is the final component and is the core architecture of the Suite, where the application interface and infrastructure resides.
Content:
As the name says it provides core information of our site, more specifically information related to the products we sell. This includes Product Catalogs, Product Categories and Classification System Media (such as product images).
Orders:
It is just like it sounds. This layer contains all details related to ordering of your products, including Promotions Payment and fulfillment detail Inventory management Order history and management Customer details.
Channel:
Channel refers to how you reach your customers. This can be a mix of both digital and physical methods. Just recall about the channels topic posted earlier.
Commerce:
Commerce component provides a collection of modules (features/functions) based on the type of commerce site we are running. Hybris provides 2 types depending on the type of client you plan to serve. They are:
1.    B2C (Business to Customer)
2.    B2B (Business to Business)

Layer Architecture:
The layer architecture will give us a technical overview of hybris suite. The hybris Commerce Suite contains several layers, each of which has a different function and data abstraction level.




The hybris Commerce Suite is built on collection of different frameworks and technologies. The different Layers are as follows:
1.    Presentation layer
2.    Functional layer
3.    Platform Layer/ Business Layer
4.    Application Server
5.    3rd Party Databases
 Presentation Layer: This layer is used for GUI part. The hybris commerce suite support Cockpit which is built using  ZK framework and next generation Framework .This enables organizations to manage about structure information and catalogs in high-volume and collaborative environments.
1) Cockpits
2) Hybris management console
3) Store foundations
4) Other frontend
Functional layer: As the name indicates it provides functionality .The packages on the Functional Layer (hybris Commerce, hybris PIM, hybris Print) use the hybris Platform to implement the functions they deliver. Actually, hybris Platform is part of any hybris Package.
Platform Layer: The hybris Platform layer abstracts data from the storage structure on the database using the persistence framework and provides functionality such as Clustering and the hybris Platform Cache. Relying on the persistence framework, the other functional components of the Platform Layer provide basic business
Application Server: In addition to the preconfigured hybris Server based on Apache Tomcat, the hybris Commerce Suite supports selected third-party application servers.
1. Oracle Web logic Server
2. IBM Web Sphere Commerce Server
3. Spring Source tcServer
Third-Party Databases: The hybris Commerce Suite supports a variety of database systems. By default, it is pre-configured for the HSQLDB database. Apart from this it supports following databases.
1.    Oracle
2.    MySQL
3.    SQL Server
4.    SAP Hana



Monday, 28 March 2016

Interesting IMPEX in hybris



Impex:
·         As we know that everything is an extension in hybris, so  integrated text-based import/export extension is called impex .
·         Before going to know impex one must have knowledge on Comma-Separated Values (CSV) data files.
·         Impex file is allowed to create,update,delete and exporting platform related data to and from comma-seperated values(CSV)data files both during runtime and hybris commerce suite initialization or update process.

Key Features:
ü  Import and export hybris Commerce Suite data from and into CSV files.
ü  To feed data into database we go for impex.
ü  Impex file is developed based on the "BeanShell Script".

The ImpEx extension is a converter between items in the hybris Commerce Suite and a CSV file, and the other way round as shown below:
By using Hybris Impex extension it is easy to:
ü                 Update data at run time
ü                 Creating initial data for a project or migrating existing data from one hybris            Commerce Suite into another.
Impex Syntax:
Before going to syntax first we should know terminology used while writing impex file. There are different line types appear  are:
  • Headers in header section 
  •  Lines of values value line section
  •  Comments 
  •  Macro definitions 
Header:
An ImpEx header line has the following structure:
mode type[modifier=value];attribute[modifier=value];attribute[modifier=value];attribute[modifier=value][;...];attribute[modifier=value]

  • Mode specifies what is to be done with the following value lines (insert, update, and so on)
  • Type defines the type of item to be processed (category, product, media, type, and so on)
  • Attribute describes which item attributes the columns are mapped to. The value lines supply the actual values for the items that are translated using the header settings.
  • Modifier gives additional information for translating a value record to the mapped type attribute.

Example for header row:

INSERT_UPDATE category;code[unique=true];name[lang=de];name[lang=en];$supercategories;$thumbnail;description[lang=de];order
Red color-Mode
Blue color-item Type
Orange color-Attribute
Violet color- Modifier
$- macros
     This header states that each following value line creates or updates a category   instance, until another header occurs.

Value of line:
The values inserted in attributes level in type are called value of line.
Ex: In the above example true, en etc represents value of line
Comments:
A comment starts with hash symbol #.
Ex: # inserting values into category type---- comment
INSERT_UPDATE  Category ;id[unique=true];name
Macro definitions:
Macro definitions start with the dollar symbol $, and they are referenced by $macro name. impex extension allows definitions of macros. you don't have to type repeating strings into your csv file.
Macro must be first  statement in impex file. We can have any number of macros.
Ex: $catalog=catalog(id)-- macro
$catalogVersion=catalogVersion($catalog,version)--- macro
INSERT Product; code; $catalogVersion--- Header
Wherever the term $catalogVersion appears, it is replaced by: catalogVersion(catalog(id),version)

In hybris, Data feeding can be done in 3 ways: 
  1.  Through HAC 
  2. Through HMC
  3.  Programmatic Way
1.     Through HAC: 
  1.               start server and navigate to http://localhost:9001 
  2.       Goto console tab -->select ImpEximport 
  3.           write or copy impex statement-->click on validate content then if script valid it will display saying that import script is valid. 
  4.      After Validating Click on Impex Import Tab. Now Impex Script is imported.

2.    Through HMC:
  •      Start server and navigate to http://localhost:9001/hmc/hybris 
  •     In tree menu select system-->Extract system-->select Tools 
  •     Tools extracted-->select import-->New window is opened 
  •     click on import file-->new window opened
  •      select choose file-->select that impex file-->next upload file 
  •          finally select start button -->your record is successfully uploaded

3.    Through Programmatic way:
As an alternative to populate the data model, we will use the ImpEx approach.
ImpEx files for essential data and project data can be prepared without the need for additional data configuration.
Convention:
During the initialization and update processes, the platform looks for ImpEx files in the <extension_name> /resources/impex folder. In particular:
    For essential data: The platform scans the <extension_name> /resources/impex  folders for files with names that match the pattern essentialdata*.impex and imports the files during the essential data creation.
    For project data: The platform scans the <extension_name> /resources/impex folders for files with names that match the pattern projectdata*.impex and imports the files during the project data creation.

The ImpEx directory does not exist by default. You must create it and copy files to it.

For example, if you have the following folder structure:
    resources/impex/essentialdataOne.impex
    resources/impex/essDataOne.impex
    resources/impex/DataOne.csv
    resources/impex/projectdataOne.impex
The files essentialdataOne.impex and projectdataOne.impex are located and imported during the essential and project data imports respectively.