แสดงบทความที่มีป้ายกำกับ apache แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ apache แสดงบทความทั้งหมด

วันพุธที่ 9 มิถุนายน พ.ศ. 2553

การ สร้าง service เพื่อ edit ข้อมูลในฐานข้อมูลโดยใช้ simple method

ในบทความนี้จะแสดงการสร้าง service ที่ใช้แก้ไขข้อมูลใน entity โดยใช้ simple method ในไฟล์ *Services.xml มีวิธีทำดังนี้

1. สร้างฟอร์มชื่อ EditBlog ที่ *Forms.xml
<form name="EditBlog" type="single" target="editBlog" title="" 
            default-map-name="resultMap" default-entity-name="NewBlog">
        <auto-fields-entity entity-name="NewBlog" default-field-type="edit"/>
        <field name="statusId">
            <drop-down allow-empty="false">
                <entity-options description="${description}" entity-name="StatusItem" key-field-name="statusId">
                <entity-constraint name="statusTypeId" value="CONTENT_STATUS"/>
                </entity-options>
            </drop-down>
        </field>
        <field name="editButton" title="Save" ><submit button-type="button"/></field>
</form>

2. include form ชื่อ EditBlog เข้าไปในไฟล์ *Screens.xml
<screen name="EditBlog">
        <section>
            <actions>
                <set field="newBlogId" from-field="parameters.newBlogId" global="true"/>
                <entity-one value-field="resultMap" entity-name="NewBlog" auto-field-map="true"></entity-one>
            </actions>
            <widgets>
                <decorator-screen name="CommonDecorator" location="component://myblog/widget/CommonScreens.xml">
                    <decorator-section name="body">
                        <container id="content">
                             <container style="post">
                                   <container style="entry">
                                        <include-form location="component://myblog/widget/MyBlogForms.xml" name="EditBlog"/>
                                   </container>
                             </container>
                        </container>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

3. กลับไปดูที่ไฟล์ *Forms.xml ฟอร์มชื่อ EditBlog มี target="editBlog"
<form name="EditBlog" type="single" target="editBlog" title="" 
            default-map-name="resultMap" default-entity-name="NewBlog">
        <auto-fields-entity entity-name="NewBlog" default-field-type="edit"/>
        <field name="statusId">
            <drop-down allow-empty="false">
                <entity-options description="${description}" entity-name="StatusItem" key-field-name="statusId">
                <entity-constraint name="statusTypeId" value="CONTENT_STATUS"/>
                </entity-options>
            </drop-down>
        </field>
        <field name="editButton" title="Save" ><submit button-type="button"/></field>
</form

4. ใน controller.xml ทำการสร้าง request-map และสั่งให้มีการการ invoke simple method ชื่อ editBlog ที่ services.xml
<request-map uri="editBlog">
        <security https="true" auth="false"/>
        <event type="service" invoke="editBlog"/>
        <response name="success" type="request-redirect-noparam" value="home"></response>
</request-map>

5. ใน services.xml มีการ invoke editBlog ในไฟล์ *Services.xml
<service name="editBlog" engine="simple" auth="false"
            location="component://myblog/script/com/org/toon/myblog/MyBlogServices.xml" invoke="editBlog">
            <attribute name="newBlogId" mode="INOUT" type="String" optional="false"></attribute>
            <attribute name="newBlogTitle" mode="IN" type="String" optional="false"></attribute>
            <attribute name="newBlogBody" mode="IN" type="String" optional="false"></attribute>
            <attribute name="statusId" mode="IN" type="String" optional="true"></attribute>
</service>

6. สร้าง service ชื่อ editBlog ในไฟล์ MyBlogServices.xml
<simple-method method-name="editBlog" short-description="edit a Blog">
        <entity-one value-field="newData" entity-name="NewBlog" auto-field-map="true"></entity-one>
        <set-nonpk-fields value-field="newData" map="parameters"/>
        <store-value value-field="newData"/>
</simple-metho

7. จบส่วนในการสร้างและเรียกใช้ Service ต่อไปจะทำการ controller ให้เรียก view ที่มีหน้า form ของการ edit new blog มาแสดงผล

8.  เพิ่ม controller ชื่อ EditBlog ใน controller.xml ให้เรียก view ชื่อ CreateBlog มาแสดงผล เมื่อมีการเรียกเข้ามาที่ controller นี้
<request-map uri="EditBlog"><security https="true" auth="false"/>
        <response name="success" type="view" value="EditBlog"/>
    </request-map>

9. สร้าง view ชื่อ EditBlog เรียกฟอร์มการสร้างมาแสดงผล
<view-map name="EditBlog" type="screen" page="component://myblog/widget/MyBlogScreens.xml#EditBlog"/>

10. ทำการ ./startofbiz.sh ใหม่อีกครั้ง แล้วทดลองเแก้ไขข้อมูลลงใน entity

วันอังคารที่ 1 มิถุนายน พ.ศ. 2553

Apache OFBiz ERP/Framework


ERP
เป็นการวางแผนการจัดการทรัพยากรขององค์กร เพื่อให้สามารถจัดการทรัพยากรของระบบให้มีประสิทธิภาพและเกิดประโยชน์สูงสุดต่อองค์กร

โดยทั่วไปในองค์กรมักจะใช้ซอฟต์แวร์สำเร็จรูปในการจัดการข้อมูลในองค์กร ทำให้เกิดความไม่เป็นอันหนึ่งอันเดียวกัน และข้อมูลไม่เป็นรูปแบบเดียวกัน เมื่อมีความต้องการจะนำเอาข้อมูลมาใช้ ความหลากหลายของซอฟต์แวร์ทำให้เกิดความไม่สะดวกในการเรียกข้อมูล ก่อให้เกิดความล่าช้าในการแข่งขันในธุรกิจยุคปัจจุบัน

ดังนั้นจึงมีแนวคิดที่จะนำเอาการวางแผนการจัดการทรัพยากรขององค์กร หรือ ERP มารวมกับระบบสารสนเทศ เพื่อรวบรวมข้อมูลทั้งหมดในองค์กรให้เป็นระบบเดียวกัน ส่งผลให้ง่ายต่อการเรียกใช้ข้อมูล, การควบคุมข้อมูล และข้อมูลทั้งหมดสามารถเชื่อมโยงกันได้อย่างทันเหตุการณ์ (real time)

OFBiz
เป็น Open Source Software ที่ช่วยให้องค์กรหรือธุรกิจสามารถวางแผนการใช้งานทรัพยากรให้เกิดประโยชน์สูงสุด โดยสามารถเชื่อมต่อกับทุกระบบ หรือเชื่อมต่อระบบสำคัญๆ ในองค์กร ช่วยให้ผู้ที่มีความสามารถเข้าถึงข้อมูลใช้ประโยชน์จากข้อมูลที่เชื่อมโยงกันได้อย่างทันเหตุการณ์ (real time)

OFBiz มาจากคำว่า Open For Business อยู่ภายใต้การดูแลของ Apache Foundation ซึ่งมี Developer จากทั่วโลกมาช่วยกันพัฒนา แล้วแจกจ่ายให้ผู้สนใจนำไปใช้งานและพัฒนาต่อโดยไม่เสียค่าใช้จ่าย แต่อยู่ภายใต้เงื่อนไขของ Open Source Software

OFBiz ประกอบด้วยแอพพลิเคชั่นที่ช่วยในการทำงานหลายด้าน เช่น Customer Relationship Management(CRM), Human Resource Management(HRM), Supply Chain Management(SCM), Purchase Management, Inventory, Sales Management, IT Management, Production Management, Data Analysis/Report เป็นต้น

ปัจจุบันมี Open Source ERP จากหลายบริษัท แต่หลักๆ แล้ว จะแบ่งตาม Framework ที่ใช้เป็นพื้นฐานในการพัฒนาได้ดังนี้

1. Apache OFBiz - ERP ที่นำเอา OFBiz ไปเป็นพื้นฐานในการพัฒนา เช่น Opentabs ERP/CRM, Shared OFBiz, OrangeGears ERP/CRM, Atlassian JIRA, Neogia ERP เป็นต้น
2. Open ERP
3. Compiere - ERP ที่นำเอา OFBiz ไปเป็นพื้นฐานในการพัฒนา เช่น Adempier, Open Bravo, Seree ERP เป็นต้น

องค์ประกอบหลักของ OFBiz
1. Application Component
2. Application Development Framework
3. Application Data Model

โครงสร้างของ OFBiz Framework แบ่งเป็น 3 ส่วน คือ
1. Presentation
2. Business Logic
3. Data

บรรยายสำหรับนักศึกษาฝึกงาน Orange Gears
เมื่อวันที่ 1 มิ.ย. 2553 โดย คุณธนกฤติ วงศ์ยืด

เอกสารอ้างอิง
http://www.slideshare.net/orangegears/apache-ofbiz-erp