Wednesday, April 27, 2011

Grails with UML diagram




กำลังมองหาการสร้าง UML จาก Grails class พอดีไปเจอลิงค์นี้ เยี่ยมมากเลยครับ

To install the plugin into your Grails application simply enter the following command line command.


C:\[???]>grails install-plugin create-domain-uml

To generate a class diagram just enter:

C:\[???]>grails create-domain-uml

??? คือ app ที่ถูกสร้างโดย Grails
พอสร้างเสร็จแล้ว ไป view html ที่สร้างขึ้นมา จะเห็น diagram uml เป็นรูป โดยลิงค์รูปผ่านเวบ http://yuml.me/




Tuesday, April 26, 2011

Domain save error log

กรณี save obj ไม่ได้ ตรวจ error จากที่นี่ // render by controller

if (!user.save()) {
render log.warn user.errors.allErrors.join(' \n')
//each error is an instance of org.springframework.validation.FieldError
}

Sample Relation in Grails

from this post

A Comment belongs to a Post.
A Post has many Comments.
A Comment has one Commentator.
A Commentator belongs to a Comment.

Saturday, September 12, 2009

วัดร่องขุน - เชียงราย


ไม่รู้ว่าเคยไปวัดร่องขุ่น มาหรือยังครับ


more my photo on


http://groovytrip.blogspot.com/2011_04_01_archive.html





การ encode ข้อมูล ด้วย groovy

ตัวอย่าง การ encode ข้อมูล

def outFile = new File('out2.txt')
outFile.delete()
datafile = new File('out.txt')
datafile.eachLine{ line ->
for (c in line) {
outFile.append( (char) ((int)c+1) )
}
outFile.append ('\n')
}
input (out.txt)
--------
This is a boy.
This is a girl.

output (out2.txt)
---------
Uijt!jt!b!cpz/
Uijt!jt!b!hjsm/

การ decode ข้อมูล ก็สามารถทำได้ไม่ยาก เหมือนกันลองไปทำดูครับ

เกี่ยวกับ file ใน groovy

ตัวอย่างการสร้างไฟล์ และ อ่านไฟล์ใน groovy

การสร้าง file

def outFile = new File('out.txt')
outFile.delete() // if file exist, delete it
def i = 1
4.times{ // 4 time loop
outFile.append i++ + '\n'
}


การอ่าน file

datafile = new File('out.txt')
datafile.eachLine{ line -> print line + '\n' } // closure

ตัวอย่าง การใช้งาน VMWare ESX Server

ดูจากรูปนี้แล้ว
XpressHost™ - Vmware ESX Server
VMware มันวางอยู่บน Hardware ชุดเดียวกัน สมมุติว่า มี CPU อยู่ 8 ตัว แบ่ง 4 ตัวให้ SQL server(Windows) และ อีก 4 ตัว ให้ Web server (Unix) นี่คงเป็นวิธีการที่ ทำให้ Database Server กับ Web Server ทำงานอยู่ใกล้กันมากที่สุด (อยู่บน Hardware ชุดเดียวกัน) เพื่อประสิทธิภาพสูง ในการทำงาน