ERP en LOGICIEL LIBRE dédié aux PME-PMI

           Devenez partenaire Principal ou Majeur de Neogia

Formation des développeurs (Widget)

Cette formation est destinée principalement aux nouveaux développeurs Neogia.

Contents

Introduction

Historique

Outils du projet

Ofbiz Mailing lists :

Neogia Mailing lists :

Méthodes de développement

Développement d'une nouvelle fonctionnalité :

Tout développement de nouvelles fonctionnalités pour Néogia se fait au travers de tâches ("feature request") déclarées sur le tracker du projet sur sourceforge.

  1. Déclarer une feature request sur sourceforge
  2. Coder la fonctionnalité
  3. Soumettre des patchs au fure et à mesure des développements. Les patchs doivent être bien divisé et pas trop gros
  4. Préfixer le sujet de la fonctionnalité sur sourceforge par [TBT] lorsqu'elle terminée et ajouter les patchs
  5. Faire un test Sélénium
  6. Faire une documentation sur le wiki Neogia

Correction de bugs :

  1. Déclarer une Bug Tracker sur sourceforge
  2. Corriger le bug
  3. Soumettre des patchs au fure et à mesure des développements. Les patchs doivent être bien divisé et pas trop gros
  4. Préfixer le sujet de la fonctionnalité sur sourceforge par [TBT] lorsqu'elle terminée
  5. Passer les tests Sélénium su composant. Ils doivent tous etre au vert.
  6. Faire une documentation sur le wiki Neogia

Architecture

Technologies Ofbiz

Entity Engine


Recherche d'une entité par sa clé primaire :

   /**
    * Find a Generic Entity by its Primary Key
    *
    * @param entityName The Name of the Entity as defined in the entity XML file
    * @param fields The fields of the named entity to query by with their corresponging values
    * @return The GenericValue corresponding to the primaryKey
    */
   public GenericValue findByPrimaryKey(String entityName, Map fields) throws GenericEntityException;


Recherche d'une entité à l'aide d'une condition simple :

   /**
    * Finds Generic Entity records by all of the specified fields (ie: combined using AND)
    *
    * @param entityName The Name of the Entity as defined in the entity XML file
    * @param fields The fields of the named entity to query by with their corresponging values
    * @param orderBy The fields of the named entity to order the query by;
    *      optionally add a " ASC" for ascending or " DESC" for descending
    * @return List of GenericValue instances that match the query
    */
   public List findByAnd(String entityName, Map fields, List orderBy) throws GenericEntityException;

   /**
    * Finds Generic Entity records by all of the specified fields (ie: combined using OR)
    *
    * @param entityName The Name of the Entity as defined in the entity XML file
    * @param fields The fields of the named entity to query by with their corresponging values
    * @param orderBy The fields of the named entity to order the query by;
    *      optionally add a " ASC" for ascending or " DESC" for descending
    * @return List of GenericValue instances that match the query
    */
   public List findByOr(String entityName, Map fields, List orderBy) throws GenericEntityException;


Recherche d'une entité liée :

   /** 
    * Get related entity where relation is of type one, uses findByPrimaryKey
    *
    * @throws IllegalArgumentException if the list found has more than one item
    */
   public GenericValue getRelatedOne(String relationName, GenericValue value) throws GenericEntityException;


Création d'une entité :

   /** 
    * Creates a Entity in the form of a GenericValue and write it to the database
    *
    * @return GenericValue instance containing the new instance
    */
   public GenericValue create(String entityName, Map fields) throws GenericEntityException;


Mise à jour d'une entité :

   /**
    * Store the Entity from the GenericValue to the persistent store
    *
    * @param value GenericValue instance containing the entity
    * @return int representing number of rows effected by this operation
    */
   public int store(GenericValue value) throws GenericEntityException;


Suppression d'une entité :

   /**
    * Remove a Generic Value from the database
    *
    * @param value The GenericValue object of the entity to remove.
    * @return int representing number of rows effected by this operation
    */
   public int removeValue(GenericValue value) throws GenericEntityException;

Controller

Service Engine

Exercice : Écrire un service echo

Widget

Introduction

La création de vues dans l'application ofbiz est basée sur l'utilisation de fichiers XML décrivant ces dernières. Chaque balise XML permet d'associer des paramètres d'affichage.

Il existe un fichier par sous-composant. Ils sont stockés dans le répertoire widget de chaque composant

ofbiz/neogia/facility/widget/xxx.xml


Chaque fichier contient les différentes vues nécessaires au sous-composant.

Description d'une vue

Chaque vue comporte une structure minimale composée de :

   <screen>
       <section>
           <condition>
           </condition>
           <actions>
           </actions>
           <widgets>
           </widgets>
           <fail-widgets>
           </fail-widgets>
       </section>
   </screen>

Une vue "screen" permet de décrire la structure d'une page html. Les balises actions préparent les variables qui seront utilisées. Les widgets définissent l'organisation des différents éléments dans une vue.


la structure élémentaire est la "section". Il est possible d'imbriquer les sections les unes dans les autres comme les poupées gigogne.

   <screen>
       <section>
           <actions>
           </actions>
           <widgets>
              <section>
                   <actions>
                   </actions>
                   <widgets>
                   </widgets>
               </section>
           </widgets>
       </section>
   </screen>
  

Cet exemple représente la description de la vue EditReceiveShipment

   <screen name="EditReceiveShipment">
       <section>
           <actions>
               <set field="titleProperty" value="PageReceiveShipment"/>
               <set field="headerItem" value="Receipt"/>
               <set field="tabButtonItem" value="EditReceiveShipment"/>
               <set field="subComponent"  value="XXXX"/>
               <set field="idName" from-field="parameters.idName"/>
               <script location="component://facility/script/widgetActions/shipment/developed/EditShipment.bsh"/>
               <set field="description" from-field="formsData.description"/> 
               <script location="component://product/webapp/facility/WEB-INF/actions/shipment/ViewShipment.bsh"/>
           </actions>
           <widgets>
               <decorator-screen name="CommonEditDecorator"  location="${parameters.mainDecoratorLocation}">
                   <decorator-section name="body">
                       <platform-specific>
                           <html><html-template location="component://facility/webapp/facility/shipment/developed/EditReceiveShipmentInfo.ftl"/></html>
                       </platform-specific>
                   </decorator-section>
               </decorator-screen>
           </widgets>
       </section>
   </screen>

Détails des balises

L'ensemble des balises est décrit dans le fichier de description xsd :

ofbiz/framework/widget/dtd/widget-screen.xsd

sont listées ici les principales balises

<actions>

Les actions constituent une section permettant de préparer les données qui seront envoyées aux sections "widget". Elles comportent des balises enfants détaillant l'action :

<set field="titleProperty" value="CreateReceiveInventory"/>
<script location="component://facility/script/widgetActions/shipment/developed/EditReceiveShipment.bsh"/>

<property-map resource="HumanresUiLabels" map-name="uiLabelMap" global="true"/>


<widgets>

Elle contient l'organisation de la page html qui sera affichée.

Dans un souci de simplification nous décrivons une à une ces balises mais il est important de voir qu'elles peuvent s'imbriquer les unes aux autres ; un exemple d'imbrication est montré en toute fin de section.

<platform-specific>
    <html>
        <html-template location="component://common/webcommon/includes/messages.ftl"/>
    </html>
</platform-specific>
<container style="boxtop">
    <label style="boxhead">[${uiLabelMap.CommonId}:${idName}] ${description}</label>
</container>
<include-form location="component://facility/webapp/facility/shipment/developed/FormsReceiveInventory.xml" name="showReceiveShipment"/>
<include-screen name="breadcrumbs"/>

Technologies Néogia

Méthodologie de développement


Mapping Objet/Entité

Fichiers générés

Exercice : ajout d'un champ à un objet métier

Modification du code généré

Retrieved from "http://neogia.org/Formation"