2
0
Fork 0

made server gui work and auto generate xml imports

This commit is contained in:
Willem Cazander 2012-11-29 20:39:24 +01:00
parent 01b3b5cc54
commit c259e28e44
69 changed files with 1669 additions and 1230 deletions

View file

@ -5,32 +5,25 @@
<groupId>net.forwardfire.vasc</groupId>
<version>0.4.1-SNAPSHOT</version>
</parent>
<groupId>net.forwardfire.vasc</groupId>
<artifactId>vasc-core</artifactId>
<version>0.4.1-SNAPSHOT</version>
<name>vasc-core</name>
<description>vasc-core</description>
<dependencies>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-core</artifactId>
<version>${x4o.version}</version>
</dependency>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-meta</artifactId>
<version>${x4o.version}</version>
</dependency>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-core</artifactId>
<version>${x4o.version}</version>
</dependency>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-meta</artifactId>
<version>${x4o.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc</groupId>
<artifactId>vasc-xpql</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc.lib</groupId>
<artifactId>vasc-lib-jr4o</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
@ -38,16 +31,16 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate-validator.version}</version>
<scope>provided</scope>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate-validator.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel</artifactId>
<version>2.1.0</version>
<scope>test</scope>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel</artifactId>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
</project>

View file

@ -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<String> getVascEntryExporterIds();
public VascEntryExporter getVascEntryExporterById(String exporterId);
public VascEntryExport getVascEntryExporterById(String exporterId);
public void configVascFrontendController(VascController vascController,VascEntryLocal entry) throws VascException;

View file

@ -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();

View file

@ -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<String> getWriterParameterKeys();
}

View file

@ -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();

View file

@ -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;
}

View file

@ -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<VascEntryConfigFinalizer> configFinalizers = null;
private List<VascBackendProxy> backendProxies = null;
private Map<String,VascEntryExporter> dataExporters = null;
private Map<String,VascEntryExport> dataExporters = null;
private List<VascEntryFieldValidatorService> fieldValidators = null;
private Map<VascInterfaceKey,Class<?>> vascInterfaceImpls = null;
private Map<VascInterfaceKeyFrontend,Class<?>> vascInterfaceImplFrontends = null;
@ -73,7 +73,7 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll
public DefaultVascEntryConfigController() {
configFinalizers = new ArrayList<VascEntryConfigFinalizer>(10);
backendProxies = new ArrayList<VascBackendProxy>(10);
dataExporters = new HashMap<String,VascEntryExporter>(10);
dataExporters = new HashMap<String,VascEntryExport>(10);
fieldValidators = new ArrayList<VascEntryFieldValidatorService>(5);
vascInterfaceImpls = new HashMap<VascInterfaceKey,Class<?>>(VascInterfaceKey.values().length);
vascInterfaceImplFrontends = new HashMap<VascInterfaceKeyFrontend,Class<?>>(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());
}

View file

@ -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());

View file

@ -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);
}

View file

@ -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

View file

@ -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<String,String> writerParameters = null;
public DefaultVascEntryExport() {
writerParameters = new HashMap<String,String>();
}
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<String> 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;
}
}

View file

@ -1,170 +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.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.VascException;
import net.forwardfire.vasc.lib.jr4o.data.AbstractJRDynamicDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import net.sf.jasperreports.engine.design.JRDesignField;
import net.sf.jasperreports.engine.design.JasperDesign;
/**
* JRDynamicDataSourceVascEntry converts the Vasc backend data to JasperReports data.
*
* @author Willem Cazander
* @version 1.0 May 11, 2012
*/
public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource {
private VascEntry vascEntry = null;
private long total = -1;
private int index = -1;
private static final String PREFIX_COLUMN = "COLUMN_";
private static final String PREFIX_HEADER = "HEADER_";
private static final String INFIX_CLASS = "CLASS_";
private List<List<String>> data = null;
public JRDynamicDataSourceVascEntry(VascEntry vascEntry) {
if (vascEntry==null) {
throw new NullPointerException("vascEntry can't be null.");
}
this.vascEntry = vascEntry;
total = vascEntry.getVascFrontendController().getVascEntryState().getTotalBackendRecords();
// hackje until calc index to page and row.
try {
data = new ArrayList<List<String>>(1000);
int pages = (int)total/vascEntry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize();
for (int page=0;page<=pages;page++) {
vascEntry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(page);
vascEntry.getVascFrontendController().getVascFrontendActions().refreshData();
for (Object o:vascEntry.getVascFrontendController().getVascEntryState().getEntryDataList()) {
List<String> row = new ArrayList<String>(30);
for (VascEntryField c:vascEntry.getVascEntryFields()) {
row.add(c.getVascEntryFieldValue().getDisplayValue(c, o));
}
data.add(row);
}
}
} catch (VascException ve) {
throw new RuntimeException(ve);
}
}
/**
* @see net.sf.jasperreports.engine.JRDataSource#getFieldValue(net.sf.jasperreports.engine.JRField)
*/
public Object getFieldValue(JRField jrField) throws JRException {
String fieldName = jrField.getName();
if (fieldName.startsWith(PREFIX_COLUMN)) {
return data.get(index).get(Integer.parseInt(fieldName.substring(7)));
}
if (fieldName.startsWith(PREFIX_HEADER)) {
return "todo"; // TODO: fixme
//List<VascEntryField> fields = vascEntry.getVascEntryFields();
//VascEntryField field = fields.get(Integer.parseInt(fieldName.substring(7)));
//return vascEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(field.getName());
}
throw new JRException("Unknown column name : " + fieldName);
}
/**
* @see net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource#addDynamicColumnClassFields(net.sf.jasperreports.engine.design.JasperDesign)
*/
public void addDynamicColumnClassFields(JasperDesign jd) throws JRException {
JRDesignField field;
for (int i=0;i<getDynamicColumnCount();i++) {
field = new JRDesignField();
field.setName(PREFIX_COLUMN+i);
field.setValueClass(String.class); // todo
jd.addField(field);
field = new JRDesignField();
field.setName(PREFIX_HEADER+i);
field.setValueClass(String.class);
jd.addField(field);
}
}
/**
* @see net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource#addDynamicELBean()
*/
public Map<String, Object> addDynamicELBean() {
Map<String,Object> result = new HashMap<String,Object>(10);
for (int i=0;i<getDynamicColumnCount();i++) {
result.put(PREFIX_COLUMN+INFIX_CLASS+i,String.class); // todo
result.put(PREFIX_HEADER+INFIX_CLASS+i,String.class);
}
return result;
}
/**
* @see net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource#getDynamicColumnX(int)
*/
public int getDynamicColumnX(int col) {
int result = 0;
for (int i=0;i<col;i++) {
result += 80;
}
return result;
}
/**
* @see net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource#getDynamicColumnWidth(int)
*/
public int getDynamicColumnWidth(int col) {
return 80; // todo
}
/**
* @see net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource#getDynamicColumnCount()
*/
public int getDynamicColumnCount() {
return vascEntry.getVascEntryFields().size();
}
/**
* @see net.sf.jasperreports.engine.JRDataSource#next()
*/
public boolean next() throws JRException {
index++;
return (index < total);
}
/**
* @see net.sf.jasperreports.engine.JRRewindableDataSource#moveFirst()
*/
public void moveFirst() throws JRException {
index = -1;
}
}

View file

@ -1,97 +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;
/**
* VascEntryExporterCsv writes data to csv output format.
*
* @author Willem Cazander
* @version 1.0 Mar 30, 2007
*/
public class VascEntryExporterCsv implements VascEntryExporter {
private static final long serialVersionUID = 2770924442917617161L;
static public final String EXPORT_TYPE = "csv";
/**
* @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("# csv\n");
for (VascEntryField c:entry.getVascEntryFields()) {
p.write(c.getId()+"\t");
}
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()) {
for (VascEntryField c:entry.getVascEntryFields()) {
p.write(c.getVascEntryFieldValue().getDisplayValue(c, o)+"\t");
}
p.write("\n");
p.flush();
}
}
p.write("# end\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/csv";
}
/**
* @see net.forwardfire.vasc.core.entry.VascEntryExporter#getFileType()
*/
public String getFileType() {
return EXPORT_TYPE;
}
}

View file

@ -1,128 +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.File;
import java.io.OutputStream;
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.VascException;
import net.forwardfire.vasc.lib.jr4o.JR4ODesignManager;
import net.forwardfire.vasc.lib.jr4o.JR4ODesignManager.JRExportType;
/**
* VascEntryExporterPdf creates an pdf view of the data.
*
* @author Willem Cazander
* @version 1.0 May 11, 2012
*/
public class VascEntryExporterJR4O implements VascEntryExporter {
private static final long serialVersionUID = -3951608685719832654L;
static public final String EXPORT_TYPE = "pdf";
private JRExportType reportType = null;
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()
*/
public String getId() {
return id;
}
public void setId(String id) {
this.id=id;
}
/**
* @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 {
Map<String,Object> parameters = new HashMap<String,Object>(5);
parameters.put("title", entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(entry.getName()));
parameters.put("description", entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(entry.getListDescription()));
parameters.put("titleSubject", entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(entry.getId()));
int oldIndex = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex();
String bundle = entry.getVascFrontendController().getVascController().getVascEntryConfigController().getResourceBundle();
JRDynamicDataSourceVascEntry dataSource = new JRDynamicDataSourceVascEntry(entry);
JR4ODesignManager jr4o = new JR4ODesignManager(dataSource,bundle,parameters);
try {
if (reportResource!=null) {
jr4o.parseResource(reportResource);
} else if (reportFile!=null) {
jr4o.parseFile(reportFile);
} else {
throw new NullPointerException("No report input data defined,reportResource and reportFile are null.");
}
jr4o.saveReportStream(reportName, reportType, out);
} catch (Exception e) {
throw new VascException(e);
} finally {
entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(oldIndex); // restore page index
}
}
/**
* @see net.forwardfire.vasc.core.entry.VascEntryExporter#getMineType()
*/
public String getMineType() {
return "text/pdf";
}
/**
* @see net.forwardfire.vasc.core.entry.VascEntryExporter#getFileType()
*/
public String getFileType() {
return EXPORT_TYPE;
}
}

View file

@ -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("<?xml version=\"1.0\"?>\n");
p.write("<data>\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<row>\n");
for (VascEntryField c:entry.getVascEntryFields()) {
if (xmlTree) {
p.write("\t\t<"+c.getId()+"><![CDATA[");
p.write(""+c.getVascEntryFieldValue().getDisplayValue(c, o));
p.write("]]></"+c.getId()+">\n");
} else {
p.write("\t\t<column name=\""+c.getId()+"\"><![CDATA[");
p.write(""+c.getVascEntryFieldValue().getDisplayValue(c, o));
p.write("]]></column>\n");
}
}
p.write("\t</row>\n");
p.flush();
}
}
p.write("</data>\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;
}
}

View file

@ -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