diff --git a/pom.xml b/pom.xml index 29d04c3..415a019 100644 --- a/pom.xml +++ b/pom.xml @@ -86,7 +86,7 @@ 4.3 - 3.1.3-SNAPSHOT + 3.2.5 2.7.3 @@ -107,18 +107,18 @@ 4.5.1 - 1.0.3 - 1.0.3 + 1.0.9 + 1.0.9 1.6.4 1.6.4 - 2.3 + 2.4 1.9.2 - 9.1-901.jdbc4 - 5.1.20 -
- * Uses a Swing dialog window to query the user for answers to authentication - * questions. This can be used by a JAAS application to instantiate a - * CallbackHandler + * VascDemoUserLoginDialog used be be true jaas auth module but now only dialog. * - * @see javax.security.auth.callback + * @author Willem Cazander + * @version 1.0 Nov 10, 2012 */ public class VascDemoUserLoginDialog { - private Component parentComponent; private static final int JPasswordFieldLen = 8; private int loginTry = 0; private String connectUrl = null; private String username = null; private String password = null; - /** - * Creates a callback dialog with the default parent window. - */ - public VascDemoUserLoginDialog() { - } - - /** - * Creates a callback dialog and specify the parent window. - * - * @param parentComponent - * the parent window -- specify null for the - * default parent - */ - public VascDemoUserLoginDialog(Component parentComponent) { - this.parentComponent = parentComponent; - } - /** * An interface for recording actions to carry out if the user clicks OK for * the dialog. @@ -105,10 +77,9 @@ public class VascDemoUserLoginDialog { */ public void handle() { this.loginTry++; - /* Collect messages to display in the dialog */ final JPanel loginDesign = new JPanel(); loginDesign.setLayout(new BoxLayout(loginDesign, BoxLayout.PAGE_AXIS)); - //final Image logoImage = Toolkit.getDefaultToolkit().createImage(getClass().getResource("/resources/images/logos/logo.png")); + final Image logoImage = Toolkit.getDefaultToolkit().createImage(getClass().getResource("/net/forwardfire/vasc/demo/client/swing/resources/logo.png")); final JPanel logoPanel = new JPanel() { private static final long serialVersionUID = 10l; protected void paintComponent(Graphics g) { @@ -119,20 +90,14 @@ public class VascDemoUserLoginDialog { // Paint the default look of the panel. super.paintComponent(g2d); - - int offsetX = 0; // for windows systems - boolean isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows") != -1; - if (isWindows) { - offsetX += 25; - } g2d.setColor(Color.BLACK); g2d.fillRect(0,0,getWidth(),getHeight()); g2d.setColor(new Color(238,212,1)); - - //int w = (getWidth()/2)-(logoImage.getWidth(null)/2); - //int h = (getHeight()/2)-(logoImage.getHeight(null)/2); - //g2d.drawImage(logoImage, w, h, this); + + int w = (getWidth()/2)-(logoImage.getWidth(null)/2); + int h = (getHeight()/2)-(logoImage.getHeight(null)/2); + g2d.drawImage(logoImage, w, h, this); } }; logoPanel.setPreferredSize(new Dimension(200, 170)); @@ -146,13 +111,11 @@ public class VascDemoUserLoginDialog { loginDesign.add(namePanel); loginDesign.add(Box.createVerticalStrut(5)); + final List okActions = new ArrayList(2); final GridLayout messagesLayout = new GridLayout(3,2); final JPanel messages = new JPanel(); messages.setLayout(messagesLayout); - /* Collection actions to perform if the user clicks OK */ - final List okActions = new ArrayList(2); - // Add server field JLabel serverName = new JLabel("Server:"); final JTextField serverField = new JTextField(getConnectUrl()); @@ -225,6 +188,7 @@ public class VascDemoUserLoginDialog { /// JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options, Object initialValue) JOptionPane jop = new JOptionPane(loginDesign, JOptionPane.PLAIN_MESSAGE,JOptionPane.OK_CANCEL_OPTION,null,options,name); + JComponent parentComponent = null; JDialog dialog = jop.createDialog(parentComponent,"Vasc Demo Login"); // We alway request focus after the windows gets focus diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/VascDemoSwingClient.properties b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/VascDemoSwingClient.properties index 003c074..28e1472 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/VascDemoSwingClient.properties +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/VascDemoSwingClient.properties @@ -29,4 +29,5 @@ Application.homepage = http://vasc.forwardfire.org/ Application.vendorId = vasc Application.id = vascdemotech Application.lookAndFeel = com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel -#Application.icon = images/icon.png +Application.icon = icon.png + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/icon.png b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/icon.png new file mode 100644 index 0000000..3acf3fc Binary files /dev/null and b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/icon.png differ diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/laf-colors.properties b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/laf-colors.properties new file mode 100644 index 0000000..dc4a3c2 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/laf-colors.properties @@ -0,0 +1,18 @@ + +# +# yellow-purple color schema from pulsefire. +# +text=#FF9900 +info=#9F3B00 +control=#5B084C +nimbusBase=#3A0053 +nimbusDisabledText=#3A0053 +nimbusFocus=#FF6600 +nimbusLightBackground=#47184D +nimbusSelectedText=#47184D +nimbusBlueGrey=#661C7D +nimbusGreen=#D2C122 +nimbusBorder=#A018D8 +nimbusSelectionBackground=#BF6204 +ComboBox.background=#380030 +TabbedPane.background=#380030 diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/logo.png b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/logo.png new file mode 100644 index 0000000..7ca6181 Binary files /dev/null and b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/logo.png differ diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/I18nController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/I18nController.java new file mode 100644 index 0000000..77f4386 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/I18nController.java @@ -0,0 +1,106 @@ +/* + * Copyright 2009-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.demo.tech.web.beans; + +import java.util.Collection; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.Set; + +import javax.faces.context.FacesContext; + +/** + * I18nController wraps to root application bundle to skip jsf cache. + * + * @author Willem Cazander + * @version 1.0 Jan 7, 2013 + */ +public class I18nController implements Map { + + public ResourceBundle getBundle() { + Locale locale = null; + FacesContext context = FacesContext.getCurrentInstance(); + locale = context.getApplication().getDefaultLocale(); + ResourceBundle bundle = ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle", locale); + return bundle; + } + + @Override + public void clear() { + } + + @Override + public boolean containsKey(Object key) { + return getBundle().containsKey((String)key); + } + + @Override + public boolean containsValue(Object value) { + return false; + } + + @Override + public Set> entrySet() { + return null; + } + + @Override + public String get(Object key) { + return getBundle().getString((String)key); + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public Set keySet() { + return getBundle().keySet(); + } + + @Override + public String put(String key, String value) { + return value; + } + + @Override + public void putAll(Map extends String, ? extends String> arg0) { + } + + @Override + public String remove(Object key) { + return (String)key; + } + + @Override + public int size() { + return getBundle().keySet().size(); + } + + @Override + public Collection values() { + return null; + } +} \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/faces-config.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/faces-config.xml index 5c870f8..c61a596 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/faces-config.xml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/faces-config.xml @@ -7,10 +7,12 @@ > + en @@ -20,6 +22,13 @@ + + I18n map bean as workaround for jsf caching. + i18n + net.forwardfire.vasc.demo.tech.web.beans.I18nController + application + + Fixes the context path for root vs non-root deployments. contextPathController diff --git a/vasc-export/vasc-export-jr4o/src/main/java/net/forwardfire/vasc/export/jr4o/JRDynamicDataSourceVascEntry.java b/vasc-export/vasc-export-jr4o/src/main/java/net/forwardfire/vasc/export/jr4o/JRDynamicDataSourceVascEntry.java index b12be28..f996c7e 100644 --- a/vasc-export/vasc-export-jr4o/src/main/java/net/forwardfire/vasc/export/jr4o/JRDynamicDataSourceVascEntry.java +++ b/vasc-export/vasc-export-jr4o/src/main/java/net/forwardfire/vasc/export/jr4o/JRDynamicDataSourceVascEntry.java @@ -30,6 +30,7 @@ import java.util.Map; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascException; +import net.forwardfire.vasc.frontend.VascFrontendDataSelector.EntryFieldSelectType; import net.forwardfire.vasc.lib.jr4o.data.AbstractJRDynamicDataSource; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JRField; @@ -46,6 +47,7 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource { private VascEntry vascEntry = null; + private List fields = null; private long total = -1; private int index = -1; private static final String PREFIX_COLUMN = "COLUMN_"; @@ -61,6 +63,8 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource { this.vascEntry = vascEntry; total = vascEntry.getVascFrontendController().getVascEntryState().getTotalBackendRecords(); + fields = vascEntry.getVascFrontendController().getVascFrontendDataSelector().getFields(EntryFieldSelectType.EXPORT); + // hackje until calc index to page and row. try { data = new ArrayList>(1000); @@ -70,7 +74,7 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource { vascEntry.getVascFrontendController().getVascFrontendActions().refreshData(); for (Object o:vascEntry.getVascFrontendController().getVascEntryState().getEntryDataList()) { List row = new ArrayList(30); - for (VascEntryField c:vascEntry.getVascEntryFields()) { + for (VascEntryField c:fields) { row.add(c.getVascEntryFieldValue().getDisplayValue(c, o)); } data.add(row); @@ -90,10 +94,8 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource { return data.get(index).get(Integer.parseInt(fieldName.substring(7))); } if (fieldName.startsWith(PREFIX_HEADER)) { - return "todo"; // TODO: fixme - //List fields = vascEntry.getVascEntryFields(); - //VascEntryField field = fields.get(Integer.parseInt(fieldName.substring(7))); - //return vascEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(field.getName()); + VascEntryField field = fields.get(Integer.parseInt(fieldName.substring(7))); + return vascEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(field.getName()); } throw new JRException("Unknown column name : " + fieldName); } diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntryEventListener.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntryEventListener.java index 826c08c..d2617d9 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntryEventListener.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntryEventListener.java @@ -51,7 +51,11 @@ public class JSFVascEntryEventListener implements VascEntryFrontendEventListener * @see net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener#getEventTypes() */ public VascFrontendEventType[] getEventTypes() { - VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.POST_READ}; + VascFrontendEventType[] result = { + VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, + VascEntryFrontendEventListener.VascFrontendEventType.POST_DELETE, + VascEntryFrontendEventListener.VascFrontendEventType.POST_UPDATE + }; return result; } diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntrySupportBean.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntrySupportBean.java index 2cc4d61..d63a118 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntrySupportBean.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntrySupportBean.java @@ -87,8 +87,6 @@ public class JSFVascEntrySupportBean implements Serializable { private Boolean backendMoveable = null; private Boolean backendSearchable = null; private Boolean backendPageable = null; - private Boolean sortOrder = null; - private String sortField = null; private VascEntryExport selectedExporter = null; private String selectedExporterAction = "null"; private String selectedDirectPage = "null"; @@ -441,8 +439,6 @@ public class JSFVascEntrySupportBean implements Serializable { VascEntry entry = comp.getVascEntry(); VascEntryField field = entry.getVascEntryFieldById(fieldIdString); entry.getVascFrontendController().getVascFrontendActions().sortAction(field); - sortOrder = entry.getVascFrontendController().getVascEntryState().getVascBackendState().isSortAscending(); - sortField = field.getId(); } public boolean getRenderBackAction() { @@ -855,20 +851,6 @@ public class JSFVascEntrySupportBean implements Serializable { return tablePagesDataModel; } - /** - * @return the sortOrder - */ - public Boolean getSortOrder() { - return sortOrder; - } - - /** - * @return the sortField - */ - public String getSortField() { - return sortField; - } - /** * @return the selectedExporter */ diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascFrontendRenderer.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascFrontendRenderer.java index f1fe2b1..87cdb44 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascFrontendRenderer.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascFrontendRenderer.java @@ -38,8 +38,6 @@ import net.forwardfire.vasc.frontend.web.jsf.ui.JSFList; import net.forwardfire.vasc.frontend.web.jsf.ui.JSFText; import net.forwardfire.vasc.frontend.web.jsf.ui.JSFTextArea; - - /** * Given the jsf vasc renderer its own class * @@ -56,8 +54,6 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser logger = Logger.getLogger(JSFVascFrontendRenderer.class.getName()); } - // Frontend Stuff - /** * @see net.forwardfire.vasc.frontend.VascFrontend#getFrontendType() */ @@ -65,10 +61,9 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser return "jsf"; } - protected void addUiComponents() { VascFrontendController vfd = getVascEntry().getVascFrontendController(); - + // required UI components vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_LABEL,JSFLabel.class.getName()); vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_TEXT, JSFText.class.getName()); @@ -82,7 +77,7 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser //vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_COLOR , JSFColorChooser.class.getName()); } - + /** * @see net.forwardfire.vasc.frontend.VascFrontend#renderDelete(java.lang.Object) */ @@ -92,7 +87,7 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId()); comp.setRenderFacetState("deleteView"); } - + /** * @see net.forwardfire.vasc.frontend.VascFrontend#renderEdit(java.lang.Object) */ @@ -114,7 +109,7 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser comp.getSupportBean().setSelected(selBean); } - + /** * @see net.forwardfire.vasc.frontend.VascFrontend#renderExport(net.forwardfire.vasc.core.entry.VascEntryExport) */ @@ -125,7 +120,7 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser comp.setRenderFacetState("exportView"); comp.getSupportBean().setSelectedExporter(exporter); } - + /** * @see net.forwardfire.vasc.frontend.VascFrontend#renderView() */ @@ -134,10 +129,5 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot(); JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId()); comp.setRenderFacetState("listView"); - - //if (comp.getSupportBean().getSelected()!=null) { - // comp.getSupportBean().getSelected().setRealValue(false); - // comp.getSupportBean().setSelected(null); - //} } -} \ No newline at end of file +} diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponent.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponent.java index f5662ed..83d2624 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponent.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponent.java @@ -26,7 +26,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.Locale; import java.util.logging.Logger; import javax.el.ValueExpression; @@ -57,63 +56,62 @@ import net.forwardfire.vasc.frontend.web.jsf.ui.JSFListModel; */ public class JSFVascUIComponent extends UIComponentBase { - public static final String FAMILY = "vasc.jsf.component.family"; - public static final String ENTRY_SUPPORT_VAR_KEY = "entrySupportVar"; - public static final String TABLE_RECORD_VAR_KEY = "tableRecordVar"; - public static final String INJECT_EDIT_FIELDS_ID = "injectEditFieldsId"; - public static final String INJECT_TABLE_OPTIONS_ID = "injectTableOptionsId"; - public static final String INJECT_TABLE_COLUMNS_ID = "injectTableColumnsId"; - public static final String DISABLE_LINK_COLUMNS = "disableLinkColumns"; - public static final String INJECT_TABLE_OPTIONS_ON_CHANGE = "injectTableOptionOnChange"; - - private JSFVascFrontendRenderer renderer = null; - private JSFVascEntrySupportBean supportBean = null; - private String renderFacetState = null; - private VascEntryLink link = null; - private VascEntryState linkState = null; - private VascEntryState state = null; - private Object stateEditId = null; - private Logger logger = null; - private Boolean initClear = null; - private String injectTableOptionOnChange = null; - - public JSFVascUIComponent() { - logger = Logger.getLogger(JSFVascUIComponent.class.getName()); - } - - public String getFamily() { - return FAMILY; - } + public static final String FAMILY = "vasc.jsf.component.family"; + public static final String ENTRY_SUPPORT_VAR_KEY = "entrySupportVar"; + public static final String TABLE_RECORD_VAR_KEY = "tableRecordVar"; + public static final String INJECT_EDIT_FIELDS_ID = "injectEditFieldsId"; + public static final String INJECT_TABLE_OPTIONS_ID = "injectTableOptionsId"; + public static final String INJECT_TABLE_COLUMNS_ID = "injectTableColumnsId"; + public static final String DISABLE_LINK_COLUMNS = "disableLinkColumns"; + public static final String INJECT_TABLE_OPTIONS_ON_CHANGE = "injectTableOptionOnChange"; + + private JSFVascFrontendRenderer renderer = null; + private JSFVascEntrySupportBean supportBean = null; + private String renderFacetState = null; + private VascEntryLink link = null; + private VascEntryState linkState = null; + private VascEntryState state = null; + private Object stateEditId = null; + private Logger logger = null; + private Boolean initClear = null; + private String injectTableOptionOnChange = null; + + public JSFVascUIComponent() { + logger = Logger.getLogger(JSFVascUIComponent.class.getName()); + } + + public String getFamily() { + return FAMILY; + } + + @Override + public Object saveState(FacesContext facesContext) { + logger.fine("Save State"); + Object values[] = new Object[5]; + values[0] = super.saveState(facesContext); + values[1] = renderer; + values[2] = supportBean; + values[3] = renderFacetState; + values[4] = this.getAttributes().get(INJECT_TABLE_OPTIONS_ON_CHANGE); + return values; + } - @Override - public Object saveState(FacesContext facesContext) { - logger.fine("Save State"); - Object values[] = new Object[5]; - values[0] = super.saveState(facesContext); - values[1] = renderer; - values[2] = supportBean; - values[3] = renderFacetState; - values[4] = this.getAttributes().get(INJECT_TABLE_OPTIONS_ON_CHANGE); - return values; + @Override + public void restoreState(FacesContext facesContext, Object state) { + logger.fine("Resotre State"); + Object values[] = (Object[])state; + super.restoreState(facesContext, values[0]); + renderer = (JSFVascFrontendRenderer) values[1]; + supportBean = (JSFVascEntrySupportBean) values[2]; + renderFacetState = (String) values[3]; + injectTableOptionOnChange = (String) values[4]; - } - - @Override - public void restoreState(FacesContext facesContext, Object state) { - logger.fine("Resotre State"); - Object values[] = (Object[])state; - super.restoreState(facesContext, values[0]); - renderer = (JSFVascFrontendRenderer) values[1]; - supportBean = (JSFVascEntrySupportBean) values[2]; - renderFacetState = (String) values[3]; - injectTableOptionOnChange = (String) values[4]; - - // TODO: check if we can move this some day... + // TODO: check if we can move this some day... String entrySupportVar = (String)getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY); ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+"}", Object.class); ve2.setValue(FacesContext.getCurrentInstance().getELContext(), getSupportBean()); - } - + } + static public JSFVascUIComponent findVascParent(UIComponent comp) { if (comp==null) { return null; @@ -146,7 +144,7 @@ public class JSFVascUIComponent extends UIComponentBase { } return null; } - + /** * Finds component with the given id */ @@ -229,7 +227,7 @@ public class JSFVascUIComponent extends UIComponentBase { // edit action copyed try { - VascEntry entry = supportBean.getVascEntry(); + VascEntry entry = supportBean.getVascEntry(); entry.getVascFrontendController().getVascEntryState().setEditCreate(false); entry.getVascFrontendController().fireVascFrontendEvent(entry, VascFrontendEventType.SELECT, rowObject); entry.getVascFrontendController().getVascEntryState().setEntryDataObject(rowObject); @@ -263,46 +261,44 @@ public class JSFVascUIComponent extends UIComponentBase { super.encodeBegin(context); } - public UIComponent getCurrentView() { - UIComponent result = getFacet(renderFacetState); - if (result==null) { - throw new IllegalArgumentException("Could not get facet: "+renderFacetState); - } - return result; - } - - public JSFVascEntrySupportBean getSupportBean() { - return supportBean; - } - - public void setRenderFacetState(String renderFacetState) { - this.renderFacetState=renderFacetState; - } - - public String getRenderFacetState() { - return renderFacetState; - } - + public UIComponent getCurrentView() { + UIComponent result = getFacet(renderFacetState); + if (result==null) { + throw new IllegalArgumentException("Could not get facet: "+renderFacetState); + } + return result; + } + + public JSFVascEntrySupportBean getSupportBean() { + return supportBean; + } + + public void setRenderFacetState(String renderFacetState) { + this.renderFacetState=renderFacetState; + } + + public String getRenderFacetState() { + return renderFacetState; + } + /** * @return the injectTableOptionOnChange */ public String getInjectTableOptionOnChange() { return injectTableOptionOnChange; } - + /** * @param injectTableOptionOnChange the injectTableOptionOnChange to set */ public void setInjectTableOptionOnChange(String injectTableOptionOnChange) { this.injectTableOptionOnChange = injectTableOptionOnChange; } - + public VascEntry createClonedVascEntry() { - - VascController vascController = (VascController)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(VascRequestFacesFilter.REQ_VASC_CONTOLLER); String entryId = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(VascRequestFacesFilter.REQ_VASC_ENTRY_ID); - + if (link!=null) { entryId = link.getVascEntryId(); } @@ -314,8 +310,6 @@ public class JSFVascUIComponent extends UIComponentBase { if (entry==null) { throw new NullPointerException("Could not get '"+entryId+"' from : "+vascController); } - - try { vascController.getVascEntryConfigController().configVascFrontendController(vascController, entry); } catch (Exception e1) { @@ -410,4 +404,4 @@ public class JSFVascUIComponent extends UIComponentBase { } } } -} \ No newline at end of file +} diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponentRenderer.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponentRenderer.java index e6e7804..0339f04 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponentRenderer.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponentRenderer.java @@ -419,14 +419,14 @@ public class JSFVascUIComponentRenderer extends Renderer { orderUp.setId(viewRoot.createUniqueId()); orderUp.setEscape(false); orderUp.setValue("↑"); // ↑ - ValueExpression ren2 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".sortOrder==true and "+entrySupportVar+".sortField=='"+c.getId()+"'}", Boolean.class); + ValueExpression ren2 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".vascEntry.vascFrontendController.vascEntryState.vascBackendState.sortAscending==true and "+entrySupportVar+".vascEntry.vascFrontendController.vascEntryState.vascBackendState.sortField=='"+c.getId()+"'}", Boolean.class); orderUp.setValueExpression("rendered", ren2); HtmlOutputText orderDown = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE); orderDown.setId(viewRoot.createUniqueId()); orderDown.setEscape(false); orderDown.setValue("↓"); // ↓ - ValueExpression ren3 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".sortOrder==false and "+entrySupportVar+".sortField=='"+c.getId()+"'}", Boolean.class); + ValueExpression ren3 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".vascEntry.vascFrontendController.vascEntryState.vascBackendState.sortAscending==false and "+entrySupportVar+".vascEntry.vascFrontendController.vascEntryState.vascBackendState.sortField=='"+c.getId()+"'}", Boolean.class); orderDown.setValueExpression("rendered", ren3); link.getChildren().add(out2); diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascDataBackendBean.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascDataBackendBean.java index fc15bb5..23712c9 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascDataBackendBean.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascDataBackendBean.java @@ -29,6 +29,7 @@ import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.entry.VascEntryFieldValue; import net.forwardfire.vasc.core.VascException; +import net.forwardfire.vasc.frontend.VascFrontendDataSelector.EntryFieldSelectType; @@ -63,7 +64,7 @@ public class VascDataBackendBean implements Serializable { if (index>entry.getVascEntryFields().size()) { throw new IllegalArgumentException("Index is bigger then total field size: "+index); } - return entry.getVascFrontendController().getVascFrontendDataSelector().getFieldsList().get(index); + return entry.getVascFrontendController().getVascFrontendDataSelector().getFields(EntryFieldSelectType.ALL).get(index); } static public int getIndexId(VascEntryField field) { diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascRequestFacesFilter.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascRequestFacesFilter.java index 9ec938c..6154477 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascRequestFacesFilter.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascRequestFacesFilter.java @@ -94,20 +94,19 @@ public class VascRequestFacesFilter implements Filter { className = className.substring(atIndex+1); } try { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - if (cl == null) { - cl = className.getClass().getClassLoader(); - } - Class> clazz = cl.loadClass(className); - if (classArgument==null) { - vascControllerProvider = (VascControllerProvider)clazz.newInstance(); - } else { - vascControllerProvider = (VascControllerProvider)clazz.getConstructor(String.class).newInstance(classArgument); - } + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl == null) { + cl = className.getClass().getClassLoader(); + } + Class> clazz = cl.loadClass(className); + if (classArgument==null) { + vascControllerProvider = (VascControllerProvider)clazz.newInstance(); + } else { + vascControllerProvider = (VascControllerProvider)clazz.getConstructor(String.class).newInstance(classArgument); + } } catch (Exception e) { throw new ServletException("Could not create VascControllerProvider: "+e.getMessage(),e); } - } /** diff --git a/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java b/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java index 05ed4db..874ba7d 100644 --- a/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java +++ b/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java @@ -56,16 +56,25 @@ public class VascBundleCheckEntryKeys { } public Map collectVascKeys(VascEntry ve) { + String value = ve.getId(); + if (ve.getVascGroupId()!=null) { + if (value.toLowerCase().startsWith(ve.getVascGroupId().toLowerCase())) { + value = value.substring(ve.getVascGroupId().length()); + if (Character.isLetterOrDigit(value.charAt(0))==false) { + value = value.substring(1); + } + } + } Map keys = new HashMap(300); - keys.put(ve.getName(), ve.getId()); + keys.put(ve.getName(), value); keys.put(ve.getImage(), ve.getId()); - keys.put(ve.getListDescription(), ve.getId()); + keys.put(ve.getListDescription(), "View list of "+value); keys.put(ve.getListImage(), imagePrefix+ve.getId()+imagePostfix); - keys.put(ve.getEditDescription(), ve.getId()); + keys.put(ve.getEditDescription(), "Edit your "+value); keys.put(ve.getEditImage(), imagePrefix+ve.getId()+imagePostfix); - keys.put(ve.getDeleteDescription(), ve.getId()); + keys.put(ve.getDeleteDescription(), "Delete this "+value); keys.put(ve.getDeleteImage(), imagePrefix+ve.getId()+imagePostfix); - keys.put(ve.getCreateDescription(), ve.getId()); + keys.put(ve.getCreateDescription(), "Create new "+value); keys.put(ve.getCreateImage(), imagePrefix+ve.getId()+imagePostfix); for (VascEntryField vef:ve.getVascEntryFields()) { keys.put(vef.getName(), vef.getId()); diff --git a/vasc-xpql-ejb3-client/src/main/resources/META-INF/vasc/vasc-xpql-ejb3.eld b/vasc-xpql-ejb3-client/src/main/resources/META-INF/vasc/vasc-xpql-ejb3.eld index 1655f1d..725a6cb 100644 --- a/vasc-xpql-ejb3-client/src/main/resources/META-INF/vasc/vasc-xpql-ejb3.eld +++ b/vasc-xpql-ejb3-client/src/main/resources/META-INF/vasc/vasc-xpql-ejb3.eld @@ -6,7 +6,7 @@ xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd" providerName="vasc.forwardfire.net" name="Vasc EJB3 Xpql query loading" - id="mod-vasc-xpql-ejb3" + id="vasc-xpql-ejb3" > queries = new HashMap(100); @PostConstruct @@ -73,117 +73,114 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa long s = System.currentTimeMillis(); Map keys = loadKeys(); - for (String key:keys.keySet()) { - String value = keys.get(key); - if (key.startsWith("load")) { - loadResource(value); - } - if ("persistenceUnit".equals(key)) { - logger.fine("getting EntityManager: "+value); - entityManager = (EntityManager)new InitialContext().lookup(value); - } - } + for (String key:keys.keySet()) { + String value = keys.get(key); + if (key.startsWith("load")) { + loadResource(value); + } + if ("persistenceUnit".equals(key)) { + logger.fine("getting EntityManager: "+value); + entityManager = (EntityManager)new InitialContext().lookup(value); + } + } long t = System.currentTimeMillis()-s; logger.info("Total loaded xpql queries: "+queries.size()+" in "+t+" ms."); } catch (Exception e) { throw new RuntimeException("Error while load xpql resources error: "+e.getMessage(),e); } } - - /** - * Loads xtes-xpql-ejb3.xml from meta-inf and gives the keys - */ - protected Map loadKeys() throws IOException { - - Properties properties = new Properties(); - - logger.fine("Getting urls"); - Enumeration e = Thread.currentThread().getContextClassLoader().getResources("META-INF/xtes-xpql-ejb3.xml"); - while(e.hasMoreElements()) { - URL u = e.nextElement(); - logger.finer("Loading reletive namespaces of: "+u+" for: META-INF/xtes-xpql-ejb3.xml"); - InputStream in = u.openStream(); - try { - properties.loadFromXML(in); - } finally { - if (in!=null) { - in.close(); - } - } - } - - - e = Thread.currentThread().getContextClassLoader().getResources("/META-INF/xtes-xpql-ejb3.xml"); - while(e.hasMoreElements()) { - URL u = e.nextElement(); - logger.finer("Loading root namespaces of: "+u+" for: /META-INF/xtes-xpql-ejb3.xml"); - InputStream in = u.openStream(); - try { - properties.loadFromXML(in); - } finally { - if (in!=null) { - in.close(); - } - } - } - logger.fine("done loading"); - - Map result = new HashMap(20); - for (Object key:properties.keySet()) { - if (key instanceof String) { - String key2 = (String) key; - String value = properties.getProperty(key2); - result.put(key2, value); - } - } - return result; - } + /** + * Loads xtes-xpql-ejb3.xml from meta-inf and gives the keys + */ + protected Map loadKeys() throws IOException { + + Properties properties = new Properties(); + logger.fine("Getting urls"); + Enumeration e = Thread.currentThread().getContextClassLoader().getResources("META-INF/xtes-xpql-ejb3.xml"); + while(e.hasMoreElements()) { + URL u = e.nextElement(); + logger.finer("Loading reletive namespaces of: "+u+" for: META-INF/xtes-xpql-ejb3.xml"); + InputStream in = u.openStream(); + try { + properties.loadFromXML(in); + } finally { + if (in!=null) { + in.close(); + } + } + } + + e = Thread.currentThread().getContextClassLoader().getResources("/META-INF/xtes-xpql-ejb3.xml"); + while(e.hasMoreElements()) { + URL u = e.nextElement(); + logger.finer("Loading root namespaces of: "+u+" for: /META-INF/xtes-xpql-ejb3.xml"); + InputStream in = u.openStream(); + try { + properties.loadFromXML(in); + } finally { + if (in!=null) { + in.close(); + } + } + } + logger.fine("done loading"); + + Map result = new HashMap(20); + for (Object key:properties.keySet()) { + if (key instanceof String) { + String key2 = (String) key; + String value = properties.getProperty(key2); + result.put(key2, value); + } + } + return result; + } - private void loadResource(String resource) { - XPQLParser parser = new XPQLParser(); - logger.fine("Try loading: "+resource); - try { + private void loadResource(String resource) { + XPQLParser parser = new XPQLParser(); + logger.fine("Try loading: "+resource); + try { parser.parseResource(resource); } catch (Exception e) { throw new RuntimeException("Could not load xpql resource: "+resource+" error: "+e.getMessage(),e); } - QueryStore store = parser.getQueryStore(); - - for (String key:store.getQueryNames()) { - Query q = store.getQuery(key); - + QueryStore store = parser.getQueryStore(); + + for (String key:store.getQueryNames()) { + Query q = store.getQuery(key); + queries.put(q.getName(),q); - String out = "\n\n=========== SQL: "+q.getName()+"\n"; - //out +=q.toSQL(q); - out +="=========== XML: "+q.getName()+"\n"; - out +=q.toXML(q); - //out +="=========== Edit: "+q.getName()+"\n"; - //out +=q.toEdit(q); - out +="=========== Prepard: "+q.getName()+"\n"; - out +=q.toPreparedSQL(q)+"\n"; - logger.finer("FOUND Query: "+out); - } - } + String out = "\n\n=========== SQL: "+q.getName()+"\n"; + //out +=q.toSQL(q); + out +="=========== XML: "+q.getName()+"\n"; + out +=q.toXML(q); + //out +="=========== Edit: "+q.getName()+"\n"; + //out +=q.toEdit(q); + out +="=========== Prepard: "+q.getName()+"\n"; + out +=q.toPreparedSQL(q)+"\n"; + logger.finer("FOUND Query: "+out); + } + } - public Query getQuery(String name) { - Query q = queries.get(name); - return q; - } - - @SuppressWarnings("unchecked") + public Query getQuery(String name) { + Query q = queries.get(name); + return q; + } + + @SuppressWarnings("unchecked") public List execute(Query query) { - String sql = query.toPreparedSQL(query); - logger.finer("Executing: "+query.getName()+" sql: "+sql); - javax.persistence.Query q2 = null; - if (Query.QueryType.hql==query.getType()) { - q2 = entityManager.createQuery(sql); - } - if (Query.QueryType.sql==query.getType()) { - q2 = entityManager.createNativeQuery(sql); - } - + String sql = query.toPreparedSQL(query); + logger.finer("Executing: "+query.getName()+" sql: "+sql); + javax.persistence.Query q2 = null; + if (Query.QueryType.hql==query.getType()) { + q2 = entityManager.createQuery(sql); + } + if (Query.QueryType.sql==query.getType()) { + q2 = entityManager.createNativeQuery(sql); + } + // TODO: move this hack to xtest xpql if (query.getProperty("limit")!=null) { int max = new Integer(query.getPropertyString("limit")); @@ -193,9 +190,8 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa int offset = new Integer(query.getPropertyString("offset")); q2.setFirstResult(offset); } - - - List options = query.getOrderQueryParameterValues(); + + List options = query.getOrderQueryParameterValues(); int i=1; for ( QueryParameterValue value : options ) { Object para = value.getValue(); @@ -208,20 +204,19 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa } return q2.getResultList(); } - - @SuppressWarnings("unchecked") + + @SuppressWarnings("unchecked") public Object executeObject(Query query) { - String sql = query.toPreparedSQL(query); - logger.finer("Executing: "+query.getName()+" sql: "+sql); - javax.persistence.Query q2 = null; - if (Query.QueryType.hql==query.getType()) { - q2 = entityManager.createQuery(sql); - } - if (Query.QueryType.sql==query.getType()) { - q2 = entityManager.createNativeQuery(sql); - } - - + String sql = query.toPreparedSQL(query); + logger.finer("Executing: "+query.getName()+" sql: "+sql); + javax.persistence.Query q2 = null; + if (Query.QueryType.hql==query.getType()) { + q2 = entityManager.createQuery(sql); + } + if (Query.QueryType.sql==query.getType()) { + q2 = entityManager.createNativeQuery(sql); + } + // TODO: move this hack to xtest xpql if (query.getProperty("limit")!=null) { int max = new Integer(query.getPropertyString("limit")); @@ -231,8 +226,8 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa int offset = new Integer(query.getPropertyString("offset")); q2.setFirstResult(offset); } - - List options = query.getOrderQueryParameterValues(); + + List options = query.getOrderQueryParameterValues(); int i=1; for ( QueryParameterValue value : options ) { Object para = value.getValue(); @@ -255,9 +250,9 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa } } return result; - } catch (Exception se) { - throw new RuntimeException("Transaction error: "+se.getMessage(),se); - } + } catch (Exception se) { + throw new RuntimeException("Transaction error: "+se.getMessage(),se); + } } public List execute(String name,Map parameters) { @@ -283,59 +278,59 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa } public Integer executeUpdate(Query query) { - String sql = query.toPreparedSQL(query); - logger.fine("Executing: "+query.getName()+" sql: "+sql); - try { - javax.persistence.Query q2 = null; - if (Query.QueryType.hql==query.getType()) { - q2 = entityManager.createQuery(sql); - List options = query.getOrderQueryParameterValues(); - int i=1; - for ( QueryParameterValue value : options ) { - Object para = value.getValue(); - if(para==null) { - para = value.getDefaultValue(); - } - logger.finest( "nr: " + i + " value: " + para+" name: "+value.getName()); - q2.setParameter(i,para); - i++; - } - utx.begin(); - Integer result = q2.executeUpdate(); - utx.commit(); - return result; - } - - if (Query.QueryType.sql==query.getType()) { - q2 = entityManager.createNativeQuery(sql); - List options = query.getOrderQueryParameterValues(); - int i=1; - for ( QueryParameterValue value : options ) { - Object para = value.getValue(); - if(para==null) { - para = value.getDefaultValue(); - } - logger.finest( "nr: " + i + " value: " + para+" name: "+value.getName()); - q2.setParameter(i,para); - i++; - } - utx.begin(); - Integer result = q2.executeUpdate(); + String sql = query.toPreparedSQL(query); + logger.fine("Executing: "+query.getName()+" sql: "+sql); + try { + javax.persistence.Query q2 = null; + if (Query.QueryType.hql==query.getType()) { + q2 = entityManager.createQuery(sql); + List options = query.getOrderQueryParameterValues(); + int i=1; + for ( QueryParameterValue value : options ) { + Object para = value.getValue(); + if(para==null) { + para = value.getDefaultValue(); + } + logger.finest( "nr: " + i + " value: " + para+" name: "+value.getName()); + q2.setParameter(i,para); + i++; + } + utx.begin(); + Integer result = q2.executeUpdate(); utx.commit(); - return result; - } - } catch (Exception se) { - throw new RuntimeException("Transaction error: "+se.getMessage(),se); - } - throw new IllegalStateException("unknow query type"); + return result; + } + + if (Query.QueryType.sql==query.getType()) { + q2 = entityManager.createNativeQuery(sql); + List options = query.getOrderQueryParameterValues(); + int i=1; + for ( QueryParameterValue value : options ) { + Object para = value.getValue(); + if(para==null) { + para = value.getDefaultValue(); + } + logger.finest( "nr: " + i + " value: " + para+" name: "+value.getName()); + q2.setParameter(i,para); + i++; + } + utx.begin(); + Integer result = q2.executeUpdate(); + utx.commit(); + return result; + } + } catch (Exception se) { + throw new RuntimeException("Transaction error: "+se.getMessage(),se); + } + throw new IllegalStateException("unknow query type"); } public Integer executeUpdate(String name,Map parameters) { Query query = getQuery(name); for (String key:parameters.keySet()) { - Object value = parameters.get(key); - query.setQueryParameter(key, value); - } + Object value = parameters.get(key); + query.setQueryParameter(key, value); + } return executeUpdate(query); } } diff --git a/vasc-xpql/src/main/resources/META-INF/vasc/vasc-xpql.eld b/vasc-xpql/src/main/resources/META-INF/vasc/vasc-xpql.eld index 0f11ea6..43752f3 100644 --- a/vasc-xpql/src/main/resources/META-INF/vasc/vasc-xpql.eld +++ b/vasc-xpql/src/main/resources/META-INF/vasc/vasc-xpql.eld @@ -6,7 +6,7 @@ xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd" providerName="vasc.forwardfire.net" name="Xpql query loading" - id="mod-vasc-xpql" + id="vasc-xpql" >
null