Learn Extjs5 with me. (33--design of individual modules [1 build tables and beans])

Source: Internet
Author: User
Tags field table

Learn Extjs5 with me. (33--design of individual modules [1 build tables and beans])
Now the first core part of the system is how to design the function of the module. See, one of the simplest modules includes the following: Module properties, field properties, list definitions, and form definitions.
In the definition above, a module can consist of n fields, there can be several list schemes and form schemes, and each list and form can have several groups, each of which has several fields below it. This design also conforms to the features designed in the first 20 sections of this tutorial.        All we have to do now is to make these functions interactive with the front and back tables. Start the definition of the module field and the list schema first.        The definitions for each of these scenarios are also placed in the database, so the tables and Java beans should be built first. Establishes the table _modulefield for the module field.
CREATE TABLE [dbo]. [_modulefield] ([tf_fieldid] [int] not null,[tf_moduleid] [nvarchar] (Ten) COLLATE chinese_prc_ci_as not null,[tf_fieldorder] [int] NULL, [Tf_title] [nvarchar] (COLLATE chinese_prc_ci_as not null,[tf_fieldname] [nvarchar] (a) COLLATE chinese_prc_ci_as not Null,[tf_fieldtype] [nvarchar] (COLLATE chinese_prc_ci_as not null,[tf_fieldgroup] [nvarchar] (a) COLLATE chinese_prc_ci_as Null,[tf_fieldlen] [ INT] Null,[tf_propertytypeid] [int] null,[tf_ishidden] [bit] null,[tf_isreadonly] [bit] null,[tf_isrequired] [bit] NULL , [tf_isdisable] [bit] null,[tf_isuserdefine] [bit] null,[tf_userdefine] [nvarchar] (max) COLLATE chinese_prc_ci_as NULL , [Tf_allowgroup] [bit] null,[tf_allowsummary] [bit] null,[tf_othersetting] [nvarchar] (max) COLLATE chinese_prc_ci_as Null,[tf_defaultvalue] [nvarchar] (COLLATE chinese_prc_ci_as null,[tf_remark] [nvarchar] (max) COLLATE chinese_prc_ Ci_as null,[tf_fieldrelation] [nvarchar] (COLLATE chinese_prc_ci_as null,[tf_newneedselected] [bit] NULL,[Tf_shownavigatortree] [Bit] Null,[tf_dbfieldname] [nvarchar] (COLLATE chinese_prc_ci_as null,[tf_dbformula] [nvarchar] (max) COLLATE Chinese_ Prc_ci_as null,[tf_divisor] [nvarchar] (a) COLLATE chinese_prc_ci_as null,[tf_denominator] [nvarchar] (COLLATE) Chinese_prc_ci_as null,[tf_allownew] [bit] null,[tf_allowedit] [bit] null,[tf_allowinsertexcel] [bit] NULL,[tf_ Alloweditexcel] [bit] null,[tf_haveattachment] [bit] null,[tf_ischartcategory] [bit] null,[tf_ischartnumeric] [bit] NULL, CONSTRAINT [pk___modulefield__4d94879b] PRIMARY KEY CLUSTERED ([Tf_fieldid] ASC) with (Ignore_dup_key = OFF) on [PRIM ARY], CONSTRAINT [_modulefield_ix1] UNIQUE nonclustered ([Tf_moduleid] asc,[tf_title] asc,[tf_fieldname] ASC) with ( Ignore_dup_key = OFF) on [PRIMARY]) on [PRIMARY]

module field: Java Bean
Package Com.jfok.server.hibernate.system;import Java.io.serializable;import Javax.persistence.cascadetype;import Javax.persistence.column;import Javax.persistence.entity;import Javax.persistence.fetchtype;import Javax.persistence.id;import Javax.persistence.joincolumn;import Javax.persistence.manytoone;import Javax.persistence.transient;import Org.codehaus.jackson.annotate.jsonignore;import Org.codehaus.jackson.annotate.jsonproperty;import Org.codehaus.jackson.map.annotate.jsonserialize;import Com.jfok.server.common.annotation.fielddefine;import com.jfok.server.common.annotation.tabledefine;/** * Each field of the module * * @author jfok * */@JsonSerialize (include = JsonSerialize.Inclusion.NON_EMPTY) @SuppressWarnings ("Serial") @ Entity@org.hibernate.annotations.entity (DynamicUpdate = True) @TableDefine (group = "System module", id = 9903, title = "Module Field") public class _modulefield implements Serializable, _imodulecontrolinterface {public static final String FieldID = "Tf_fiel Did ";p ublic static final String fieldnAME = "Tf_fieldname";p ublic static final String manytoone = "Manytoone";p ublic static final String onetoone = "Onetoone";p Ublic static final String Onetomany = "Onetomany"; @Id @fielddefine (title = "Field Ordinal", Number = Ten) @Column (nullable = False) pri Vate Integer Tf_fieldid; @JsonIgnore @manytoone (cascade = cascadetype.refresh, fetch = Fetchtype.eager) @JoinColumn (name = "Tf_moduleid", nullable = False) @FieldDefine (title = "Owning Module", number =) Private _module tf_module; @JsonIgnore @fielddef INE (title = "Ordinal", number =) private Integer tf_fieldorder; @FieldDefine (title = "Field description", Number = +, NameField = True) @c Olumn (length = six, nullable = False) private String Tf_title; @FieldDefine (title = "Field name", Number =) @Column (length = number, n Ullable = False) private String tf_fieldname; @FieldDefine (title = "Type", Number = number) @Column (length =, nullable = False) p Rivate String Tf_fieldtype; @JsonProperty ("L") @FieldDefine (title = "Length", Number = $) Private Integer tf_fieldlen;@ Fielddefine (title = "Field Grouping", Number = 75) The association type of the private String tf_fieldgroup;//field, manytoone,onetoone,onetomany@jsonignore@fielddefine (title = "Association type", number @Column (length =) private String tf_fieldrelation; @JsonIgnore @fielddefine (title = "real name of the table field", Remark = "Actual fields in the datasheet", Number = All) @Column (length =) private String tf_dbfieldname; @JsonIgnore @fielddefine (title = "Field Formula", Remark = "The specific contents of the Formula field ", number = two) private String Tf_dbformula; @JsonIgnore @fielddefine (title =" percent molecule ", number =, remark =" If this field is a ratio Values, set the numerator field and the denominator field, can also draw the correct ratio at the time of Summarization ") @Column (length =) private String tf_divisor; @JsonIgnore @fielddefine (title =" percent Denominator ", Number = 106) @Column (length =.) Private String Tf_denominator; @FieldDefine (title =" Default "," # = ") @Column (length =) Private String tf_defaultvalue;//@ManyToOne (cascade = cascadetype.refresh, fetch = Fetchtype.eager)//@JoinColumn ( Name = "Tf_propertytypeid")//@FieldDefine (title = "Field List attribute", Number = +)//private _propertytype Tf_propertytype; @Field Define (title = "Disabled", Number = Priva)Te boolean tf_isdisable; @FieldDefine (title = "Hidden", Number = $) Private Boolean Tf_ishidden; @JsonIgnore (FALSE) @ Fielddefine (title = "Required", Number = max) private Boolean tf_isrequired; @FieldDefine (title = "can be added", number = +) Private Bool Ean Tf_allownew; @FieldDefine (title = "Modifiable", Number = Tf_allowedit) Private Boolean, @JsonIgnore @fielddefine (title = " Navigable ", remark =" checked to display in navigation tree, Number = tf_shownavigatortree) private Boolean; @FieldDefine (title = "Ungrouped", Number = 190) Private Boolean Tf_allowgroup; Whether to allow grouping @fielddefine (title = "Subtotal", Number = $) Private Boolean tf_allowsummary; Whether it is possible to subtotal and total @fielddefine (title = "New Check", Remark = "Whether the value of this field must be selected in the navigation tree when a new record is added", number =) Private Boolean Tf_newneedsel ected; @FieldDefine (title = "Field Attachment", Remark = "Can increase attachments for this field", Number = 212) Private Boolean tf_haveattachment;@ Jsonignore@fielddefine (title = "Custom", Number = +) private Boolean tf_isuserdefine; @FieldDefine (title = "Other Settings", Number = 2 ) Private String tf_othersetting; @JsonIgnore @fielddefine (titlE = "Excel import", remark = "Add this field when Excel import is added", number = +) private Boolean tf_allowinsertexcel; @JsonIgnore @fielddefine ( title = "Excel Modified", Remark = "Excel modified and then imported when this field can be updated", Number = +) private Boolean tf_alloweditexcel; @FieldDefine (title = "Chart Item ", Remark =" This field can be used as an item in the chart analysis ", Number = 260) private Boolean tf_ischartcategory; @FieldDefine (title =" Chart Data ", Remark =" This The field can be used as a data in the chart analysis ", number = +) private Boolean tf_ischartnumeric; @FieldDefine (title =" Remark ", Number = +) Private String t f_remark;//if it is a manytoone field, then the field that displays the actual ID _@transientprivate String manytoone_idname;//If it is a manytoone field, Then the field that displays the actual title _@transientprivate String manytoone_titlename;public _modulefield () {}//getter and Setter}

In the Java class above, a number of properties are set for the module field, which can be added and processed according to the expansion of the software. In this example, I can only talk about some of the simplest properties of the application.
Set up the Module List Scheme table, List Scheme grouping table and List Scheme Group Field table.
CREATE TABLE [dbo]. [_modulegridscheme] ([Tf_gridschemeid] [int] not null,[tf_moduleid] [nvarchar] (Ten) COLLATE chinese_prc_ci_as not null,[tf_schemeorder] [int ] not null,[tf_schemename] [nvarchar] (a) COLLATE chinese_prc_ci_as not null,[tf_issystemscheme] [bit] null,[tf_ Isalloweditingrid] [bit] null,[tf_autoshowfiltereditor] [bit] null,[tf_dblclickaction] [nvarchar] (a) COLLATE Chinese _prc_ci_as null,[tf_defaultsort] [nvarchar] (a) COLLATE chinese_prc_ci_as null,[tf_othersetting] [nvarchar] (max) COLLATE chinese_prc_ci_as NULL, CONSTRAINT [pk___modulegridschem__33d4b598] PRIMARY KEY CLUSTERED ([Tf_gridschemeid] ASC) with (Ignore_dup_key = OFF) on [PRIMARY], CONSTRAINT [_modulegridscheme_ix1] UNIQUE nonclustered ([Tf_moduleid] asc,[ Tf_schemeorder] ASC) with (Ignore_dup_key = OFF) on [PRIMARY]) on [Primary]goalter TABLE [dbo].  [_modulegridscheme] With CHECK ADD CONSTRAINT [_MODULEGRIDSCHEME_FK1] FOREIGN KEY ([Tf_moduleid]) REFERENCES [dbo]. [_module] ([Tf_moduleid]) On UPDATE Cascadeon DELETE CASCADE 

CREATE TABLE [dbo]. [_modulegridschemegroup] ([tf_gridgroupid] [int] not Null,[tf_gridschemeid] [int.] NOT Null,[tf_gridgrouporder] [int.] not Null,[tf_gridgroupname] [nvarchar] (COLLATE chinese_prc_ci_as not Null,[tf_isshowheaderspans] [bit] null,[tf_islocked] [bit] null,[tf_othersetting] [ NVARCHAR] (max) COLLATE chinese_prc_ci_as NULL, CONSTRAINT [pk___modulegridschem__534d60f1] PRIMARY KEY CLUSTERED ([tf_ Gridgroupid] ASC) with (Ignore_dup_key = OFF) on [PRIMARY]) on [Primary]goalter TABLE [dbo]. [_modulegridschemegroup]  With CHECK ADD  CONSTRAINT [_MODULEGRIDSCHEMEGROUP_FK1] FOREIGN KEY ([Tf_gridschemeid]) REFERENCES [dbo].[ _modulegridscheme] ([Tf_gridschemeid]) on UPDATE cascadeon DELETE CASCADE

CREATE TABLE [dbo]. [_modulegridschemegroupfield] ([tf_gridfieldid] [int] not NULL,[TF_GRIDGROUPID] [int.] NOT Null,[tf_gridfieldorder] [int.] not NULL,[TF_FIELDID] [int] NO T null,[tf_columnwidth] [int] null,[tf_islocked] [bit] null,[tf_isallowtotal] [bit] null,[tf_isallowsort] [bit] NULL,[ Tf_ishidden] [bit] null,[tf_notexportexcel] [bit] null,[tf_additiontype] [nvarchar] (a) COLLATE chinese_prc_ci_as NULL , [tf_othersetting] [nvarchar] (max) COLLATE chinese_prc_ci_as NULL, CONSTRAINT [pk___modulegridschem__72c60c4a] PRIMARY KEY CLUSTERED ([Tf_gridfieldid] ASC) with (Ignore_dup_key = OFF) on [PRIMARY], CONSTRAINT [_MODULEGRIDSCHEMEGROUPF IELD_IX1] UNIQUE nonclustered ([Tf_gridgroupid] asc,[tf_fieldid] ASC) with (Ignore_dup_key = OFF) on [PRIMARY]) on [PRIMARY ]goalter TABLE [dbo].  [_modulegridschemegroupfield] With CHECK ADD CONSTRAINT [_MODULEGRIDSCHEMEGROUPFIELD_FK1] FOREIGN KEY ([tf_gridgroupid]) REFERENCES [dbo]. [_modulegridschemegroup] ([Tf_gridgroupid]) On DELETE cascadegoalter TABLE [dbo]. [_Modulegridschemegroupfield] with CHECK ADD CONSTRAINT [Fk__modulegridschemegroupfield__modulefield] FOREIGN KEY ([tf_ FieldID]) REFERENCES [dbo]. [_modulefield] ([Tf_fieldid]) On UPDATE Cascadeon DELETE CASCADE

The Java beans corresponding to the three tables are as follows:
Package Com.jfok.server.hibernate.system;import Java.io.serializable;import Java.util.list;import Javax.persistence.cascadetype;import Javax.persistence.column;import Javax.persistence.entity;import Javax.persistence.fetchtype;import Javax.persistence.generatedvalue;import Javax.persistence.id;import Javax.persistence.joincolumn;import Javax.persistence.manytoone;import Javax.persistence.onetomany;import Javax.persistence.orderby;import Org.codehaus.jackson.annotate.jsonignore;import Org.hibernate.annotations.genericgenerator;import Com.jfok.server.common.annotation.fielddefine;import com.jfok.server.common.annotation.tabledefine;/** * Module list scheme, a module can have multiple list schemes, can display different fields, have different properties * * @author Jfok * */@ Suppresswarnings ("Serial") @Entity @org.hibernate.annotations.entity (dynamicupdate = True) @TableDefine (group = "System module ", id = 9904, title =" Module List scheme ", ShortName =" list Scheme ") public class _modulegridscheme implements _imodulecontrolinterface, Ser ializable {@Id @generatedvalue (generator = "increment") @GeNericgenerator (name = "Increment", strategy = "increment") @FieldDefine (title = "id", Number = ten, Hidden = true) Private I Nteger Tf_gridschemeid; @JsonIgnore @manytoone (cascade = cascadetype.refresh, fetch = Fetchtype.lazy) @JoinColumn (name = "Tf_moduleid", nullable = False) @FieldDefine (title = "Module", number =) Private _module tf_module; @FieldDefine (title = "Sequential ", number =) @Column (nullable = False) private Integer Tf_schemeorder; @FieldDefine (title =" scheme name ", NameField = True, numb ER = nullable) @Column (length =, = False) private String tf_schemename; @FieldDefine (title = "System Scheme", Number =) privat e boolean tf_issystemscheme; @FieldDefine (title = "Editable", Number = number) private Boolean Tf_isalloweditingrid; @FieldDefine ( title = "Double-click operation", Number = $) private string tf_dblclickaction; @FieldDefine (title = "sort Field", Number = +) private string Tf_de Faultsort; The default sort field, such as null, is the default sort for the database @fielddefine (title = "Additional Settings", Number = +) private String tf_othersetting; @OneToMany ( Targetentity = _modulegridschemegroUp.class, fetch = fetchtype.lazy, cascade = Cascadetype.all) @JoinColumn (name = "Tf_gridschemeid") @OrderBy ("Tf_ Gridgrouporder ") Private list<_modulegridschemegroup> modulegridschemegroups;public _ModuleGridScheme () {}// Setter and Getter}

Package Com.jfok.server.hibernate.system;import Java.io.serializable;import Java.util.list;import Javax.persistence.cascadetype;import Javax.persistence.column;import Javax.persistence.entity;import Javax.persistence.fetchtype;import Javax.persistence.generatedvalue;import Javax.persistence.id;import Javax.persistence.joincolumn;import Javax.persistence.manytoone;import Javax.persistence.onetomany;import Javax.persistence.orderby;import Org.codehaus.jackson.annotate.jsonignore;import Org.hibernate.annotations.genericgenerator;import Com.jfok.server.common.annotation.fielddefine;import com.jfok.server.common.annotation.tabledefine;/** * Show field groupings in each module list scheme * * @author jfok * */@SuppressWarnings ("Serial") @Entity @org.hibernate.annotations.entity (dynamicupdate = True) @TableDefine (group = "System module", id = 9905, title = "Module list field grouping" , shortname = "list field grouping") public class _modulegridschemegroup implements _imodulecontrolinterface, Serializable {public Static final String gridgroupid = "Tf_gridgroupid";@Id @generatedvalue (generator = "increment") @GenericGenerator (name = "Increment", strategy = "increment") @FieldDefine ( title = "id", Number = ten, Hidden = true) private Integer tf_gridgroupid; @JsonIgnore @manytoone (cascade = Cascadetype.refre SH, fetch = Fetchtype.lazy) @JoinColumn (name = "Tf_gridschemeid", nullable = False) @FieldDefine (title = "Module List Scheme", Number = () private _modulegridscheme tf_modulegridscheme; @FieldDefine (title = "Order Number", # =) @Column (nullable = False)  Private Integer Tf_gridgrouporder; @FieldDefine (title = "Group name", NameField = true, Number = +) @Column (length =, nullable = False) private String tf_gridgroupname; @FieldDefine (title = "Table Header grouping", number =) Private Boolean tf_isshowheaderspans;@f Ielddefine (title = "Lock", Number = number) private Boolean tf_islocked; @FieldDefine (title = "Other Settings", Number = +) Private String t f_othersetting; @OneToMany (targetentity = _modulegridschemegroupfield.class, fetch = fetchtype.lazy, cascade = Cascadetype.all) @JoinColumn (name = "Tf_gridgroupid") @OrderBy (" Tf_gridfieldorder ") private list<_modulegridschemegroupfield> modulegridschemegroupfields; Public _modulegridschemegroup () {}//setter and Getter}

Package Com.jfok.server.hibernate.system;import Java.io.serializable;import Javax.persistence.cascadetype;import Javax.persistence.column;import Javax.persistence.entity;import Javax.persistence.fetchtype;import Javax.persistence.generatedvalue;import Javax.persistence.id;import Javax.persistence.joincolumn;import Javax.persistence.manytoone;import Org.codehaus.jackson.annotate.jsonignore;import Org.codehaus.jackson.map.annotate.jsonserialize;import Org.hibernate.annotations.genericgenerator;import Com.jfok.server.common.annotation.fielddefine;import com.jfok.server.common.annotation.tabledefine;/** * Each module list field groups The fields shown below * * @author jfok * */@JsonSerialize (Include=jsonserialize.inclusion.non_empty) @SuppressWarnings (" Serial ") @Entity @org.hibernate.annotations.entity (dynamicupdate = True) @TableDefine (group =" System module ", id = 9906, title =" Module List Field ", ShortName =" list field ") public class _modulegridschemegroupfield implements _imodulecontrolinterface, Serializable {@Id @generatedvalue (generator = "INcrement ") @GenericGenerator (name =" Increment ", strategy =" increment ") @FieldDefine (title =" ID Number ", hidden = true, Number = ) Private Integer Tf_gridfieldid; @JsonIgnore @manytoone (cascade = cascadetype.refresh, fetch = Fetchtype.eager) @ Joincolumn (name = "Tf_gridgroupid", nullable = False) @FieldDefine (title = "Module list field grouping", number =) Private _modulegridsche Megroup Tf_modulegridschemegroup; @JsonIgnore @fielddefine (title = "Ordinal", Number =) @Column (nullable = False) private Integer Tf_gridfieldorder; @JsonIgnore @manytoone (cascade = cascadetype.refresh, fetch = Fetchtype.eager) @JoinColumn ( Name = "Tf_fieldid", nullable = False) @FieldDefine (title = "Module Field", NameField = true, Number = +) Private _modulefield tf_m Odulefield; @Column (insertable = false, updatable = false) private Integer Tf_fieldid; @FieldDefine (title = "Column width", number = 5 0) Private Integer tf_columnwidth; @FieldDefine (title = "Locked Column", number = number) private Boolean tf_islocked; @FieldDefine (title = "Additional Type", Number = All) Private String tf_additionType; @FieldDefine (title = "Additional Settings", Number = +) private String tf_othersetting; @FieldDefine (title = "Hidden column", number = Priva) Te boolean tf_ishidden; @JsonIgnore @fielddefine (title = "Excel does not export", number = +) private Boolean tf_notexportexcel; Public _modulegridschemegroupfield () {}//getter and setter}






Learn Extjs5 with me. (33--design of individual modules [1 build tables and beans])

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.