Apache OFBiz คืออะไร


Apache OFBiz คืออะไร

    ผมเคยนำเสนอ บทความเกี่ยวกับ Apache OFBiz ไว้ที่ นาริสา และที่ Wordpress  ไว้นานพอสมควรแต่อย่างไรก็ตาม ผมก็ยังอยากที่จะบอกเล่าเก้าสิบเรื่องราวของ Apache OFBiz อีกครั้ง

Apache OFBiz หรือ Apache Open For Busienss Project เป็นโครงการซอฟต์แวร์โอเพนซอร์สที่สังกัดใน Apache Software Foundation Apache OFBiz เป็น  Enterprise Automation ซอฟต์แวร์ คือประกอบไปด้วยระบบต่างๆที่จำเป็นต่อการนำไปใช้งานอาทิ เช่น ERP, CRM, E Commerce, SCM, MRP, CMS และอื่นๆ(รายละเอียดเพิ่มเติม ) Apache OFBiz เป็นโอเพนซอร์สซอฟตแวร์ที่อยู่ภายใต้ Apache License Version 2.0

Apache OFBiz มีส่วนประกอบอยู่ 3 ส่วนหลักๆ คือ
  1. Application Component
  2. Application Development Framework
  3. Data Model


Application Component


  Apache OFBiz ได้จัดเตรียม ระบบบัญชี ระบบซื้อ-ขาย ระบบคลังสินค้า ระบบงานผลิต ระบบลูกค้าสัมพันธ์ ระบบร้านค้าออนไลน์ และ ระบบงานขายหน้าร้าน ระบบเหล่านี้พร้อมใช้งาน เราสามารถที่จะนำระบบนี้มาใช้ได้ฟรีๆโดยไม่ต้องเสียค่าใช้จ่ายใดๆ แต่ต้องอยู่ภายได้ Apache License Version 2.0 และนอกจากนี้เรายังสามารถแก้ไขโค้ดของ Apache OFBiz ได้โดยใช้ Application Development Framework เป็นเครื่องมือในการแก้ไข รายละเอียดเพิ่มเติม

Application Development Framework

Application Development Framework ถือเป็นจุดเด่นของ Apache OFBiz ที่ช่วยให้เราแก้ไขปรับแต่ Application Component ได้อย่างง่ายดายและรวดเร็ว ง่ายและเร็วจริงๆ นอกจากที่จะใช้ในการแก้ไขปรับแต่ง Application Component แล้วยังสามารถนำไปพัฒนา Application อื่นได้อีกด้วย Application Development  Framework แบ่งออกเป็น 3 ส่วน คือ

  1. ส่วนแสดงผล Web Framework Engine
    Apache OFBiz ใช้หลักการของ M-V-C และ Screens คือหน้าจอแสดงผลของ Apache OFBiz นั้นจะมีการ Define ส่วนต่างๆเพื่อประกอบเป็น Screen เช่น Header, Footer, Left Navigation เป็นต้น Apache OFBiz ได้เตรียม Screen Widget และ Form Widget และ Menu Widget ไว้สำหรับการสร้างส่วนแสดงผล นอกจากนี้เรายังใช้ JSP หรือ Swing ในการสสร้างส่วนแสดงผลอีกด้วย


        <screen name="FindExample">
            <section>
                <actions>
                    <set field="headerItem" value="Example"/>
                    <set field="titleProperty" value="PageTitleFindExample"/>
                </actions>
                <widgets>
                    <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
                        <decorator-section name="body">
                            <section>
                                <condition>
                                    <if-has-permission permission="EXAMPLE" action="_VIEW"/>
                                </condition>
                                <widgets>
                                    <container><label style="head1">${uiLabelMap.${titleProperty}}</label></container>
                                    <container style="button-bar"><link target="EditExample" text="${uiLabelMap.ExampleNewExample}" style="buttontext"/></container>
                                    <include-form name="ListExamples" location="component://example/widget/example/ExampleForms.xml"/>
                                </widgets>
                                <fail-widgets>
                                    <label style="head3">${uiLabelMap.ExampleViewPermissionError}</label>
                                </fail-widgets>
                            </section>
                        </decorator-section>
                    </decorator-screen>
                </widgets>
            </section>
        </screen>
    ตัวอย่าง Screen Widget

        <form name="AddExampleItem" type="single" target="createExampleItem" title="">
            <auto-fields-service service-name="createExampleItem"/>

            <field name="exampleId"><hidden/></field>
            <field name="exampleItemSeqId"><ignored/><!-- this will be auto-sequenced --></field>
            <field name="amountUomId" title="${uiLabelMap.CommonUom}">
                <drop-down allow-empty="true">
                    <entity-options entity-name="UomAndType" key-field-name="uomId" description="${typeDescription}: ${description} (${abbreviation})">
                        <entity-order-by field-name="typeDescription"/>
                        <entity-order-by field-name="description"/>
                    </entity-options>
                </drop-down>
            </field>
            <field name="submitButton" title="${uiLabelMap.CommonAdd}"><submit button-type="button"/></field>
        </form>

    ตัวอย่าง Form Widget

        <menu name="EditExample" default-selected-style="selected" type="simple"
                menu-container-style="button-bar button-style-1" selected-menuitem-context-field-name="tabButtonItem">
            <menu-item name="EditExample" title="${uiLabelMap.ExampleExample}">
                <link target="EditExample?exampleId=${exampleId}"/>
            </menu-item>
            <menu-item name="EditExampleItems" title="${uiLabelMap.CommonItems}">
                <link target="EditExampleItems?exampleId=${exampleId}"/>
            </menu-item>
            <menu-item name="EditExampleFeatureAppls" title="${uiLabelMap.ExampleFeatures}">
                <link target="EditExampleFeatureAppls?exampleId=${exampleId}"/>
            </menu-item>
        </menu>

    ตัวอย่าง Menu Widget


    Apache OFBiz ใช้ Freemarker เป็น Template Engine และใช้งานร่วมกับ BeanShell

    ส่วนความคุมการแสดงผลนั้น (Controller) เราสามารถ ที่จะ Clone จาก Application Component อื่นๆได้และเรายังสามารถที่จะ Overide Request และ View Map เพื่อความยืดหยุ่นในการแก้ไขปรับแต่ง

    <site-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/site-conf.xsd">
        <include location="component://ecommerce/webapp/ecommerce/WEB-INF/controller.xml"/>
        <description>OFBiz: Cloned eCommerce Controller Configuration File</description>
    </site-conf>

    การ Clone Controller

    <site-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/site-conf.xsd">
        <include location="component://ecommerce/webapp/ecommerce/WEB-INF/controller.xml"/>
        <description>OFBiz: Cloned eCommerce Controller Configuration File</description>

    <view-map name="main" type="screen" page="component://example/widget/Screens/CommonScreens.xml#main"/>


    </site-conf>

  2. ส่วนของ  Service Engine
     Apache OFBiz สามารถที่จะสร้าง service ได้หลายวิธี คือ Java Method, SOAP,  RMI, Simple Method(XML Meta-Programming), Workflow Apache OFBiz  โดยมี  Transaction, Security,  และอีกหลายอย่างให้พร้อม


        protected static boolean verifyContentToWebSite(GenericDelegator delegator, String webSiteId, String contentId) throws GeneralException {
            // first check the top level publish point
            // get the root content id
            List publishPoints = null;
            try {
                publishPoints = delegator.findByAndCache("WebSiteContent",
                        UtilMisc.toMap("webSiteId", webSiteId, "contentId", contentId, "webSiteContentTypeId", "PUBLISH_POINT"),
                        UtilMisc.toList("-fromDate"));
            } catch (GenericEntityException e) {
                throw e;
            }

            publishPoints = EntityUtil.filterByDate(publishPoints);
            if (publishPoints == null || publishPoints.size() == 0) {
                List topLevel = delegator.findByAndCache("WebSiteContent",
                    UtilMisc.toMap("webSiteId", webSiteId, "webSiteContentTypeId", "PUBLISH_POINT"),
                        UtilMisc.toList("-fromDate"));
                topLevel = EntityUtil.filterByDate(topLevel);
                if (topLevel != null) {
                    Iterator i = topLevel.iterator();
                    while (i.hasNext()) {
                        GenericValue point = (GenericValue) i.next();
                        if (verifySubContent(delegator, contentId, point.getString("contentId"))) {
                            return true;
                        }
                    }
                }
            } else {
                Debug.log("Found publish points: " + publishPoints, module);
                return true;
            }

            return false;
        }

    ต้วอย่าง Java Method

        <simple-method method-name="createExample" short-description="create a Example">
            <make-value entity-name="Example" value-name="newEntity"/>
            <sequenced-id-to-env sequence-name="Example" env-name="newEntity.exampleId"/> <!-- get the next sequenced ID -->
            <field-to-result field-name="newEntity.exampleId" result-name="exampleId"/>
            <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
            <create-value value-name="newEntity"/>

            <set-service-fields service-name="createExampleStatus" map-name="newEntity" to-map-name="createExampleStatusMap"/>
            <call-service service-name="createExampleStatus" in-map-name="createExampleStatusMap"/>
        </simple-method>  

    ตัวอย่าง Simple Method

  3. ส่วนของ Entity Engine
    ถือเป็นจุดเด่นที่สุดของ Apache OFBiz จะประกาศโครงสร้างของ Entity ใน XML เช่นการสร้างความสัมพันธ์ของตางราง การสร้างวิว หลักการจะคล้าย O/R Mapping Entity จะส่งค่าให้กับ Service Engine เป็น Generic Value จะอยู่ในรูปของ Map และ List ข้อดีอีกประการอีกเมื่อเราประกาศโครงสร้างของ Entity เราไม่จะเป็นต้องไปสร้าง Table ในฐานข้อมูลอีกเพราะเมื่อเราสตาร์ท Apache OFBiz Entity Engine จะสร้าง Table ในฐานข้อมูลให้อัตโนมัติ


        <entity entity-name="Example" package-name="org.ofbiz.example.example" title="Example Entity">
            <field name="exampleId" type="id-ne"><!-- primary sequenced ID --></field>
            <field name="exampleTypeId" type="id-ne"></field>
            <field name="statusId" type="id-ne"></field>
            <field name="exampleName" type="name"></field>
            <field name="description" type="description"></field>
            <field name="longDescription" type="very-long"></field>
            <field name="comments" type="comment"></field>
            <field name="exampleSize" type="numeric"></field>
            <field name="exampleDate" type="date-time"></field>
            <prim-key field="exampleId"/>
            <relation type="one" fk-name="EXMPL_TYP" rel-entity-name="ExampleType">
                <key-map field-name="exampleTypeId"/>
            </relation>
            <relation type="one" fk-name="EXMPL_STTS" rel-entity-name="StatusItem">
                <key-map field-name="statusId"/>
            </relation>
        </entity>

    ตัวอย่าง ของ Entity Definition
เราได้ทราบข้อมูลของ Apache OFBiz พอสังเขป อาจจะทำให้หลายๆท่านเข้าใจ Apache OFBiz มากขึ้นหากสนใจและต้องการทราบรายละเอียดสามารถติดตามอ่านได้ที่เว็บไซต์ของ Apache OFBiz
คำสำคัญ (Tags): #opensource#framework#crm#erp#ofbiz
หมายเลขบันทึก: 115467เขียนเมื่อ 29 กรกฎาคม 2007 10:16 น. ()แก้ไขเมื่อ 11 มิถุนายน 2012 12:32 น. ()สัญญาอนุญาต: จำนวนที่อ่านจำนวนที่อ่าน:


ความเห็น (1)
พบปัญหาการใช้งานกรุณาแจ้ง LINE ID @gotoknow
ClassStart
ระบบจัดการการเรียนการสอนผ่านอินเทอร์เน็ต
ทั้งเว็บทั้งแอปใช้งานฟรี
ClassStart Books
โครงการหนังสือจากคลาสสตาร์ท