diff --git a/pom.xml b/pom.xml index 6c19ec8..d0182b3 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,7 @@ vasc-lib vasc-core-ejb3-client vasc-core-ejb3-server + vasc-export UTF-8 @@ -90,6 +91,9 @@ 2.7.3 + + 1.1 + 2.6.0 diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelSchemaAutoEntry.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelSchemaAutoEntry.java index cf91db6..aaed3cc 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelSchemaAutoEntry.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelSchemaAutoEntry.java @@ -40,6 +40,7 @@ import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryAccessType; import net.forwardfire.vasc.core.VascEntryControllerLocal; +import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryFieldLocal; import net.forwardfire.vasc.core.VascEntryGroupLocal; import net.forwardfire.vasc.core.VascEntryLinkType; @@ -297,6 +298,39 @@ public class MetaModelSchemaAutoEntry { ve.setDisplayNameFieldId(c.getName()); } } + + // Some auto detection on fields so default imported list view looks oke on 8++ columns. + if (ve.getVascEntryFields().size()>8) { + List vefListIds = new ArrayList(20); + for (VascEntryField vef:ve.getVascEntryFields()) { + String id = vef.getId().toLowerCase(); + if ( id.contains("create") | + id.contains("update") | + id.contains("delete") | + id.contains("classname") | + id.contains("description") + ) { + vef.setList(false); + } + if (ve.getDisplayNameFieldId()!=null && ve.getDisplayNameFieldId().equals(vef.getId())) { + continue; + } + if (ve.getPrimaryKeyFieldId()!=null && ve.getPrimaryKeyFieldId().equals(vef.getId())) { + continue; + } + if (vef.getList()!=null && vef.getList()==false) { + continue; + } + vefListIds.add(vef.getId()); + } + if (vefListIds.size()<8) { + List vefListFalseIds = vefListIds.subList(8-1, vefListIds.size()); + for (String key:vefListFalseIds) { + VascEntryField vef = ve.getVascEntryFieldById(key); + vef.setList(false); + } + } + } } /** diff --git a/vasc-core/pom.xml b/vasc-core/pom.xml index ddd2e17..07eed1f 100644 --- a/vasc-core/pom.xml +++ b/vasc-core/pom.xml @@ -5,32 +5,25 @@ net.forwardfire.vasc 0.4.1-SNAPSHOT - net.forwardfire.vasc vasc-core - 0.4.1-SNAPSHOT vasc-core vasc-core - - org.x4o - x4o-core - ${x4o.version} - - - org.x4o - x4o-meta - ${x4o.version} - + + org.x4o + x4o-core + ${x4o.version} + + + org.x4o + x4o-meta + ${x4o.version} + net.forwardfire.vasc vasc-xpql ${project.version} - - net.forwardfire.vasc.lib - vasc-lib-jr4o - ${project.version} - javax.persistence persistence-api @@ -38,16 +31,16 @@ provided - org.hibernate - hibernate-validator - ${hibernate-validator.version} - provided + org.hibernate + hibernate-validator + ${hibernate-validator.version} + provided - de.odysseus.juel - juel - 2.1.0 - test + de.odysseus.juel + juel + 2.1.0 + test - \ No newline at end of file + diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigController.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigController.java index 1b0f7ff..ca5cbb0 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigController.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigController.java @@ -25,7 +25,7 @@ package net.forwardfire.vasc.core; import java.util.List; import net.forwardfire.vasc.backend.VascBackend; -import net.forwardfire.vasc.core.entry.VascEntryExporter; +import net.forwardfire.vasc.core.entry.VascEntryExport; import net.forwardfire.vasc.core.VascException; /** @@ -51,7 +51,7 @@ public interface VascEntryConfigController { public List getVascEntryExporterIds(); - public VascEntryExporter getVascEntryExporterById(String exporterId); + public VascEntryExport getVascEntryExporterById(String exporterId); public void configVascFrontendController(VascController vascController,VascEntryLocal entry) throws VascException; diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigControllerLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigControllerLocal.java index ed3ae40..c77a4e9 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigControllerLocal.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigControllerLocal.java @@ -26,7 +26,7 @@ import java.util.List; import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.proxy.VascBackendProxy; -import net.forwardfire.vasc.core.entry.VascEntryExporter; +import net.forwardfire.vasc.core.entry.VascEntryExport; import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService; /** @@ -58,9 +58,9 @@ public interface VascEntryConfigControllerLocal extends VascEntryConfigControlle - public void addVascEntryExporter(VascEntryExporter exporter); + public void addVascEntryExporter(VascEntryExport exporter); - public void removeVascEntryExporter(VascEntryExporter exporter); + public void removeVascEntryExporter(VascEntryExport exporter); public VascBackendState getMasterVascBackendState(); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterXmlTree.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/entry/VascEntryExport.java similarity index 69% rename from vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterXmlTree.java rename to vasc-core/src/main/java/net/forwardfire/vasc/core/entry/VascEntryExport.java index 8a2cb95..7eccc7c 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterXmlTree.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/entry/VascEntryExport.java @@ -20,31 +20,31 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.impl.entry.export; +package net.forwardfire.vasc.core.entry; + +import java.io.Serializable; +import java.util.Set; + +import net.forwardfire.vasc.core.VascException; /** - * VascEntryExporterXmlTree exports the data as xml tree. + * VascEntryExporter handles the export of data to an stream. * * @author Willem Cazander - * @version 1.0 May 9, 2012 + * @version 1.0 May 19, 2007 */ -public class VascEntryExporterXmlTree extends VascEntryExporterXml { - - private static final long serialVersionUID = 179434457857022828L; - static public final String EXPORT_TYPE = "xmltree"; - - /** - * Creates an VascEntryExporterXmlTree - */ - public VascEntryExporterXmlTree() { - setXmlTree(true); - } +public interface VascEntryExport extends Serializable { - /** - * @see net.forwardfire.vasc.impl.entry.export.VascEntryExporterXml#getId() - */ - @Override - public String getId() { - return EXPORT_TYPE; - } + // move ? + public VascEntryExportWriter createExportWriter() throws VascException; + + public String getId(); + + public String getRolesExport(); + + public String getExportWriterClass(); + + public void addWriterParameter(String key,String value); + public String getWriterParameter(String key); + public Set getWriterParameterKeys(); } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/entry/VascEntryExporter.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/entry/VascEntryExportWriter.java similarity index 84% rename from vasc-core/src/main/java/net/forwardfire/vasc/core/entry/VascEntryExporter.java rename to vasc-core/src/main/java/net/forwardfire/vasc/core/entry/VascEntryExportWriter.java index 53ff540..54d0268 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/entry/VascEntryExporter.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/entry/VascEntryExportWriter.java @@ -22,24 +22,24 @@ package net.forwardfire.vasc.core.entry; +import java.io.IOException; import java.io.OutputStream; import java.io.Serializable; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascException; - - /** + * VascEntryExportWriter handles the export of data to an stream. * * @author Willem Cazander * @version 1.0 May 19, 2007 */ -public interface VascEntryExporter extends Serializable { +public interface VascEntryExportWriter extends Serializable { - public String getId(); + public void doInit(VascEntryExport export,VascEntry vascEntry) throws VascException; - public void doExport(OutputStream out,VascEntry vascEntry) throws VascException; + public void doExport(OutputStream out) throws IOException,VascException; public String getMineType(); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontend.java b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontend.java index 52e735b..d167cec 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontend.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontend.java @@ -23,7 +23,7 @@ package net.forwardfire.vasc.frontend; import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.entry.VascEntryExporter; +import net.forwardfire.vasc.core.entry.VascEntryExport; /** @@ -47,5 +47,5 @@ public interface VascFrontend { public void renderDelete() throws VascFrontendException; - public void renderExport(VascEntryExporter exporter) throws VascFrontendException; + public void renderExport(VascEntryExport exporter) throws VascFrontendException; } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryConfigController.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryConfigController.java index 3403d63..bfdbb3e 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryConfigController.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryConfigController.java @@ -43,7 +43,7 @@ import net.forwardfire.vasc.core.VascEntryState; import net.forwardfire.vasc.core.VascInterfaceKey; import net.forwardfire.vasc.core.VascInterfaceKeyFrontend; import net.forwardfire.vasc.core.VascInterfaceLoader; -import net.forwardfire.vasc.core.entry.VascEntryExporter; +import net.forwardfire.vasc.core.entry.VascEntryExport; import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService; import net.forwardfire.vasc.core.entry.VascEntryFieldValue; import net.forwardfire.vasc.core.VascException; @@ -62,7 +62,7 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll private List configFinalizers = null; private List backendProxies = null; - private Map dataExporters = null; + private Map dataExporters = null; private List fieldValidators = null; private Map> vascInterfaceImpls = null; private Map> vascInterfaceImplFrontends = null; @@ -73,7 +73,7 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll public DefaultVascEntryConfigController() { configFinalizers = new ArrayList(10); backendProxies = new ArrayList(10); - dataExporters = new HashMap(10); + dataExporters = new HashMap(10); fieldValidators = new ArrayList(5); vascInterfaceImpls = new HashMap>(VascInterfaceKey.values().length); vascInterfaceImplFrontends = new HashMap>(VascInterfaceKeyFrontend.values().length); @@ -332,21 +332,21 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll /** * @see net.forwardfire.vasc.core.VascEntryConfigController#getVascEntryExporterById(java.lang.String) */ - public VascEntryExporter getVascEntryExporterById(String exporterId) { + public VascEntryExport getVascEntryExporterById(String exporterId) { return dataExporters.get(exporterId); } /** - * @see net.forwardfire.vasc.core.VascEntryConfigController#addVascEntryExporter(net.forwardfire.vasc.core.entry.VascEntryExporter) + * @see net.forwardfire.vasc.core.VascEntryConfigController#addVascEntryExporter(net.forwardfire.vasc.core.entry.VascEntryExport) */ - public void addVascEntryExporter(VascEntryExporter exporter) { + public void addVascEntryExporter(VascEntryExport exporter) { dataExporters.put(exporter.getId(),exporter); } /** - * @see net.forwardfire.vasc.core.VascEntryConfigController#removeVascEntryExporter(net.forwardfire.vasc.core.entry.VascEntryExporter) + * @see net.forwardfire.vasc.core.VascEntryConfigController#removeVascEntryExporter(net.forwardfire.vasc.core.entry.VascEntryExport) */ - public void removeVascEntryExporter(VascEntryExporter exporter) { + public void removeVascEntryExporter(VascEntryExport exporter) { dataExporters.remove(exporter.getId()); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascFactory.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascFactory.java index 01e6e7c..f941e08 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascFactory.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascFactory.java @@ -42,9 +42,6 @@ import net.forwardfire.vasc.impl.entry.config.VascHelpIdFinalizer; import net.forwardfire.vasc.impl.entry.config.VascI18nFinalizer; import net.forwardfire.vasc.impl.entry.config.VascIdAutoFinalizer; import net.forwardfire.vasc.impl.entry.config.VascIdCheckFinalizer; -import net.forwardfire.vasc.impl.entry.export.VascEntryExporterCsv; -import net.forwardfire.vasc.impl.entry.export.VascEntryExporterXml; -import net.forwardfire.vasc.impl.entry.export.VascEntryExporterXmlTree; import net.forwardfire.vasc.impl.frontend.DefaultVascFrontendActions; import net.forwardfire.vasc.impl.frontend.DefaultVascFrontendController; import net.forwardfire.vasc.impl.frontend.DefaultVascFrontendDataSelector; @@ -101,11 +98,6 @@ public class DefaultVascFactory { vascConfig.addVascEntryConfigFinalizer(new VascHelpIdFinalizer()); vascConfig.addVascEntryConfigFinalizer(new VascDefaultsFinalizer()); - // Add all exporters in reverse ORDER - vascConfig.addVascEntryExporter(new VascEntryExporterXmlTree()); - vascConfig.addVascEntryExporter(new VascEntryExporterXml()); - vascConfig.addVascEntryExporter(new VascEntryExporterCsv()); - // Add only the default internal vasc validator. vascConfig.addVascEntryFieldValidatorService(new VascValidatorsValidatorService()); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/ExportDataGlobalAction.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/ExportDataGlobalAction.java index 99030a6..23593ff 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/ExportDataGlobalAction.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/actions/ExportDataGlobalAction.java @@ -25,7 +25,7 @@ package net.forwardfire.vasc.impl.actions; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.core.actions.AbstractVascGlobalActionLocal; -import net.forwardfire.vasc.core.entry.VascEntryExporter; +import net.forwardfire.vasc.core.entry.VascEntryExport; /** * ExportDataGlobalAction is action per exporter. @@ -53,7 +53,7 @@ public class ExportDataGlobalAction extends AbstractVascGlobalActionLocal { } public void doGlobalAction(VascEntry entry) throws VascException { - VascEntryExporter exporter = entry.getVascFrontendController().getVascController().getVascEntryConfigController().getVascEntryExporterById(exporterId); + VascEntryExport exporter = entry.getVascFrontendController().getVascController().getVascEntryConfigController().getVascEntryExporterById(exporterId); entry.getVascFrontendController().getVascFrontend().renderExport(exporter); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/BeanVascEntryRecordCreator.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/BeanVascEntryRecordCreator.java index 13ed242..e6c5a32 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/BeanVascEntryRecordCreator.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/BeanVascEntryRecordCreator.java @@ -26,9 +26,8 @@ import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.entry.VascEntryRecordCreator; import net.forwardfire.vasc.core.VascException; - - /** + * BeanVascEntryRecordCreator creates an new instance Object from a defined objectClass. * * @author Willem Cazander * @version 1.0 Mar 21, 2007 diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/DefaultVascEntryExport.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/DefaultVascEntryExport.java new file mode 100644 index 0000000..6fa0b94 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/DefaultVascEntryExport.java @@ -0,0 +1,118 @@ +/* + * Copyright 2007-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.impl.entry; + + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import net.forwardfire.vasc.core.VascException; +import net.forwardfire.vasc.core.entry.VascEntryExport; +import net.forwardfire.vasc.core.entry.VascEntryExportWriter; + +/** + * DefaultVascEntryExport holds the id and roles for the export writer. + * + * @author Willem Cazander + * @version 1.0 Nov 23, 2012 + */ +public class DefaultVascEntryExport implements VascEntryExport { + + private static final long serialVersionUID = 4949926724589747264L; + private String id = null; + private String rolesExport = null; + private String exportWriterClass = null; + private Map writerParameters = null; + + public DefaultVascEntryExport() { + writerParameters = new HashMap(); + } + + public VascEntryExportWriter createExportWriter() throws VascException { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl == null) { + cl = DefaultVascEntryExport.class.getClassLoader(); + } + try { + Class clazz = cl.loadClass(getExportWriterClass()); + Object instance = clazz.newInstance(); + VascEntryExportWriter writer = (VascEntryExportWriter)instance; + return writer; + } catch (Exception e) { + throw new VascException(e); + } + } + + public void addWriterParameter(String key,String value) { + writerParameters.put(key,value); + } + public String getWriterParameter(String key) { + return writerParameters.get(key); + } + public Set getWriterParameterKeys() { + return writerParameters.keySet(); + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return the rolesExport + */ + public String getRolesExport() { + return rolesExport; + } + + /** + * @param rolesExport the rolesExport to set + */ + public void setRolesExport(String rolesExport) { + this.rolesExport = rolesExport; + } + + /** + * @return the exportWriterClass + */ + public String getExportWriterClass() { + return exportWriterClass; + } + + /** + * @param exportWriterClass the exportWriterClass to set + */ + public void setExportWriterClass(String exportWriterClass) { + this.exportWriterClass = exportWriterClass; + } +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterXml.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterXml.java deleted file mode 100644 index 95ac7b8..0000000 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterXml.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2007-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.impl.entry.export; - -import java.io.OutputStream; -import java.io.PrintWriter; - -import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.VascEntryField; -import net.forwardfire.vasc.core.entry.VascEntryExporter; -import net.forwardfire.vasc.core.VascException; - -/** - * VascEntryExporterXml writes entry data to xml format. - * - * @author Willem Cazander - * @version 1.0 Mar 30, 2007 - */ -public class VascEntryExporterXml implements VascEntryExporter { - - private static final long serialVersionUID = 3719424578585760828L; - static public final String EXPORT_TYPE = "xml"; - private boolean xmlTree = false; - - /** - * @see net.forwardfire.vasc.core.entry.VascEntryExporter#getId() - */ - public String getId() { - return EXPORT_TYPE; - } - - /** - * @see net.forwardfire.vasc.core.entry.VascEntryExporter#doExport(java.io.OutputStream, net.forwardfire.vasc.core.VascEntry) - */ - public void doExport(OutputStream out, VascEntry entry) throws VascException { - PrintWriter p = new PrintWriter(out); - p.write("\n"); - p.write("\n"); - - int oldIndex = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex(); - Long total = entry.getVascFrontendController().getVascEntryState().getTotalBackendRecords(); - int pages = total.intValue()/entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize(); - for (int page=0;page<=pages;page++) { - entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(page); - entry.getVascFrontendController().getVascFrontendActions().refreshData(); - for (Object o:entry.getVascFrontendController().getVascEntryState().getEntryDataList()) { - p.write("\t\n"); - for (VascEntryField c:entry.getVascEntryFields()) { - if (xmlTree) { - p.write("\t\t<"+c.getId()+">\n"); - } else { - p.write("\t\t\n"); - } - } - p.write("\t\n"); - p.flush(); - } - } - p.write("\n"); - p.flush(); - - // restore old page size - entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(oldIndex); - } - - /** - * @see net.forwardfire.vasc.core.entry.VascEntryExporter#getMineType() - */ - public String getMineType() { - return "text/xml"; - } - - /** - * @see net.forwardfire.vasc.core.entry.VascEntryExporter#getFileType() - */ - public String getFileType() { - return EXPORT_TYPE; - } - - /** - * @return the xmlTree - */ - public boolean isXmlTree() { - return xmlTree; - } - - /** - * @param xmlTree the xmlTree to set - */ - public void setXmlTree(boolean xmlTree) { - this.xmlTree = xmlTree; - } -} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java index 9610031..f6308ad 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java @@ -208,7 +208,9 @@ public class DefaultVascFrontendActions implements VascFrontendActions { backendState.removeDataParameterAll(); for (String key:entry.getEntryParameterKeys()) { Object value = entry.getEntryParameter(key); - backendState.setDataParameter(key, value); + if (value!=null) { + backendState.setDataParameter(key, value); + } } // Update total every time first diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/demo-csv.xml b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/demo-csv.xml index 4152c2c..a59de0c 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/demo-csv.xml +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/demo-csv.xml @@ -4,10 +4,7 @@ xmlns:mm="http://vasc.forwardfire.net/xml/ns/vasc-backend-metamodel" > - + - + @@ -84,9 +84,9 @@ - + - + diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/tech-server.xml b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/tech-server.xml index f83d620..9eac388 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/tech-server.xml +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/tech-server.xml @@ -7,7 +7,7 @@ diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/pom.xml b/vasc-demo/vasc-demo-server/vasc-demo-server-core/pom.xml index 64c580f..b11c701 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/pom.xml +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/pom.xml @@ -76,6 +76,16 @@ vasc-backend-jdbc ${project.version} + + net.forwardfire.vasc.export + vasc-export-jr4o + ${project.version} + + + net.forwardfire.vasc.export + vasc-export-json + ${project.version} + net.forwardfire.vasc.lib vasc-lib-i18n diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/VascTechDemoControllerConfig.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/VascTechDemoControllerConfig.java index 382814a..ade33a4 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/VascTechDemoControllerConfig.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/VascTechDemoControllerConfig.java @@ -26,9 +26,12 @@ import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascControllerProvider; import net.forwardfire.vasc.core.VascEntryConfigControllerLocal; import net.forwardfire.vasc.core.VascException; +import net.forwardfire.vasc.export.generic.VascEntryExportWriterCsv; +import net.forwardfire.vasc.export.generic.VascEntryExportWriterXml; +import net.forwardfire.vasc.export.jr4o.VascEntryExportWriterJR4O; +import net.forwardfire.vasc.export.json.VascEntryExportWriterJson; import net.forwardfire.vasc.impl.DefaultVascFactory; -import net.forwardfire.vasc.impl.entry.export.VascEntryExporterJR4O; -import net.forwardfire.vasc.lib.jr4o.JR4ODesignManager.JRExportType; +import net.forwardfire.vasc.impl.entry.DefaultVascEntryExport; /** * DemoVascControllerProvider gets the static local jvm vasc controller for this tech demo. @@ -49,12 +52,78 @@ public class VascTechDemoControllerConfig implements VascControllerProvider { VascEntryConfigControllerLocal vecc = (VascEntryConfigControllerLocal)vascController.getVascEntryConfigController(); // Config all report export engines for demo. - vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrPdfLandscape",JRExportType.PDF,"generic-landscape","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml")); - vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrPdfPortrait",JRExportType.PDF,"generic-portrait","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml")); - vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrRtf",JRExportType.RTF,"generic-landscape","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml")); - vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrXls",JRExportType.XLS,"generic-landscape","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml")); - vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrXml",JRExportType.XML,"generic-landscape","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml")); - vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrCsv",JRExportType.CSV,"generic-landscape","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml")); + // Add all exporters in reverse ORDER + + DefaultVascEntryExport export; + + export = new DefaultVascEntryExport(); + export.setExportWriterClass(VascEntryExportWriterXml.class.getName()); + export.setId("xml"); + vecc.addVascEntryExporter(export); + + export = new DefaultVascEntryExport(); + export.setExportWriterClass(VascEntryExportWriterXml.class.getName()); + export.addWriterParameter("xmltree", "true"); + export.setId("xmltree"); + vecc.addVascEntryExporter(export); + + export = new DefaultVascEntryExport(); + export.setExportWriterClass(VascEntryExportWriterCsv.class.getName()); + export.setId("csv"); + vecc.addVascEntryExporter(export); + + export = new DefaultVascEntryExport(); + export.setExportWriterClass(VascEntryExportWriterJR4O.class.getName()); + export.addWriterParameter("reportType", "PDF"); + export.addWriterParameter("reportName", "generic-landscape"); + export.addWriterParameter("reportResource", "net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml"); + export.setId("jrPdfLandscape"); + vecc.addVascEntryExporter(export); + + export = new DefaultVascEntryExport(); + export.setExportWriterClass(VascEntryExportWriterJR4O.class.getName()); + export.addWriterParameter("reportType", "PDF"); + export.addWriterParameter("reportName", "generic-portrait"); + export.addWriterParameter("reportResource", "net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml"); + export.setId("jrPdfPortrait"); + vecc.addVascEntryExporter(export); + + export = new DefaultVascEntryExport(); + export.setExportWriterClass(VascEntryExportWriterJR4O.class.getName()); + export.addWriterParameter("reportType", "RTF"); + export.addWriterParameter("reportName", "generic-landscape"); + export.addWriterParameter("reportResource", "net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml"); + export.setId("jrRtf"); + vecc.addVascEntryExporter(export); + + export = new DefaultVascEntryExport(); + export.setExportWriterClass(VascEntryExportWriterJR4O.class.getName()); + export.addWriterParameter("reportType", "XLS"); + export.addWriterParameter("reportName", "generic-landscape"); + export.addWriterParameter("reportResource", "net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml"); + export.setId("jrXls"); + vecc.addVascEntryExporter(export); + + export = new DefaultVascEntryExport(); + export.setExportWriterClass(VascEntryExportWriterJR4O.class.getName()); + export.addWriterParameter("reportType", "XML"); + export.addWriterParameter("reportName", "generic-landscape"); + export.addWriterParameter("reportResource", "net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml"); + export.setId("jrXml"); + vecc.addVascEntryExporter(export); + + export = new DefaultVascEntryExport(); + export.setExportWriterClass(VascEntryExportWriterJR4O.class.getName()); + export.addWriterParameter("reportType", "CSV"); + export.addWriterParameter("reportName", "generic-landscape"); + export.addWriterParameter("reportResource", "net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml"); + export.setId("jrCsv"); + vecc.addVascEntryExporter(export); + + export = new DefaultVascEntryExport(); + export.setExportWriterClass(VascEntryExportWriterJson.class.getName()); + export.setId("json"); + vecc.addVascEntryExporter(export); // Config root bundle to load all resources. vecc.setResourceBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle"); diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/VascTechDemoStartup.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/VascTechDemoStartup.java index a29b542..dc5349a 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/VascTechDemoStartup.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/VascTechDemoStartup.java @@ -43,7 +43,7 @@ import net.forwardfire.vasc.demo.server.tomcat.TomcatService; * * @author Willem Cazander * @version 1.0 May 3, 2012 - */ + */ public class VascTechDemoStartup { private Logger logger = null; diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/tomcat/TomcatService.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/tomcat/TomcatService.java index d83518a..fa10d06 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/tomcat/TomcatService.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/tomcat/TomcatService.java @@ -24,22 +24,16 @@ package net.forwardfire.vasc.demo.server.tomcat; import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.net.URL; -import java.util.ArrayList; import java.util.Enumeration; -import java.util.List; -import java.util.Properties; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.logging.Logger; import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup; -import org.apache.catalina.Container; import org.apache.catalina.Context; import org.apache.catalina.Host; import org.apache.catalina.Server; @@ -48,24 +42,8 @@ import org.apache.catalina.Wrapper; import org.apache.catalina.core.StandardContext; import org.apache.catalina.startup.Bootstrap; import org.apache.catalina.startup.ContextConfig; -import org.apache.naming.NamingContext; import org.apache.naming.resources.VirtualDirContext; -import org.apache.openejb.assembler.Deployer; -import org.apache.openejb.assembler.DeployerEjb; -import org.apache.openejb.assembler.classic.AppInfo; -import org.apache.openejb.config.AppModule; -import org.apache.openejb.config.ConfigurationFactory; -import org.apache.openejb.config.DeploymentsResolver; -import org.apache.openejb.config.sys.AdditionalDeployments; -import org.apache.openejb.config.sys.Deployments; -import org.apache.openejb.config.sys.JaxbOpenejb; -import org.apache.openejb.loader.FileUtils; -import org.apache.openejb.loader.IO; -import org.apache.openejb.loader.Options; -import org.apache.openejb.loader.SystemInstance; -import org.apache.openejb.server.ejbd.EjbServer; -import org.apache.openejb.spi.ContainerSystem; -import org.apache.openejb.util.URLs; + /** * TomcatService config and starts Tomcat in semi embedded mode. @@ -95,17 +73,8 @@ public class TomcatService { } */ - //org.apache.tomee.catalina.ServerListener + //we use org.apache.tomee.catalina.ServerListener System.setProperty("openejb.servicemanager.enabled", "true"); - System.setProperty("openejb.embedded.remotable", "true"); - System.setProperty("openejb.validation.output.level", "VERBOSE"); - - // System.setProperty("openejb.deployments.classpath", "true"); - // System.setProperty("openejb.deployments.classpath.ear", "true"); - //System.setProperty("openejb.deployments.classpath", "false"); - //System.setProperty("openejb.deployments.classpath.ear", "false"); - //System.setProperty("openejb.deployments.classpath.include", ".*"); - //System.setProperty("openejb.deployments.classpath.exclude", ""); Bootstrap boot = new Bootstrap(); boot.setCatalinaHome(System.getProperty("user.dir")); @@ -129,78 +98,6 @@ public class TomcatService { } } } - - - public static final String ADDITIONAL_DEPLOYMENTS = "conf/deployments.xml"; - private static final String CLASSPATH_AS_EAR = "openejb.deployments.classpath.ear"; - - private List getDeclaredApps() { - // make a copy of the list because we update it - final List deployments = new ArrayList(); - //if (openejb != null) { - // deployments.addAll(openejb.getDeployments()); - //} - File additionalDeploymentFile; - try { - additionalDeploymentFile = SystemInstance.get().getBase().getFile(ADDITIONAL_DEPLOYMENTS, false); - } catch (IOException e) { - additionalDeploymentFile = null; - } - if (additionalDeploymentFile.exists()) { - InputStream fis = null; - try { - fis = IO.read(additionalDeploymentFile); - final AdditionalDeployments additionalDeployments = JaxbOpenejb.unmarshal(AdditionalDeployments.class, fis); - deployments.addAll(additionalDeployments.getDeployments()); - } catch (Exception e) { - e.printStackTrace(); - //logger.error("can't read " + ADDITIONAL_DEPLOYMENTS, e); - } finally { - IO.close(fis); - } - } - - // resolve jar locations ////////////////////////////////////// BEGIN /////// - - final FileUtils base = SystemInstance.get().getBase(); - - final List declaredAppsUrls = new ArrayList(); - try { - for (final Deployments deployment : deployments) { - DeploymentsResolver.loadFrom(deployment, base, declaredAppsUrls); - } - } catch (SecurityException ignored) { - } - return toString(declaredAppsUrls); - } - - public ArrayList getModulesFromClassPath(List declaredApps, final ClassLoader classLoader) { - final FileUtils base = SystemInstance.get().getBase(); - if (declaredApps == null) { - declaredApps = getDeclaredApps(); - } - final List classpathAppsUrls = new ArrayList(); - DeploymentsResolver.loadFromClasspath(base, classpathAppsUrls, classLoader); - - final ArrayList jarFiles = new ArrayList(); - for (final URL path : classpathAppsUrls) { - if (declaredApps.contains(URLs.toFilePath(path))) continue; - - jarFiles.add(new File(URLs.toFilePath(path))); - } - return jarFiles; - } - - private List toString(final List urls) { - final List toReturn = new ArrayList(urls.size()); - for (final URL url : urls) { - try { - toReturn.add(url.toString()); - } catch (Exception ignore) { - } - } - return toReturn; - } public void deploy(String deployContext) throws Exception { Service service = server.findService("Catalina"); @@ -249,103 +146,23 @@ public class TomcatService { logger.info("Deploy war path: "+deployPath); } - Context ctx = new StandardContext(); - ctx.setName(deployContext); - ctx.setPath(deployContext); - ctx.setDocBase(deployPath); - //ctx.setParentClassLoader(commonLoader); - ctx.setConfigured(true); - - ContextConfig ctxCfg = new ContextConfig(); - ctx.addLifecycleListener(ctxCfg); - - VirtualDirContext vDir = new VirtualDirContext(); - vDir.setExtraResourcePaths("../../vasc-demo-tech/vasc-demo-tech-web/target/classes"); - ctx.setResources(vDir); - - //VirtualWebappLoader loader = new VirtualWebappLoader(); - //String cl = System.getProperty("java.class.path").replace(":", ";"); - //logger.info("Virtal class path: "+cl); - //loader.setVirtualClasspath(cl); - //loader.setSearchVirtualFirst(true); - //ctx.setLoader(loader); - - //ctx.getJarScanner().scan - host.addChild(ctx); - - applicationContext = ctx; - - /* - ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); - Deployer dep = (Deployer)containerSystem.getJNDIContext().lookup("java:global/openejb/openejb/Deployer"); - for (AppInfo ai:dep.getDeployedApps()) { - System.out.println("AppInfo: "+ai.appId); - } + ctx.setName(deployContext); + ctx.setPath(deployContext); + ctx.setDocBase(deployPath); + //ctx.setParentClassLoader(commonLoader); + ctx.setConfigured(true); - System.out.println("Deploy JarFile: "+deployPath); - Properties p = new Properties(); - p.setProperty(Deployer.FILENAME, ""+deployPath); - p.setProperty(DeployerEjb.OPENEJB_DEPLOYER_FORCED_APP_ID_PROP, deployContext); - AppInfo app = dep.deploy(p); + ContextConfig ctxCfg = new ContextConfig(); + ctx.addLifecycleListener(ctxCfg); - for (Container c:host.findChildren()) { - System.out.println("Containter: "+c.getName()+" info: "+c.getInfo()); - if ("/webapp".equals(c.getName()) | deployContext.equals(c.getName())) { - applicationContext = (Context)c; - } - } - */ - - /* deploy embedded ejbs . - for (AppInfo ai:dep.getDeployedApps()) { - System.out.println("AppInfo2: "+ai.appId); - } - - final List declaredApps = getDeclaredApps(); - final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - final ArrayList jarFiles = getModulesFromClassPath(declaredApps, classLoader); - try { - for (final File jarFile : jarFiles) { - System.out.println("Deploy JarFile: "+jarFile); - - boolean skip = false; - for (AppInfo ai:dep.getDeployedApps()) { - if ((""+jarFile).contains(ai.appId)) { - System.out.println("Skip deplyo: "+ai.appId); - skip = true; - break; - } - } - if ((""+jarFile).contains("vasc-core-ejb3-server")) { - System.out.println("Skip vasc-core-ejb3-server"); - skip = true; - } - if ((""+jarFile).contains("vasc-xpql-ejb3-server")) { - System.out.println("Skip vasc-xpql-ejb3-server"); - skip = true; - } - if ((""+jarFile).contains("vasc-demo-tech-ejb3")) { - System.out.println("Skip vasc-demo-tech-ejb3"); - skip = true; - } - if (skip) { - continue; - } - - p = new Properties(); - p.setProperty(Deployer.FILENAME, ""+jarFile); - p.setProperty(DeployerEjb.OPENEJB_DEPLOYER_FORCED_APP_ID_PROP, "webapp"); - dep.deploy(p); - } - if (jarFiles.size() == 0) { - logger.warning("config.noModulesFoundToDeploy"); - } + VirtualDirContext vDir = new VirtualDirContext(); + vDir.setExtraResourcePaths("../../vasc-demo-tech/vasc-demo-tech-web/target/classes"); + ctx.setResources(vDir); - } catch (Exception e) { - e.printStackTrace(); - } -*/ + host.addChild(ctx); + + applicationContext = ctx; } public void deployDebug() throws Exception { diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/ServerGuiApplication.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/ServerGuiApplication.java index 6fe1f6f..1b16850 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/ServerGuiApplication.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/ServerGuiApplication.java @@ -32,8 +32,6 @@ import java.awt.SystemTray; import java.awt.TrayIcon; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.io.IOException; import java.io.InputStream; import java.net.URL; @@ -61,6 +59,7 @@ public class ServerGuiApplication extends SingleFrameApplication { private Logger logger = null; private JStatusPanel statusPanel = null; private ImageIcon serverIcon = null; + private UpdateInfoTask updateInfoTask = null; public ServerGuiApplication() { logger = Logger.getLogger(ServerGuiApplication.class.getName()); @@ -75,31 +74,45 @@ public class ServerGuiApplication extends SingleFrameApplication { mainView.setComponent(statusPanel); mainView.getFrame().setMinimumSize(new Dimension(640,480)); mainView.getFrame().setMaximumSize(new Dimension(800,600)); - mainView.getFrame().addWindowListener(new UpdateInfoListener()); show(mainView); startSystemTray(); + + updateInfoTask = new UpdateInfoTask(); + Thread t = new Thread(updateInfoTask); + t.setName(UpdateInfoTask.class.getSimpleName()); + t.start(); } - class UpdateInfoListener extends WindowAdapter { + class UpdateInfoTask implements Runnable { + volatile public boolean run = true; + volatile public boolean doUpdate = true; @Override - public void windowActivated(WindowEvent e) { - System.out.println("vis: opened -ac"); - statusPanel.updateInfo(); + public void run() { + logger.finest("Updating thread started."); + while(run) { + try { + Thread.sleep(1000); + if (doUpdate) { + statusPanel.updateInfo(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + logger.finest("Updating thread stopped."); } - @Override - public void windowDeactivated(WindowEvent e) { - System.out.println("vis: closed - ac"); - } - } class CloseWindowExitListener implements ExitListener { @Override public boolean canExit(EventObject event) { if (event!=null && event.getSource().equals(ServerGuiApplication.this)) { + updateInfoTask.run=false; // app will exit so stop update return true; } else { + logger.finer("Closing application window."); + updateInfoTask.doUpdate=false; // close window ServerGuiApplication.getInstance().getMainFrame().setVisible(false); return false; } @@ -142,6 +155,7 @@ public class ServerGuiApplication extends SingleFrameApplication { aboutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + logger.finer("Systray show about."); JOptionPane.showMessageDialog(ServerGuiApplication.getInstance().getMainFrame(), "Vasc Demo Tech Server:\nIs build to test and demo different parts of the vasc package.", "About Vasc Demo", JOptionPane.PLAIN_MESSAGE); } }); @@ -149,6 +163,8 @@ public class ServerGuiApplication extends SingleFrameApplication { statusItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + logger.finer("Systray open status window."); + updateInfoTask.doUpdate=true; getMainFrame().setVisible(true); } }); @@ -156,6 +172,7 @@ public class ServerGuiApplication extends SingleFrameApplication { exitItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { + logger.finer("Systray exit application."); VascTechDemoStartup.getInstance().shutdown(); } }); diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepWriteFile.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepWriteFile.java index 9ab5736..93c54bb 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepWriteFile.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepWriteFile.java @@ -31,6 +31,7 @@ import java.io.StringWriter; import java.io.Writer; import javax.swing.JComponent; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; @@ -93,25 +94,23 @@ public class JLoadStepWriteFile extends JPanel implements LoadStep,ActionListene text.setText(out.getBuffer().toString()); } catch (Exception e) { e.printStackTrace(); + JOptionPane.showMessageDialog(null, "Fatal error:\n"+e.getMessage(), "Generate xml error", JOptionPane.ERROR_MESSAGE); } } @Override public boolean performStep(LoadStepData model) { - try { - VascController vc = VascTechDemoStartup.getInstance().getVascControllerService().getVascController(); - File tmpFile = new File("conf/vasc.d/"+model.filename);// File.createTempFile("vasc","xml"); - System.out.println("write to : "+tmpFile); - Writer out = new OutputStreamWriter(new FileOutputStream(tmpFile)); - XMLWriter outXml = new XMLWriter(out); - LoadVascXmlWriter writer = new LoadVascXmlWriter(outXml,vc); - writer.writeXml(model); - - + File writeFile = new File("conf/vasc.d/"+model.filename); + System.out.println("write to : "+writeFile); + Writer out = new OutputStreamWriter(new FileOutputStream(writeFile)); + out.append(text.getText()); + out.flush(); + out.close(); } catch (Exception e) { - // TODO Auto-generated catch block e.printStackTrace(); + JOptionPane.showMessageDialog(null, "Fatal error:\n"+e.getMessage(), "Write file error", JOptionPane.ERROR_MESSAGE); + return false; } return true; } diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/core/service/resources/init-db.sql b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/core/service/resources/init-db.sql index 39c5c8f..589d53a 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/core/service/resources/init-db.sql +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/core/service/resources/init-db.sql @@ -39,7 +39,6 @@ CREATE TABLE vasc_page ( id IDENTITY not null primary key, slug varchar not null, title varchar not null, - i18n_key boolean not null, active boolean not null, sitemap boolean not null, roles varchar not null @@ -52,7 +51,6 @@ CREATE TABLE vasc_page_part ( page_id integer not null, title varchar not null, text varchar not null, - i18n_key boolean not null, active boolean not null, sitemap boolean not null, part_order integer not null, @@ -92,45 +90,51 @@ INSERT INTO vasc_user_change_field VALUES(2,'Password', 'password', TRUE); INSERT INTO vasc_user_change_field VALUES(3,'Description', 'description', TRUE); INSERT INTO vasc_user_change_field VALUES(4,'Birthdate', 'date_age', TRUE); --- ID SLUG TITLE I18N ACTIVE SITEMAP -INSERT INTO vasc_page VALUES(4, 'debug', 'Debug', FALSE, TRUE, FALSE, ''); -INSERT INTO vasc_page VALUES(5, 'contact', '', TRUE, TRUE, TRUE, ''); -INSERT INTO vasc_page VALUES(6, 'help', '', TRUE, TRUE, TRUE, ''); +-- ID SLUG TITLE ATIVE SITEMAP +INSERT INTO vasc_page VALUES(1, 'contact', 'Contact', TRUE, TRUE, ''); +INSERT INTO vasc_page VALUES(2, 'techno', 'Techno', TRUE, TRUE, ''); +INSERT INTO vasc_page VALUES(3, 'help', 'Help', TRUE, TRUE, ''); +INSERT INTO vasc_page VALUES(4, 'config', 'Config', TRUE, FALSE, ''); -INSERT INTO vasc_page_part VALUES(1, 4, 'vasc', '', TRUE,TRUE,TRUE,1,'HTML', ''); -INSERT INTO vasc_page_part VALUES(2, 4, 'jdbc', '', TRUE,TRUE,TRUE,2,'HTML', ''); -INSERT INTO vasc_page_part VALUES(3, 4, 'jndi', '', TRUE,TRUE,TRUE,3,'HTML', ''); -INSERT INTO vasc_page_part VALUES(4, 4, 'logback', '', TRUE,TRUE,TRUE,3,'HTML', ''); +INSERT INTO vasc_page_part VALUES(1, 1, 'Project', 'The vasc project is build for amazing ease of editing data.', TRUE,TRUE,1,'HTML', ''); +INSERT INTO vasc_page_part VALUES(2, 1, 'Website', 'VASC: Website', TRUE,TRUE,2,'HTML', ''); -INSERT INTO vasc_page_part VALUES(5, 5, 'project', '', TRUE,TRUE,TRUE,1,'WIKI', ''); -INSERT INTO vasc_page_part VALUES(6, 5, 'support', '', TRUE,TRUE,TRUE,2,'WIKI', ''); -INSERT INTO vasc_page_part VALUES(7, 5, 'location', '', TRUE,TRUE,TRUE,3,'HTML', ''); +INSERT INTO vasc_page_part VALUES(3, 2, 'Used technologies.', 'Example: XML,JSF,JDBC,etc', TRUE,TRUE,1,'HTML', ''); +INSERT INTO vasc_page_part VALUES(4, 2, 'Used liberies', 'Todo make long list ?', TRUE,TRUE,2,'HTML', ''); -INSERT INTO vasc_page_part VALUES(8, 6, 'server', '', TRUE,TRUE,TRUE,1,'WIKI', ''); -INSERT INTO vasc_page_part VALUES(9, 6, 'vasc', '', TRUE,TRUE,TRUE,2,'WIKI', ''); -INSERT INTO vasc_page_part VALUES(10,6, 'metamodel','', TRUE,TRUE,TRUE,3,'WIKI', ''); +INSERT INTO vasc_page_part VALUES(5, 3, 'Documenation.', 'See docs directory.', TRUE,TRUE,1,'HTML', ''); +INSERT INTO vasc_page_part VALUES(6, 3, 'Mailing list.', 'Goto some page to see.', TRUE,TRUE,2,'HTML', ''); + +INSERT INTO vasc_page_part VALUES(10, 4, 'Vasc', 'Config entries in conf/vasc.d directory.', TRUE,TRUE,1,'HTML', ''); +INSERT INTO vasc_page_part VALUES(11, 4, 'Jdbc', 'Config in vasc xml or context.xml', TRUE,TRUE,2,'HTML', ''); +INSERT INTO vasc_page_part VALUES(12, 4, 'Jndi', 'Example of data source.', TRUE,TRUE,3,'HTML', ''); +INSERT INTO vasc_page_part VALUES(13, 4, 'Logback', 'Change logging options.', TRUE,TRUE,3,'HTML', ''); -- INSERT INTO vasc_page VALUES(1, 'home','home','Welcome to the vasc demo, please login as admin to view all stuff.'); -INSERT INTO vasc_menu_web VALUES(1, '/html/index.jsf','Home', '',true,'',1,'BAR_RIGHT'); -INSERT INTO vasc_menu_web VALUES(2, '/html/admin/debug.jsf','Debug','',true,'admin',2,'BAR_RIGHT'); -INSERT INTO vasc_menu_web VALUES(3, '/html/admin/index.jsf','Admin','',true,'admin',3,'BAR_RIGHT'); +INSERT INTO vasc_menu_web VALUES(1, '/html/index.jsf','Home', '',true,'' ,1,'BAR_LEFT'); +INSERT INTO vasc_menu_web VALUES(2, '/html/admin/debug.jsf','Debug','',true,'admin' ,2,'BAR_LEFT'); +INSERT INTO vasc_menu_web VALUES(3, '/html/admin/index.jsf','Admin','',true,'admin' ,3,'BAR_LEFT'); -INSERT INTO vasc_menu_web VALUES(4, '/html/index.jsf','Home', '',true,'',1,'BAR_BOTTOM'); -INSERT INTO vasc_menu_web VALUES(5, '/html/index.jsf','Contact', '',true,'',2,'BAR_BOTTOM'); -INSERT INTO vasc_menu_web VALUES(6, '/html/index.jsf','Help', '',true,'',3,'BAR_BOTTOM'); -INSERT INTO vasc_menu_web VALUES(7, '/html/index.jsf','Techno', '',true,'',3,'BAR_BOTTOM'); -INSERT INTO vasc_menu_web VALUES(8, '/html/index.jsf','Licences', '',true,'',3,'BAR_BOTTOM'); +INSERT INTO vasc_menu_web VALUES(4, '/html/index.jsf', 'Home', '',true,'' ,1,'BAR_BOTTOM'); +INSERT INTO vasc_menu_web VALUES(5, '/page/contact', 'Contact', '',true,'' ,2,'BAR_BOTTOM'); +INSERT INTO vasc_menu_web VALUES(6, '/page/help', 'Help', '',true,'' ,3,'BAR_BOTTOM'); +INSERT INTO vasc_menu_web VALUES(7, '/page/techno', 'Techno', '',true,'' ,4,'BAR_BOTTOM'); -INSERT INTO vasc_menu_web VALUES(10, '/vasc/AdminVascUser/list.jsf', 'Users', '',true,'admin',4,'PAGE_ADMIN'); -INSERT INTO vasc_menu_web VALUES(11, '/vasc/AdminVascUserRole/list.jsf', 'UserRoles', '',true,'admin',5,'PAGE_ADMIN'); -INSERT INTO vasc_menu_web VALUES(12, '/vasc/AdminVascUserChangeField/list.jsf', 'ChangeField', '',true,'admin',5,'PAGE_ADMIN'); -INSERT INTO vasc_menu_web VALUES(13, '/vasc/AdminVascUserChangeLog/list.jsf', 'ChangeFieldLog', '',true,'admin',5,'PAGE_ADMIN'); +INSERT INTO vasc_menu_web VALUES(8, '/page/contact', 'Contact', '',true,'' ,1,'BAR_RIGHT'); +INSERT INTO vasc_menu_web VALUES(9, '/page/help', 'Help', '',true,'' ,2,'BAR_RIGHT'); -INSERT INTO vasc_menu_web VALUES(14, '/vasc/AdminVascPage/list.jsf', 'Pages', '',true,'admin',5,'PAGE_ADMIN'); -INSERT INTO vasc_menu_web VALUES(15, '/vasc/AdminVascPagePart/list.jsf', 'PageParts', '',true,'admin',5,'PAGE_ADMIN'); -INSERT INTO vasc_menu_web VALUES(16, '/vasc/AdminVascMenu/list.jsf', 'Menu', '',true,'admin',4,'PAGE_ADMIN'); +INSERT INTO vasc_menu_web VALUES(10, '/html/user/profile.jsf', 'Profile', '',true,'login',4,'MAIN_MENU_0'); +INSERT INTO vasc_menu_web VALUES(11, '/vasc/VascEntry/list.jsf', 'VascEntries', '',true,'admin',5,'MAIN_MENU_0'); + +INSERT INTO vasc_menu_web VALUES(20, '/vasc/AdminVascUser/list.jsf', 'Users', '',true,'admin',4,'PAGE_ADMIN'); +INSERT INTO vasc_menu_web VALUES(21, '/vasc/AdminVascUserRole/list.jsf', 'UserRoles', '',true,'admin',5,'PAGE_ADMIN'); +INSERT INTO vasc_menu_web VALUES(22, '/vasc/AdminVascUserChangeField/list.jsf', 'ChangeField', '',true,'admin',5,'PAGE_ADMIN'); +INSERT INTO vasc_menu_web VALUES(23, '/vasc/AdminVascUserChangeLog/list.jsf', 'ChangeFieldLog', '',true,'admin',5,'PAGE_ADMIN'); +INSERT INTO vasc_menu_web VALUES(24, '/vasc/AdminVascPage/list.jsf', 'Pages', '',true,'admin',5,'PAGE_ADMIN'); +INSERT INTO vasc_menu_web VALUES(25, '/vasc/AdminVascPagePart/list.jsf', 'PageParts', '',true,'admin',5,'PAGE_ADMIN'); +INSERT INTO vasc_menu_web VALUES(26, '/vasc/AdminVascMenu/list.jsf', 'Menu', '',true,'admin',4,'PAGE_ADMIN'); diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/ServerGuiApplication.properties b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/ServerGuiApplication.properties index ff7165d..eafaf72 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/ServerGuiApplication.properties +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/ServerGuiApplication.properties @@ -43,6 +43,7 @@ Application.web.footer.center = Vasc Tech Demo Web Based on JSF and Faclets and Application.web.footer.left = Copyright © 2012 Application.web.footer.right = Version 0.4.x(beta) +generic.all = All generic.active.labelText = active generic.active.toolTipText = active generic.createdDate.labelText = createdDate @@ -58,6 +59,10 @@ generic.name.toolTipText = name generic.orderNumber.labelText = orderNumber generic.orderNumber.toolTipText = orderNumber +menu.mainMenu0.title = Menu +menu.mainMenu1.title = Menu +menu.mainMenu2.title = Menu + # hibernate validators validator.assertFalse=assertion failed validator.assertTrue=assertion failed @@ -112,7 +117,8 @@ vasc.action.jrXmlExportAction.description = JR-XML vasc.action.jrXmlExportAction.name = JR-XML vasc.action.jrCsvExportAction.description = JR-CSV vasc.action.jrCsvExportAction.name = JR-CSV - +vasc.action.jsonExportAction.description = JSON +vasc.action.jsonExportAction.name = JSON # Temp jsf generic.vasc.jsf.listOption.header = Searchoptions diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerImpl.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerImpl.java index 09af0cc..4405595 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerImpl.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerImpl.java @@ -208,36 +208,4 @@ public class VascMenuControllerImpl implements VascMenuControllerLocal,VascMenuC Collections.sort(result,vascMenuWebComparator); return result; } - - private List getMenuFiltered(VascMenuWebType type) { - return getFilteredMenuWeb(type); - } - - public List getMenuBarLeft() { - return getMenuFiltered(VascMenuWebType.BAR_LEFT); - } - - public List getMenuBarRight() { - return getMenuFiltered(VascMenuWebType.BAR_RIGHT); - } - - public List getMenuBarBottom() { - return getMenuFiltered(VascMenuWebType.BAR_BOTTOM); - } - - public List getMenuPageIndex() { - return getMenuFiltered(VascMenuWebType.PAGE_INDEX); - } - - public List getMenuPageUserLeft() { - return getMenuFiltered(VascMenuWebType.PAGE_USER_LEFT); - } - - public List getMenuPageUserRight() { - return getMenuFiltered(VascMenuWebType.PAGE_USER_RIGHT); - } - - public List getMenuPageAdmin() { - return getMenuFiltered(VascMenuWebType.PAGE_ADMIN); - } } \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuWebType.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuWebType.java index 05c3190..31dd3a2 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuWebType.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuWebType.java @@ -34,6 +34,10 @@ public enum VascMenuWebType { BAR_RIGHT, BAR_BOTTOM, + MAIN_MENU_0, + MAIN_MENU_1, + MAIN_MENU_2, + PAGE_INDEX, PAGE_USER_LEFT, PAGE_USER_RIGHT, diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/MenuController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/MenuController.java index 76f6464..c8afc0e 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/MenuController.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/MenuController.java @@ -23,23 +23,13 @@ package net.forwardfire.vasc.demo.tech.web.beans; import java.io.Serializable; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import javax.ejb.EJB; -import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import javax.sql.DataSource; import net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuController; import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroup; -import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebComparator; import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWeb; import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebType; @@ -52,7 +42,6 @@ import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebType; public class MenuController implements Serializable { private static final long serialVersionUID = -6820749860984575869L; - private List userVascMenu = null; private UserController userController = null; private VascMenuController vascMenuController = null; @@ -108,6 +97,17 @@ public class MenuController implements Serializable { return getMenuFiltered(VascMenuWebType.PAGE_ADMIN); } + public List getMainMenu0() { + return getMenuFiltered(VascMenuWebType.MAIN_MENU_0); + } + + public List getMainMenu1() { + return getMenuFiltered(VascMenuWebType.MAIN_MENU_1); + } + + public List getMainMenu2() { + return getMenuFiltered(VascMenuWebType.MAIN_MENU_2); + } /** * @return the userController diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/VascPageController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/VascPageController.java index 0bd1d11..f2875f0 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/VascPageController.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/VascPageController.java @@ -23,24 +23,34 @@ package net.forwardfire.vasc.demo.tech.web.pages; import java.io.Serializable; +import java.lang.reflect.Method; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; -import java.util.Collections; import java.util.List; +import javax.faces.context.FacesContext; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; +import javax.servlet.ServletRequest; import javax.sql.DataSource; -import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebComparator; +import de.tudarmstadt.ukp.wikipedia.parser.ParsedPage; +import de.tudarmstadt.ukp.wikipedia.parser.Section; +import de.tudarmstadt.ukp.wikipedia.parser.html.HtmlWriter; +import de.tudarmstadt.ukp.wikipedia.parser.mediawiki.MediaWikiParser; +import de.tudarmstadt.ukp.wikipedia.parser.mediawiki.MediaWikiParserFactory; + import net.forwardfire.vasc.demo.tech.web.beans.UserController; +import net.forwardfire.vasc.demo.tech.web.pages.model.VascPage; +import net.forwardfire.vasc.demo.tech.web.pages.model.VascPagePart; +import net.forwardfire.vasc.demo.tech.web.pages.model.VascPagePartType; /** - * MenuController Shows the menu for the user. + * VascPageController very hacky page context controller. * * @author Willem Cazander * @version 1.0 May 19, 2012 @@ -48,40 +58,32 @@ import net.forwardfire.vasc.demo.tech.web.beans.UserController; public class VascPageController implements Serializable { private static final long serialVersionUID = -6820749860984575869L; - //private List userVascMenu = null; - //private VascMenuComparator vascMenuComparator = null; private UserController userController = null; + private VascPage page = null; - /* - public List fetchVascPage() { - - vascMenuComparator = new VascMenuComparator(); - userVascMenu = new ArrayList(50); - - - + public VascPage fetchVascPage(String slug) { + VascPage result = null; Connection connection = null; try { DataSource ds = getDataSource("java:comp/env/jdbc/DemoManagerDataDS"); connection = ds.getConnection(); Statement s = connection.createStatement(); - s.execute("SELECT * FROM VASC_MENU"); + s.execute("SELECT * FROM VASC_PAGE WHERE SLUG='"+slug+"'"); // bad so redo .. ResultSet rs = s.getResultSet(); - //int cols = rs.getMetaData().getColumnCount(); - while (rs.next()) { - VascMenu menu = new VascMenu(); - menu.setId(rs.getInt(1)); - menu.setHref(rs.getString(2)); - menu.setTitle(rs.getString(3)); - menu.setTarget(rs.getString(4)); - menu.setActive(rs.getBoolean(5)); - menu.setRoles(rs.getString(6)); + if (rs.next()) { + result = new VascPage(); + result.setId(rs.getInt(1)); + result.setSlug(rs.getString(2)); + result.setTitle(rs.getString(3)); + result.setActive(rs.getBoolean(4)); + result.setSitemap(rs.getBoolean(5)); + result.setRoles(rs.getString(6)); + /* menu.setMenuOrder(rs.getInt(7)); menu.setMenuType(VascMenuType.valueOf(rs.getString(8))); if (filterVascMenuRoles(menu)==false) { continue; - } - userVascMenu.add(menu); + }*/ } } catch (Exception e) { e.printStackTrace(); @@ -93,8 +95,48 @@ public class VascPageController implements Serializable { } } } - - return userVascMenu; + return result; + } + + public List fetchVascPageParts(int pageId) { + List result = new ArrayList(50); + Connection connection = null; + try { + DataSource ds = getDataSource("java:comp/env/jdbc/DemoManagerDataDS"); + connection = ds.getConnection(); + Statement s = connection.createStatement(); + s.execute("SELECT * FROM VASC_PAGE_PART WHERE PAGE_ID="+pageId); // bad + ResultSet rs = s.getResultSet(); + while (rs.next()) { + VascPagePart menu = new VascPagePart(); + menu.setId(rs.getInt(1)); + menu.setPageId(rs.getInt(2)); + menu.setTitle(rs.getString(3)); + menu.setText(rs.getString(4)); + menu.setActive(rs.getBoolean(5)); + menu.setSitemap(rs.getBoolean(6)); + menu.setPartOrder(rs.getInt(7)); + menu.setPartType(VascPagePartType.valueOf(rs.getString(8))); + menu.setRoles(rs.getString(9)); + /* + menu.setMenuOrder(rs.getInt(7)); + menu.setMenuType(VascMenuType.valueOf(rs.getString(8))); + if (filterVascMenuRoles(menu)==false) { + continue; + }*/ + result.add(menu); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (connection!=null) { + try { + connection.close(); + } catch (Exception e) { + } + } + } + return result; } private DataSource getDataSource(String name) throws SQLException { @@ -110,6 +152,7 @@ public class VascPageController implements Serializable { } } + /* private boolean filterVascMenuRoles(VascMenu menu) { if (menu.getActive()!=null && menu.getActive()==false) { return false; @@ -127,30 +170,100 @@ public class VascPageController implements Serializable { } return true; } + */ - private List getMenuFiltered(VascMenuType type) { - if (type==null) { - throw new NullPointerException("Can't filter on null type."); + public VascPage getPage() { + + FacesContext context = FacesContext.getCurrentInstance(); + String pageId = (String)((ServletRequest)context.getExternalContext().getRequest()).getAttribute("pageId"); + + if (pageId==null) { + return null; // todo send somewhere } - List result = new ArrayList(15); - for (VascMenu menu:fetchVascMenu()) { - if (type.equals(menu.getMenuType())) { - result.add(menu); + if (page!=null && page.getSlug().equals(pageId)) { + return page; + } + + page = fetchVascPage(pageId); + page.getPageParts().addAll(fetchVascPageParts(page.getId())); + + return page; + } + + public String renderContent(VascPagePart part) { + if (part==null) { + return ""; + } + if (VascPagePartType.HTML.equals(part.getPartType())) { + return part.getText(); + } else if (VascPagePartType.PRE.equals(part.getPartType())) { + return "
"+part.getText()+"
\n"; + } else { + MediaWikiParserFactory pf = new MediaWikiParserFactory(); + MediaWikiParser parser = pf.createParser(); + ParsedPage page = parser.parse(part.getText()); + String result = FixedHtmlWriter.parsedPageToHtml(page); + return result; + } + } + + static class FixedHtmlWriter extends HtmlWriter { + public static String parsedPageToHtml( ParsedPage pp ){ + StringBuilder result = new StringBuilder(); + + if( pp != null ) { + //Title + result.append( + "\n"+ + "\n"); + + //Sections + result.append( + "\n"); + + //Categories + if( pp.getCategoryElement()!= null ){ + result.append("\n"); + } + + //Languages + if( pp.getLanguagesElement()!= null ){ + result.append("\n"); + } + + //Finalize + result.append("
ParsedPage: \n" + + pp.getName()+ + "
\n" ); + for( Section s: pp.getSections() ) { + result.append( invokePrivate("sectionToHtml",s)); + } + result.append( + "
\n"); + result.append("Categories:\n" + invokePrivate("contentElementToHtml",pp.getCategoryElement() )); + result.append("
\n"); + result.append("Languages:\n" + invokePrivate("contentElementToHtml",pp.getLanguagesElement() )); + result.append("
\n"); + } + + return result.toString(); + } + + static private String invokePrivate(String method,Object arg) { + for (Method m:FixedHtmlWriter.class.getDeclaredMethods()) { + if (m.getName().equals(method)) { + m.setAccessible(true); + try { + return (String)m.invoke(null, arg); + } catch (Exception e) { + e.printStackTrace(); + } + } } + return ""; } - Collections.sort(result,vascMenuComparator); - return result; } - public List getMenuBarLeft() { - return getMenuFiltered(VascMenuType.BAR_LEFT); - } - - public List getMenuBarRight() { - return getMenuFiltered(VascMenuType.BAR_RIGHT); - } -*/ - /** * @return the userController */ diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/VascPageFilter.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/VascPageFilter.java new file mode 100644 index 0000000..e277b8c --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/VascPageFilter.java @@ -0,0 +1,160 @@ +/* + * 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.pages; + +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.faces.FactoryFinder; +import javax.faces.application.ViewExpiredException; +import javax.faces.component.UIViewRoot; +import javax.faces.context.FacesContext; +import javax.faces.context.FacesContextFactory; +import javax.faces.lifecycle.Lifecycle; +import javax.faces.lifecycle.LifecycleFactory; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * VascPageServket + * + * @author Willem Cazander + * @version 1.0 Nov 29, 2012 + */ +public class VascPageFilter implements Filter { + + + private Logger logger = null; + private String templateFile = null; + private ServletContext servletContext = null; + + /** + * @see javax.servlet.Filter#destroy() + */ + public void destroy() { + servletContext = null; + templateFile = null; + logger = null; + } + + /** + * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) + */ + public void init(FilterConfig config) throws ServletException { + logger = Logger.getLogger(VascPageFilter.class.getName()); + servletContext = config.getServletContext(); + templateFile = config.getInitParameter("templateFile"); + if (templateFile==null) { + throw new ServletException("No templateFile init-param found."); + } + } + + /** + * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) + */ + public void doFilter(ServletRequest servletRequest,ServletResponse servletResponse,FilterChain chain) throws IOException, ServletException { + + HttpServletRequest request = (HttpServletRequest)servletRequest; + HttpServletResponse response = (HttpServletResponse)servletResponse; + + // request info + String path = request.getRequestURI(); + String v = "/page/"; + if (path.contains(v)) { + path = path.substring(path.indexOf(v)+v.length()); + } + + // stuff to fill + String pageId = null; + String actionName = null; + String actionRecordId = null; + + // parse request info + //path = path.substring(1); // rm / + int index = path.indexOf("/"); // check next / + String actionString = null; + if (index>0) { + actionString = path.substring(index+1); + pageId = path.substring(0,index); + } else { + pageId = path; + } + + if (actionString!=null) { + index = actionString.indexOf("/"); + String recordString = null; + if (index>0) { + recordString = actionString.substring(index+1); + actionName = actionString.substring(0,index); + } else { + actionName = actionString; + } + if (recordString!=null) { + actionRecordId = recordString; + } + } + + //log + if (logger.isLoggable(Level.FINE)) { + logger.log(Level.FINE,"pageId="+pageId+" actionName="+actionName+" actionRecordId="+actionRecordId); + } + + // Acquire the FacesContext instance for this request + FacesContext facesContext = FacesContext.getCurrentInstance(); + if (facesContext == null) { + FacesContextFactory facesContextFactory = (FacesContextFactory)FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); + LifecycleFactory lifecycleFactory = (LifecycleFactory)FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); + Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE); + + facesContext = facesContextFactory.getFacesContext(servletContext, request, response, lifecycle); + ProtectedFacesContext.setFacesContextAsCurrentInstance(facesContext); + + UIViewRoot viewRoot = facesContext.getApplication().getViewHandler().createView(facesContext,pageId+actionName); + facesContext.setViewRoot(viewRoot); + } + + // add to request attributes + request.setAttribute("pageId", pageId); + + // And dispatch to the vasc template file. + try { + request.getRequestDispatcher(templateFile).forward(request, response); + } catch (ViewExpiredException e) { + response.sendRedirect(request.getRequestURL().toString()); // lets try again + } + } + + private abstract static class ProtectedFacesContext extends FacesContext { + protected static void setFacesContextAsCurrentInstance(FacesContext facesContext) { + FacesContext.setCurrentInstance(facesContext); + } + } +} \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPage.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPage.java index 8848299..dd7fd7d 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPage.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPage.java @@ -22,6 +22,9 @@ package net.forwardfire.vasc.demo.tech.web.pages.model; +import java.util.ArrayList; +import java.util.List; + /** @@ -35,10 +38,10 @@ public class VascPage { private Integer id = null; private String slug = null; private String title = null; - private Boolean i18nKey = null; private Boolean active = null; private Boolean sitemap = null; private String roles = null; + private List pageParts = new ArrayList(); /** * @return the id @@ -81,20 +84,6 @@ public class VascPage { this.title = title; } - /** - * @return the i18nKey - */ - public Boolean getI18nKey() { - return i18nKey; - } - - /** - * @param i18nKey the i18nKey to set - */ - public void setI18nKey(Boolean i18nKey) { - this.i18nKey = i18nKey; - } - /** * @return the active */ @@ -119,7 +108,7 @@ public class VascPage { /** * @param sitemap the sitemap to set */ - public void setSiteMap(Boolean sitemap) { + public void setSitemap(Boolean sitemap) { this.sitemap = sitemap; } @@ -135,5 +124,19 @@ public class VascPage { */ public void setRoles(String roles) { this.roles = roles; - } + } + + /** + * @return the pageParts + */ + public List getPageParts() { + return pageParts; + } + + /** + * @param pageParts the pageParts to set + */ + public void setPageParts(List pageParts) { + this.pageParts = pageParts; + } } diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPagePart.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPagePart.java index b72d7eb..b7d3ed9 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPagePart.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/pages/model/VascPagePart.java @@ -33,10 +33,9 @@ package net.forwardfire.vasc.demo.tech.web.pages.model; public class VascPagePart { private Integer id = null; - private VascPage vascPage = null; + private Integer pageId = null; private String title = null; private String text = null; - private Boolean i18nKey = null; private Boolean active = null; private Boolean sitemap = null; private Integer partOrder = null; @@ -58,19 +57,19 @@ public class VascPagePart { } /** - * @return the vascPage + * @return the pageId */ - public VascPage getVascPage() { - return vascPage; + public Integer getPageId() { + return pageId; } - + /** - * @param vascPage the vascPage to set + * @param pageId the pageId to set */ - public void setVascPage(VascPage vascPage) { - this.vascPage = vascPage; + public void setPageId(Integer pageId) { + this.pageId = pageId; } - + /** * @return the title */ @@ -99,20 +98,6 @@ public class VascPagePart { this.text = text; } - /** - * @return the i18nKey - */ - public Boolean getI18nKey() { - return i18nKey; - } - - /** - * @param i18nKey the i18nKey to set - */ - public void setI18nKey(Boolean i18nKey) { - this.i18nKey = i18nKey; - } - /** * @return the active */ 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 611e025..5c870f8 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 @@ -45,6 +45,17 @@ + + Controls the Pages + pageController + net.forwardfire.vasc.demo.tech.web.pages.VascPageController + session + + userController + #{userController} + + + Controls Vasc Export Url Generator exportController diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-wiki.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-wiki.xhtml index 5a4f401..422f2a5 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-wiki.xhtml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/page-wiki.xhtml @@ -4,15 +4,17 @@ xmlns:jawr="https://jawr.dev.java.net/jsf/facelets" > - + - +

- +

+ +

diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-footer.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-footer.xhtml index 452b250..26ced5d 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-footer.xhtml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-footer.xhtml @@ -5,22 +5,24 @@ xmlns:f="http://java.sun.com/jsf/core" > -
-
- - - - - - - - - - - - -
-
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-login.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-login.xhtml new file mode 100644 index 0000000..e6eebd2 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-login.xhtml @@ -0,0 +1,21 @@ + +
+ + + + + + + + + + + + +
+
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-menu.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-menu.xhtml index 9daa9eb..b6c46a8 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-menu.xhtml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-menu.xhtml @@ -5,17 +5,53 @@ xmlns:f="http://java.sun.com/jsf/core" >
+ +
+

+ +

+ +
+
+ +
+

+ +

+ +
+
+ +
+

+ +

+ +
+
- diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body.xhtml index 6fdf001..1770875 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body.xhtml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body.xhtml @@ -6,6 +6,9 @@ >
+ + + @@ -21,10 +24,10 @@

- - -
+ + +
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/web.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/web.xml index 68cdd5d..163d762 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/web.xml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/web.xml @@ -212,27 +212,6 @@ vascFilter /vasc/* REQUEST - - - - - VASC Filter - vascFilterServerAdmin - net.forwardfire.vasc.frontend.web.jsf.VascRequestFacesFilter - - templateFile - /WEB-INF/template/page-vasc.jsf - - - vascControllerProvider - java:comp/env/vasc/server-admin@net.forwardfire.vasc.impl.jndi.JndiVascControllerProvider - - - - vascFilterServerAdmin - /server-admin/* - REQUEST - @@ -267,6 +246,23 @@ /cxf/* + + + + Page Filter + pageFilter + net.forwardfire.vasc.demo.tech.web.pages.VascPageFilter + + templateFile + /WEB-INF/template/page-wiki.jsf + + + + pageFilter + /page/* + REQUEST + + @@ -297,14 +293,13 @@ - - EjbServerServlet - org.apache.openejb.server.httpd.ServerServlet - - - - EjbServerServlet - /ejb/* - + + EjbServerServlet + org.apache.openejb.server.httpd.ServerServlet + + + EjbServerServlet + /ejb/* + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/site.css b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/site.css deleted file mode 100644 index 125f5cc..0000000 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/site.css +++ /dev/null @@ -1,334 +0,0 @@ - -body { - color:#000000; - background-color:#FFFFFF; -} - -h1 { - font-size:1.2em; - font-weight:bold; - padding-bottom:10px; -} - -h2 { - border-radius:3px; - display:block; - font-size:1.0em; - font-weight:bold; - padding:10px 10px 10px 10px; -} - -p { - margin:10px 10px 10px 10px; -} - -img { - border:none; - vertical-align: middle; -} - -ul { - margin-left:10px; -} - -a { - text-decoration:underline; -} - - -/* DIVS */ - - -/* MENU */ - -#page_menu_left,#page_menu_right { - border-color:#DDCCCC; - border-style:solid; - border-width:0 0 1px 0; - vertical-align:bottom; - display:inline; -} - -#page_menu_right { - position:absolute; - bottom:0; - right:0; -} - -#page_menu_left a,#page_menu_right a { - border:1px solid #e0e0e0; - background-color:#DDCCCC; - border-bottom-width:0px; - text-align:center; - -moz-border-radius-topleft:3xp; - -moz-border-radius-topright:3xp; - -webkit-border-top-left-radius:3px; - -webkit-border-top-right-radius:3px; - -khtml-border-radius-topleft:3px; - -khtml-border-radius-topright:3px; - color:#000; - margin:0px 5px 0px 0px; - padding:3px 15px 2px 15px; - text-decoration:none; -} - -#page_menu_left a:hover,#page_menu_right a:hover { - text-decoration:none; - background-color:#fff; - border-color:#e0e0e0; -} - -#page_menu_left a.active,#page_menu_left a.active { - background-color:#fff; - font-weight:700; -} - -#page_user_info { - padding:5px; - position:absolute; - right:0; - top:0; - font-size:11px; -} - - - - - -/* TABLES */ -/* -#m_content table { - text-align: left; -} -*/ - -table.table5, table.rating_table { - border-collapse:collapse; - font-size:11px; - width:100%; - margin-bottom: 30px; -} - -table.table5 th, table.rating_table th { - padding-top:5px; - padding-bottom:5px; - font-weight:700; - text-align:left; - vertical-align:top; - padding-left: 3px; -} - -table.table5 td, table.rating_table td { - vertical-align:top; - padding-top:5px; - padding-bottom:5px; - padding-left: 3px; -} - -.dataTableHeaderRow { - border:1px solid #e0e0e0; - background-color:#e4e4e4; - border-bottom-width:0; -} - -.dataTableHeaderRow th, td { - padding-right: 5px; -} - -table input,table select { - font-size: 11px; - margin-left:6px; - margin-right:6px; -} - -table.table5 tr:nth-child(even) { - background-color:#f0f0f0; -} - -.table_options_top { - -moz-border-radius-topleft:3px; - -moz-border-radius-topright:3px; - background-color:#DDCCCC; - font-size:12px; - font-weight:700; - padding:6px 15px; - display: block; -} - -.table_options_bottom { - -moz-border-radius-bottomleft:3px; - -moz-border-radius-bottomright:3px; - background-color:#DDCCCC; - font-size:12px; - font-weight:700; - padding:6px 15px; - display: block; - - margin-top:5px; -} - - -.table_sub_header { - -moz-border-radius-topleft:5px; - -moz-border-radius-topright:5px; - background-color:#EEEEEE; - border:1px solid #BBBBBB; - display:block; - font-size:14px; - font-weight:700; - margin:0 2px; - padding:3px 6px; - text-align:center; -} - - - - - - -/* MESSAGES */ - -.message_info, -.message_1 { - display:block; - font-size: 14px; - font-weight: bold; - border:solid 1px #a0ff7d; - -moz-border-radius:3px; - -webkit-border-radius:3px; - -khtml-border-radius:3px; - background-color: #a0ff7d; - padding: 15px 15px; - margin-bottom: 15px; -} - -.message_warning, -.message_2 { - display:block; - font-size: 14px; - font-weight: bold; - border:solid 1px #ffae4c; - -moz-border-radius:3px; - -webkit-border-radius:3px; - -khtml-border-radius:3px; - background-color: #ffae4c; - padding: 15px 15px; - margin-bottom: 15px; -} - -.message_error, -.message_3 { - display:block; - font-size: 14px; - font-weight: bold; - border:solid 1px #ff5b43; - -moz-border-radius:3px; - -webkit-border-radius:3px; - -khtml-border-radius:3px; - background-color: #ff5b43; - padding: 15px 15px; - margin-bottom: 15px; -} - -.message_4 { - display:block; - font-size: 14px; - font-weight: bold; - border:solid 1px #fc9200; - background-color: #fc9200; - -moz-border-radius-topleft:3px; - -webkit-border-top-left-radius:3px; - -khtml-border-radius-topleft:3px; - -moz-border-radius-topright:3px; - -webkit-border-top-right-radius:3px; - -khtml-border-radius-topright:3px; - padding: 5px; - margin-bottom: 10px; -} - -.message_1 input, .message_1 button, .message_2 input, .message_2 button, .message_3 input, .message_3 button { - margin:0px; -} - -.message_4 h2 { - margin: 0px; - padding:5px; -} - -.message_4 input { - margin: 0px; - font-weight: bold; - font-size: 14px; - padding: 2px 5px; - margin-right: 5px; -} - -/* LOGINBOX */ - - - - - -/* -** WIKI styles -*/ - -#toc, -.toc, -.mw-warning { - border: 1px solid #aaa; - background-color: #f9f9f9; - padding: 5px; - font-size: 95%; -} -#toc h2, -.toc h2 { - display: inline; - border: none; - padding: 0; - font-size: 100%; - font-weight: bold; -} -#toc #toctitle, -.toc #toctitle, -#toc .toctitle, -.toc .toctitle { - text-align: center; -} -#toc ul, -.toc ul { - list-style-type: none; - list-style-image: none; - margin-left: 0; - padding-left: 0; - text-align: left; -} -#toc ul ul, -.toc ul ul { - margin: 0 0 0 2em; -} -#toc .toctoggle, -.toc .toctoggle { - font-size: 94%; -} - -.thumbcaption { - border: none; - text-align: left; - line-height: 1.4em; - padding: 3px !important; - font-size: 94%; -} - -.location-right { - clear: right; - float: right; - border-width: .5em 0 .8em 1.4em; -} -.location-left { - float: left; - clear: left; - margin-right: .5em; - border-width: .5em 1.4em .8em 0; -} - diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/layout.css b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/layout.css index 0ebb32e..6df3e59 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/layout.css +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/layout.css @@ -9,7 +9,7 @@ body { } #body-content { - margin-left: 200px; + margin-left: 210px; padding: 10px; } @@ -23,38 +23,40 @@ body { #page-header-left { float:left; - margin-left: 200px; -} - -#page-header-info { - float:right; - padding-right: 20%; + margin-left: 210px; } #page-header-right { float:right; } -#page-header-left,#page-header-right { +#page-header-left,#page-header-right { padding-top: 10px; } +#page-body-login { + position: absolute; + top: 0px; +} + +#body-deco-logo { + position: absolute; + right: 5px; + top: 40px; +} + +#body-deco-menu { + position: absolute; + width: 200px; +} + #body-footer { - text-align: center; + margin-left: 210px; +} + +#body-footer-content { padding: 5px; margin-left:20em; margin-right:20em; margin-top:1em; } - -#body-deco-logo { - position: absolute; - right: 20px; - top: 50px; -} - -#body-deco-menu { - float: left; - width: 190px; -} - diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/theme.css b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/theme.css index 0005e66..5243d04 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/theme.css +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/default/theme.css @@ -8,28 +8,52 @@ body { } #body-content { + min-height: 400px; border: 1px solid #ccc; - border-bottom-left-radius:3px; - border-bottom-right-radius:3px; + border-bottom-left-radius:5px; + border-bottom-right-radius:5px; background-image: url(/demo/img/skin/default/body-view-bg.png); } -#page-header-left a,#page-header-right a,#page-header-info-body { +#page-body-login { + text-align: center; + height: 28px; + width: 198px; + padding-top: 7px; + border: 1px solid #BBBBBB; + border-top: none; + border-bottom-left-radius:5px; + border-bottom-right-radius:5px; + background-image: url(/demo/img/skin/default/body-view-bg.png); +} + +#page-header-left a,#page-header-right a { padding:10px; padding-bottom:5px; } -#page-header-left a,#page-header-right a,#page-header-info-body { +#page-header-left a,#page-header-right a { background-color:#DDCCCC; font-weight:bold; border-top-left-radius:5px; border-top-right-radius:5px; } +#page-header-left a { + margin-right: 3px; +} +#page-header-right a { + margin-left: 3px; +} #body-footer { - border-color:#e5e5e5; - border-style:solid; - border-width:1px 1px 1px 1px; - border-radius:3px; + margin-top: 10px; + border: 1px solid #BBBBBB; + border-radius:5px; + background-image: url(/demo/img/skin/default/body-view-bg.png); +} + +#body-footer-content { + text-align:center; + font-size:80%; } @@ -42,9 +66,7 @@ h1 { } h2 { - font-style: italic; - float: right; - margin-top: -45px; + font-style: italic; padding: 10px; color: #2d1100; } @@ -67,50 +89,22 @@ h3 span { padding-bottom: 4px; } - -/* - -#summary { - float: left; - width: 200px; - margin-right: 15px; - text-align: center; - border: 1px solid #ccc; - padding: 5px; - font-family: Georgia, serif; - font-style: italic; - -} - -*/ - -#body-deco-logo { - -} -#body-deco-menu { - -} - -#body-deco-logo-div,#body-deco-menu0-div,#body-deco-menu1-div,#body-deco-menu2-div { - /* - font: 10px verdana, sans-serif; - padding: 10px; - margin-top: 130px; - width: 130px; - border: 1px solid #ccc; - background-image: url(../../../img/skin/default/wrapper2.png); -*/ -} - - -#body-deco-menu-group { +.body-deco-menu-group { padding:5px; + margin-top: 5px; margin-bottom: 10px; border-radius:5px; border: 1px solid #BBBBBB; background-image: url(/demo/img/skin/default/body-view-bg.png); } +.body-deco-menu-group ul { + margin-left: 5px; + padding-left: 0px; + list-style:none; + font-size:80%; +} + .rf-p { border-radius:5px; border: 1px solid #BBBBBB; diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/green/theme.css b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/green/theme.css index 53851f3..28a18e2 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/green/theme.css +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/css/skins/green/theme.css @@ -6,15 +6,15 @@ body { input:hover,textarea:hover,select:hover{ - border: 2px solid rgba(100, 224, 64, 0.6); + border: 2px solid rgba(10, 224, 64, 0.6); } .even { - background-color:rgba(70, 180, 60, 0.6); + background-color:rgba(70, 18, 60, 0.6); } .odd { - background-color:rgba(10, 230, 120, 0.6); + background-color:rgba(180, 230, 12, 0.6); } #page-header-left a,#page-header-right a,#page-header-info-body,.rf-dt-shdr-c a,.table_sub_header { @@ -26,6 +26,6 @@ input:hover,textarea:hover,select:hover{ } ul.actionboxtab li a:hover,#page-header-left a:hover,#page-header-right a:hover,#page-header-info-body:hover { - background-color:rgba(65, 182, 33, 0.6); + background-color:rgba(65, 18, 33, 0.6); } diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/admin/index.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/admin/index.xhtml index 6046d2d..2418aa1 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/admin/index.xhtml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/admin/index.xhtml @@ -7,7 +7,7 @@ > Admin Index - + @@ -45,6 +45,7 @@ +
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/index.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/index.xhtml index e9c287f..d4b8d4c 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/index.xhtml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/index.xhtml @@ -7,23 +7,7 @@ > Index - - - - - - - - - - - - - - - +

Welcome to the vasc tech demo.

+

Please login to see more options.

+
diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/user/profile.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/user/profile.xhtml index cfec6f0..a56e03c 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/user/profile.xhtml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/html/user/profile.xhtml @@ -16,11 +16,12 @@ - +

Select theme

+ diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/img/logo.png b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/img/logo.png index 7c2a57d..7ca6181 100644 Binary files a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/img/logo.png and b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/img/logo.png differ diff --git a/vasc-export/.project b/vasc-export/.project new file mode 100644 index 0000000..906f5df --- /dev/null +++ b/vasc-export/.project @@ -0,0 +1,17 @@ + + + vasc-export + + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + + diff --git a/vasc-export/pom.xml b/vasc-export/pom.xml new file mode 100644 index 0000000..b0e01c5 --- /dev/null +++ b/vasc-export/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + + net.forwardfire.vasc + vasc + 0.4.1-SNAPSHOT + + vasc-export + net.forwardfire.vasc.export + pom + vasc-export + vasc-export + + vasc-export-jr4o + vasc-export-json + vasc-export-generic + + \ No newline at end of file diff --git a/vasc-export/vasc-export-generic/.project b/vasc-export/vasc-export-generic/.project new file mode 100644 index 0000000..c0ae249 --- /dev/null +++ b/vasc-export/vasc-export-generic/.project @@ -0,0 +1,23 @@ + + + vasc-export-generic + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/vasc-export/vasc-export-generic/pom.xml b/vasc-export/vasc-export-generic/pom.xml new file mode 100644 index 0000000..b869215 --- /dev/null +++ b/vasc-export/vasc-export-generic/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + + net.forwardfire.vasc.export + vasc-export + 0.4.1-SNAPSHOT + + vasc-export-generic + vasc-export-generic + vasc-export-generic + + + net.forwardfire.vasc + vasc-core + ${project.version} + + + \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterCsv.java b/vasc-export/vasc-export-generic/src/main/java/net/forwardfire/vasc/export/generic/AbstractVascEntryExportWriter.java similarity index 50% rename from vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterCsv.java rename to vasc-export/vasc-export-generic/src/main/java/net/forwardfire/vasc/export/generic/AbstractVascEntryExportWriter.java index 5dee7e8..2b52480 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterCsv.java +++ b/vasc-export/vasc-export-generic/src/main/java/net/forwardfire/vasc/export/generic/AbstractVascEntryExportWriter.java @@ -20,78 +20,89 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.impl.entry.export; +package net.forwardfire.vasc.export.generic; +import java.io.IOException; import java.io.OutputStream; -import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.List; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; -import net.forwardfire.vasc.core.entry.VascEntryExporter; +import net.forwardfire.vasc.core.entry.VascEntryExport; +import net.forwardfire.vasc.core.entry.VascEntryExportWriter; import net.forwardfire.vasc.core.VascException; /** - * VascEntryExporterCsv writes data to csv output format. + * AbstractVascEntryExportWriter make read of paged data into methods. * * @author Willem Cazander - * @version 1.0 Mar 30, 2007 + * @version 1.0 Nov 23, 2012 */ -public class VascEntryExporterCsv implements VascEntryExporter { +@SuppressWarnings("serial") +abstract public class AbstractVascEntryExportWriter implements VascEntryExportWriter { - private static final long serialVersionUID = 2770924442917617161L; - static public final String EXPORT_TYPE = "csv"; + private VascEntryExport vascEntryExport = null; + private VascEntry vascEntry = null; - /** - * @see net.forwardfire.vasc.core.entry.VascEntryExporter#getId() - */ - public String getId() { - return EXPORT_TYPE; + public void doInit(VascEntryExport vascEntryExport,VascEntry vascEntry) throws VascException { + this.vascEntryExport=vascEntryExport; + this.vascEntry=vascEntry; } - - /** - * @see net.forwardfire.vasc.core.entry.VascEntryExporter#doExport(java.io.OutputStream, net.forwardfire.vasc.core.VascEntry) - */ - public void doExport(OutputStream out, VascEntry entry) throws VascException { - PrintWriter p = new PrintWriter(out); - p.write("# csv\n"); - for (VascEntryField c:entry.getVascEntryFields()) { - p.write(c.getId()+"\t"); - } - p.write("\n"); + + public void doExport(OutputStream out) throws IOException,VascException { + doExportInit(out); + doExportStart(); + + VascEntry entry = getVascEntry(); int oldIndex = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex(); Long total = entry.getVascFrontendController().getVascEntryState().getTotalBackendRecords(); int pages = total.intValue()/entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize(); for (int page=0;page<=pages;page++) { entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(page); entry.getVascFrontendController().getVascFrontendActions().refreshData(); - for (Object o:entry.getVascFrontendController().getVascEntryState().getEntryDataList()) { - for (VascEntryField c:entry.getVascEntryFields()) { - p.write(c.getVascEntryFieldValue().getDisplayValue(c, o)+"\t"); - } - p.write("\n"); - p.flush(); + + int dataSize = entry.getVascFrontendController().getVascEntryState().getEntryDataList().size(); + for (int dataIndex=0;dataIndex fieldList = new ArrayList(getVascEntry().getVascEntryFields()); + int fields = fieldList.size(); + for (int i=0;i\n"); + p.write("\n"); + } + + @Override + protected void doExportEnd() { + p.write("\n"); + p.flush(); + } + + @Override + protected void doExportRowStart(Object row) { + p.write("\t\n"); + } + + @Override + protected void doExportRowEnd(Object row,boolean isLast) { + p.write("\t\n"); + p.flush(); + } + + @Override + protected void doExportRowField(Object o, VascEntryField c,boolean isLast) throws VascException { + if (xmlTree) { + p.write("\t\t<"+c.getId()+">\n"); + } else { + p.write("\t\t\n"); + } + } + + /** + * @see net.forwardfire.vasc.core.entry.VascEntryExport#getMineType() + */ + public String getMineType() { + return "text/xml"; + } + + /** + * @see net.forwardfire.vasc.core.entry.VascEntryExport#getFileType() + */ + public String getFileType() { + return EXPORT_TYPE; + } +} diff --git a/vasc-export/vasc-export-jr4o/.project b/vasc-export/vasc-export-jr4o/.project new file mode 100644 index 0000000..39b54d2 --- /dev/null +++ b/vasc-export/vasc-export-jr4o/.project @@ -0,0 +1,23 @@ + + + vasc-export-jr4o + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/vasc-export/vasc-export-jr4o/pom.xml b/vasc-export/vasc-export-jr4o/pom.xml new file mode 100644 index 0000000..006dbf5 --- /dev/null +++ b/vasc-export/vasc-export-jr4o/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + net.forwardfire.vasc.export + vasc-export + 0.4.1-SNAPSHOT + + vasc-export-jr4o + vasc-export-jr4o + vasc-export-jr4o + + + net.forwardfire.vasc.export + vasc-export-generic + ${project.version} + + + net.forwardfire.vasc.lib + vasc-lib-jr4o + ${project.version} + + + \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/JRDynamicDataSourceVascEntry.java b/vasc-export/vasc-export-jr4o/src/main/java/net/forwardfire/vasc/export/jr4o/JRDynamicDataSourceVascEntry.java similarity index 99% rename from vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/JRDynamicDataSourceVascEntry.java rename to vasc-export/vasc-export-jr4o/src/main/java/net/forwardfire/vasc/export/jr4o/JRDynamicDataSourceVascEntry.java index 2873fa6..b12be28 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/JRDynamicDataSourceVascEntry.java +++ b/vasc-export/vasc-export-jr4o/src/main/java/net/forwardfire/vasc/export/jr4o/JRDynamicDataSourceVascEntry.java @@ -20,7 +20,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.impl.entry.export; +package net.forwardfire.vasc.export.jr4o; import java.util.ArrayList; import java.util.HashMap; diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterJR4O.java b/vasc-export/vasc-export-jr4o/src/main/java/net/forwardfire/vasc/export/jr4o/VascEntryExportWriterJR4O.java similarity index 68% rename from vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterJR4O.java rename to vasc-export/vasc-export-jr4o/src/main/java/net/forwardfire/vasc/export/jr4o/VascEntryExportWriterJR4O.java index 3cbc83a..8408b7e 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/export/VascEntryExporterJR4O.java +++ b/vasc-export/vasc-export-jr4o/src/main/java/net/forwardfire/vasc/export/jr4o/VascEntryExportWriterJR4O.java @@ -20,7 +20,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.impl.entry.export; +package net.forwardfire.vasc.export.jr4o; import java.io.File; import java.io.OutputStream; @@ -28,64 +28,55 @@ import java.util.HashMap; import java.util.Map; import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.entry.VascEntryExporter; +import net.forwardfire.vasc.core.entry.VascEntryExport; +import net.forwardfire.vasc.core.entry.VascEntryExportWriter; import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.lib.jr4o.JR4ODesignManager; import net.forwardfire.vasc.lib.jr4o.JR4ODesignManager.JRExportType; /** - * VascEntryExporterPdf creates an pdf view of the data. + * VascEntryExportWriterJR4O creates an pdf view of the data. * * @author Willem Cazander * @version 1.0 May 11, 2012 */ -public class VascEntryExporterJR4O implements VascEntryExporter { +public class VascEntryExportWriterJR4O implements VascEntryExportWriter { private static final long serialVersionUID = -3951608685719832654L; static public final String EXPORT_TYPE = "pdf"; - private JRExportType reportType = null; + private VascEntry entry = null; + private JRExportType reportType = JRExportType.PDF; private String reportResource = null; private String reportName = null; private File reportFile = null; - private String id = null; - - private VascEntryExporterJR4O(String id,JRExportType reportType,String reportName) { - if (reportName == null) { - throw new NullPointerException("Can't export null reportName."); - } - if (reportType == null) { - throw new NullPointerException("Can't export null reportType."); - } - this.id = id; - this.reportType = reportType; - this.reportName = reportName; - } - - public VascEntryExporterJR4O(String id,JRExportType reportType,String reportName,String reportResource) { - this(id,reportType,reportName); - this.reportResource=reportResource; - } - - public VascEntryExporterJR4O(String id,JRExportType reportType,String reportName,File reportFile) { - this(id,reportType,reportName); - this.reportFile=reportFile; - } /** - * @see net.forwardfire.vasc.core.entry.VascEntryExporter#getId() + * @see net.forwardfire.vasc.core.entry.VascEntryExportWriter#doInit(net.forwardfire.vasc.core.entry.VascEntryExport, net.forwardfire.vasc.core.VascEntry) */ - public String getId() { - return id; + @Override + public void doInit(VascEntryExport export, VascEntry vascEntry) throws VascException { + this.entry = vascEntry; + + String reportTypeString = export.getWriterParameter("reportType"); + if (reportTypeString!=null && reportTypeString.isEmpty()==false) { + reportType = JRExportType.valueOf(reportTypeString); + } + reportName = export.getWriterParameter("reportName"); + if (reportName==null) { + throw new NullPointerException("Can work with null reportName parameter."); + } + + String reportFileString = export.getWriterParameter("reportFile"); + if (reportFileString!=null && reportFileString.isEmpty()==false) { + reportFile = new File(reportFileString); + } + reportResource = export.getWriterParameter("reportResource"); } - public void setId(String id) { - this.id=id; - } - /** - * @see net.forwardfire.vasc.core.entry.VascEntryExporter#doExport(java.io.OutputStream, net.forwardfire.vasc.core.VascEntry) + * @see net.forwardfire.vasc.core.entry.VascEntryExport#doExport(java.io.OutputStream, net.forwardfire.vasc.core.VascEntry) */ - public void doExport(OutputStream out, VascEntry entry) throws VascException { + public void doExport(OutputStream out) throws VascException { Map parameters = new HashMap(5); parameters.put("title", entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(entry.getName())); @@ -113,14 +104,14 @@ public class VascEntryExporterJR4O implements VascEntryExporter { } /** - * @see net.forwardfire.vasc.core.entry.VascEntryExporter#getMineType() + * @see net.forwardfire.vasc.core.entry.VascEntryExport#getMineType() */ public String getMineType() { return "text/pdf"; } /** - * @see net.forwardfire.vasc.core.entry.VascEntryExporter#getFileType() + * @see net.forwardfire.vasc.core.entry.VascEntryExport#getFileType() */ public String getFileType() { return EXPORT_TYPE; diff --git a/vasc-export/vasc-export-json/.project b/vasc-export/vasc-export-json/.project new file mode 100644 index 0000000..8befc3e --- /dev/null +++ b/vasc-export/vasc-export-json/.project @@ -0,0 +1,23 @@ + + + vasc-export-json + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/vasc-export/vasc-export-json/pom.xml b/vasc-export/vasc-export-json/pom.xml new file mode 100644 index 0000000..45b3760 --- /dev/null +++ b/vasc-export/vasc-export-json/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + net.forwardfire.vasc.export + vasc-export + 0.4.1-SNAPSHOT + + vasc-export-json + vasc-export-json + vasc-export-json + + + net.forwardfire.vasc.export + vasc-export-generic + ${project.version} + + + com.googlecode.json-simple + json-simple + ${json-simple.version} + + + diff --git a/vasc-export/vasc-export-json/src/main/java/net/forwardfire/vasc/export/json/VascEntryExportWriterJson.java b/vasc-export/vasc-export-json/src/main/java/net/forwardfire/vasc/export/json/VascEntryExportWriterJson.java new file mode 100644 index 0000000..7a215e3 --- /dev/null +++ b/vasc-export/vasc-export-json/src/main/java/net/forwardfire/vasc/export/json/VascEntryExportWriterJson.java @@ -0,0 +1,115 @@ +/* + * Copyright 2007-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.export.json; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.util.HashMap; +import java.util.Map; + +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; + +import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascException; +import net.forwardfire.vasc.export.generic.AbstractVascEntryExportWriter; + +/** + * VascEntryExportWriterJson exports the entry data to json format. + * + * @author Willem Cazander + * @version 1.0 Nov 23, 2012 + */ +public class VascEntryExportWriterJson extends AbstractVascEntryExportWriter { + + private static final long serialVersionUID = 2965474124451161061L; + private PrintWriter p = null; + private Map rowData = null; + + public VascEntryExportWriterJson() { + rowData = new HashMap(60); + } + + @Override + public String getMineType() { + return "text/json"; + } + + @Override + public String getFileType() { + return "json"; + } + + @Override + protected void doExportInit(OutputStream out) { + p = new PrintWriter(out); + } + + private void writeField(String key,String value) { + p.write("\""); + p.write(key); + p.write("\": \""); + p.write(JSONValue.escape(value)); + p.write("\""); + } + + @Override + protected void doExportStart() { + p.write("{\"entry\": {\n"); + writeField("id",getVascEntry().getId()); + p.write(",\n"); + writeField("vascGroupId",getVascEntry().getVascGroupId()); + p.write(",\n"); + p.write("\"data\": [\n"); + } + + @Override + protected void doExportEnd() { + p.write("]\n"); + p.write("}}\n"); + p.flush(); + } + + @Override + protected void doExportRowStart(Object row) { + rowData.clear(); + } + + @Override + protected void doExportRowEnd(Object row,boolean isLast) throws IOException { + JSONObject.writeJSONString(rowData, p); + if (isLast==false) { + p.write(","); + } + p.write("\n"); + p.flush(); + } + + @Override + protected void doExportRowField(Object row, VascEntryField field,boolean isLast) throws VascException { + String key = field.getId(); + Object data = field.getVascEntryFieldValue().getValue(field, row); + rowData.put(key, data); + } +} diff --git a/vasc-export/vasc-export-json/src/main/java/net/forwardfire/vasc/export/json/package-info.java b/vasc-export/vasc-export-json/src/main/java/net/forwardfire/vasc/export/json/package-info.java new file mode 100644 index 0000000..1b20b3e --- /dev/null +++ b/vasc-export/vasc-export-json/src/main/java/net/forwardfire/vasc/export/json/package-info.java @@ -0,0 +1,6 @@ + +/** + * @author willemc + * + */ +package net.forwardfire.vasc.export.json; \ No newline at end of file diff --git a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingVascFrontend.java b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingVascFrontend.java index f99a7d8..9c12189 100644 --- a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingVascFrontend.java +++ b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/SwingVascFrontend.java @@ -66,7 +66,8 @@ import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryListOption; import net.forwardfire.vasc.core.actions.GlobalVascAction; import net.forwardfire.vasc.core.actions.RowVascAction; -import net.forwardfire.vasc.core.entry.VascEntryExporter; +import net.forwardfire.vasc.core.entry.VascEntryExport; +import net.forwardfire.vasc.core.entry.VascEntryExportWriter; import net.forwardfire.vasc.core.ui.VascOptionValueModelListener; import net.forwardfire.vasc.core.ui.VascUIComponent; import net.forwardfire.vasc.core.ui.VascValueModel; @@ -215,40 +216,40 @@ public class SwingVascFrontend extends AbstractVascFrontend { /** * @see net.forwardfire.vasc.core.VascViewRenderer#renderExport(net.forwardfire.vasc.core.VascEntry, net.forwardfire.vasc.core.VascDataExporter) */ - public void renderExport(VascEntryExporter exporter) throws VascFrontendException { + public void renderExport(VascEntryExport exporter) throws VascFrontendException { String fileName = null; JFileChooser c = new JFileChooser(); - int rVal = c.showSaveDialog(null); - if (rVal == JFileChooser.APPROVE_OPTION) { - fileName = c.getSelectedFile().getAbsolutePath(); - // filename.setText(c.getSelectedFile().getName()); - //dir.setText(c.getCurrentDirectory().toString()); - } - if (rVal == JFileChooser.CANCEL_OPTION) { - return; - } + int rVal = c.showSaveDialog(null); + if (rVal == JFileChooser.APPROVE_OPTION) { + fileName = c.getSelectedFile().getAbsolutePath(); + } + if (rVal == JFileChooser.CANCEL_OPTION) { + return; + } - logger.fine("FileName: "+fileName); - if (fileName == null) { - return; - } - OutputStream out = null; - try { - out = new FileOutputStream(fileName); - exporter.doExport(out, entry); - } catch (VascException e) { - throw new VascFrontendException(e); - } catch (FileNotFoundException e) { - throw new VascFrontendException(e); + logger.fine("Export fileName: "+fileName); + if (fileName == null) { + return; + } + OutputStream out = null; + try { + VascEntryExportWriter veew = exporter.createExportWriter(); + veew.doInit(exporter, entry); + out = new FileOutputStream(fileName); + veew.doExport(out); + } catch (VascException e) { + throw new VascFrontendException(e); + } catch (IOException e) { + throw new VascFrontendException(e); } finally { - if (out!=null) { - try { + if (out!=null) { + try { out.close(); } catch (IOException e) { } - } - } + } + } } diff --git a/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtVascFrontend.java b/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtVascFrontend.java index 87a99c7..3583e54 100644 --- a/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtVascFrontend.java +++ b/vasc-frontend/vasc-frontend-swt/src/main/java/net/forwardfire/vasc/frontend/swt/SwtVascFrontend.java @@ -35,7 +35,8 @@ import net.forwardfire.vasc.core.VascEntryListOption; import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.core.actions.GlobalVascAction; import net.forwardfire.vasc.core.actions.RowVascAction; -import net.forwardfire.vasc.core.entry.VascEntryExporter; +import net.forwardfire.vasc.core.entry.VascEntryExport; +import net.forwardfire.vasc.core.entry.VascEntryExportWriter; import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener; import net.forwardfire.vasc.core.ui.VascOptionValueModelListener; import net.forwardfire.vasc.core.ui.VascUIComponent; @@ -163,7 +164,7 @@ public class SwtVascFrontend extends AbstractVascFrontend { /** These filter extensions are used to filter which files are displayed. */ private static final String[] FILTER_EXTS = { "*.*","*.csv","*.xls" }; - public void renderExport(VascEntryExporter exporter) throws VascFrontendException { + public void renderExport(VascEntryExport exporter) throws VascFrontendException { FileDialog dlg = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE); dlg.setFilterNames(FILTER_NAMES); dlg.setFilterExtensions(FILTER_EXTS); @@ -175,13 +176,15 @@ public class SwtVascFrontend extends AbstractVascFrontend { } OutputStream out = null; try { + VascEntryExportWriter veew = exporter.createExportWriter(); + veew.doInit(exporter, entry); out = new FileOutputStream(fileName); - exporter.doExport(out, entry); + veew.doExport(out); } catch (VascException e) { //MessageDialog.openError(Display.getCurrent().getActiveShell(),crudTable.i18n("crud.event.export.error.title"),crudTable.i18n("crud.event.export.error.message")); logger.log(Level.WARNING,"Error: "+e.getMessage(),e); throw new VascFrontendException(e); - } catch (FileNotFoundException e) { + } catch (IOException e) { throw new VascFrontendException(e); } finally { if (out!=null) { diff --git a/vasc-frontend/vasc-frontend-web-export/src/main/java/net/forwardfire/vasc/frontend/web/export/VascExportServlet.java b/vasc-frontend/vasc-frontend-web-export/src/main/java/net/forwardfire/vasc/frontend/web/export/VascExportServlet.java index 516b98d..71491ae 100644 --- a/vasc-frontend/vasc-frontend-web-export/src/main/java/net/forwardfire/vasc/frontend/web/export/VascExportServlet.java +++ b/vasc-frontend/vasc-frontend-web-export/src/main/java/net/forwardfire/vasc/frontend/web/export/VascExportServlet.java @@ -34,7 +34,8 @@ import javax.servlet.http.HttpServletResponse; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascControllerProvider; import net.forwardfire.vasc.core.VascEntryLocal; -import net.forwardfire.vasc.core.entry.VascEntryExporter; +import net.forwardfire.vasc.core.entry.VascEntryExport; +import net.forwardfire.vasc.core.entry.VascEntryExportWriter; import net.forwardfire.vasc.core.VascException; /** @@ -176,14 +177,16 @@ public class VascExportServlet extends HttpServlet { // Update total every time first Long total = ve.getVascFrontendController().getVascEntryState().getVascBackend().fetchTotalExecuteSize(ve.getVascFrontendController().getVascEntryState().getVascBackendState()); ve.getVascFrontendController().getVascEntryState().setTotalBackendRecords(total); - VascEntryExporter ex = vc.getVascEntryConfigController().getVascEntryExporterById(exportId); + VascEntryExport ex = vc.getVascEntryConfigController().getVascEntryExporterById(exportId); + VascEntryExportWriter exw = ex.createExportWriter(); + exw.doInit(ex, ve); - String filename = entryId+"-export."+ex.getFileType(); + String filename = entryId+"-export."+exw.getFileType(); response.setHeader("Content-disposition", "attachment; filename=" + filename); - String contentType = ex.getMineType(); + String contentType = exw.getMineType(); response.setContentType(contentType); - ex.doExport(out, ve); + exw.doExport(out); } catch (VascException e) { response.setStatus(500); response.setContentType("text/html"); 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 caade7d..2cc4d61 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 @@ -58,7 +58,8 @@ import net.forwardfire.vasc.core.VascEntryLinkType; import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.core.actions.GlobalVascAction; import net.forwardfire.vasc.core.actions.RowVascAction; -import net.forwardfire.vasc.core.entry.VascEntryExporter; +import net.forwardfire.vasc.core.entry.VascEntryExport; +import net.forwardfire.vasc.core.entry.VascEntryExportWriter; import net.forwardfire.vasc.frontend.VascFrontendException; import net.forwardfire.vasc.impl.actions.AddRowAction; import net.forwardfire.vasc.impl.actions.DeleteRowAction; @@ -88,7 +89,7 @@ public class JSFVascEntrySupportBean implements Serializable { private Boolean backendPageable = null; private Boolean sortOrder = null; private String sortField = null; - private VascEntryExporter selectedExporter = null; + private VascEntryExport selectedExporter = null; private String selectedExporterAction = "null"; private String selectedDirectPage = "null"; private String selectedMultiRowAction = "null"; @@ -723,7 +724,7 @@ public class JSFVascEntrySupportBean implements Serializable { // restore normal view for next request. comp.setRenderFacetState("listView"); - VascEntryExporter ex = getSelectedExporter(); + VascEntryExport ex = getSelectedExporter(); if (ex==null) { logger.fine("No exporter selected for download."); @@ -733,15 +734,17 @@ public class JSFVascEntrySupportBean implements Serializable { FacesContext fc = FacesContext.getCurrentInstance(); try { + VascEntryExportWriter veew = ex.createExportWriter(); + veew.doInit(ex, entry); HttpServletResponse response = (HttpServletResponse)fc.getExternalContext().getResponse(); - String filename = "export-list."+ex.getFileType(); + String filename = "export-list."+veew.getFileType(); response.setHeader("Content-disposition", "attachment; filename=" + filename); - String contentType = ex.getMineType(); + String contentType = veew.getMineType(); response.setContentType(contentType); ServletOutputStream out = response.getOutputStream(); - ex.doExport(out, entry); + veew.doExport(out); out.close(); } catch (VascException e) { throw new VascFrontendException(e); @@ -869,14 +872,14 @@ public class JSFVascEntrySupportBean implements Serializable { /** * @return the selectedExporter */ - public VascEntryExporter getSelectedExporter() { + public VascEntryExport getSelectedExporter() { return selectedExporter; } /** * @param selectedExporter the selectedExporter to set */ - public void setSelectedExporter(VascEntryExporter selectedExporter) { + public void setSelectedExporter(VascEntryExport selectedExporter) { this.selectedExporter = 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 82116e1..f1fe2b1 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 @@ -28,7 +28,7 @@ import java.util.logging.Logger; import javax.faces.component.UIViewRoot; import javax.faces.context.FacesContext; -import net.forwardfire.vasc.core.entry.VascEntryExporter; +import net.forwardfire.vasc.core.entry.VascEntryExport; import net.forwardfire.vasc.frontend.AbstractVascFrontend; import net.forwardfire.vasc.frontend.VascFrontendException; import net.forwardfire.vasc.frontend.VascFrontendController; @@ -116,9 +116,9 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser } /** - * @see net.forwardfire.vasc.frontend.VascFrontend#renderExport(net.forwardfire.vasc.core.entry.VascEntryExporter) + * @see net.forwardfire.vasc.frontend.VascFrontend#renderExport(net.forwardfire.vasc.core.entry.VascEntryExport) */ - public void renderExport(VascEntryExporter exporter) throws VascFrontendException { + public void renderExport(VascEntryExport exporter) throws VascFrontendException { logger.finer("renderExport"); UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot(); JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId());