2014年9月18日

ExtJS Tutorials: Rules for HasMany Associations in ExtJS

ExtJS Tutorials: Rules for HasMany Associations in ExtJS:

Rules for HasMany Associations in ExtJS

  1. Always put your Proxies in your Models, not your Stores, unless you have a very good reason not to *
  2. Always require your child models if using them in hasMany relationships. ** 
  3. Always use foreignKey if you want to load the children at will
  4. Always use associationKey if you return the children in the same response as the parent
  5. You can use both foreignKey and associationKey if you like
  6. Always name your hasMany relationships
  7. Always use fully qualified model names in your hasMany relationship
  8. Consider giving the reader root a meaningful name (other than "data")
  9. The child model does not need a belongsTo relationship for the hasMany to work

Example:
Ext.define('Assoc.model.Contact', {

    extend:'Ext.data.Model',

    requires:[
        'Assoc.model.PhoneNumber'          /* rule 2 */
    ],

    fields:[
        'name'                             /* id field is inherited from Ext.data.Model */
    ],

    hasMany:[
    {
        foreignKey: 'contact_id',          /* rule 3, 5 */
        associationKey: 'phoneNumbers',    /* rule 4, 5 */
        name: 'phoneNumbers',              /* rule 6 */
        model: 'Assoc.model.PhoneNumber'   /* rule 7 */
}
    ],

    proxy:{                                /* rule 1 */
        type: 'ajax',
        url: 'assoc/data/contacts.json',
        
        reader: {
            type: 'json',
            root: 'contacts'               /* rule 8 */
        }
    }
});

// example usage:

var c = new Assoc.model.Contact({id:99});

/*
 * assuming that PhoneNumber.proxy is AJAX and has a url set to 'phonenumbers', the below function would make an http request like this:
 * /phonenumbers?page=1&start=0&limit=25&filter=[{"property":"contact_id","value":"99"}]
 * ie, it would make a request for all phone numbers, but ask the server to filter them by the contact_id of the Contact, which is 99 in this case
 */
c.phoneNumbers().load(); 

* The store will inherit its model's proxy, and you can always override it
** To make it easy, and avoid potential circular references, you can require them in app.js .

2011年1月18日

Debian 6 Squeeze 里编译安装Spring游戏

官方安装文档说debian 6可以直接apt-get install srping安装。但是,安装的版本比较老,下载的mod不能运行。可以如下编译安装,debian 6测试通过
参考资料: http://springrts.com/wiki/Building_Spring_on_Linux

#安装需要的包
apt-get install \
libboost-system-dev libboost-thread-dev \
libboost-regex-dev \
libboost-serialization-dev  \
libboost-program-options-dev \
build-essential zlib1g-dev libfreetype6-dev \
libsdl1.2-dev libopenal-dev  libopenal-dev zip \
 libvorbis-dev libxcursor-dev libdevil-dev \
libglew1.5-dev libboost-signals-dev \
cmake

#下载http://ncu.dl.sourceforge.net/project/springrts/springrts/spring-0.82.7.1/spring_0.82.7.1_src.tar.gz,解压缩,

#查看如何安装
more README.markdown

#生成编译配置文件,看是否有什么错误,一般错误信息是缺少什么包
cmake .

#编译 时间有点久,慢慢等
make

#安装
make install

下载mod,地图就可以玩了

2010年12月9日

Email Notifytion When Oracle Stream Replication Fail

All object in schema FRAME are replicated by Oracle Stream Replication. I create a job to check the data in table FRAME.SYS_STREAM_REPLICATION if they are same in source database and destination database.

If the data are different, use UTL_MAIL to send an email to me .
create table FRAME.SYS_STREAM_REPLICATION
(
  COL      NUMBER,
  SMS_SENT NUMBER
);

comment on table FRAME.SYS_STREAM_REPLICATION
  is '数据库同步测试表';
comment on column FRAME.SYS_STREAM_REPLICATION.SMS_SENT
  is '1 已发送,  0未发送';
grant select, insert, update, delete on FRAME.SYS_STREAM_REPLICATION to STREAMADMIN;
/* 检测数据库复制是否正常 */
declare
  src_value number;
  dest_value number;
  sms_sent number;
  err varchar2(3000);
BEGIN
  select col,sms_sent into src_value,sms_sent from frame.sys_stream_replication;
  select col into dest_value from frame.sys_stream_replication@dest_db;
  if src_value<> dest_value then  
     if sms_sent<>'1' then 
        UTL_MAIL.send(sender => 'name@domain.com',
            recipients => 'name@domain.com',
               subject => 'Database Stream Replication Fail',
               message => 'Hello World',
             mime_type => 'text; charset=us-ascii');
          
         insert into frame.sms_info_prepare_send  (sms_id,mobile_no,sms_content) values ('999'||src_value,'18912345678','Oracle Stream Replication Fail!');
         update  frame.sys_stream_replication set sms_sent='1';
     end if;
   else
     update frame.sys_stream_replication set col=col+1, sms_sent='0';

   end if;
   commit;
  EXCEPTION
  WHEN OTHERS THEN
    err := SQLERRM;
    ROLLBACK;    
      INSERT INTO job_log
             (date_time, err, remark)
      VALUES
             (sysdate,  err, '检测数据库复制是否正常 job 65');
  COMMIT;
END;

2010年9月27日

DML SQL with keyword SYSDATE may cause trouble in Oracle Stream Replication

Tow database, one way replication, if you execute DML SQL like "insert into tab (id, operate_time) values ('1',SYSDATA)" in source database. this exactly SQL will execute in destination database too, but it will execute on destination database short after the executing of source database.

(I think the period is not short sometimes, if some network problem occurs, or some other operation delay the executing on destination database.)

Yes, this SQL do not execute at same time on source database and the destination database. and the column operate_time will have different value in the two database.

OK, the value of column operate_time in two database have little different, it is not a big problem. I don't care!

Latter, I execute this SQL: "delete tab where 1=1" in source database. Oops, I got this ORA-26786 shit in destination database

My Mon

There are many peddler along the street. They sell fruits, vegetables, snack. It is too usual so that we often ignore their exists. But a few of them do touch me.

They are not mongering, the fruits or vegetables that they sell are planted by themselves. In fact, they are farmer.

Obviously, they are new here, and not have enough selling experiences. The goods may be not good looking. They haven't take a good place to sell. So They still sell even it is very late.

Their eyes tell me They are worrying about how to deal with their goods. It makes me sorrow.

My parents sell orange every winter. To take a good place, they must reach town before sun rise. So they set out about 4:00AM. They go to town by feet, carrying 50kg oranges. There is no bus because it is too early, the whole travel is by feet. And there is a hill block the way, they must go over it.

How to make self wake at 4:00AM? Alarm clock? No, most of farmer have not got that. They drink a lot water before sleep. It is much more useful than an alarm clock.

The burden is heavy. It make them sweating. But it would change minutes latter after arrival. It is so cold in winter, especially the clothes have been wet by sweat.

As industrious farmers, the difficulties above are just pieces of cake. The real discouraging is that oranges have not sold out.

That is the life of my parents 8 years before. My mom have went to heaven 5 years.

Yes, it is make me real sad that I saw a farmer with lots of fruit or vegetables not sold.

Bowl Lotus

Bowl lotus, also called mini lotus, It is a kind of small lotus that you can plant it in a big bowl. If you love Lotus, you can grow it in your yard or balcony, because she lives in water, So you don't need to water her carefully, just keep here in water will be OK. But remember, She loves sunshine very much, she may not flower if she did not get enough sunshine.

The following photoes are Lotus growed in 2008 by me.

 Leaves

 First Daughter

She is Growing Up 

 All Children

 Close Up to First Daughter

Fructus