Learn extjs5 with me (33 -- Design of a single module [1 create a table and bean])

Source: Internet
Author: User
Tags field table

Learn extjs5 with me (33 -- Design of a single module [1 create a table and bean])
Learn extjs5 with me (33 -- Design of a single module [1 create a table and bean])
Now the first core part of the system is how to design the functions of the module. The simplest module includes module attributes, field attributes, list definitions, and form definitions.
In the preceding definition, a module can contain n fields and several list schemes and form schemes. Each list and form can contain several groups, each group contains several fields. This design also conforms to the features designed in the first 20 sections of this tutorial. What we need to do now is to make these functions interactive between the front and back. First, define the module fields and list scheme. The definitions of the above solutions are also stored in the database. Therefore, you must first create tables and java Beans. Create the module field table _ ModuleField.

CREATE TABLE [dbo].[_ModuleField]([tf_fieldId] [int] NOT NULL,[tf_moduleId] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL,[tf_fieldOrder] [int] NULL,[tf_title] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,[tf_fieldName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,[tf_fieldType] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,[tf_fieldGroup] [nvarchar](50) 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](50) COLLATE Chinese_PRC_CI_AS NULL,[tf_remark] [nvarchar](max) COLLATE Chinese_PRC_CI_AS NULL,[tf_fieldRelation] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,[tf_newNeedSelected] [bit] NULL,[tf_showNavigatorTree] [bit] NULL,[tf_DBFieldName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,[tf_DBformula] [nvarchar](max) COLLATE Chinese_PRC_CI_AS NULL,[tf_divisor] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,[tf_denominator] [nvarchar](50) 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 [PRIMARY], 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;/*** fields of each module ** @ author jfok **/@ JsonSerialize (include = JsonSerialize. permission Sion. 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, _ optional {public static final String FIELDID = "tf_fieldId"; public static final String FIELDNAME = "tf_fieldName"; public static final String MANYTOONE = "ManyToOne "; public static final String ONETOONE = "OneToOne"; public static final String ONETOMANY = "OneToMany"; @ Id @ FieldDefine (title = "field no.", number = 10) @ Column (nullable = false) private Integer tf_fieldId; @ JsonIgnore @ ManyToOne (cascade = CascadeType. REFRESH, fetch = FetchType. EAGER) @ JoinColumn (name = "tf_moduleId", nullable = false) @ FieldDefine (title = "Module", number = 20) private _ Module tf_Module; @ JsonIgnore @ FieldDefine (title = "Sn", number = 30) private Integer tf_fieldOrder; @ FieldDefine (title = "field description", number = 40, nameField = true) @ Column (length = 50, nullable = false) private String tf_title; @ FieldDefine (title = "field name", number = 50) @ Column (length = 50, nullable = false) private String tf_fieldName; @ FieldDefine (title = "type", number = 60) @ Column (length = 50, nullable = false) private String tf_fieldType; @ JsonProperty ("l ") @ FieldDefine (title = "length", number = 70) private Integer tf_fieldLen; @ FieldDefine (title = "field group", number = 75) private String tf_fieldGroup; // association type of fields, ManyToOne, OneToOne, oneto133 @ JsonIgnore @ FieldDefine (title = "association type", number = 80) @ Column (length = 20) private String tf_fieldRelation; @ JsonIgnore @ FieldDefine (title = "Table field real name", remark = "actual field name in the data table", number = 90) @ Column (length = 50) private String tf_DBfieldName; @ JsonIgnore @ FieldDefine (title = "field formula", remark = "content of the formula field", number = 100) private String tf_DBformula; @ JsonIgnore @ FieldDefine (title = "percentage Numerator", number = 105, remark = "if this field is the ratio of two fields, set the numerator field and denominator field, the correct ratio can also be obtained during the summary ") @ Column (length = 50) private String tf_divisor; @ JsonIgnore @ FieldDefine (title =" percentage Denominator ", number = 106) @ Column (length = 50) private String tf_denominator; @ FieldDefine (title = "Default Value", number = 110) @ Column (length = 50) private String tf_defaultValue; // @ ManyToOne (cascade = CascadeType. REFRESH, fetch = FetchType. EAGER) // @ JoinColumn (name = "tf_propertyTypeId") // @ FieldDefine (title = "Field List attribute", number = 120) // private _ PropertyType tf_PropertyType; @ FieldDefine (title = "disabled", number = 130) private Boolean tf_isDisable; @ FieldDefine (title = "hidden", number = 140) private Boolean tf_isHidden; @ JsonIgnore (false) @ FieldDefine (title = "required", number = 150) private Boolean tf_isRequired; @ FieldDefine (title = "available", number = 160) private Boolean tf_allowNew; @ FieldDefine (title = "modifiable", number = 170) private Boolean tf_allowEdit; @ JsonIgnore @ FieldDefine (title = "navigable ", remark = "selected to display in the navigation tree", number = 180) private Boolean tf_showNavigatorTree; @ FieldDefine (title = "grouped", number = 190) private Boolean tf_allowGroup; // whether to allow grouping @ FieldDefine (title = "subtotal", number = 200) private Boolean tf_allowSummary; // whether subtotal and total @ FieldDefine (title = "add selected ", remark = "when adding a record, do you have to select the value of this field in the navigation tree", number = 210) private Boolean tf_newNeedSelected; @ FieldDefine (title = "field attachment ", remark = "attachments to this field can be added", number = 212) private Boolean tf_haveAttachment; @ JsonIgnore @ FieldDefine (title = "Custom", number = 220) private Boolean tf_isUserDefine; @ FieldDefine (title = "other settings", number = 230) private String tf_otherSetting; @ JsonIgnore @ FieldDefine (title = "Excel import ", remark = "this field can be added when Excel is added", number = 240) private Boolean tf_allowInsertExcel; @ JsonIgnore @ FieldDefine (title = "Excel modification ", remark = "this field can be updated after Excel is modified and then imported", number = 250) private Boolean tf_allowEditExcel; @ FieldDefine (title = "chart Project ", remark = "this field can be used as a project in chart analysis", number = 260) private Boolean tf_isChartCategory; @ FieldDefine (title = "chart data ", remark = "this field can be used as a data in chart analysis", number = 270) private Boolean tf_isChartNumeric; @ FieldDefine (title = "Remarks", number = 800) private String tf_remark; // if it is a manytoone field, the actual ID field _ @ Transientprivate String manytoone_IdName is displayed; // if it is a manytoone field, the actual title field _ @ Transientprivate String manytoone_TitleName; public _ ModuleField () {}// getter and setter} is displayed}

In the above java class, many attributes are set for the module field to be defined. This can be added and processed by the software extension. In this example, I can only talk about some of the simplest attributes of the application.
Create a module list scheme table, a list scheme grouping table, and a list scheme grouping field table.
CREATE TABLE [dbo].[_ModuleGridScheme]([tf_gridSchemeId] [int] NOT NULL,[tf_moduleId] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL,[tf_schemeOrder] [int] NOT NULL,[tf_schemeName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,[tf_isSystemScheme] [bit] NULL,[tf_isAllowEditInGrid] [bit] NULL,[tf_autoShowFilterEditor] [bit] NULL,[tf_dblClickAction] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,[tf_defaultSort] [nvarchar](50) 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](50) 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] NOT 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](50) 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 [_ModuleGridSchemeGroupField_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. onetovel; 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;/*** list scheme of the module. A module can have multiple list schemes and 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 solution", shortname = "list solution") public class _ ModuleGridScheme implements _ IModuleControlInterface, Serializable {@ Id @ GeneratedValue (generator = "increment ") @ GenericGenerator (name = "increment", strategy = "increment") @ FieldDefine (title = "ID", number = 10, hidden = true) private Integer tf_gridSchemeId; @ JsonIgnore @ ManyToOne (cascade = CascadeType. REFRESH, fetch = FetchType. LAZY) @ JoinColumn (name = "tf_moduleId", nullable = false) @ FieldDefine (title = "Module", number = 20) private _ Module tf_Module; @ FieldDefine (title = "sequence number", number = 30) @ Column (nullable = false) private Integer tf_schemeOrder; @ FieldDefine (title = "solution name", nameField = true, number = 40) @ Column (length = 50, nullable = false) private String tf_schemeName; @ FieldDefine (title = "system solution", number = 50) private Boolean tf_isSystemScheme; @ FieldDefine (title = "editable", number = 60) private Boolean tf_isAllowEditInGrid; @ FieldDefine (title = "double-click operation", number = 70) private String tf_dblClickAction; @ FieldDefine (title = "sorting field", number = 80) private String tf_defaultSort; // default sorting field, if it is null, the database is sorted by default @ FieldDefine (title = "Additional Settings", number = 90) private String tf_otherSetting; @ onetoting (targetEntity = _ ModuleGridSchemeGroup. class, fetch = FetchType. LAZY, cascade = CascadeType. ALL) @ JoinColumn (name = "tf_gridSchemeId") @ OrderBy ("Courier") 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. onetovel; 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;/*** display field groups 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 group", shortname = "list field group") 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 = 10, hidden = true) private Integer tf_gridGroupId; @ JsonIgnore @ ManyToOne (cascade = CascadeType. REFRESH, fetch = FetchType. LAZY) @ JoinColumn (name = "tf_gridSchemeId", nullable = false) @ FieldDefine (title = "", number = 20) private _ ModuleGridScheme tf_ModuleGridScheme; @ FieldDefine (title = "sequence number", number = 30) @ Column (nullable = false) private Integer tf_gridGroupOrder; @ FieldDefine (title = "group name", nameField = true, number = 40) @ Column (length = 50, nullable = false) private String tf_gridGroupName; @ FieldDefine (title = "header group", number = 50) private Boolean tf_isShowHeaderSpans; @ FieldDefine (title = "locked", number = 60) private Boolean tf_isLocked; @ FieldDefine (title = "other settings", number = 90) private String tf_otherSetting; @ OneToMany (targetEntity = _ ModuleGridSchemeGroupField. class, fetch = FetchType. LAZY, cascade = CascadeType. ALL) @ JoinColumn (name = "tf_gridGroupId") @ OrderBy ("tf_gridFieldOrder") private List <_ blank> tables; 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;/*** fields displayed under each module list field group ** @ author jfok **/@ JsonSerialize (include = JsonSerialize. permission Sion. 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", hidden = true, number = 10) private Integer tf_gridFieldId; @ JsonIgnore @ ManyToOne (cascade = CascadeType. REFRESH, fetch = FetchType. EAGER) @ JoinColumn (name = "tf_gridGroupId", nullable = false) @ FieldDefine (title = "module list field group", number = 20) private _ ModuleGridSchemeGroup tf_ModuleGridSchemeGroup; @ JsonIgnore @ FieldDefine (title = "Sn", number = 30) @ 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 = 40) private _ ModuleField tf_ModuleField; @ Column (insertable = false, updatable = false) private Integer tf_fieldId; @ FieldDefine (title = "Column width", number = 50) private Integer tf_columnWidth; @ FieldDefine (title = "lock column", number = 60) private Boolean tf_isLocked; @ FieldDefine (title = "additional type", number = 70) private String tf_additionType; @ FieldDefine (title = "Additional Settings", number = 80) private String tf_otherSetting; @ FieldDefine (title = "Hidden Column", number = 90) private Boolean tf_ishidden; @ JsonIgnore @ FieldDefine (title = "Excel not exported", number = 100) private Boolean tf_notExportExcel; public _ ModuleGridSchemeGroupField () {}// getter and setter}






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.