📄 viewobjectsdaoimpl.java
字号:
DBRealmManager.getSql("insert_form_settings")); try { sqlWrapper.getLongParser().setValue(insertFormSettings, 1, viewObject.getId()); sqlWrapper.getStringParser().setValue(insertFormSettings, 2, form.getEntity()); sqlWrapper.getIntParser().setValue(insertFormSettings, 3, form.getGrid() ? 1:0); sqlWrapper.getIntParser().setValue(insertFormSettings, 4, form.getDefaultactions() ? 1:0); sqlWrapper.getIntParser().setValue(insertFormSettings, 5, form.getLabelsOrientation().getType()); sqlWrapper.getIntParser().setValue(insertFormSettings, 6, form.getMyqueweb() ? 1 : 0); sqlWrapper.getIntParser().setValue(insertFormSettings, 7, form.getAutosearch() ? 1 : 0); sqlWrapper.executeUpdate(insertFormSettings); } finally { insertFormSettings.close(); } } private void updateFormSettings(Form form, ViewObject viewObject, Connection con) throws SQLException { PreparedStatement deleteFormSettings = sqlWrapper.doPreparedStatement(con, DBRealmManager.getSql("delete_form_settings")); try { sqlWrapper.getLongParser().setValue(deleteFormSettings, 1, viewObject.getId()); sqlWrapper.executeUpdate(deleteFormSettings); } finally { deleteFormSettings.close(); } insertFormSettings(viewObject, form, con); } private void insertLinkedDatasets(Form form, Connection con) throws SQLException { // .. insert linked datasets for current form in cycle. PreparedStatement ps = sqlWrapper.doPreparedStatement(con, DBRealmManager.getSql("insert_linked_datasource")); try { for(int k = 0; k < form.getLinkedDatasetCount(); k++) { LinkedDataset linkedds = form.getLinkedDataset(k); sqlWrapper.getStringParser().setValue(ps, 1, form.getName()); sqlWrapper.getStringParser().setValue(ps, 2, linkedds.getForm()); sqlWrapper.getStringParser().setValue(ps, 3, linkedds.getName()); sqlWrapper.executeUpdate(ps); } } finally { ps.close(); } } private void insertExternalFields(Form form, Connection con) throws SQLException { // .. insert external fields for current form in cycle. PreparedStatement ps = sqlWrapper.doPreparedStatement(con, DBRealmManager.getSql("insert_external_field")); try { for(int k = 0; k < form.getExternalFieldCount(); k++) { ExternalField extfield = form.getExternalField(k); sqlWrapper.getStringParser().setValue(ps, 1, form.getName()); sqlWrapper.getStringParser().setValue(ps, 2, extfield.getForm()); sqlWrapper.getStringParser().setValue(ps, 3, extfield.getName()); sqlWrapper.getStringParser().setValue(ps, 4, extfield.getSourceField()); sqlWrapper.executeUpdate(ps); } } finally { ps.close(); } } private void insertExternalForms(Form form, Connection con) throws SQLException { // .. insert external forms for current form in cycle. PreparedStatement ps = sqlWrapper.doPreparedStatement(con, DBRealmManager.getSql("insert_external_form")); try { for(int k = 0; k < form.getExternalFormCount(); k++) { ExternalForm extform = form.getExternalForm(k); sqlWrapper.getStringParser().setValue(ps, 1, form.getName()); sqlWrapper.getStringParser().setValue(ps, 2, extform.getName()); sqlWrapper.executeUpdate(ps); } } finally { ps.close(); } } private void insertExternalSets(Form form, Connection con) throws SQLException { // .. insert external sets for current form in cycle. PreparedStatement ps = sqlWrapper.doPreparedStatement(con, DBRealmManager.getSql("insert_external_set")); try { for(int k = 0; k < form.getExternalSetCount(); k++) { ExternalSet extset = form.getExternalSet(k); sqlWrapper.getStringParser().setValue(ps, 1, form.getName()); sqlWrapper.getStringParser().setValue(ps, 2, extset.getName()); sqlWrapper.executeUpdate(ps); } } finally { ps.close(); } } private PermissionObjectType getPermission(int type) { PermissionObjectType ret = PermissionObjectType.FOCUS; if(type == SUBFOCUS_TYPE) { ret = PermissionObjectType.SUB_FOCUS; } else if(type == TAB_TYPE) { ret = PermissionObjectType.TAB; } else if(type == FORM_TYPE) { ret = PermissionObjectType.FORM; } else if(type == FIELD_TYPE) { ret = PermissionObjectType.FIELD; } return ret; } private void saveButtons(Connection con, Form form) throws SQLException { Button[] buttons = EntityHelper.FormHelper.getFormButtons(form); if(buttons.length != 0) { PreparedStatement psButton = sqlWrapper.doPreparedStatement(con, DBRealmManager.getSql("insert_button")); try { for(Button button : buttons) { sqlWrapper.getStringParser().setValue(psButton, 1, form.getName()); sqlWrapper.getStringParser().setValue(psButton, 2, button.getName()); sqlWrapper.getIntParser().setValue(psButton, 3, button.getOrder()); if (button.getPermission() != null) { sqlWrapper.getIntParser().setValue(psButton, 4, button.getPermission().getType()); } else { sqlWrapper.getIntParser().setValue(psButton, 4, AccessLevel.READ.level); } sqlWrapper.executeUpdate(psButton); } } finally { psButton.close(); } } } private void saveHtmlElements(Connection con, Form form) throws SQLException { Htmlelements htmlElements = form.getHtmlelements(); if(htmlElements == null) return; Htmlelement[] elements = htmlElements.getHtmlelement(); if(elements.length != 0) { PreparedStatement psButton = sqlWrapper.doPreparedStatement(con, DBRealmManager.getSql("insert_html_element")); try { for(Htmlelement element : elements) { sqlWrapper.getStringParser().setValue(psButton, 1, form.getName()); sqlWrapper.getStringParser().setValue(psButton, 2, element.getName()); sqlWrapper.getIntParser().setValue(psButton, 3, element.getOrder()); sqlWrapper.executeUpdate(psButton); } } finally { psButton.close(); } } } private void saveLayout(Connection con, Form form) throws SQLException { Header[] headers = EntityHelper.FormHelper.getLayoutHeaders(form); if(headers.length != 0) { //save headers PreparedStatement psHeader = sqlWrapper.doPreparedStatement(con, DBRealmManager.getSql("insert_header")); try { for(int i = 0; i < headers.length; i++) { Header header = headers[i]; sqlWrapper.getStringParser().setValue(psHeader, 1, form.getName()); sqlWrapper.getIntParser().setValue(psHeader, 2, i); sqlWrapper.getIntParser().setValue(psHeader, 3, header.getClientwidth()); sqlWrapper.executeUpdate(psHeader); } } finally { psHeader.close(); } } Row[] rows = EntityHelper.FormHelper.getLayoutRows(form); if(rows.length != 0) { //save rows PreparedStatement psRow = sqlWrapper.doPreparedStatement(con, DBRealmManager.getSql("insert_row")); PreparedStatement psCol = sqlWrapper.doPreparedStatement(con, DBRealmManager.getSql("insert_col")); try { for(int rowOrder = 0; rowOrder < rows.length; rowOrder++) { Row row = rows[rowOrder]; sqlWrapper.getStringParser().setValue(psRow, 1, form.getName()); sqlWrapper.getIntParser().setValue(psRow, 2, rowOrder); sqlWrapper.executeUpdate(psRow); Col[] cols = row.getCol(); for(int colOrder = 0; colOrder < cols.length; colOrder++) { Col col = cols[colOrder]; sqlWrapper.getStringParser().setValue(psCol, 1, form.getName()); sqlWrapper.getIntParser().setValue(psCol, 2, rowOrder); sqlWrapper.getIntParser().setValue(psCol, 3, colOrder); sqlWrapper.getStringParser().setValue(psCol, 4, col.getFieldid()); sqlWrapper.getIntParser().setValue(psCol, 5, col.getRowspan()); sqlWrapper.getIntParser().setValue(psCol, 6, col.getColspan()); sqlWrapper.executeUpdate(psCol); } } } finally { psRow.close(); } } HiddenControl[] hiddenControls = EntityHelper.FormHelper.getHiddenControls(form); if(hiddenControls.length != 0) { PreparedStatement ps = sqlWrapper.doPreparedStatement(con, DBRealmManager.getSql("insert_hiddencontrol")); try { for(HiddenControl hiddenControl : hiddenControls) { sqlWrapper.getStringParser().setValue(ps, 1, form.getName()); sqlWrapper.getStringParser().setValue(ps, 2, hiddenControl.getFieldid()); sqlWrapper.executeUpdate(ps); } } finally { ps.close(); } } } /* * No javadoc * @see FocusConfigDAO#loadFocusVO */ public Focus loadFocusVO(String focusName) { Connection con = null; PreparedStatement ps = null; Focus focus = new Focus(); try { con = sqlWrapper.doConnection(); // Load focus. ps = sqlWrapper.doPreparedStatement(con, DBRealmManager.getSql("select_focus")); ps.setString(1, focusName); ResultSet rs = sqlWrapper.executeQuery(ps); if(rs.next()) { focus.setName(focusName); focus.setOrder(sqlWrapper.getIntParser().getValue(rs, 1)); focus.setIcon(sqlWrapper.getStringParser().getValue(rs, 2)); ps.close(); // Fill out focus. fillFocusVO(focus, con); } } catch (SQLException ex) { throw new GenericSystemException("SQL exception: " + ex.getMessage(), ex); } finally { sqlWrapper.closeConnection(con, ps); } return focus; } /* * No javadoc * @see FocusConfigDAO#loadAllFocusVO */ public Collection<Focus> loadAllFocusVO() { Connection con = null; PreparedStatement ps = null; Collection<Focus> focusList = new ArrayList<Focus>(); try { con = sqlWrapper.doConnection(); // Load focuses. ps = sqlWrapper.doPreparedStatement(con, DBRealmManager.getSql("select_all_focuses")); ResultSet rs = sqlWrapper.executeQuery(ps); while(rs.next()) { Focus focus = new Focus(); focus.setName(sqlWrapper.getStringParser().getValue(rs, 1)); focus.setOrder(sqlWrapper.getIntParser().getValue(rs, 2)); focus.setIcon(sqlWrapper.getStringParser().getValue(rs, 3)); focusList.add(focus); } ps.close(); // Fill out focuses. for(Focus focus : focusList) { fillFocusVO(focus, con); } } catch (SQLException ex) { throw new GenericSystemException("SQL exception: " + ex.getMessage(), ex); } finally { sqlWrapper.closeConnection(con, ps); } return focusList; } private void fillFocusVO(Focus focus, Connection con) throws SQLException { loadSubFocuses(con, focus); for(int i = 0; i < focus.getSubFocusCount(); i++) { SubFocus subFocus = focus.getSubFocus(i); loadTabs(con, subFocus); for(int j = 0; j < subFocus.getTabCount(); j++) { Tab tab = subFocus.getTab(j); loadForms(con, tab); for(int k = 0; k < tab.getFormCount(); k++) { Form form = tab.getForm(k); loadExternalSets(con, form); loadExternalForms(con, form); loadExternalFields(con, form); loadInternalFields(con, form); loadLinkedDatasets(con, form); } } } } private void loadSubFocuses(Connection con, Focus focus) throws SQLException { String focusName = focus.getName(); PreparedStatement ps = sqlWrapper.doPreparedStatement(con, DBRealmManager.getSql("select_all_subfocus")); ps.setString(1, focusName); ResultSet rs = sqlWrapper.executeQuery(ps); while(rs.next()) { SubFocus subFocus = new SubFocus(); subFocus.setFocus(focusName); subFocus.setName(sqlWrapper.getStringParser().getValue(rs, 1)); subFocus.setOrder(sqlWrapper.getIntParser().getValue(rs, 2)); subFocus.setIcon(sqlWrapper.getStringParser().getValue(rs, 3)); focus.addSubFocus(subFocus);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -