Added pdf export support, export servlet support, renamed frontends
without s and made vasc config object.
This commit is contained in:
parent
efcbdbd519
commit
b3923bd2fb
160 changed files with 5001 additions and 2552 deletions
|
|
@ -21,6 +21,11 @@
|
|||
<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>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.data;
|
||||
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
|
|
@ -30,6 +29,7 @@ import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
|||
import org.x4o.xml.impl.DefaultElementObjectPropertyValue;
|
||||
|
||||
/**
|
||||
* BeanVascEntryFieldValue provides get/set support for bean based backends.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 05, 2009
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ package net.forwardfire.vasc.backend.data;
|
|||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author willemc
|
||||
*
|
||||
* BeanVascEntryRecordCreator creates a new backend record based on class object.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 05, 2009
|
||||
*/
|
||||
public class BeanVascEntryRecordCreator implements VascEntryRecordCreator {
|
||||
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ import net.forwardfire.vasc.core.VascEntryField;
|
|||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author willemc
|
||||
*
|
||||
* MapVascEntryFieldValue provides get/set support on Map record object.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 05, 2009
|
||||
*/
|
||||
public class MapVascEntryFieldValue implements VascEntryFieldValue {
|
||||
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ import java.util.Map;
|
|||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author willemc
|
||||
*
|
||||
* MapVascEntryRecordCreator creates a new HashMap for Map based record backends.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 05, 2009
|
||||
*/
|
||||
public class MapVascEntryRecordCreator implements VascEntryRecordCreator {
|
||||
|
||||
|
|
|
|||
|
|
@ -35,22 +35,39 @@ import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
|||
|
||||
|
||||
/**
|
||||
* AbstractVascBackendProxy to implement missing features of the backend.
|
||||
* VascBackendProxy to implement missing features of the backend.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 1, 2009
|
||||
*/
|
||||
abstract public class AbstractVascBackendProxy implements VascBackend {
|
||||
abstract public class AbstractVascBackendProxy implements VascBackendProxy {
|
||||
|
||||
protected VascBackend backend = null;
|
||||
protected VascEntry entry = null;
|
||||
|
||||
public AbstractVascBackendProxy(VascBackend backend) {
|
||||
abstract public VascBackendProxy clone() throws CloneNotSupportedException;
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.proxy.VascBackendProxy#initProxy(net.forwardfire.vasc.backend.VascBackend, net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public void initProxy(VascBackend backend, VascEntry entry) {
|
||||
if (backend==null) {
|
||||
throw new NullPointerException("backend object mey not be null.");
|
||||
throw new NullPointerException("backend object may not be null.");
|
||||
}
|
||||
if (entry==null) {
|
||||
throw new NullPointerException("entry object may not be null.");
|
||||
}
|
||||
this.backend=backend;
|
||||
this.entry=entry;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.proxy.VascBackendProxy#isProxyNeeded()
|
||||
*/
|
||||
public boolean isProxyNeeded() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#isReadOnly()
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -20,26 +20,22 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.impl;
|
||||
package net.forwardfire.vasc.backend.proxy;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryFinalizer;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
|
||||
/**
|
||||
* VascBackendProxy interface to make proxies configable.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 14, 2008
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public class DefaultVascFrontendEntryFinalizer implements VascEntryFinalizer {
|
||||
public interface VascBackendProxy extends VascBackend,Cloneable {
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryFinalizer#finalizeVascEntry(net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public VascEntry finalizeVascEntry(VascEntry entry,VascController vascController) throws VascException {
|
||||
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
public void initProxy(VascBackend backend,VascEntry entry);
|
||||
|
||||
public boolean isProxyNeeded();
|
||||
|
||||
public VascBackendProxy clone() throws CloneNotSupportedException;
|
||||
}
|
||||
|
|
@ -26,9 +26,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
/**
|
||||
|
|
@ -41,14 +39,27 @@ public class VascBackendProxyCache extends AbstractVascBackendProxy {
|
|||
|
||||
private Long records = null;
|
||||
private List<Object> data = null;
|
||||
private String dataSearchString = null;
|
||||
private String searchString = null;
|
||||
private Map<String,Object> dataState = null;
|
||||
private int pageIndex = 0;
|
||||
private int pageSize = 0;
|
||||
private int pageSizeMax = 0;
|
||||
private String sortField = null;
|
||||
private boolean sortDir = true;
|
||||
|
||||
public VascBackendProxyCache(VascBackend backend,VascEntry entry) {
|
||||
super(backend);
|
||||
public VascBackendProxyCache() {
|
||||
dataState = new HashMap<String,Object>(10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
public VascBackendProxy clone() throws CloneNotSupportedException {
|
||||
VascBackendProxyCache result = new VascBackendProxyCache();
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isStateChanged(VascBackendState state) {
|
||||
boolean changed = false;
|
||||
for (String key:state.getDataParameterKeys()) {
|
||||
|
|
@ -68,10 +79,32 @@ public class VascBackendProxyCache extends AbstractVascBackendProxy {
|
|||
}
|
||||
}
|
||||
|
||||
if (state.getSearchString()!=null && state.getSearchString().equals(dataSearchString)==false) {
|
||||
if (state.getSortField()!=null && state.getSortField().equals(sortField)==false) {
|
||||
changed = true;
|
||||
}
|
||||
dataSearchString = state.getSearchString();
|
||||
sortField = state.getSortField();
|
||||
if (state.isSortAscending()==sortDir) {
|
||||
changed = true;
|
||||
}
|
||||
sortDir = state.isSortAscending();
|
||||
|
||||
if (state.getPageSizeMax()==pageSizeMax) {
|
||||
changed = true;
|
||||
}
|
||||
pageSizeMax = state.getPageSizeMax();
|
||||
if (state.getPageSize()==pageSize) {
|
||||
changed = true;
|
||||
}
|
||||
pageSize = state.getPageSize();
|
||||
if (state.getPageIndex()==pageIndex) {
|
||||
changed = true;
|
||||
}
|
||||
pageIndex = state.getPageIndex();
|
||||
|
||||
if (state.getSearchString()!=null && state.getSearchString().equals(searchString)==false) {
|
||||
changed = true;
|
||||
}
|
||||
searchString = state.getSearchString();
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,9 +32,6 @@ import net.forwardfire.vasc.core.VascException;
|
|||
import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener.VascBackendEventType;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Holds !! and fires the backend event listeners.
|
||||
*
|
||||
|
|
@ -44,10 +41,18 @@ import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener.VascBackend
|
|||
public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
||||
|
||||
private List<VascEntryBackendEventListener> listeners = null;
|
||||
private VascEntry entry = null;
|
||||
|
||||
public VascBackendProxyEventExecutor(VascBackend backend,VascEntry entry) {
|
||||
super(backend);
|
||||
/**
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
public VascBackendProxy clone() throws CloneNotSupportedException {
|
||||
VascBackendProxyEventExecutor result = new VascBackendProxyEventExecutor();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void initProxy(VascBackend backend,VascEntry entry) {
|
||||
super.initProxy(backend, entry);
|
||||
this.entry=entry;
|
||||
this.listeners=new ArrayList<VascEntryBackendEventListener>(10);
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
|
|
@ -64,13 +69,19 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
|||
listeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public VascBackendProxyEventExecutor(VascBackend backend,VascEntry entry,List<VascEntryBackendEventListener> listeners) {
|
||||
super(backend);
|
||||
this.entry=entry;
|
||||
this.listeners=listeners;
|
||||
}
|
||||
|
||||
public void addVascEntryBackendEventListener(VascEntryBackendEventListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeVascEntryBackendEventListener(VascEntryBackendEventListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
public List<VascEntryBackendEventListener> getVascEntryBackendEventListeners() {
|
||||
return listeners;
|
||||
}
|
||||
|
||||
private void fireVascEvent(VascBackendEventType type, Object data) {
|
||||
for (int i=0;i<listeners.size();i++) {
|
||||
VascEntryBackendEventListener l = listeners.get(i);
|
||||
|
|
|
|||
|
|
@ -42,11 +42,37 @@ import net.forwardfire.vasc.core.VascException;
|
|||
public class VascBackendProxyFilter extends AbstractVascBackendProxy {
|
||||
|
||||
private long records = 0;
|
||||
private VascBackendFilter filter = null;
|
||||
private List<VascBackendFilter> filters = null;
|
||||
|
||||
public VascBackendProxyFilter(VascBackend backend,VascEntry entry,VascBackendFilter filter) {
|
||||
super(backend);
|
||||
this.filter=filter;
|
||||
/**
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
public VascBackendProxy clone() throws CloneNotSupportedException {
|
||||
VascBackendProxyFilter result = new VascBackendProxyFilter();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.proxy.VascBackendProxy#initProxy(net.forwardfire.vasc.backend.VascBackend, net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public void initProxy(VascBackend backend, VascEntry entry) {
|
||||
super.initProxy(backend,entry);
|
||||
filters = entry.getVascBackendFilters();
|
||||
for (VascBackendFilter filter:filters) {
|
||||
filter.initFilter(entry);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#isProxyNeeded()
|
||||
*/
|
||||
@Override
|
||||
public boolean isProxyNeeded() {
|
||||
if (entry.getVascBackendFilters().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -55,14 +81,19 @@ public class VascBackendProxyFilter extends AbstractVascBackendProxy {
|
|||
@Override
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
List<Object> result = backend.execute(state);
|
||||
if (filter==null) {
|
||||
if (filters==null) {
|
||||
return result;
|
||||
}
|
||||
if (filters.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
List<Object> search = new ArrayList<Object>(result.size()/2);
|
||||
for (Object o:result) {
|
||||
Object r = filter.filterObject(o);
|
||||
if (r!=null) {
|
||||
search.add(r);
|
||||
for (VascBackendFilter filter:filters) {
|
||||
Object r = filter.filterObject(o);
|
||||
if (r!=null) {
|
||||
search.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
records = search.size();
|
||||
|
|
|
|||
|
|
@ -25,13 +25,9 @@ package net.forwardfire.vasc.backend.proxy;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Simulates a real pages backend.
|
||||
*
|
||||
|
|
@ -42,10 +38,26 @@ public class VascBackendProxyPaged extends AbstractVascBackendProxy {
|
|||
|
||||
private long records = 0;
|
||||
|
||||
public VascBackendProxyPaged(VascBackend backend,VascEntry entry) {
|
||||
super(backend);
|
||||
/**
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
public VascBackendProxy clone() throws CloneNotSupportedException {
|
||||
VascBackendProxyPaged result = new VascBackendProxyPaged();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#isProxyNeeded()
|
||||
*/
|
||||
@Override
|
||||
public boolean isProxyNeeded() {
|
||||
if (backend.isPageable()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#isPageable()
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -25,9 +25,7 @@ package net.forwardfire.vasc.backend.proxy;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
|
|
@ -41,13 +39,27 @@ import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
|||
public class VascBackendProxySearch extends AbstractVascBackendProxy {
|
||||
|
||||
private long records = 0;
|
||||
private VascEntry entry = null;
|
||||
|
||||
public VascBackendProxySearch(VascBackend backend,VascEntry entry) {
|
||||
super(backend);
|
||||
this.entry=entry;
|
||||
/**
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
public VascBackendProxy clone() throws CloneNotSupportedException {
|
||||
VascBackendProxySearch result = new VascBackendProxySearch();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#isProxyNeeded()
|
||||
*/
|
||||
@Override
|
||||
public boolean isProxyNeeded() {
|
||||
if (backend.isSearchable()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#isSearchable()
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ import java.util.Collections;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
|
|
@ -40,15 +38,26 @@ import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
|||
* @version 1.0 Oct 27, 2007
|
||||
*/
|
||||
public class VascBackendProxySort extends AbstractVascBackendProxy {
|
||||
|
||||
private VascEntry entry = null;
|
||||
|
||||
public VascBackendProxySort(VascBackend backend,VascEntry entry) {
|
||||
super(backend);
|
||||
this.entry=entry;
|
||||
/**
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
public VascBackendProxy clone() throws CloneNotSupportedException {
|
||||
VascBackendProxySort result = new VascBackendProxySort();
|
||||
return result;
|
||||
}
|
||||
|
||||
// sort stuff
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#isProxyNeeded()
|
||||
*/
|
||||
@Override
|
||||
public boolean isProxyNeeded() {
|
||||
if (backend.isSortable()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||
|
|
|
|||
|
|
@ -26,14 +26,11 @@ import java.util.List;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
|
||||
/**
|
||||
* Does simple caching for the data.
|
||||
* Does simple timer logging for the backend actions.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 19, 2009
|
||||
|
|
@ -43,11 +40,20 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy {
|
|||
protected Logger logger = null;
|
||||
protected Level logLevel = Level.INFO;
|
||||
|
||||
public VascBackendProxyTimerLogger(VascBackend backend,VascEntry entry) {
|
||||
super(backend);
|
||||
public VascBackendProxyTimerLogger() {
|
||||
logger = Logger.getLogger(VascBackendProxyTimerLogger.class.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
public VascBackendProxy clone() throws CloneNotSupportedException {
|
||||
VascBackendProxyTimerLogger result = new VascBackendProxyTimerLogger();
|
||||
result.logLevel=logLevel;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -34,6 +34,11 @@ import net.forwardfire.vasc.backend.VascBackendController;
|
|||
*/
|
||||
public interface VascController {
|
||||
|
||||
/**
|
||||
* @return Returns the VascConfigController
|
||||
*/
|
||||
public VascEntryConfigController getVascEntryConfigController();
|
||||
|
||||
/**
|
||||
* @return Returns the VascBackendController
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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.core;
|
||||
|
||||
/**
|
||||
* Interface to get an VascController from somewhere.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public interface VascControllerProvider {
|
||||
|
||||
/**
|
||||
* @return Returns the VascController
|
||||
*/
|
||||
public VascController getVascController();
|
||||
}
|
||||
|
|
@ -304,6 +304,26 @@ public interface VascEntry extends Cloneable,Serializable {
|
|||
*/
|
||||
public void removeGlobalAction(GlobalVascAction globalAction);
|
||||
|
||||
/**
|
||||
* @return the exportActions
|
||||
*/
|
||||
public List<GlobalVascAction> getExportActions();
|
||||
|
||||
/**
|
||||
* @return the GlobalVascAction exportAction
|
||||
*/
|
||||
public GlobalVascAction getExportActionById(String actionId);
|
||||
|
||||
/**
|
||||
* @param exportAction the exportAction to add
|
||||
*/
|
||||
public void addExportAction(GlobalVascAction exportAction);
|
||||
|
||||
/**
|
||||
* @param exportAction the exportAction to remove
|
||||
*/
|
||||
public void removeExportAction(GlobalVascAction exportAction);
|
||||
|
||||
/**
|
||||
* @return the vascEntryFieldSets
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* 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.core;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.backend.proxy.VascBackendProxy;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryExporter;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService;
|
||||
|
||||
/**
|
||||
* Interface to make default fill/etc config plugable.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public interface VascEntryConfigController {
|
||||
|
||||
public VascEntry configVascEntry(VascController vascController,String entryId) throws VascException;
|
||||
|
||||
public void configVascEntry(VascController vascController,VascEntry vascEntry) throws VascException;
|
||||
|
||||
|
||||
public void addVascEntryConfigFinalizer(VascEntryConfigFinalizer vascEntryConfigFinalizer);
|
||||
|
||||
public void removeVascEntryConfigFinalizer(VascEntryConfigFinalizer vascEntryConfigFinalizer);
|
||||
|
||||
public List<VascEntryConfigFinalizer> getVascEntryConfigFinalizers();
|
||||
|
||||
|
||||
public VascBackend configVascBackendProxied(VascController vascController,VascEntry vascEntry) throws VascException;
|
||||
|
||||
public VascBackend configVascBackendProxied(VascController vascController,VascEntry vascEntry,VascBackend realBackend) throws VascException;
|
||||
|
||||
public void addVascBackendProxy(VascBackendProxy proxy);
|
||||
|
||||
public void removeVascBackendProxy(VascBackendProxy proxy);
|
||||
|
||||
public List<VascBackendProxy> getVascBackendProxies();
|
||||
|
||||
|
||||
public VascEntryExporter getVascEntryExporterById(String exporterId);
|
||||
|
||||
public void addVascEntryExporter(VascEntryExporter exporter);
|
||||
|
||||
public void removeVascEntryExporter(VascEntryExporter exporter);
|
||||
|
||||
public List<VascEntryExporter> getVascEntryExporters();
|
||||
|
||||
|
||||
public void configVascFrontendData(VascController vascController,VascEntry entry,Locale locale) throws VascException;
|
||||
|
||||
public String getResourceBundle();
|
||||
|
||||
public void setResourceBundle(String resourceBundle);
|
||||
|
||||
public int getDefaultPageSizeMax();
|
||||
|
||||
public void setDefaultPageSizeMax(int max);
|
||||
|
||||
public int getDefaultPageSize();
|
||||
|
||||
public void setDefaultPageSize(int size);
|
||||
|
||||
public void addVascEntryFieldValidatorService(VascEntryFieldValidatorService validator);
|
||||
|
||||
public void removeVascEntryFieldValidatorService(VascEntryFieldValidatorService validator);
|
||||
|
||||
public List<VascEntryFieldValidatorService> getVascEntryFieldValidatorServices();
|
||||
|
||||
}
|
||||
|
|
@ -22,13 +22,13 @@
|
|||
|
||||
package net.forwardfire.vasc.core;
|
||||
|
||||
|
||||
/**
|
||||
* Finalizes the VascEntry so it is ready to use.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 9, 2008
|
||||
*/
|
||||
public interface VascEntryFinalizer {
|
||||
public interface VascEntryConfigFinalizer {
|
||||
|
||||
public VascEntry finalizeVascEntry(VascEntry entry,VascController vascController) throws VascException;
|
||||
public void configVascEntry(VascController vascController,VascEntry entry) throws VascException;
|
||||
}
|
||||
|
|
@ -35,6 +35,4 @@ public interface VascEntryController {
|
|||
public VascEntry getVascEntryById(String id);
|
||||
|
||||
public List<String> getVascEntryIds();
|
||||
|
||||
public List<String> getVascEntryAdminIds();
|
||||
}
|
||||
|
|
@ -32,7 +32,9 @@ package net.forwardfire.vasc.core;
|
|||
*/
|
||||
public interface VascEntryControllerLocal extends VascEntryController {
|
||||
|
||||
public void addVascEntry(VascEntry entry,VascController vascController) throws VascException;
|
||||
public void addVascEntry(VascEntry entry);
|
||||
|
||||
public VascEntry getMasterVascEntryById(String id);
|
||||
public void removeVascEntry(String entryId);
|
||||
|
||||
public VascEntry getMasterVascEntryById(String entryId);
|
||||
}
|
||||
|
|
@ -27,17 +27,13 @@ import java.util.List;
|
|||
|
||||
|
||||
/**
|
||||
* VascLinkEntry
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 7, 2008
|
||||
*/
|
||||
public interface VascLinkEntry extends Cloneable,Serializable {
|
||||
|
||||
public String getId();
|
||||
public void setId(String id);
|
||||
|
||||
public String getVascEntryId();
|
||||
public void setVascEntryId(String vascEntryId);
|
||||
|
||||
public String getEntryParameterFieldId(String parameterName);
|
||||
public void addEntryParameterFieldId(String parameterName,String valueFieldId);
|
||||
|
|
@ -47,6 +43,26 @@ public interface VascLinkEntry extends Cloneable,Serializable {
|
|||
public void addEntryCreateFieldValue(String valueFieldId,String selectedFieldId);
|
||||
public List<String> getEntryCreateFieldValueKeys();
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId();
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(String id);
|
||||
|
||||
/**
|
||||
* @return the vascEntryId
|
||||
*/
|
||||
public String getVascEntryId();
|
||||
|
||||
/**
|
||||
* @param vascEntryId the vascEntryId to set
|
||||
*/
|
||||
public void setVascEntryId(String vascEntryId);
|
||||
|
||||
/**
|
||||
* @return the vascLinkEntryType
|
||||
*/
|
||||
|
|
@ -77,6 +93,16 @@ public interface VascLinkEntry extends Cloneable,Serializable {
|
|||
*/
|
||||
public void setName(String name);
|
||||
|
||||
/**
|
||||
* @return the helpId
|
||||
*/
|
||||
public String getHelpId();
|
||||
|
||||
/**
|
||||
* @param helpId the helpId to set
|
||||
*/
|
||||
public void setHelpId(String helpId);
|
||||
|
||||
/**
|
||||
* Force impl to have public clone methode
|
||||
* @return
|
||||
|
|
|
|||
|
|
@ -37,10 +37,12 @@ import net.forwardfire.vasc.core.VascException;
|
|||
*/
|
||||
public interface VascEntryExporter extends Serializable {
|
||||
|
||||
public String getId();
|
||||
|
||||
public void doExport(OutputStream out,VascEntry vascEntry) throws VascException;
|
||||
|
||||
public String getMineType();
|
||||
|
||||
public String getType();
|
||||
public String getFileType();
|
||||
|
||||
}
|
||||
|
|
@ -37,5 +37,14 @@ import net.forwardfire.vasc.core.VascException;
|
|||
*/
|
||||
public interface VascEntryFieldValidatorService {
|
||||
|
||||
/**
|
||||
* Validated a field and returns zero or more error messsages.
|
||||
*
|
||||
* @param field
|
||||
* @param selectedRecord
|
||||
* @param objectValue
|
||||
* @return
|
||||
* @throws VascException
|
||||
*/
|
||||
public List<String> validateObjectField(VascEntryField field, Object selectedRecord,Object objectValue) throws VascException;
|
||||
}
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
package net.forwardfire.vasc.impl;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendController;
|
||||
import net.forwardfire.vasc.core.VascEntryConfigController;
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntryController;
|
||||
import net.forwardfire.vasc.core.VascEntryFieldTypeController;
|
||||
|
|
@ -37,12 +38,27 @@ import net.forwardfire.vasc.core.VascUserRoleController;
|
|||
*/
|
||||
public class DefaultVascController implements VascController {
|
||||
|
||||
private VascEntryConfigController vascEntryConfigController = null;
|
||||
private VascBackendController vascBackendController = null;
|
||||
private VascEntryController vascEntryController = null;
|
||||
private VascEntryFieldTypeController vascEntryFieldTypeController = null;
|
||||
private VascEventChannelController vascEventChannelController = null;
|
||||
private VascUserRoleController vascUserRoleController = null;
|
||||
|
||||
/**
|
||||
* @return the vascEntryConfigController
|
||||
*/
|
||||
public VascEntryConfigController getVascEntryConfigController() {
|
||||
return vascEntryConfigController;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascEntryConfigController the vascEntryConfigController to set
|
||||
*/
|
||||
public void setVascEntryConfigController(VascEntryConfigController vascEntryConfigController) {
|
||||
this.vascEntryConfigController = vascEntryConfigController;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascEventChannelController
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ public class DefaultVascEntry implements VascEntry {
|
|||
private List<RowVascAction> rowActions = null;
|
||||
private List<ColumnVascAction> columnActions = null;
|
||||
private List<GlobalVascAction> globalActions = null;
|
||||
private List<GlobalVascAction> exportActions = null;
|
||||
|
||||
private List<VascEntryFieldSet> vascEntryFieldSets = null;
|
||||
private List<VascLinkEntry> vascLinkEntries = null;
|
||||
|
|
@ -99,8 +100,9 @@ public class DefaultVascEntry implements VascEntry {
|
|||
vascFields = new ArrayList<VascEntryField>(20);
|
||||
|
||||
rowActions = new ArrayList<RowVascAction>(10);
|
||||
columnActions = new ArrayList<ColumnVascAction>(10);
|
||||
globalActions = new ArrayList<GlobalVascAction>(10);
|
||||
columnActions = new ArrayList<ColumnVascAction>(5);
|
||||
globalActions = new ArrayList<GlobalVascAction>(5);
|
||||
exportActions = new ArrayList<GlobalVascAction>(10);
|
||||
|
||||
vascEntryFieldSets = new ArrayList<VascEntryFieldSet>(10);
|
||||
vascLinkEntries = new ArrayList<VascLinkEntry>(10);
|
||||
|
|
@ -160,6 +162,9 @@ public class DefaultVascEntry implements VascEntry {
|
|||
for (VascAction a:globalActions) {
|
||||
result.globalActions.add((GlobalVascAction)a.clone());
|
||||
}
|
||||
for (VascAction a:exportActions) {
|
||||
result.exportActions.add((GlobalVascAction)a.clone());
|
||||
}
|
||||
for (VascEntryFieldSet s:vascEntryFieldSets) {
|
||||
result.vascEntryFieldSets.add(s.clone());
|
||||
}
|
||||
|
|
@ -572,6 +577,39 @@ public class DefaultVascEntry implements VascEntry {
|
|||
globalActions.remove(globalAction);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the exportActions
|
||||
*/
|
||||
public List<GlobalVascAction> getExportActions() {
|
||||
return exportActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the GlobalVascAction exportAction
|
||||
*/
|
||||
public GlobalVascAction getExportActionById(String actionId) {
|
||||
for (GlobalVascAction a:exportActions) {
|
||||
if (a.getId().equals(actionId)) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param exportAction the exportAction to add
|
||||
*/
|
||||
public void addExportAction(GlobalVascAction exportAction) {
|
||||
exportActions.add(exportAction);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param exportAction the exportAction to remove
|
||||
*/
|
||||
public void removeExportAction(GlobalVascAction exportAction) {
|
||||
exportActions.remove(exportAction);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascEntryFieldSets
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,289 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.backend.proxy.VascBackendProxy;
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryConfigController;
|
||||
import net.forwardfire.vasc.core.VascEntryConfigFinalizer;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryExporter;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.impl.entry.DefaultVascEntryResourceResolver;
|
||||
|
||||
/**
|
||||
* DefaultVascEntryConfigController runs all VascEntryConfigFinalizers on VascEntry.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public class DefaultVascEntryConfigController implements VascEntryConfigController {
|
||||
|
||||
private List<VascEntryConfigFinalizer> configFinalizers = null;
|
||||
private List<VascBackendProxy> backendProxies = null;
|
||||
private Map<String,VascEntryExporter> dataExporters = null;
|
||||
private List<VascEntryFieldValidatorService> fieldValidators = null;
|
||||
private int defaultPageSize = 100;
|
||||
private int defaultPageSizeMax = 1000;
|
||||
private String resourceBundle = null;
|
||||
|
||||
public DefaultVascEntryConfigController() {
|
||||
configFinalizers = new ArrayList<VascEntryConfigFinalizer>(10);
|
||||
backendProxies = new ArrayList<VascBackendProxy>(10);
|
||||
dataExporters = new HashMap<String,VascEntryExporter>(10);
|
||||
fieldValidators = new ArrayList<VascEntryFieldValidatorService>(5);
|
||||
}
|
||||
|
||||
public VascEntry configVascEntry(VascController vascController,String entryId) throws VascException {
|
||||
VascEntry vascEntry = vascController.getVascEntryController().getVascEntryById(entryId);
|
||||
configVascEntry(vascController,vascEntry);
|
||||
return vascEntry;
|
||||
}
|
||||
|
||||
public void configVascEntry(VascController vascController,VascEntry vascEntry) throws VascException {
|
||||
for (VascEntryConfigFinalizer finalizer:configFinalizers) {
|
||||
finalizer.configVascEntry(vascController,vascEntry);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#configVascBackendProxied(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public VascBackend configVascBackendProxied(VascController vascController,VascEntry vascEntry) throws VascException {
|
||||
VascBackend realBackend = vascController.getVascBackendController().getVascBackendById(vascEntry.getBackendId());
|
||||
return configVascBackendProxied(vascController,vascEntry,realBackend);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#configVascBackendProxied(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry, net.forwardfire.vasc.backend.VascBackend)
|
||||
*/
|
||||
public VascBackend configVascBackendProxied(VascController vascController,VascEntry vascEntry, VascBackend realBackend) throws VascException {
|
||||
VascBackend backend = realBackend;
|
||||
for (VascBackendProxy proxy:backendProxies) {
|
||||
VascBackendProxy proxyClone;
|
||||
try {
|
||||
proxyClone = proxy.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new VascException(e);
|
||||
}
|
||||
proxyClone.initProxy(backend, vascEntry);
|
||||
if (proxyClone.isProxyNeeded()==false) {
|
||||
continue;
|
||||
}
|
||||
backend = proxyClone;
|
||||
}
|
||||
return backend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @throws VascException
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#configVascFrontendData(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry, java.util.Locale)
|
||||
*/
|
||||
public void configVascFrontendData(VascController vascController,VascEntry entry, Locale locale) throws VascException {
|
||||
|
||||
|
||||
DefaultVascFrontendData vascFrontendData = new DefaultVascFrontendData();
|
||||
DefaultVascEntryState state = new DefaultVascEntryState();
|
||||
DefaultVascBackendState backendState = new DefaultVascBackendState();
|
||||
|
||||
backendState.setPageSize(vascController.getVascEntryConfigController().getDefaultPageSize());
|
||||
backendState.setPageSizeMax(vascController.getVascEntryConfigController().getDefaultPageSizeMax());
|
||||
|
||||
state.setVascBackendState(backendState);
|
||||
vascFrontendData.setVascEntryState(state);
|
||||
|
||||
// init resource resultsers
|
||||
vascFrontendData.setVascEntryResourceResolver(new DefaultVascEntryResourceResolver(ResourceBundle.getBundle(vascController.getVascEntryConfigController().getResourceBundle(), locale)));
|
||||
vascFrontendData.setVascFrontendHelper(new DefaultVascFrontendHelper());
|
||||
//vascFrontendData.setVascEntryResourceImageResolver(new ImageResources());
|
||||
|
||||
for(VascEntryFieldValidatorService validator:vascController.getVascEntryConfigController().getVascEntryFieldValidatorServices()) {
|
||||
vascFrontendData.addVascValidatorService(validator);
|
||||
}
|
||||
|
||||
|
||||
vascFrontendData.setVascController(vascController);
|
||||
entry.setVascFrontendData(vascFrontendData);
|
||||
VascBackend backend = vascController.getVascEntryConfigController().configVascBackendProxied(vascController, entry);
|
||||
vascFrontendData.getVascEntryState().setVascBackend(backend);
|
||||
vascFrontendData.getVascEntryState().setVascEntry(entry);
|
||||
|
||||
for (VascEntryField field:entry.getVascEntryFields()) {
|
||||
if (field.getVascEntryFieldValue()==null) {
|
||||
VascEntryFieldValue v = backend.provideVascEntryFieldValue(field);
|
||||
field.setVascEntryFieldValue(v);
|
||||
}
|
||||
}
|
||||
|
||||
vascFrontendData.setVascFrontendPager(new DefaultVascFrontendPager(entry));
|
||||
vascFrontendData.setVascFrontendActions(new DefaultVascFrontendActions(entry));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#addVascEntryConfigFinalizer(net.forwardfire.vasc.core.VascEntryConfigFinalizer)
|
||||
*/
|
||||
public void addVascEntryConfigFinalizer(VascEntryConfigFinalizer vascEntryConfigFinalizer) {
|
||||
configFinalizers.add(vascEntryConfigFinalizer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#removeVascEntryConfigFinalizer(net.forwardfire.vasc.core.VascEntryConfigFinalizer)
|
||||
*/
|
||||
public void removeVascEntryConfigFinalizer(VascEntryConfigFinalizer vascEntryConfigFinalizer) {
|
||||
configFinalizers.remove(vascEntryConfigFinalizer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#getVascEntryConfigFinalizers()
|
||||
*/
|
||||
public List<VascEntryConfigFinalizer> getVascEntryConfigFinalizers() {
|
||||
return configFinalizers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#addVascBackendProxy(net.forwardfire.vasc.backend.proxy.VascBackendProxy)
|
||||
*/
|
||||
public void addVascBackendProxy(VascBackendProxy proxy) {
|
||||
backendProxies.add(proxy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#removeVascBackendProxy(net.forwardfire.vasc.backend.proxy.VascBackendProxy)
|
||||
*/
|
||||
public void removeVascBackendProxy(VascBackendProxy proxy) {
|
||||
backendProxies.remove(proxy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#getVascBackendProxies()
|
||||
*/
|
||||
public List<VascBackendProxy> getVascBackendProxies() {
|
||||
return backendProxies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#getVascEntryExporterById(java.lang.String)
|
||||
*/
|
||||
public VascEntryExporter getVascEntryExporterById(String exporterId) {
|
||||
return dataExporters.get(exporterId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#addVascEntryExporter(net.forwardfire.vasc.core.entry.VascEntryExporter)
|
||||
*/
|
||||
public void addVascEntryExporter(VascEntryExporter exporter) {
|
||||
dataExporters.put(exporter.getId(),exporter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#removeVascEntryExporter(net.forwardfire.vasc.core.entry.VascEntryExporter)
|
||||
*/
|
||||
public void removeVascEntryExporter(VascEntryExporter exporter) {
|
||||
dataExporters.remove(exporter.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#getVascEntryExporters()
|
||||
*/
|
||||
public List<VascEntryExporter> getVascEntryExporters() {
|
||||
return new ArrayList<VascEntryExporter>(dataExporters.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#getResourceBundle()
|
||||
*/
|
||||
public String getResourceBundle() {
|
||||
return resourceBundle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#setResourceBundle(java.lang.String)
|
||||
*/
|
||||
public void setResourceBundle(String resourceBundle) {
|
||||
this.resourceBundle=resourceBundle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#getDefaultPageSizeMax()
|
||||
*/
|
||||
public int getDefaultPageSizeMax() {
|
||||
return defaultPageSizeMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#setDefaultPageSizeMax(int)
|
||||
*/
|
||||
public void setDefaultPageSizeMax(int defaultPageSizeMax) {
|
||||
this.defaultPageSizeMax=defaultPageSizeMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#getDefaultPageSize()
|
||||
*/
|
||||
public int getDefaultPageSize() {
|
||||
return defaultPageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#setDefaultPageSize(int)
|
||||
*/
|
||||
public void setDefaultPageSize(int defaultPageSize) {
|
||||
this.defaultPageSize=defaultPageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#addVascEntryFieldValidatorService(net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService)
|
||||
*/
|
||||
public void addVascEntryFieldValidatorService(VascEntryFieldValidatorService validator) {
|
||||
fieldValidators.add(validator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#removeVascEntryFieldValidatorService(net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService)
|
||||
*/
|
||||
public void removeVascEntryFieldValidatorService(VascEntryFieldValidatorService validator) {
|
||||
fieldValidators.remove(validator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigController#getVascEntryFieldValidatorServices()
|
||||
*/
|
||||
public List<VascEntryFieldValidatorService> getVascEntryFieldValidatorServices() {
|
||||
return fieldValidators;
|
||||
}
|
||||
}
|
||||
|
|
@ -28,14 +28,11 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* DefaultVascEntryController holds the VascEntries which we can work with.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 18, 2008
|
||||
|
|
@ -47,13 +44,27 @@ public class DefaultVascEntryController implements VascEntryControllerLocal {
|
|||
public DefaultVascEntryController() {
|
||||
entries = new HashMap<String,VascEntry>();
|
||||
}
|
||||
|
||||
public void addVascEntry(VascEntry entry,VascController vascController) throws VascException {
|
||||
DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer();
|
||||
entry = f.finalizeVascEntry(entry,vascController);
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryControllerLocal#addVascEntry(net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public void addVascEntry(VascEntry entry) {
|
||||
if (entry==null) {
|
||||
throw new NullPointerException("Can't add null VascEntry.");
|
||||
}
|
||||
if (entry.getId()==null) {
|
||||
throw new NullPointerException("Can't add VascEntry with null Id.");
|
||||
}
|
||||
entries.put(entry.getId(), entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryControllerLocal#removeVascEntry(java.lang.String)
|
||||
*/
|
||||
public void removeVascEntry(String entryId) {
|
||||
entries.remove(entryId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryController#getVascEntryById(java.lang.String)
|
||||
*/
|
||||
|
|
@ -69,9 +80,11 @@ public class DefaultVascEntryController implements VascEntryControllerLocal {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public VascEntry getMasterVascEntryById(String id) {
|
||||
VascEntry entry = entries.get(id);
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryControllerLocal#getMasterVascEntryById(java.lang.String)
|
||||
*/
|
||||
public VascEntry getMasterVascEntryById(String entryId) {
|
||||
VascEntry entry = entries.get(entryId);
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
|
@ -83,18 +96,4 @@ public class DefaultVascEntryController implements VascEntryControllerLocal {
|
|||
Collections.sort(result); // lets do abc for consistance behauvior.
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retuns only the adminList table entries
|
||||
*/
|
||||
public List<String> getVascEntryAdminIds() {
|
||||
List<String> adminIds = new ArrayList<String>(30);
|
||||
for (VascEntry e:entries.values()) {
|
||||
if (Boolean.TRUE.equals(e.isVascAdminList())) {
|
||||
adminIds.add(e.getId());
|
||||
}
|
||||
}
|
||||
Collections.sort(adminIds); // lets do abc for consistance behauvior.
|
||||
return adminIds;
|
||||
}
|
||||
}
|
||||
|
|
@ -26,7 +26,6 @@ import java.util.Locale;
|
|||
import java.util.ResourceBundle;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendFilter;
|
||||
import net.forwardfire.vasc.backend.proxy.VascBackendProxyCache;
|
||||
import net.forwardfire.vasc.backend.proxy.VascBackendProxyEventExecutor;
|
||||
import net.forwardfire.vasc.backend.proxy.VascBackendProxyFilter;
|
||||
|
|
@ -41,14 +40,17 @@ import net.forwardfire.vasc.core.VascEntryField;
|
|||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.frontend.VascFrontendData;
|
||||
import net.forwardfire.vasc.impl.actions.AddRowAction;
|
||||
import net.forwardfire.vasc.impl.actions.CSVExportGlobalAction;
|
||||
import net.forwardfire.vasc.impl.actions.DeleteRowAction;
|
||||
import net.forwardfire.vasc.impl.actions.EditRowAction;
|
||||
import net.forwardfire.vasc.impl.actions.RefreshDataGlobalAction;
|
||||
import net.forwardfire.vasc.impl.actions.XMLExportGlobalAction;
|
||||
import net.forwardfire.vasc.impl.entry.DefaultVascEntryResourceResolver;
|
||||
import net.forwardfire.vasc.impl.entry.VascValidatorsValidatorService;
|
||||
import net.forwardfire.vasc.impl.entry.config.VascActionsFinalizer;
|
||||
import net.forwardfire.vasc.impl.entry.config.VascDefaultsFinalizer;
|
||||
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.type.DefaultVascEntryFieldTypeController;
|
||||
|
||||
/**
|
||||
|
|
@ -62,8 +64,35 @@ public class DefaultVascFactory {
|
|||
|
||||
static public VascController getDefaultVascController(Long userId,String userName,String...roles) throws VascException {
|
||||
|
||||
// config full controller for local jvm use
|
||||
DefaultVascEntryConfigController vascConfig = new DefaultVascEntryConfigController();
|
||||
|
||||
// Add all backend proxy in ORDER
|
||||
vascConfig.addVascBackendProxy(new VascBackendProxyTimerLogger());
|
||||
vascConfig.addVascBackendProxy(new VascBackendProxyEventExecutor());
|
||||
vascConfig.addVascBackendProxy(new VascBackendProxyCache());
|
||||
vascConfig.addVascBackendProxy(new VascBackendProxyFilter());
|
||||
vascConfig.addVascBackendProxy(new VascBackendProxySearch());
|
||||
vascConfig.addVascBackendProxy(new VascBackendProxySort());
|
||||
vascConfig.addVascBackendProxy(new VascBackendProxyPaged());
|
||||
|
||||
// Add all finalizers in ORDER
|
||||
vascConfig.addVascEntryConfigFinalizer(new VascActionsFinalizer());
|
||||
vascConfig.addVascEntryConfigFinalizer(new VascIdAutoFinalizer());
|
||||
vascConfig.addVascEntryConfigFinalizer(new VascIdCheckFinalizer());
|
||||
vascConfig.addVascEntryConfigFinalizer(new VascI18nFinalizer());
|
||||
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 per default the internal vasc validator
|
||||
vascConfig.addVascEntryFieldValidatorService(new VascValidatorsValidatorService());
|
||||
|
||||
DefaultVascController c = new DefaultVascController();
|
||||
c.setVascEntryConfigController(vascConfig);
|
||||
|
||||
DefaultVascBackendController vascBackendController = new DefaultVascBackendController();
|
||||
c.setVascBackendController(vascBackendController);
|
||||
|
|
@ -90,7 +119,7 @@ public class DefaultVascFactory {
|
|||
DefaultVascFrontendData vascFrontendData = new DefaultVascFrontendData(); //
|
||||
vascFrontendData.setVascEntryState(new DefaultVascEntryState());
|
||||
vascFrontendData.getVascEntryState().setVascBackendState(new DefaultVascBackendState());
|
||||
vascFrontendData.getVascEntryState().getVascBackendState().setPageSize(100); // default page size is zero aka disabled
|
||||
vascFrontendData.getVascEntryState().getVascBackendState().setPageSize(100);
|
||||
vascFrontendData.getVascEntryState().getVascBackendState().setPageSizeMax(1000); // max 1k records on screen.
|
||||
|
||||
// init resource resultsers
|
||||
|
|
@ -102,65 +131,17 @@ public class DefaultVascFactory {
|
|||
return vascFrontendData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a backend of the backend controller and addes all the proxy classes.
|
||||
* @param entry
|
||||
* @return
|
||||
*/
|
||||
static public VascBackend getProxyVascBackend(VascEntry entry) {
|
||||
// Get the 'real' backend
|
||||
VascBackend backend = entry.getVascFrontendData().getVascController().getVascBackendController().getVascBackendById(entry.getBackendId());
|
||||
|
||||
// logs all actions log logger
|
||||
backend = new VascBackendProxyTimerLogger(backend,entry);
|
||||
|
||||
// Fire event listeners before caching.
|
||||
backend = new VascBackendProxyEventExecutor(backend,entry);
|
||||
|
||||
// only cached one result, checks for paramater differnce
|
||||
backend = new VascBackendProxyCache(backend,entry);
|
||||
|
||||
for (VascBackendFilter filter:entry.getVascBackendFilters()) {
|
||||
filter.initFilter(entry);
|
||||
backend = new VascBackendProxyFilter(backend,entry,filter);
|
||||
}
|
||||
if (backend.isSearchable()==false) {
|
||||
backend = new VascBackendProxySearch(backend,entry);
|
||||
}
|
||||
if (backend.isSortable()==false) {
|
||||
backend = new VascBackendProxySort(backend,entry);
|
||||
}
|
||||
if (backend.isPageable()==false) {
|
||||
backend = new VascBackendProxyPaged(backend,entry);
|
||||
}
|
||||
|
||||
// return the configed backend.
|
||||
return backend;
|
||||
}
|
||||
|
||||
static public void fillVascControllerLocalEntries(VascEntryControllerLocal c,VascController con) throws VascException {
|
||||
|
||||
|
||||
static public void fillVascControllerLocalEntries(VascEntryControllerLocal c,VascController vascController) throws VascException {
|
||||
for (String id:c.getVascEntryIds()) {
|
||||
VascEntry entry = c.getMasterVascEntryById(id);
|
||||
|
||||
// hackje for calling multiple times on same entries.
|
||||
if (entry.getGlobalActionById(XMLExportGlobalAction.ACTION_ID)==null) {
|
||||
|
||||
if (entry.isVascDisplayOnly()==false) {
|
||||
if (entry.isVascAdminCreate()) {
|
||||
entry.addRowAction(new AddRowAction());
|
||||
}
|
||||
if (entry.isVascAdminEdit()) {
|
||||
entry.addRowAction(new EditRowAction());
|
||||
}
|
||||
if (entry.isVascAdminDelete()) {
|
||||
entry.addRowAction(new DeleteRowAction());
|
||||
}
|
||||
}
|
||||
entry.addGlobalAction(new XMLExportGlobalAction());
|
||||
entry.addGlobalAction(new CSVExportGlobalAction());
|
||||
entry.addGlobalAction(new RefreshDataGlobalAction());
|
||||
}
|
||||
|
||||
vascController.getVascEntryConfigController().configVascEntry(vascController, entry);
|
||||
}
|
||||
}
|
||||
|
||||
/* MOVED to VascEntryConfigController
|
||||
|
||||
/*
|
||||
DefaultVascEntryResourceResolver t = new DefaultVascEntryResourceResolver(resourceBundle);
|
||||
|
|
@ -196,7 +177,7 @@ public class DefaultVascFactory {
|
|||
|
||||
entry.getVa
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// hackje om deze manuale actions van i18n keys te voorzien;
|
||||
// this is temp untill x4o templaing
|
||||
|
|
@ -209,11 +190,12 @@ public class DefaultVascFactory {
|
|||
// ((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(vb);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
static public void fillVascEntryFrontend(VascEntry entry,VascController vascController,VascFrontendData frontendData) {
|
||||
static public void fillVascEntryFrontend(VascEntry entry,VascController vascController,VascFrontendData frontendData) throws VascException {
|
||||
frontendData.setVascController(vascController);
|
||||
entry.setVascFrontendData(frontendData);
|
||||
VascBackend backend = DefaultVascFactory.getProxyVascBackend(entry);
|
||||
VascBackend backend = vascController.getVascEntryConfigController().configVascBackendProxied(vascController, entry);
|
||||
frontendData.getVascEntryState().setVascBackend(backend);
|
||||
frontendData.getVascEntryState().setVascEntry(entry);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import java.util.Map;
|
|||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascEntryFinalizer;
|
||||
import net.forwardfire.vasc.core.VascEntryConfigFinalizer;
|
||||
import net.forwardfire.vasc.core.VascEntryState;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.actions.ColumnVascAction;
|
||||
|
|
@ -62,7 +62,7 @@ public class DefaultVascFrontendData implements VascFrontendData {
|
|||
private VascFrontend vascFrontend = null;
|
||||
private VascFrontendActions vascFrontendActions = null;
|
||||
private VascFrontendPager vascFrontendPager = null;
|
||||
private VascEntryFinalizer vascEntryFinalizer = null;
|
||||
private VascEntryConfigFinalizer vascEntryFinalizer = null;
|
||||
private VascFrontendHelper vascFrontendHelper = null;
|
||||
private VascEntryResourceResolver vascEntryResourceResolver = null;
|
||||
private VascEntryResourceImageResolver vascEntryResourceImageResolver = null;
|
||||
|
|
@ -129,14 +129,14 @@ public class DefaultVascFrontendData implements VascFrontendData {
|
|||
/**
|
||||
* @see net.forwardfire.vasc.core.VascBackendData#getVascEntryFinalizer()
|
||||
*/
|
||||
public VascEntryFinalizer getVascEntryFinalizer() {
|
||||
public VascEntryConfigFinalizer getVascEntryFinalizer() {
|
||||
return vascEntryFinalizer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascBackendData#setVascEntryFinalizer(net.forwardfire.vasc.core.VascEntryFinalizer)
|
||||
* @see net.forwardfire.vasc.core.VascBackendData#setVascEntryFinalizer(net.forwardfire.vasc.core.VascEntryConfigFinalizer)
|
||||
*/
|
||||
public void setVascEntryFinalizer(VascEntryFinalizer vascEntryFinalizer) {
|
||||
public void setVascEntryFinalizer(VascEntryConfigFinalizer vascEntryFinalizer) {
|
||||
this.vascEntryFinalizer=vascEntryFinalizer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ public class DefaultVascLinkEntry implements VascLinkEntry {
|
|||
private VascLinkEntryType vascLinkEntryType = null;
|
||||
private String doActionId = null;
|
||||
private String name = null;
|
||||
private String helpId = null;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
|
|
@ -140,6 +141,20 @@ public class DefaultVascLinkEntry implements VascLinkEntry {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the helpId
|
||||
*/
|
||||
public String getHelpId() {
|
||||
return helpId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param helpId the helpId to set
|
||||
*/
|
||||
public void setHelpId(String helpId) {
|
||||
this.helpId = helpId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
|
|
@ -153,6 +168,7 @@ public class DefaultVascLinkEntry implements VascLinkEntry {
|
|||
result.entryCreateFieldValues=entryCreateFieldValues;
|
||||
result.id=id;
|
||||
result.name=name;
|
||||
result.helpId=helpId;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* 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.actions;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.actions.AbstractVascAction;
|
||||
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
||||
import net.forwardfire.vasc.core.actions.VascAction;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryExporter;
|
||||
|
||||
/**
|
||||
* ExportDataGlobalAction is action per exporter.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 10, 2012
|
||||
*/
|
||||
public class ExportDataGlobalAction extends AbstractVascAction implements GlobalVascAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String exporterId = null;
|
||||
static public final String ACTION_POSTFIX = "ExportAction";
|
||||
|
||||
public ExportDataGlobalAction(String exporterId) {
|
||||
this.exporterId=exporterId;
|
||||
setId(exporterId+ACTION_POSTFIX);
|
||||
}
|
||||
|
||||
protected String getActionId() {
|
||||
return exporterId;
|
||||
}
|
||||
|
||||
public void doGlobalAction(VascEntry entry) throws Exception {
|
||||
VascEntryExporter exporter = entry.getVascFrontendData().getVascController().getVascEntryConfigController().getVascEntryExporterById(exporterId);
|
||||
entry.getVascFrontendData().getVascFrontend().renderExport(exporter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.actions.AbstractVascAction#clone()
|
||||
*/
|
||||
@Override
|
||||
public VascAction clone() throws CloneNotSupportedException {
|
||||
VascAction action = new ExportDataGlobalAction(exporterId);
|
||||
action.setId(getId());
|
||||
action.setName(getName());
|
||||
action.setDescription(getDescription());
|
||||
action.setImage(getImage());
|
||||
action.setHelpId(getHelpId());
|
||||
return action;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* 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.config;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryConfigFinalizer;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryExporter;
|
||||
import net.forwardfire.vasc.impl.actions.AddRowAction;
|
||||
import net.forwardfire.vasc.impl.actions.DeleteRowAction;
|
||||
import net.forwardfire.vasc.impl.actions.EditRowAction;
|
||||
import net.forwardfire.vasc.impl.actions.ExportDataGlobalAction;
|
||||
import net.forwardfire.vasc.impl.actions.RefreshDataGlobalAction;
|
||||
|
||||
/**
|
||||
* VascActionsFinalizer Adds all the default actions.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public class VascActionsFinalizer implements VascEntryConfigFinalizer {
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigFinalizer#configVascEntry(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public void configVascEntry(VascController vascController, VascEntry entry) throws VascException {
|
||||
|
||||
|
||||
if (entry.getExportActions().isEmpty()==false) {
|
||||
return; // hackje for calling multiple times on same entries.
|
||||
}
|
||||
|
||||
if (entry.isVascDisplayOnly()==false) { // TODO: redo to flags
|
||||
if (entry.isVascAdminCreate()) {
|
||||
entry.addRowAction(new AddRowAction());
|
||||
}
|
||||
if (entry.isVascAdminEdit()) {
|
||||
entry.addRowAction(new EditRowAction());
|
||||
}
|
||||
if (entry.isVascAdminDelete()) {
|
||||
entry.addRowAction(new DeleteRowAction());
|
||||
}
|
||||
}
|
||||
entry.addGlobalAction(new RefreshDataGlobalAction());
|
||||
|
||||
// Add all exporter actions
|
||||
for (VascEntryExporter export:vascController.getVascEntryConfigController().getVascEntryExporters()) {
|
||||
entry.addExportAction(new ExportDataGlobalAction(export.getId()));
|
||||
}
|
||||
}}
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.impl;
|
||||
package net.forwardfire.vasc.impl.entry.config;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
|
@ -32,49 +32,29 @@ import net.forwardfire.vasc.backend.VascBackend;
|
|||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascEntryFieldSet;
|
||||
import net.forwardfire.vasc.core.VascEntryFinalizer;
|
||||
import net.forwardfire.vasc.core.VascEntryConfigFinalizer;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||
import net.forwardfire.vasc.core.VascLinkEntryType;
|
||||
import net.forwardfire.vasc.core.actions.VascAction;
|
||||
|
||||
/**
|
||||
* Checks for minimal needed stuff
|
||||
* and fills up the rest.
|
||||
*
|
||||
* VascDefaultsFinalizer does set some default in objects of entry.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 14, 2008
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
||||
public class VascDefaultsFinalizer implements VascEntryConfigFinalizer {
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryFinalizer#finalizeVascEntry(net.forwardfire.vasc.core.VascEntry)
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigFinalizer#configVascEntry(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public VascEntry finalizeVascEntry(VascEntry entry,VascController vascController) throws VascException {
|
||||
|
||||
public void configVascEntry(VascController vascController, VascEntry entry) throws VascException {
|
||||
|
||||
// First Check if we all have ids
|
||||
String id = entry.getId();
|
||||
if (id==null) {
|
||||
throw new IllegalArgumentException("The VascEntry need an id.");
|
||||
}
|
||||
if (entry.getBackendId()==null) {
|
||||
throw new IllegalArgumentException("The VascEntry need an backendId in entryId: "+id);
|
||||
}
|
||||
if (entry.getVascEntryFields().size()==0) {
|
||||
throw new IllegalArgumentException("We need at least one VascEntryField in entryId: "+id);
|
||||
}
|
||||
for (VascEntryField vef:entry.getVascEntryFields()) {
|
||||
if (vef.getId()==null) {
|
||||
throw new IllegalArgumentException("All VascEntryField need an id in entryId: "+id);
|
||||
}
|
||||
}
|
||||
for (VascEntryField vef:entry.getListOptions()) {
|
||||
if (vef.getId()==null) {
|
||||
throw new IllegalArgumentException("All listOption VascEntryField to have an id in entryId: "+id);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if backendId is valid
|
||||
VascBackend back = vascController.getVascBackendController().getVascBackendById( entry.getBackendId() );
|
||||
|
|
@ -82,89 +62,13 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
throw new IllegalArgumentException("The VascEntry backend is not found in backends: '"+entry.getBackendId()+"' in entryId: "+id);
|
||||
}
|
||||
|
||||
|
||||
// Fill up all not field i18n keys
|
||||
|
||||
// entry fields
|
||||
if (entry.getName()==null) {
|
||||
entry.setName("vasc.entry."+id+".name");
|
||||
}
|
||||
if (entry.getImage()==null) {
|
||||
entry.setImage("vasc.entry."+id+".image");
|
||||
}
|
||||
if (entry.getHelpId()==null) {
|
||||
entry.setHelpId("vasc.entry."+id+".helpId");
|
||||
}
|
||||
|
||||
if (entry.getListDescription()==null) {
|
||||
entry.setListDescription("vasc.entry."+id+".listDescription");
|
||||
}
|
||||
if (entry.getListImage()==null) {
|
||||
entry.setListImage("vasc.entry."+id+".listImage");
|
||||
}
|
||||
if (entry.getEditDescription()==null) {
|
||||
entry.setEditDescription("vasc.entry."+id+".editDescription");
|
||||
}
|
||||
if (entry.getEditImage()==null) {
|
||||
entry.setEditImage("vasc.entry."+id+".editImage");
|
||||
}
|
||||
if (entry.getDeleteDescription()==null) {
|
||||
entry.setDeleteDescription("vasc.entry."+id+".deleteDescription");
|
||||
}
|
||||
if (entry.getDeleteImage()==null) {
|
||||
entry.setDeleteImage("vasc.entry."+id+".deleteImage");
|
||||
}
|
||||
if (entry.getCreateDescription()==null) {
|
||||
entry.setCreateDescription("vasc.entry."+id+".createDescription");
|
||||
}
|
||||
if (entry.getCreateImage()==null) {
|
||||
entry.setCreateImage("vasc.entry."+id+".createImage");
|
||||
}
|
||||
|
||||
// boolean view helper
|
||||
if (entry.isVascDisplayOnly()) {
|
||||
entry.setVascAdminCreate(false);
|
||||
entry.setVascAdminDelete(false);
|
||||
entry.setVascAdminEdit(false);
|
||||
}
|
||||
|
||||
// optional field sets
|
||||
for (VascEntryFieldSet s:entry.getVascEntryFieldSets()) {
|
||||
|
||||
// check id
|
||||
String sid = s.getId();
|
||||
if (sid==null) {
|
||||
throw new IllegalArgumentException("All VascEntryFieldSet need an id in entryId: "+id);
|
||||
}
|
||||
|
||||
// check if refenced ids are avalible
|
||||
for (String fid:s.getVascEntryFieldIds()) {
|
||||
if (entry.getVascEntryFieldById(fid)==null) {
|
||||
throw new IllegalArgumentException("VascEntryFieldSet "+sid+" has non excisting field id: "+fid+" in entryId: "+id);
|
||||
}
|
||||
}
|
||||
|
||||
// fill up properties
|
||||
if (s.getName()==null) {
|
||||
s.setName("vasc.entry."+id+"."+sid+".name");
|
||||
}
|
||||
if (s.getDescription()==null) {
|
||||
s.setDescription("vasc.entry."+id+"."+sid+".description");
|
||||
}
|
||||
if (s.getImage()==null) {
|
||||
s.setImage("vasc.entry."+id+"."+sid+".image");
|
||||
}
|
||||
if (s.getHelpId()==null) {
|
||||
s.setHelpId("vasc.entry."+id+"."+sid+".helpId");
|
||||
}
|
||||
if (s.getStyleEdit()==null) {
|
||||
s.setStyleEdit("vasc.entry."+id+"."+sid+".styleEdit");
|
||||
}
|
||||
if (s.getStyleList()==null) {
|
||||
s.setStyleList("vasc.entry."+id+"."+sid+".styleEdit");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set defaults field Id for key ad display
|
||||
if (entry.getPrimaryKeyFieldId()==null) {
|
||||
entry.setPrimaryKeyFieldId(entry.getVascEntryFields().get(0).getId());
|
||||
|
|
@ -174,7 +78,6 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
entry.setDisplayNameFieldId(entry.getVascEntryFields().get(0).getId());
|
||||
}
|
||||
|
||||
|
||||
// Check fields
|
||||
int orderIndex = 0;
|
||||
for (VascEntryField vef:entry.getVascEntryFields()) {
|
||||
|
|
@ -188,32 +91,11 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
vef.setVascEntry(entry);
|
||||
}
|
||||
|
||||
//System.out.println("Field: "+vef.getId()+" order: "+vef.getOrderIndex()+" else: "+orderIndex);
|
||||
if (vef.getOrderIndex()==null) {
|
||||
vef.setOrderIndex(orderIndex);
|
||||
}
|
||||
orderIndex = orderIndex+100;
|
||||
|
||||
// fill up properties
|
||||
if (vef.getName()==null) {
|
||||
vef.setName("vasc.entry."+id+"."+vid+".name");
|
||||
}
|
||||
if (vef.getDescription()==null) {
|
||||
vef.setDescription("vasc.entry."+id+"."+vid+".description");
|
||||
}
|
||||
if (vef.getImage()==null) {
|
||||
vef.setImage("vasc.entry."+id+"."+vid+".image");
|
||||
}
|
||||
if (vef.getHelpId()==null) {
|
||||
vef.setHelpId("vasc.entry."+id+"."+vid+".helpId");
|
||||
}
|
||||
if (vef.getStyleEdit()==null) {
|
||||
vef.setStyleEdit("vasc.entry."+id+"."+vid+".styleEdit");
|
||||
}
|
||||
if (vef.getStyleList()==null) {
|
||||
vef.setStyleList("vasc.entry."+id+"."+vid+".styleEdit");
|
||||
}
|
||||
|
||||
//if (vef.getDefaultValue()==null) {
|
||||
// vef.setDefaultValue("vasc.entry."+id+"."+vid+".defaultValue");
|
||||
//}
|
||||
|
|
@ -249,7 +131,6 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
if (vef.getVascEntryFieldType()==null) {
|
||||
vef.setVascEntryFieldType(vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeById("TextField"));
|
||||
}
|
||||
//vef.setStyleList("vasc.entry."+id+"."+vid+".styleEdit");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -269,7 +150,6 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
//}
|
||||
}
|
||||
|
||||
|
||||
class OrderIndexComparator implements Comparator<VascEntryField> {
|
||||
public int compare(VascEntryField v1, VascEntryField v2) {
|
||||
return v1.getOrderIndex().compareTo(v2.getOrderIndex());
|
||||
|
|
@ -277,7 +157,6 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
}
|
||||
Collections.sort(entry.getVascEntryFields(),new OrderIndexComparator());
|
||||
|
||||
|
||||
// place primary key in front
|
||||
int index = 0;
|
||||
for (VascEntryField vef:entry.getVascEntryFields()) {
|
||||
|
|
@ -295,22 +174,12 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
|
||||
// Check if link entries excists
|
||||
for (VascLinkEntry vle:entry.getVascLinkEntries()) {
|
||||
|
||||
// check id
|
||||
String vid = vle.getId();
|
||||
if (vid==null) {
|
||||
throw new IllegalArgumentException("All VascLinkEntry need an id in entryId: "+id);
|
||||
}
|
||||
if (vle.getVascEntryId()==null) {
|
||||
throw new IllegalArgumentException("All VascLinkEntry need an vascEntryId: "+id);
|
||||
}
|
||||
|
||||
if (vle.getVascLinkEntryType()==null) {
|
||||
vle.setVascLinkEntryType(VascLinkEntryType.DEFAULT_TYPE);
|
||||
}
|
||||
if (vle.getName()==null) {
|
||||
vle.setName("vasc.entry."+vle.getVascEntryId()+".name");
|
||||
}
|
||||
}
|
||||
|
||||
for (VascEntryField vef:entry.getListOptions()) {
|
||||
|
|
@ -326,27 +195,7 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
vef.setOrderIndex(orderIndex);
|
||||
}
|
||||
orderIndex = orderIndex+100;
|
||||
|
||||
// fill up properties
|
||||
if (vef.getName()==null) {
|
||||
vef.setName("vasc.entry."+id+"."+vid+".name");
|
||||
}
|
||||
if (vef.getDescription()==null) {
|
||||
vef.setDescription("vasc.entry."+id+"."+vid+".description");
|
||||
}
|
||||
if (vef.getImage()==null) {
|
||||
vef.setImage("vasc.entry."+id+"."+vid+".image");
|
||||
}
|
||||
if (vef.getHelpId()==null) {
|
||||
vef.setHelpId("vasc.entry."+id+"."+vid+".helpId");
|
||||
}
|
||||
if (vef.getStyleEdit()==null) {
|
||||
vef.setStyleEdit("vasc.entry."+id+"."+vid+".styleEdit");
|
||||
}
|
||||
if (vef.getStyleList()==null) {
|
||||
vef.setStyleList("vasc.entry."+id+"."+vid+".styleEdit");
|
||||
}
|
||||
|
||||
|
||||
//if (vef.getDefaultValue()==null) {
|
||||
// vef.setDefaultValue("vasc.entry."+id+"."+vid+".defaultValue");
|
||||
//}
|
||||
|
|
@ -382,71 +231,7 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
}
|
||||
vef.setDefaultValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (VascAction action:entry.getGlobalActions()) {
|
||||
String aid = action.getId();
|
||||
if (aid==null) {
|
||||
throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+id);
|
||||
}
|
||||
if (action.getName()==null) {
|
||||
action.setName("vasc.action."+aid+".name");
|
||||
}
|
||||
if (action.getDescription()==null) {
|
||||
action.setDescription("vasc.action."+aid+".description");
|
||||
}
|
||||
if (action.getImage()==null) {
|
||||
action.setImage("vasc.action."+aid+".image");
|
||||
}
|
||||
if (action.getHelpId()==null) {
|
||||
action.setHelpId("vasc.action."+aid+".helpId");
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getRowActions()) {
|
||||
String aid = action.getId();
|
||||
if (aid==null) {
|
||||
throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+id);
|
||||
}
|
||||
if (action.getName()==null) {
|
||||
action.setName("vasc.action."+aid+".name");
|
||||
}
|
||||
if (action.getDescription()==null) {
|
||||
action.setDescription("vasc.action."+aid+".description");
|
||||
}
|
||||
if (action.getImage()==null) {
|
||||
action.setImage("vasc.action."+aid+".image");
|
||||
}
|
||||
if (action.getHelpId()==null) {
|
||||
action.setHelpId("vasc.action."+aid+".helpId");
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getColumnActions()) {
|
||||
String aid = action.getId();
|
||||
if (aid==null) {
|
||||
throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+id);
|
||||
}
|
||||
if (action.getName()==null) {
|
||||
action.setName("vasc.action."+aid+".name");
|
||||
}
|
||||
if (action.getDescription()==null) {
|
||||
action.setDescription("vasc.action."+aid+".description");
|
||||
}
|
||||
if (action.getImage()==null) {
|
||||
action.setImage("vasc.action."+aid+".image");
|
||||
}
|
||||
if (action.getHelpId()==null) {
|
||||
action.setHelpId("vasc.action."+aid+".helpId");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* 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.config;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascEntryFieldSet;
|
||||
import net.forwardfire.vasc.core.VascEntryConfigFinalizer;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||
import net.forwardfire.vasc.core.actions.VascAction;
|
||||
|
||||
/**
|
||||
* VascHelpIdFinalizer copies the (optional)capitalized Id's into helpId field.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public class VascHelpIdFinalizer implements VascEntryConfigFinalizer {
|
||||
|
||||
private boolean upperCase = true;
|
||||
private char seperatorChar = '_';
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigFinalizer#configVascEntry(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public void configVascEntry(VascController vascController, VascEntry entry) throws VascException {
|
||||
|
||||
String id = entry.getId();
|
||||
if (entry.getHelpId()==null) {
|
||||
entry.setHelpId(format(entry.getId()));
|
||||
}
|
||||
for (VascEntryFieldSet s:entry.getVascEntryFieldSets()) {
|
||||
if (s.getHelpId()==null) {
|
||||
s.setHelpId(format(id,s.getId()));
|
||||
}
|
||||
}
|
||||
for (VascEntryField vef:entry.getVascEntryFields()) {
|
||||
if (vef.getHelpId()==null) {
|
||||
vef.setHelpId(format(id,vef.getId()));
|
||||
}
|
||||
}
|
||||
for (VascLinkEntry vle:entry.getVascLinkEntries()) {
|
||||
if (vle.getHelpId()==null) {
|
||||
vle.setHelpId(format(id,vle.getId()));
|
||||
}
|
||||
}
|
||||
for (VascEntryField vef:entry.getListOptions()) {
|
||||
if (vef.getHelpId()==null) {
|
||||
vef.setHelpId(format(id,vef.getId()));
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getGlobalActions()) {
|
||||
if (action.getHelpId()==null) {
|
||||
action.setHelpId(format(id,action.getId()));
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getExportActions()) {
|
||||
if (action.getHelpId()==null) {
|
||||
action.setHelpId(format(id,action.getId()));
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getRowActions()) {
|
||||
if (action.getHelpId()==null) {
|
||||
action.setHelpId(format(id,action.getId()));
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getColumnActions()) {
|
||||
if (action.getHelpId()==null) {
|
||||
action.setHelpId(format(id,action.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String format(String ... ids) {
|
||||
StringBuilder idBuff = new StringBuilder();
|
||||
for (int i=0;i<ids.length;i++) {
|
||||
idBuff.append(ids[i]);
|
||||
if (i<ids.length-1) {
|
||||
idBuff.append(getSeperatorChar());
|
||||
}
|
||||
}
|
||||
if (isUpperCase()) {
|
||||
return idBuff.toString().toUpperCase();
|
||||
}
|
||||
return idBuff.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the upperCase
|
||||
*/
|
||||
public boolean isUpperCase() {
|
||||
return upperCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param upperCase the upperCase to set
|
||||
*/
|
||||
public void setUpperCase(boolean upperCase) {
|
||||
this.upperCase = upperCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the seperatorChar
|
||||
*/
|
||||
public char getSeperatorChar() {
|
||||
return seperatorChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param seperatorChar the seperatorChar to set
|
||||
*/
|
||||
public void setSeperatorChar(char seperatorChar) {
|
||||
this.seperatorChar = seperatorChar;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,190 @@
|
|||
/*
|
||||
* 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.config;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascEntryFieldSet;
|
||||
import net.forwardfire.vasc.core.VascEntryConfigFinalizer;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||
import net.forwardfire.vasc.core.actions.VascAction;
|
||||
|
||||
/**
|
||||
* VascI18NFinalizer fills all missing i18n fields.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public class VascI18nFinalizer implements VascEntryConfigFinalizer {
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigFinalizer#configVascEntry(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public void configVascEntry(VascController vascController, VascEntry entry) throws VascException {
|
||||
|
||||
// Fill up all not field i18n keys
|
||||
String id = entry.getId();
|
||||
|
||||
// entry fields
|
||||
if (entry.getName()==null) {
|
||||
entry.setName("vasc.entry."+id+".name");
|
||||
}
|
||||
if (entry.getImage()==null) {
|
||||
entry.setImage("vasc.entry."+id+".image");
|
||||
}
|
||||
if (entry.getListDescription()==null) {
|
||||
entry.setListDescription("vasc.entry."+id+".listDescription");
|
||||
}
|
||||
if (entry.getListImage()==null) {
|
||||
entry.setListImage("vasc.entry."+id+".listImage");
|
||||
}
|
||||
if (entry.getEditDescription()==null) {
|
||||
entry.setEditDescription("vasc.entry."+id+".editDescription");
|
||||
}
|
||||
if (entry.getEditImage()==null) {
|
||||
entry.setEditImage("vasc.entry."+id+".editImage");
|
||||
}
|
||||
if (entry.getDeleteDescription()==null) {
|
||||
entry.setDeleteDescription("vasc.entry."+id+".deleteDescription");
|
||||
}
|
||||
if (entry.getDeleteImage()==null) {
|
||||
entry.setDeleteImage("vasc.entry."+id+".deleteImage");
|
||||
}
|
||||
if (entry.getCreateDescription()==null) {
|
||||
entry.setCreateDescription("vasc.entry."+id+".createDescription");
|
||||
}
|
||||
if (entry.getCreateImage()==null) {
|
||||
entry.setCreateImage("vasc.entry."+id+".createImage");
|
||||
}
|
||||
|
||||
// Field sets
|
||||
for (VascEntryFieldSet s:entry.getVascEntryFieldSets()) {
|
||||
String sid = s.getId();
|
||||
if (s.getName()==null) {
|
||||
s.setName("vasc.entry."+id+"."+sid+".name");
|
||||
}
|
||||
if (s.getDescription()==null) {
|
||||
s.setDescription("vasc.entry."+id+"."+sid+".description");
|
||||
}
|
||||
if (s.getImage()==null) {
|
||||
s.setImage("vasc.entry."+id+"."+sid+".image");
|
||||
}
|
||||
}
|
||||
|
||||
// Check fields
|
||||
for (VascEntryField vef:entry.getVascEntryFields()) {
|
||||
String vid = vef.getId();
|
||||
if (vef.getName()==null) {
|
||||
vef.setName("vasc.entry."+id+"."+vid+".name");
|
||||
}
|
||||
if (vef.getDescription()==null) {
|
||||
vef.setDescription("vasc.entry."+id+"."+vid+".description");
|
||||
}
|
||||
if (vef.getImage()==null) {
|
||||
vef.setImage("vasc.entry."+id+"."+vid+".image");
|
||||
}
|
||||
}
|
||||
|
||||
for (VascLinkEntry vle:entry.getVascLinkEntries()) {
|
||||
if (vle.getName()==null) {
|
||||
vle.setName("vasc.entry."+vle.getVascEntryId()+".name");
|
||||
}
|
||||
}
|
||||
|
||||
for (VascEntryField vef:entry.getListOptions()) {
|
||||
String vid = vef.getId();
|
||||
if (vef.getName()==null) {
|
||||
vef.setName("vasc.entry."+id+"."+vid+".name");
|
||||
}
|
||||
if (vef.getDescription()==null) {
|
||||
vef.setDescription("vasc.entry."+id+"."+vid+".description");
|
||||
}
|
||||
if (vef.getImage()==null) {
|
||||
vef.setImage("vasc.entry."+id+"."+vid+".image");
|
||||
}
|
||||
}
|
||||
|
||||
for (VascAction action:entry.getGlobalActions()) {
|
||||
String aid = action.getId();
|
||||
if (aid==null) {
|
||||
throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+id);
|
||||
}
|
||||
if (action.getName()==null) {
|
||||
action.setName("vasc.action."+aid+".name");
|
||||
}
|
||||
if (action.getDescription()==null) {
|
||||
action.setDescription("vasc.action."+aid+".description");
|
||||
}
|
||||
if (action.getImage()==null) {
|
||||
action.setImage("vasc.action."+aid+".image");
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getExportActions()) {
|
||||
String aid = action.getId();
|
||||
if (aid==null) {
|
||||
throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+id);
|
||||
}
|
||||
if (action.getName()==null) {
|
||||
action.setName("vasc.action."+aid+".name");
|
||||
}
|
||||
if (action.getDescription()==null) {
|
||||
action.setDescription("vasc.action."+aid+".description");
|
||||
}
|
||||
if (action.getImage()==null) {
|
||||
action.setImage("vasc.action."+aid+".image");
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getRowActions()) {
|
||||
String aid = action.getId();
|
||||
if (aid==null) {
|
||||
throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+id);
|
||||
}
|
||||
if (action.getName()==null) {
|
||||
action.setName("vasc.action."+aid+".name");
|
||||
}
|
||||
if (action.getDescription()==null) {
|
||||
action.setDescription("vasc.action."+aid+".description");
|
||||
}
|
||||
if (action.getImage()==null) {
|
||||
action.setImage("vasc.action."+aid+".image");
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getColumnActions()) {
|
||||
String aid = action.getId();
|
||||
if (aid==null) {
|
||||
throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+id);
|
||||
}
|
||||
if (action.getName()==null) {
|
||||
action.setName("vasc.action."+aid+".name");
|
||||
}
|
||||
if (action.getDescription()==null) {
|
||||
action.setDescription("vasc.action."+aid+".description");
|
||||
}
|
||||
if (action.getImage()==null) {
|
||||
action.setImage("vasc.action."+aid+".image");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* 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.config;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascEntryFieldSet;
|
||||
import net.forwardfire.vasc.core.VascEntryConfigFinalizer;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||
import net.forwardfire.vasc.core.actions.VascAction;
|
||||
|
||||
/**
|
||||
* VascAutoIdFinalizer fills the missing id automaticly.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public class VascIdAutoFinalizer implements VascEntryConfigFinalizer {
|
||||
|
||||
private char seperatorChar = '_';
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigFinalizer#configVascEntry(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public void configVascEntry(VascController vascController, VascEntry entry) throws VascException {
|
||||
|
||||
// count all auto objects as one index
|
||||
int index = 0;
|
||||
String id = entry.getId();
|
||||
if (id==null) {
|
||||
throw new IllegalArgumentException("The VascEntry need an id.");
|
||||
}
|
||||
for (VascEntryField vef:entry.getListOptions()) {
|
||||
if (vef.getId()==null) {
|
||||
vef.setId(format(id,"list",""+index++));
|
||||
}
|
||||
}
|
||||
for (VascEntryFieldSet s:entry.getVascEntryFieldSets()) {
|
||||
String sid = s.getId();
|
||||
if (sid==null) {
|
||||
s.setId(format(id,"fieldset",""+index++));
|
||||
}
|
||||
}
|
||||
for (VascLinkEntry vle:entry.getVascLinkEntries()) {
|
||||
String vid = vle.getId();
|
||||
if (vid==null) {
|
||||
if (vle.getVascEntryId()==null) {
|
||||
vle.setId(format(id,"link",""+index++));
|
||||
} else {
|
||||
vle.setId(format(id,"link",vle.getVascEntryId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getGlobalActions()) {
|
||||
String aid = action.getId();
|
||||
if (aid==null) {
|
||||
action.setId(format(id,"action",""+index++));
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getExportActions()) {
|
||||
String aid = action.getId();
|
||||
if (aid==null) {
|
||||
action.setId(format(id,"action",""+index++));
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getRowActions()) {
|
||||
String aid = action.getId();
|
||||
if (aid==null) {
|
||||
action.setId(format(id,"action",""+index++));
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getColumnActions()) {
|
||||
String aid = action.getId();
|
||||
if (aid==null) {
|
||||
action.setId(format(id,"action",""+index++));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String format(String ... ids) {
|
||||
StringBuilder idBuff = new StringBuilder();
|
||||
for (int i=0;i<ids.length;i++) {
|
||||
idBuff.append(ids[i]);
|
||||
if (i<ids.length-1) {
|
||||
idBuff.append(getSeperatorChar());
|
||||
}
|
||||
}
|
||||
return idBuff.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the seperatorChar
|
||||
*/
|
||||
public char getSeperatorChar() {
|
||||
return seperatorChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param seperatorChar the seperatorChar to set
|
||||
*/
|
||||
public void setSeperatorChar(char seperatorChar) {
|
||||
this.seperatorChar = seperatorChar;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* 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.config;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascEntryFieldSet;
|
||||
import net.forwardfire.vasc.core.VascEntryConfigFinalizer;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||
import net.forwardfire.vasc.core.actions.VascAction;
|
||||
|
||||
/**
|
||||
* VascIdCheckFinalizer Checks the all objects have an ID.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
public class VascIdCheckFinalizer implements VascEntryConfigFinalizer {
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascEntryConfigFinalizer#configVascEntry(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public void configVascEntry(VascController vascController, VascEntry entry) throws VascException {
|
||||
|
||||
// First Check if we all have ids
|
||||
String id = entry.getId();
|
||||
if (id==null) {
|
||||
throw new IllegalArgumentException("The VascEntry need an id.");
|
||||
}
|
||||
if (entry.getBackendId()==null) {
|
||||
throw new IllegalArgumentException("The VascEntry need an backendId in entryId: "+id);
|
||||
}
|
||||
for (VascEntryField vef:entry.getVascEntryFields()) {
|
||||
if (vef.getId()==null) {
|
||||
throw new IllegalArgumentException("All VascEntryField need an id in entryId: "+id);
|
||||
}
|
||||
}
|
||||
for (VascEntryField vef:entry.getListOptions()) {
|
||||
if (vef.getId()==null) {
|
||||
throw new IllegalArgumentException("All listOption VascEntryField to have an id in entryId: "+id);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if backendId is valid
|
||||
VascBackend back = vascController.getVascBackendController().getVascBackendById( entry.getBackendId() );
|
||||
if (back==null) {
|
||||
throw new IllegalArgumentException("The VascEntry backend is not found in backends: '"+entry.getBackendId()+"' in entryId: "+id);
|
||||
}
|
||||
|
||||
// optional field sets
|
||||
for (VascEntryFieldSet s:entry.getVascEntryFieldSets()) {
|
||||
String sid = s.getId();
|
||||
if (sid==null) {
|
||||
throw new IllegalArgumentException("All VascEntryFieldSet need an id in entryId: "+id);
|
||||
}
|
||||
|
||||
// check if refenced ids are avalible
|
||||
for (String fid:s.getVascEntryFieldIds()) {
|
||||
if (entry.getVascEntryFieldById(fid)==null) {
|
||||
throw new IllegalArgumentException("VascEntryFieldSet "+sid+" has non excisting field id: "+fid+" in entryId: "+id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if link entries excists
|
||||
for (VascLinkEntry vle:entry.getVascLinkEntries()) {
|
||||
String vid = vle.getId();
|
||||
if (vid==null) {
|
||||
throw new IllegalArgumentException("All VascLinkEntry need an id in entryId: "+id);
|
||||
}
|
||||
if (vle.getVascEntryId()==null) {
|
||||
throw new IllegalArgumentException("All VascLinkEntry need an vascEntryId: "+id);
|
||||
}
|
||||
}
|
||||
|
||||
for (VascAction action:entry.getGlobalActions()) {
|
||||
String aid = action.getId();
|
||||
if (aid==null) {
|
||||
throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+id);
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getExportActions()) {
|
||||
String aid = action.getId();
|
||||
if (aid==null) {
|
||||
throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+id);
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getRowActions()) {
|
||||
String aid = action.getId();
|
||||
if (aid==null) {
|
||||
throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+id);
|
||||
}
|
||||
}
|
||||
for (VascAction action:entry.getColumnActions()) {
|
||||
String aid = action.getId();
|
||||
if (aid==null) {
|
||||
throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* 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.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
|
||||
|
||||
// hackje until calc index to page and row.
|
||||
try {
|
||||
data = new ArrayList<List<String>>(1000);
|
||||
int pages = (int)total/vascEntry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
|
||||
for (int page=0;page<=pages;page++) {
|
||||
vascEntry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(page);
|
||||
vascEntry.getVascFrontendData().getVascFrontendActions().refreshData();
|
||||
for (Object o:vascEntry.getVascFrontendData().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)) {
|
||||
List<VascEntryField> fields = vascEntry.getVascEntryFields();
|
||||
VascEntryField field = fields.get(Integer.parseInt(fieldName.substring(7)));
|
||||
return vascEntry.getVascFrontendData().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;
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.impl.actions;
|
||||
package net.forwardfire.vasc.impl.entry.export;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
|
@ -28,31 +28,30 @@ import java.io.PrintWriter;
|
|||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.actions.AbstractVascAction;
|
||||
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryExporter;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* VascEntryExporterCsv writes data to csv output format.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 30, 2007
|
||||
*/
|
||||
public class CSVExportGlobalAction extends AbstractVascAction implements GlobalVascAction,VascEntryExporter {
|
||||
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;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -3951608685719832654L;
|
||||
static public final String ACTION_ID = "csvExportAction";
|
||||
|
||||
protected String getActionId() {
|
||||
return ACTION_ID;
|
||||
}
|
||||
|
||||
public void doGlobalAction(VascEntry entry) throws Exception {
|
||||
entry.getVascFrontendData().getVascFrontend().renderExport(this);
|
||||
}
|
||||
|
||||
public void doExport(OutputStream out,VascEntry entry) throws VascException {
|
||||
/**
|
||||
* @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()) {
|
||||
|
|
@ -82,11 +81,17 @@ public class CSVExportGlobalAction extends AbstractVascAction implements GlobalV
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.entry.VascEntryExporter#getMineType()
|
||||
*/
|
||||
public String getMineType() {
|
||||
return "text/csv";
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return "csv";
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.entry.VascEntryExporter#getFileType()
|
||||
*/
|
||||
public String getFileType() {
|
||||
return EXPORT_TYPE;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* 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.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryExporter;
|
||||
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.getVascFrontendData().getVascEntryResourceResolver().getTextValue(entry.getName()));
|
||||
parameters.put("description", entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(entry.getListDescription()));
|
||||
parameters.put("titleSubject", entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(entry.getId()));
|
||||
|
||||
int oldIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
|
||||
String bundle = entry.getVascFrontendData().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.getVascFrontendData().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;
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.impl.actions;
|
||||
package net.forwardfire.vasc.impl.entry.export;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
|
@ -28,31 +28,31 @@ import java.io.PrintWriter;
|
|||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.actions.AbstractVascAction;
|
||||
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryExporter;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* VascEntryExporterXml writes entry data to xml format.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 30, 2007
|
||||
*/
|
||||
public class XMLExportGlobalAction extends AbstractVascAction implements GlobalVascAction,VascEntryExporter {
|
||||
public class VascEntryExporterXml implements VascEntryExporter {
|
||||
|
||||
private static final long serialVersionUID = 3719424578585760828L;
|
||||
static public final String ACTION_ID = "xmlExportAction";
|
||||
static public final String EXPORT_TYPE = "xml";
|
||||
private boolean xmlTree = false;
|
||||
|
||||
protected String getActionId() {
|
||||
return ACTION_ID;
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.entry.VascEntryExporter#getId()
|
||||
*/
|
||||
public String getId() {
|
||||
return EXPORT_TYPE;
|
||||
}
|
||||
|
||||
public void doGlobalAction(VascEntry entry) throws Exception {
|
||||
entry.getVascFrontendData().getVascFrontend().renderExport(this);
|
||||
}
|
||||
|
||||
public void doExport(OutputStream out,VascEntry entry) throws VascException {
|
||||
|
||||
/**
|
||||
* @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");
|
||||
|
|
@ -66,9 +66,15 @@ public class XMLExportGlobalAction extends AbstractVascAction implements GlobalV
|
|||
for (Object o:entry.getVascFrontendData().getVascEntryState().getEntryDataList()) {
|
||||
p.write("\t<row>\n");
|
||||
for (VascEntryField c:entry.getVascEntryFields()) {
|
||||
p.write("\t\t<column name=\""+c.getId()+"\"><![CDATA[");
|
||||
p.write(""+c.getVascEntryFieldValue().getDisplayValue(c, o));
|
||||
p.write("]]></column>\n");
|
||||
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();
|
||||
|
|
@ -81,11 +87,31 @@ public class XMLExportGlobalAction extends AbstractVascAction implements GlobalV
|
|||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(oldIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.entry.VascEntryExporter#getMineType()
|
||||
*/
|
||||
public String getMineType() {
|
||||
return "text/xml";
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return "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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* VascEntryExporterXmlTree exports the data as xml tree.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 9, 2012
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.impl.entry.export.VascEntryExporterXml#getId()
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return EXPORT_TYPE;
|
||||
}
|
||||
}
|
||||
|
|
@ -36,17 +36,13 @@ import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
|||
import net.forwardfire.vasc.core.ui.VascSelectItem;
|
||||
import net.forwardfire.vasc.core.ui.VascSelectItemModel;
|
||||
import net.forwardfire.vasc.impl.DefaultVascBackendState;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The DefaultVascSelectItemModel
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Oct 27, 2007
|
||||
*/
|
||||
* The DefaultVascSelectItemModel
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Oct 27, 2007
|
||||
*/
|
||||
public class VascSelectItemModelEntry implements VascSelectItemModel {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -84,7 +80,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel {
|
|||
|
||||
// set frontend data for new clone, we need te get better lifecycle management for stats/entry/etc
|
||||
entry.setVascFrontendData(currentEntry.getVascFrontendData());
|
||||
VascBackend back = DefaultVascFactory.getProxyVascBackend(entry);
|
||||
VascBackend back = currentEntry.getVascFrontendData().getVascController().getVascEntryConfigController().configVascBackendProxied(currentEntry.getVascFrontendData().getVascController(), entry);
|
||||
try {
|
||||
if (nullLabel!=null) {
|
||||
if (nullKeyValue==null) {
|
||||
|
|
@ -97,6 +93,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel {
|
|||
|
||||
// set def para
|
||||
VascBackendState state = new DefaultVascBackendState();
|
||||
|
||||
for (String key2:entry.getEntryParameterKeys()) {
|
||||
Object value = entry.getEntryParameter(key2);
|
||||
//System.out.println("Copy paras name: "+key2+" value: "+value+" class: "+value.getClass().getName());
|
||||
|
|
|
|||
|
|
@ -22,18 +22,15 @@
|
|||
|
||||
package net.forwardfire.vasc.impl.x4o;
|
||||
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryController;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
import org.x4o.xml.element.AbstractElementConfigurator;
|
||||
import org.x4o.xml.element.Element;
|
||||
import org.x4o.xml.element.ElementConfiguratorException;
|
||||
|
||||
|
||||
/**
|
||||
* Converts the type to the type object
|
||||
*
|
||||
|
|
@ -46,18 +43,12 @@ public class VascEntryElementConfigurator extends AbstractElementConfigurator {
|
|||
* @see org.x4o.xml.element.AbstractElementConfigurator#doConfigEndTag(org.x4o.xml.element.Element)
|
||||
*/
|
||||
public void doConfigElement(Element element) throws ElementConfiguratorException {
|
||||
|
||||
VascEntry entry = (VascEntry)element.getElementObject();
|
||||
|
||||
VascController vascController = VascParser.getVascController(element.getElementContext());
|
||||
VascEntryController entryController = vascController.getVascEntryController();
|
||||
|
||||
if (entryController instanceof VascEntryControllerLocal) {
|
||||
try {
|
||||
((VascEntryControllerLocal)entryController).addVascEntry(entry, vascController);
|
||||
} catch (VascException e) {
|
||||
throw new ElementConfiguratorException(this,"Couln't add entry: "+e.getMessage(),e);
|
||||
}
|
||||
((VascEntryControllerLocal)entryController).addVascEntry(entry);
|
||||
} else {
|
||||
throw new ElementConfiguratorException(this,"Can not add entry '"+entry.getId()+"' to VascEntryController because we have no access to VascEntryControllerLocal interface.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue