2
0
Fork 0

deleted renamed files.

This commit is contained in:
Willem Cazander 2012-06-04 22:55:18 +02:00
parent 6ccd763d1f
commit d4e537a2bf
56 changed files with 0 additions and 7032 deletions

View file

@ -1,235 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.core;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.x4o.xml.conv.ObjectConverter;
import net.forwardfire.vasc.core.ui.VascUIComponent;
import net.forwardfire.vasc.core.ui.VascValueModel;
import net.forwardfire.vasc.validators.VascValidator;
/**
*
* @author Willem Cazander
* @version 1.0 Aug 2, 2007
*/
abstract public class AbstractVascEntryFieldType implements VascEntryFieldType {
private static final long serialVersionUID = 1L;
protected String id = null;
protected Class<?> autoDetectClass = null;
protected List<VascValidator> vascValidators = null;
protected Map<String,String> properties = null;
protected ObjectConverter objectConverter = null;
protected Object dataObject = null;
protected String uiComponentId = null;
protected String inputMask = null;
public AbstractVascEntryFieldType() {
vascValidators = new ArrayList<VascValidator>(4);
properties = new HashMap<String,String>();
}
/**
* @see java.lang.Object#clone()
*/
@Override
abstract public VascEntryFieldType clone() throws CloneNotSupportedException;
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#getId()
*/
public String getId() {
return id;
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#setId(java.lang.String)
*/
public void setId(String id) {
this.id=id;
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#getProperty(java.lang.String)
*/
public String getProperty(String name) {
return properties.get(name);
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#setProperty(java.lang.String, java.lang.String)
*/
public void setProperty(String name, String value) {
properties.put(name, value);
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#getPropertyNames()
*/
public List<String> getPropertyNames() {
return new ArrayList<String>(properties.keySet());
}
/**
* @return the dataObject
*/
public Object getDataObject() {
return dataObject;
}
/**
* @param dataObject the dataObject to set
*/
public void setDataObject(Object dataObject) {
this.dataObject = dataObject;
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#getVascValidators()
*/
public List<VascValidator> getVascValidators() {
return vascValidators;
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#addVascValidator(net.forwardfire.vasc.validators.VascValidator)
*/
public void addVascValidator(VascValidator vascValidator) {
vascValidators.add(vascValidator);
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#removeVascValidator(net.forwardfire.vasc.validators.VascValidator)
*/
public void removeVascValidator(VascValidator vascValidator) {
vascValidators.remove(vascValidator);
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#getAutoDetectClass()
*/
public Class<?> getAutoDetectClass() {
return autoDetectClass;
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#setAutoDetectClass(java.lang.Class)
*/
public void setAutoDetectClass(Class<?> classObject) {
if (classObject==null) {
throw new NullPointerException("Can't add null classObject to fieldtype.");
}
autoDetectClass=classObject;
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#getInputMask()
*/
public String getInputMask() {
return inputMask;
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#setInputMask(java.lang.String)
*/
public void setInputMask(String inputMask) {
this.inputMask=inputMask;
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#getUIComponentId()
*/
public String getUIComponentId() {
return uiComponentId;
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#setUIComponentId(java.lang.String)
*/
public void setUIComponentId(String uiComponentId) {
this.uiComponentId=uiComponentId;
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#getUIComponentCount()
*/
public int getUIComponentCount(VascEntryField entryField) throws VascException {
return 1;
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#provideEditorUIComponent(int)
*/
public VascUIComponent provideEditorUIComponent(int index,VascEntryField entryField) throws VascException {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl == null) {
cl = entryField.getClass().getClassLoader(); // fallback
}
String compId = getUIComponentId();
if (compId==null) {
compId = VascUIComponent.VASC_TEXT;
}
return entryField.getVascEntry().getVascFrontendData().getVascUIComponent(compId);
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#provideLabelUIComponent(int)
*/
public VascUIComponent provideLabelUIComponent(int index,VascEntryField entryField) throws VascException {
return entryField.getVascEntry().getVascFrontendData().getVascUIComponent(VascUIComponent.VASC_LABEL);
}
/**
* @see net.forwardfire.vasc.core.VascEntryFieldType#provideEditorVascValueModel()
*/
public VascValueModel provideEditorVascValueModel(int index,VascEntryField entryField) throws VascException {
if (index>0) {
throw new IllegalArgumentException("You have to override provideEditorVascValueModel if multi editor support is needed");
}
VascValueModel model = new VascValueModel();
return model;
}
/**
* @return the objectConverter
*/
public ObjectConverter getObjectConverter() {
return objectConverter;
}
/**
* @param objectConverter the objectConverter to set
*/
public void setObjectConverter(ObjectConverter objectConverter) {
this.objectConverter = objectConverter;
}
}

View file

@ -1,112 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.core;
import java.io.Serializable;
import java.util.List;
/**
* VascLinkEntry
*
* @author Willem Cazander
* @version 1.0 Sep 7, 2008
*/
public interface VascLinkEntry extends Cloneable,Serializable {
public String getEntryParameterFieldId(String parameterName);
public void addEntryParameterFieldId(String parameterName,String valueFieldId);
public List<String> getEntryParameterFieldIdKeys();
public String getEntryCreateFieldValue(String valueFieldId);
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
*/
public VascLinkEntryType getVascLinkEntryType();
/**
* @param vascLinkEntryType the vascLinkEntryType to set
*/
public void setVascLinkEntryType(VascLinkEntryType vascLinkEntryType);
/**
* @return the doActionId
*/
public String getDoActionId();
/**
* @param doActionId the doActionId to set
*/
public void setDoActionId(String doActionId);
/**
* @return the name
*/
public String getName();
/**
* @param name the name to set
*/
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
* @throws CloneNotSupportedException
*/
public VascLinkEntry clone() throws CloneNotSupportedException;
}

View file

@ -1,40 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.core;
import java.io.Serializable;
/**
* The type of a VascLinkEntry
*
* @author Willem Cazander
* @version 1.0 Mrt 16, 2010
*/
public enum VascLinkEntryType implements Serializable {
EDIT_INLINE,
EDIT_TAB,
LIST;
public static VascLinkEntryType DEFAULT_TYPE = VascLinkEntryType.EDIT_TAB;
}

View file

@ -1,42 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.core;
import java.util.List;
/**
*
* @author Willem Cazander
* @version 1.0 Nov 19, 2008
*/
public interface VascUserRoleController {
public Long getUserId();
public String getUserName();
public List<String> getUserRoles();
public boolean hasRole(String roles);
}

View file

@ -1,130 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.core.actions;
/**
*
* @author Willem Cazander
* @version 1.0 Mar 30, 2007
*/
abstract public class AbstractVascAction implements VascAction {
private static final long serialVersionUID = 1L;
private String id = null;
private String name = null;
private String description = null;
private String image = null;
private String helpId = null;
public AbstractVascAction() {
setId(getActionId());
}
abstract protected String getActionId();
public VascAction clone() throws CloneNotSupportedException {
VascAction action;
try {
action = this.getClass().newInstance();
} catch (Exception e) {
throw new CloneNotSupportedException("Could not create action from myClass: "+e.getMessage());
}
action.setId(id);
action.setName(name);
action.setDescription(description);
action.setImage(image);
action.setHelpId(helpId);
return action;
}
/**
* @see net.forwardfire.vasc.core.actions.VascAction#getId()
*/
public String getId() {
return id;
}
/**
* @see net.forwardfire.vasc.core.actions.VascAction#setId(java.lang.String)
*/
public void setId(String id) {
this.id=id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description description toolTip to set
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return the helpId
*/
public String getHelpId() {
return helpId;
}
/**
* @param helpId the helpId to set
*/
public void setHelpId(String helpId) {
this.helpId = helpId;
}
/**
* @return the image
*/
public String getImage() {
return image;
}
/**
* @param image the image to set
*/
public void setImage(String image) {
this.image = image;
}
}

View file

@ -1,134 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.frontend;
import java.util.List;
import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.VascEntryState;
import net.forwardfire.vasc.core.VascException;
import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService;
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
import net.forwardfire.vasc.core.entry.VascEntryResourceImageResolver;
import net.forwardfire.vasc.core.entry.VascEntryResourceResolver;
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
import net.forwardfire.vasc.core.ui.VascUIComponent;
/**
*
* @author Willem Cazander
* @version 1.0 Mar 21, 2007
*/
public interface VascFrontendData {
/**
* @return the vascFrontend
*/
public VascFrontend getVascFrontend();
/**
* @param vascFrontend the vascFrontend to set
*/
public void setVascFrontend(VascFrontend vascFrontend);
/**
* Gets the VascFrontendActions to make frontend actions simple.
*/
public VascFrontendActions getVascFrontendActions();
/**
* @param vascFrontendActions the vascFrontendActions to set
*/
public void setVascFrontendActions(VascFrontendActions vascFrontendActions);
/**
* @return the vascFrontendPager
*/
public VascFrontendPager getVascFrontendPager();
/**
* @param vascFrontendPager the vascFrontendPager to set
*/
public void setVascFrontendPager(VascFrontendPager vascFrontendPager);
/**
* @return the VascFrontendHelper
*/
public VascFrontendHelper getVascFrontendHelper();
/**
* @param vascFrontendHelper The VascFrontendHelper to set.
*/
public void setVascFrontendHelper(VascFrontendHelper vascFrontendHelper);
/**
* @return the vascEntryResourceResolver
*/
public VascEntryResourceResolver getVascEntryResourceResolver();
/**
* @param vascEntryResourceResolver the vascEntryResourceResolver to set
*/
public void setVascEntryResourceResolver(VascEntryResourceResolver vascEntryResourceResolver);
public void putVascUIComponent(String rendererId,String uiComponentClass);
public VascUIComponent getVascUIComponent(String rendererId) throws VascException;
public String getVascUIComponentClass(String rendererId);
public void setVascController(VascController vascController);
public VascController getVascController();
public void addFieldVascUIComponents(VascEntryField field,VascUIComponent uiComponent,Object editor);
public VascUIComponent getFieldVascUIComponent(VascEntryField field);
public Object getFieldRealRenderer(VascEntryField field);
public void clearFieldRenderObjects();
/**
* @return the vascEntryResourceImageResolver
*/
public VascEntryResourceImageResolver getVascEntryResourceImageResolver();
/**
* @param vascEntryResourceImageResolver the vascEntryResourceImageResolver to set
*/
public void setVascEntryResourceImageResolver(VascEntryResourceImageResolver vascEntryResourceImageResolver);
public void addVascValidatorService(VascEntryFieldValidatorService validatorService);
public List<VascEntryFieldValidatorService> getVascValidatorServices();
public VascEntryState getVascEntryState();
public void setVascEntryState(VascEntryState state);
public void initFrontendListeners(VascEntry entry,String frontendType) throws InstantiationException, IllegalAccessException;
public void addVascEntryFrontendEventListener(VascEntryFrontendEventListener listener);
public List<VascEntryFrontendEventListener> getVascEntryFrontendEventListener(VascEntryFrontendEventListener.VascFrontendEventType type);
public void fireVascFrontendEvent(VascEntry entry,VascFrontendEventType type,Object data);
}

View file

@ -1,318 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.impl;
import java.util.Date;
import java.util.logging.Logger;
import net.forwardfire.vasc.backend.VascBackendFilter;
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.VascEntryFrontendEventListener;
import net.forwardfire.vasc.frontend.VascFrontendActions;
/**
* Default impl of default frontend actions
*
* @author Willem Cazander
* @version 1.0 Jan 22, 2012
*/
public class DefaultVascFrontendActions implements VascFrontendActions {
private Logger logger = Logger.getLogger(DefaultVascFrontendActions.class.getName());
private VascEntry entry = null;
public DefaultVascFrontendActions(VascEntry entry) {
this.entry=entry;
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#initEditObject(net.forwardfire.vasc.core.VascEntry)
*/
public Object createObject() {
try {
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_CREATE, null);
Object object = entry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryRecordCreator(entry.clone()).newRecord(entry);
if (object==null) {
throw new IllegalStateException("Can't work with null object for backend storage.");
}
for (VascEntryField field:entry.getVascEntryFields()) {
if (field.getDefaultValue()==null) {
continue; // no default value to set.
}
Object value = field.getVascEntryFieldValue().getValue(field, object);
if (value!=null) {
continue; // value is already set by backend creator.
}
Object defaultValue = field.getDefaultValue();
if (defaultValue instanceof String) {
String def = (String)defaultValue;
if (def.equals("now()")) { // TODO: add default string parsers
defaultValue = new Date();
}
}
logger.finer("Setting default value for: "+field.getName()+" def: "+defaultValue);
field.getVascEntryFieldValue().setValue(field, object, defaultValue);
}
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_CREATE, object);
return object;
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,e);
return null; /// ?? ,,
}
}
protected int removeObjectFromDataList(Object object) {
int indexOld = entry.getVascFrontendData().getVascEntryState().getEntryDataList().indexOf(object);
if (entry.getVascFrontendData().getVascEntryState().getEntryDataList().remove(object)) {
return indexOld; // java worked well for use
}
// remove only work on (jpa)beans with an overrided equals method.
// we lets do the search ourselfs here because we should know the primary key value
try {
VascEntryField field = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId());
Object idObject = field.getVascEntryFieldValue().getValue(field, object);
// is only null when creating objects
if (idObject!=null) {
int index = 0;
for (Object o:entry.getVascFrontendData().getVascEntryState().getEntryDataList()) {
field = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId());
Object id = field.getVascEntryFieldValue().getValue(field, o);
if (idObject.equals(id)) {
break;
}
index++;
}
if (index<entry.getVascFrontendData().getVascEntryState().getEntryDataList().size()) {
entry.getVascFrontendData().getVascEntryState().getEntryDataList().remove(index);
return index;
}
}
} catch (VascException e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,e);
}
return 0; // make better (0=top of list)
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendActions#persistObject()
*/
public void persistObject() {
saveObject(true);
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendActions#mergeObject()
*/
public Object mergeObject() {
return saveObject(false);
}
protected Object saveObject(boolean persist) {
Object object = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
Object result = null;
try {
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_UPDATE,object);
int index = removeObjectFromDataList(object);
// save object on backend
if (persist) {
entry.getVascFrontendData().getVascEntryState().getVascBackend().persist(object);
} else {
result = entry.getVascFrontendData().getVascEntryState().getVascBackend().merge(object);
}
// put object thrue the filters
for (VascBackendFilter filter:entry.getVascBackendFilters()) {
result = filter.filterObject(result);
}
// put object back in list
entry.getVascFrontendData().getVascEntryState().getEntryDataList().add(index, result);
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_UPDATE,result);
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,e);
}
return result;
}
/**
* Deletes the selected row object from the back-end and list and fires events.
* @param entry
* @param object
*/
public void deleteObject() {
Object object = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_DELETE, object);
try {
entry.getVascFrontendData().getVascEntryState().getVascBackend().delete(object);
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,e);
}
removeObjectFromDataList(object);
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_DELETE, object);
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#refreshData(net.forwardfire.vasc.core.VascEntry)
*/
public void refreshData() {
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_READ, null);
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
VascBackendState backendState = entry.getVascFrontendData().getVascEntryState().getVascBackendState();
try {
// check and correct max page size
if (backendState.getPageSize() > backendState.getPageSizeMax()) {
backendState.setPageSize(backendState.getPageSizeMax());
}
// Sets parameters to backend state
for (String key:entry.getEntryParameterKeys()) {
Object value = entry.getEntryParameter(key);
backendState.setDataParameter(key, value);
}
// Execute to get data.
entry.getVascFrontendData().getVascEntryState().setEntryDataList(entry.getVascFrontendData().getVascEntryState().getVascBackend().execute(backendState));
// Update total every time first
Long total = entry.getVascFrontendData().getVascEntryState().getVascBackend().fetchTotalExecuteSize(backendState);
entry.getVascFrontendData().getVascEntryState().setTotalBackendRecords(total);
// check if we need to change the current page
int pages = new Long(total/backendState.getPageSize()).intValue();
if (backendState.getPageIndex() > pages) {
backendState.setPageIndex(pages);
entry.getVascFrontendData().getVascEntryState().setEntryDataList(entry.getVascFrontendData().getVascEntryState().getVascBackend().execute(backendState));
}
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
}
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, null);
}
public void sortAction(VascEntryField field) {
String curSort = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getSortField();
if (field.getBackendName().equals(curSort)) {
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortAscending(!entry.getVascFrontendData().getVascEntryState().getVascBackendState().isSortAscending());
}
String sortID = field.getBackendName();
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortField(sortID);
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(0);
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.SORT, field);
refreshData();
try {
entry.getVascFrontendData().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
}
}
public void searchAction(String searchString) {
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSearchString(searchString);
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortField(null);
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(0);
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.SEARCH, searchString);
refreshData();
try {
entry.getVascFrontendData().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
}
}
public void pageAction(Integer pageIndex) {
if (pageIndex<1) {
pageIndex = 0;
}
Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords(); // note: total is only null when pageAction is done before first refresh, which should never happen anyway.
if (total!=null && pageIndex>(total/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize())) {
pageIndex = new Long(total/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize()).intValue();
}
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(pageIndex);
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PAGE, pageIndex);
// lets load data;
refreshData();
try {
entry.getVascFrontendData().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
}
}
public void moveUpAction(Object record) {
if (entry.getVascFrontendData().getVascEntryState().getVascBackend().isRecordMoveable()) {
try {
VascEntryField p = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId());
Object primaryId = p.getVascEntryFieldValue().getValue(p, record);
entry.getVascFrontendData().getVascEntryState().getVascBackend().doRecordMoveUpById(entry.getVascFrontendData().getVascEntryState().getVascBackendState(),primaryId);
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
}
// lets load data;
refreshData();
}
try {
entry.getVascFrontendData().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
}
}
public void moveDownAction(Object record) {
if (entry.getVascFrontendData().getVascEntryState().getVascBackend().isRecordMoveable()) {
try {
VascEntryField p = entry.getVascEntryFieldById(entry.getPrimaryKeyFieldId());
Object primaryId = p.getVascEntryFieldValue().getValue(p, record);
entry.getVascFrontendData().getVascEntryState().getVascBackend().doRecordMoveDownById(entry.getVascFrontendData().getVascEntryState().getVascBackendState(),primaryId);
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
}
// lets load data;
refreshData();
}
try {
entry.getVascFrontendData().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
}
}
}

View file

@ -1,365 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.impl;
import java.util.ArrayList;
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.VascEntryField;
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;
import net.forwardfire.vasc.core.actions.GlobalVascAction;
import net.forwardfire.vasc.core.actions.RowVascAction;
import net.forwardfire.vasc.core.actions.VascAction;
import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService;
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
import net.forwardfire.vasc.core.entry.VascEntryResourceImageResolver;
import net.forwardfire.vasc.core.entry.VascEntryResourceResolver;
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
import net.forwardfire.vasc.core.ui.VascUIComponent;
import net.forwardfire.vasc.frontend.VascFrontend;
import net.forwardfire.vasc.frontend.VascFrontendActions;
import net.forwardfire.vasc.frontend.VascFrontendData;
import net.forwardfire.vasc.frontend.VascFrontendHelper;
import net.forwardfire.vasc.frontend.VascFrontendPager;
/**
* Stores state data for the frontend
*
* @author Willem Cazander
* @version 1.0 Mar 21, 2007
*/
public class DefaultVascFrontendData implements VascFrontendData {
private VascFrontend vascFrontend = null;
private VascFrontendActions vascFrontendActions = null;
private VascFrontendPager vascFrontendPager = null;
private VascEntryConfigFinalizer vascEntryFinalizer = null;
private VascFrontendHelper vascFrontendHelper = null;
private VascEntryResourceResolver vascEntryResourceResolver = null;
private VascEntryResourceImageResolver vascEntryResourceImageResolver = null;
private Map<String,String> uiComponents = null;
private VascController vascController = null;
private Map<VascEntryFrontendEventListener.VascFrontendEventType,List<VascEntryFrontendEventListener>> vascEntryFrontendEventListeners = null;
private VascEntryState state = null;
private Map<VascEntryField,VascUIComponent> fieldComps = null;
private Map<VascEntryField,Object> fieldEditors = null;
private List<VascEntryFieldValidatorService> validatorServices = null;
public DefaultVascFrontendData() {
uiComponents = new HashMap<String,String>(8);
fieldComps = new HashMap<VascEntryField,VascUIComponent>(8);
fieldEditors = new HashMap<VascEntryField,Object>(8);
validatorServices = new ArrayList<VascEntryFieldValidatorService>(4);
vascEntryFrontendEventListeners = new HashMap<VascEntryFrontendEventListener.VascFrontendEventType,List<VascEntryFrontendEventListener>>(10);
}
/**
* @return the vascFrontend
*/
public VascFrontend getVascFrontend() {
return vascFrontend;
}
/**
* @param vascFrontend the vascFrontend to set
*/
public void setVascFrontend(VascFrontend vascFrontend) {
this.vascFrontend = vascFrontend;
}
/**
* @return the vascFrontendActions
*/
public VascFrontendActions getVascFrontendActions() {
return vascFrontendActions;
}
/**
* @param vascFrontendActions the vascFrontendActions to set
*/
public void setVascFrontendActions(VascFrontendActions vascFrontendActions) {
this.vascFrontendActions = vascFrontendActions;
}
/**
* @return the vascFrontendPager
*/
public VascFrontendPager getVascFrontendPager() {
return vascFrontendPager;
}
/**
* @param vascFrontendPager the vascFrontendPager to set
*/
public void setVascFrontendPager(VascFrontendPager vascFrontendPager) {
this.vascFrontendPager = vascFrontendPager;
}
/**
* @see net.forwardfire.vasc.core.VascBackendData#getVascEntryFinalizer()
*/
public VascEntryConfigFinalizer getVascEntryFinalizer() {
return vascEntryFinalizer;
}
/**
* @see net.forwardfire.vasc.core.VascBackendData#setVascEntryFinalizer(net.forwardfire.vasc.core.VascEntryConfigFinalizer)
*/
public void setVascEntryFinalizer(VascEntryConfigFinalizer vascEntryFinalizer) {
this.vascEntryFinalizer=vascEntryFinalizer;
}
/**
* @return the vascFrontendHelper
*/
public VascFrontendHelper getVascFrontendHelper() {
return vascFrontendHelper;
}
/**
* @param vascFrontendHelper the vascFrontendHelper to set
*/
public void setVascFrontendHelper(VascFrontendHelper vascFrontendHelper) {
this.vascFrontendHelper = vascFrontendHelper;
}
/**
* @return the vascEntryResourceResolver
*/
public VascEntryResourceResolver getVascEntryResourceResolver() {
return vascEntryResourceResolver;
}
/**
* @param vascEntryResourceResolver the vascEntryResourceResolver to set
*/
public void setVascEntryResourceResolver(VascEntryResourceResolver vascEntryResourceResolver) {
this.vascEntryResourceResolver = vascEntryResourceResolver;
}
public VascUIComponent getVascUIComponent(String rendererId) throws VascException {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl == null) {
cl = rendererId.getClass().getClassLoader(); // fallback
}
String componentClass = getVascUIComponentClass(rendererId);
if (componentClass==null) {
// TODO: auto wire text <-> object converts
componentClass = getVascUIComponentClass(VascUIComponent.VASC_TEXT);
}
if (componentClass==null) {
throw new VascException("No component Class found for frontend UIComponent: "+rendererId);
}
try {
return (VascUIComponent)cl.loadClass(componentClass).newInstance();
} catch (Exception e) {
throw new VascException(e);
}
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendData#getVascUIComponent(java.lang.String)
*/
public String getVascUIComponentClass(String rendererId) {
return uiComponents.get(rendererId);
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendData#putVascUIComponent(java.lang.String, java.lang.String)
*/
public void putVascUIComponent(String rendererId, String uiComponentClass) {
uiComponents.put(rendererId, uiComponentClass);
}
/**
* @return the vascController
*/
public VascController getVascController() {
return vascController;
}
/**
* @param vascController the vascController to set
*/
public void setVascController(VascController vascController) {
this.vascController = vascController;
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendData#addFieldVascUIComponents(net.forwardfire.vasc.core.VascEntryField, net.forwardfire.vasc.core.ui.VascUIComponent, java.lang.Object)
*/
public void addFieldVascUIComponents(VascEntryField field,VascUIComponent uiComponent, Object editor) {
fieldComps.put(field, uiComponent);
fieldEditors.put(field, editor);
}
public void clearFieldRenderObjects() {
fieldComps.clear();
fieldEditors.clear();
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendData#getFieldRealRenderer(net.forwardfire.vasc.core.VascEntryField)
*/
public Object getFieldRealRenderer(VascEntryField field) {
return fieldEditors.get(field);
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendData#getFieldVascUIComponent(net.forwardfire.vasc.core.VascEntryField)
*/
public VascUIComponent getFieldVascUIComponent(VascEntryField field) {
return fieldComps.get(field);
}
/**
* @return the vascEntryResourceImageResolver
*/
public VascEntryResourceImageResolver getVascEntryResourceImageResolver() {
return vascEntryResourceImageResolver;
}
/**
* @param vascEntryResourceImageResolver the vascEntryResourceImageResolver to set
*/
public void setVascEntryResourceImageResolver(VascEntryResourceImageResolver vascEntryResourceImageResolver) {
this.vascEntryResourceImageResolver = vascEntryResourceImageResolver;
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendData#addVascValidatorService(net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService)
*/
public void addVascValidatorService(VascEntryFieldValidatorService validatorService) {
validatorServices.add(validatorService);
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendData#getVascValidatorServices()
*/
public List<VascEntryFieldValidatorService> getVascValidatorServices() {
return validatorServices;
}
public VascEntryState getVascEntryState() {
return state;
}
public void setVascEntryState(VascEntryState state) {
this.state=state;
}
public void initFrontendListeners(VascEntry entry,String frontendType) throws InstantiationException, IllegalAccessException {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl==null) {
cl = entry.getClass().getClassLoader();
}
for (String clazz:entry.getVascEntryFrontendEventListenersByType(frontendType)) {
VascEntryFrontendEventListener listener;
try {
listener = (VascEntryFrontendEventListener)cl.loadClass(clazz).newInstance();
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not load VascEntryFrontendEventListener of: "+clazz);
}
addVascEntryFrontendEventListener(listener);
}
for (String clazz:entry.getVascEntryFrontendActionsByType(frontendType)) {
Object obj = null;
try {
obj = cl.loadClass(clazz).newInstance();
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not load frontend action of: "+clazz);
}
if (obj instanceof VascAction) {
VascAction action = (VascAction)obj;
String aid = action.getId();
if (aid==null) {
throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+entry.getId());
}
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");
}
}
if (obj instanceof RowVascAction) {
entry.addRowAction((RowVascAction)obj);
}
if (obj instanceof ColumnVascAction) {
entry.addColumnAction((ColumnVascAction)obj);
}
if (obj instanceof GlobalVascAction) {
entry.addGlobalAction((GlobalVascAction)obj);
}
}
}
public void addVascEntryFrontendEventListener(VascEntryFrontendEventListener listener) {
for (VascEntryFrontendEventListener.VascFrontendEventType type:listener.getEventTypes()) {
List<VascEntryFrontendEventListener> list = vascEntryFrontendEventListeners.get(type);
if (list==null) {
list = new ArrayList<VascEntryFrontendEventListener>(10);
vascEntryFrontendEventListeners.put(type, list);
}
list.add(listener);
}
}
public List<VascEntryFrontendEventListener> getVascEntryFrontendEventListener(VascEntryFrontendEventListener.VascFrontendEventType type) {
List<VascEntryFrontendEventListener> list = vascEntryFrontendEventListeners.get(type);
if (list==null) {
return new ArrayList<VascEntryFrontendEventListener>(0);
}
return list;
}
public void fireVascFrontendEvent(VascEntry entry,VascFrontendEventType type, Object data) {
List<VascEntryFrontendEventListener> list = getVascEntryFrontendEventListener(type);
for (VascEntryFrontendEventListener l:list) {
l.vascEvent(entry, data);
}
}
}

View file

@ -1,337 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.VascException;
import net.forwardfire.vasc.core.VascLinkEntry;
import net.forwardfire.vasc.core.VascLinkEntryType;
import net.forwardfire.vasc.core.VascUserRoleController;
import net.forwardfire.vasc.core.actions.GlobalVascAction;
import net.forwardfire.vasc.core.actions.RowVascAction;
import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService;
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
import net.forwardfire.vasc.core.ui.VascUIComponent;
import net.forwardfire.vasc.frontend.VascFrontendHelper;
/**
*
* @author Willem Cazander
* @version 1.0 Apr 28, 2007
*/
public class DefaultVascFrontendHelper implements VascFrontendHelper {
private Logger logger = Logger.getLogger(DefaultVascFrontendHelper.class.getName());
/**
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#renderView(net.forwardfire.vasc.core.VascEntryField)
*/
public boolean renderView(VascEntryField field) {
if (field.getView()==false) {
return false;
}
return true;
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#renderCreate(net.forwardfire.vasc.core.VascEntryField)
*/
public boolean renderCreate(VascEntryField field) {
if (renderView(field)==false) {
return false;
}
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleController();
if (field.getRolesCreate()!=null && u.hasRole(field.getRolesCreate())) {
return true;
}
if (field.getCreate()) {
return true;
}
return false;
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#renderEdit(net.forwardfire.vasc.core.VascEntryField)
*/
public boolean renderEdit(VascEntryField field) {
if (renderView(field)==false) {
return false;
}
if (field.getVascEntry().getVascFrontendData().getVascEntryState().isEditCreate()) {
if (renderCreate(field)==false) {
return false;
}
}
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleController();
if (field.getRolesEdit()!=null && u.hasRole(field.getRolesEdit())) {
return true;
}
if (field.getEdit()) {
return true;
}
return false;
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#renderEditReadOnly(net.forwardfire.vasc.core.VascEntryField)
*/
public boolean renderEditReadOnly(VascEntryField field) {
if (renderView(field)==false) {
return false;
}
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleController();
if (field.getRolesEditReadOnly()!=null && u.hasRole(field.getRolesEditReadOnly())) {
return true;
}
if (field.getEditReadOnly()) {
return true;
}
return false;
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#renderList(net.forwardfire.vasc.core.VascEntryField)
*/
public boolean renderList(VascEntryField field) {
if (renderView(field)==false) {
return false;
}
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleController();
if (field.getRolesList()!=null && u.hasRole(field.getRolesList())) {
return true;
}
if (field.getList()) {
return true;
}
return false;
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#renderGlobalVascAction(net.forwardfire.vasc.core.actions.GlobalVascAction)
*/
public boolean renderGlobalVascAction(GlobalVascAction action) {
return true;
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#renderRowVascAction(net.forwardfire.vasc.core.actions.RowVascAction)
*/
public boolean renderRowVascAction(RowVascAction action) {
return true;
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#getTotalColumnsWidth(net.forwardfire.vasc.core.VascEntry)
*/
public Integer getTotalColumnsWidth(VascEntry entry) {
int result = 0;
for(VascEntryField c:entry.getVascEntryFields()) {
if(c.getSizeList()==null) {
logger.finer("Column no size: "+c.getName());
} else {
result+=c.getSizeList();
}
}
return result;
}
public List<VascLinkEntry> getVascLinkEntryByType(VascEntry entry,VascLinkEntryType type) {
List<VascLinkEntry> result = new ArrayList<VascLinkEntry>(10);
for (VascLinkEntry link:entry.getVascLinkEntries()) {
if (type==null) {
result.add(link);
continue;
}
if (type.equals(link.getVascLinkEntryType())) {
result.add(link);
}
}
return result;
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#handleException(net.forwardfire.vasc.core.VascEntry,java.lang.Exception)
*/
public void handleException(VascEntry entry,Exception exception) {
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascFrontendEventType.EXCEPTION , exception);
}
public void headerOptionsCreatedFillData(VascEntry entry) {
// fix conv defs of options to object. ?
entry.getVascFrontendData().getVascFrontendActions().refreshData();
}
/**
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#validateObjectField(net.forwardfire.vasc.core.VascEntryField, java.lang.Object)
*/
public List<String> validateObjectField(VascEntryField field) {
if (field==null) {
throw new NullPointerException("Can't validate null field.");
}
VascEntry entry = field.getVascEntry();
if (entry.getVascFrontendData().getVascEntryState().getEntryDataObject()==null) {
throw new NullPointerException("Can't validate null entry object.");
}
List<String> error = new ArrayList<String>(3);
// skip non-create and non-edit fields
if (entry.getVascFrontendData().getVascFrontendHelper().renderCreate(field) == false &
entry.getVascFrontendData().getVascEntryState().isEditCreate()) {
return error;
}
if (entry.getVascFrontendData().getVascFrontendHelper().renderEditReadOnly(field) &
entry.getVascFrontendData().getVascEntryState().isEditCreate()==false) {
return error;
}
try {
Object objectSelected = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
Object objectValue = field.getVascEntryFieldValue().getValue(field, objectSelected);
for (VascEntryFieldValidatorService s:entry.getVascFrontendData().getVascValidatorServices()) {
error.addAll(s.validateObjectField(field, objectSelected, objectValue));
}
} catch (VascException e) {
handleException(entry, e);
}
return error;
}
/**
*
*/
public boolean validateAndSetErrorText(VascEntry entry) {
boolean hadError = false;
for (VascEntryField field:entry.getVascEntryFields()) {
VascUIComponent comp = entry.getVascFrontendData().getFieldVascUIComponent(field);
List<String> error = validateObjectField(field);
logger.info("Check field: "+field.getId()+" comp: "+comp+" Errors: "+error.size());
if (error.isEmpty()) {
if (comp!=null) {
comp.setErrorText(null);
}
continue;
}
if (comp==null) {
logger.warning("Field: "+field.getId()+" gives errors but no UI component to display.");
continue;
}
hadError=true;
StringBuffer buf = new StringBuffer(100);
for (String s:error) {
buf.append(s);
buf.append('\n');
}
comp.setErrorText(buf.toString());
}
return hadError;
}
public void editReadOnlyUIComponents(VascEntry entry) {
// reset edit read only
for (VascEntryField f:entry.getVascEntryFields()) {
if (entry.getVascFrontendData().getFieldVascUIComponent(f)==null) {
continue;
}
// TODO: move back to rendered when jsf fixes
if (entry.getVascFrontendData().getVascFrontendHelper().renderCreate(f) == false &
entry.getVascFrontendData().getVascEntryState().isEditCreate()) {
//entry.getVascFrontendData().getFieldVascUIComponent(f).setRendered(false);
entry.getVascFrontendData().getFieldVascUIComponent(f).setDisabled(true);
} else {
//entry.getVascFrontendData().getFieldVascUIComponent(f).setRendered(true);
entry.getVascFrontendData().getFieldVascUIComponent(f).setDisabled(false);
}
// only when editing set edit readonlys
if (entry.getVascFrontendData().getVascFrontendHelper().renderEditReadOnly(f) &
entry.getVascFrontendData().getVascEntryState().isEditCreate()==false) {
entry.getVascFrontendData().getFieldVascUIComponent(f).setDisabled(true);
} else {
if (entry.getVascFrontendData().getVascEntryState().isEditCreate()==false) { // todo: remove when jsf fixes
entry.getVascFrontendData().getFieldVascUIComponent(f).setDisabled(false);
}
}
}
}
public List<RowVascAction> getMultiRowActions(VascEntry entry) {
List<RowVascAction> result = new ArrayList<RowVascAction>(5);
for (RowVascAction a:entry.getRowActions()) {
if (a.isMultiRowAction()) {
result.add(a);
}
}
return result;
}
public String getSelectedDisplayName(VascEntry entry) {
Object row = entry.getVascFrontendData().getVascEntryState().getEntryDataObject();
if (row==null) {
return "no-selection";
}
VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId());
VascEntryFieldValue ve = v.getVascEntryFieldValue();
String result = "no-data";
try {
result = ve.getDisplayValue(v, row);
} catch (VascException e) {
throw new RuntimeException("Could not get selected name DisplayValue: "+e.getMessage(),e);
}
return result;
}
public String getParentSelectedDisplayName(VascEntry entry) {
if (entry.getVascFrontendData().getVascEntryState().getParent()==null) {
return ""; // no parent
}
VascEntry parent = entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry();
Object row = entry.getVascFrontendData().getVascEntryState().getParent().getEntryDataObject();
if (row==null) {
return "no-selection";
}
VascEntryField v = parent.getVascEntryFieldById(parent.getDisplayNameFieldId());
VascEntryFieldValue ve = v.getVascEntryFieldValue();
String result = "no-data";
try {
result = ve.getDisplayValue(v, row);
} catch (VascException e) {
throw new RuntimeException("Could not get parent name DisplayValue: "+e.getMessage(),e);
}
return result;
}
}

View file

@ -1,223 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.impl;
import java.util.ArrayList;
import java.util.List;
import net.forwardfire.vasc.backend.VascBackendPageNumber;
import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
import net.forwardfire.vasc.frontend.VascFrontendPager;
/**
* Default impl of default frontend actions
*
* @author Willem Cazander
* @version 1.0 Jan 22, 2012
*/
public class DefaultVascFrontendPager implements VascFrontendPager {
//private Logger logger = Logger.getLogger(DefaultVascFrontendPager.class.getName());
private VascEntry entry = null;
private List<VascBackendPageNumber> pagesAll = null;
public DefaultVascFrontendPager(VascEntry entry) {
this.entry=entry;
pagesAll = new ArrayList<VascBackendPageNumber>(0);
entry.getVascFrontendData().addVascEntryFrontendEventListener(new DefaultVascFrontendPagerEventListener());
}
class DefaultVascFrontendPagerEventListener implements VascEntryFrontendEventListener {
private static final long serialVersionUID = -6667099892801941650L;
public VascFrontendEventType[] getEventTypes() {
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.POST_READ};
return result;
}
public void vascEvent(VascEntry entry, Object data) {
pagesAll = getTablePagesFromBackend();
}
}
public long getPageTotalRecordCount() {
long result = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
return result;
}
public long getPageSize() {
long result = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
return result;
}
public long getPageStartCount() {
int index = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
int pageSize = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
long result = index*pageSize;
return result;
}
public long getPageStopCount() {
int index = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
int pageSize = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
long result = (index*pageSize)+pageSize;
// limit for small result sets.
if (result>entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords()) {
result = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
}
return result;
}
public boolean getHasPageNextAction() {
int pageIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
pageIndex++;
// copyed from helper
Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
if (total!=null && pageIndex>(total/entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize())) {
return false;
}
return true;
}
public boolean getHasPagePreviousAction() {
int pageIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
if (pageIndex==0) {
return false;
}
return true;
}
public boolean getHasOnlySinglePage() {
int pages = pagesAll.size();
if (pages==1) {
return true;
}
return false;
}
public boolean getHasExtendedPageMode() {
int pages = pagesAll.size();
if (pages>13) {
return true;
}
return false;
}
public boolean getHasExtendedPageModeCenter() {
if (getHasExtendedPageMode()==false) {
return false;
}
int page = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
if (page<5) {
return false;
}
int pages = pagesAll.size();
if (page>pages-6) {
return false;
}
return true;
}
public List<VascBackendPageNumber> getTablePagesFromBackend() {
List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(30);
VascBackendState state = entry.getVascFrontendData().getVascEntryState().getVascBackendState();
if (state.getPageSize()==0) {
return result; // paging disabled
}
Long total = entry.getVascFrontendData().getVascEntryState().getTotalBackendRecords();
if (total==null) {
return result; // no pages
}
int pages = new Long(total/state.getPageSize()).intValue();
for (int i=0;i<=pages;i++) {
VascBackendPageNumber pn = new VascBackendPageNumber(i);
if (state.getPageIndex()==i) {
pn.setSelected(true);
}
result.add(pn);
}
return result;
}
public List<VascBackendPageNumber> getTablePagesNormal() {
if (getHasExtendedPageMode()) {
return new ArrayList<VascBackendPageNumber>(0);
} else {
return pagesAll;
}
}
public List<VascBackendPageNumber> getTablePagesExtendedBegin() {
List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(6);
result.add(pagesAll.get(0));
result.add(pagesAll.get(1));
result.add(pagesAll.get(2));
int page = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
if (page==2 | page==3 | page==4) {
result.add(pagesAll.get(3));
}
if (page==3 | page==4) {
result.add(pagesAll.get(4));
}
if (page==4) {
result.add(pagesAll.get(5));
}
return result;
}
public List<VascBackendPageNumber> getTablePagesExtendedEnd() {
List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(6);
int pages = pagesAll.size();
int page = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
int off = pages-page;
if (off==5) {
result.add(pagesAll.get(pages-6));
}
if (off==4 | off==5) {
result.add(pagesAll.get(pages-5));
}
if (off==3 | off==4 | off==5) {
result.add(pagesAll.get(pages-4));
}
if (pages>4) {
result.add(pagesAll.get(pages-3));
result.add(pagesAll.get(pages-2));
result.add(pagesAll.get(pages-1));
}
return result;
}
public List<VascBackendPageNumber> getTablePagesExtendedCenter() {
List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(3);
int page = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
if (page>0) {
result.add(pagesAll.get(page-1));
}
result.add(pagesAll.get(page));
result.add(pagesAll.get(page+1));
return result;
}
}

View file

@ -1,174 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.forwardfire.vasc.core.VascLinkEntry;
import net.forwardfire.vasc.core.VascLinkEntryType;
/**
* The DefaultVascLinkEntry
*
* @author Willem Cazander
* @version 1.0 Oct 27, 2007
*/
public class DefaultVascLinkEntry implements VascLinkEntry {
private static final long serialVersionUID = 1L;
private String id = null;
private String vascEntryId = null;
private Map<String,String> entryParameterFieldIds = new HashMap<String,String>(3);
private Map<String,String> entryCreateFieldValues = new HashMap<String,String>(3);
private VascLinkEntryType vascLinkEntryType = null;
private String doActionId = null;
private String name = null;
private String helpId = null;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
public String getEntryParameterFieldId(String parameterName) {
return entryParameterFieldIds.get(parameterName);
}
public void addEntryParameterFieldId(String parameterName,String valueFieldId) {
entryParameterFieldIds.put(parameterName, valueFieldId);
}
public List<String> getEntryParameterFieldIdKeys() {
return new ArrayList<String>(entryParameterFieldIds.keySet());
}
public String getEntryCreateFieldValue(String valueFieldId) {
return entryCreateFieldValues.get(valueFieldId);
}
public void addEntryCreateFieldValue(String valueFieldId,String selectedFieldId) {
entryCreateFieldValues.put(valueFieldId, selectedFieldId);
}
public List<String> getEntryCreateFieldValueKeys() {
return new ArrayList<String>(entryCreateFieldValues.keySet());
}
/**
* @return the vascEntryId
*/
public String getVascEntryId() {
return vascEntryId;
}
/**
* @param vascEntryId the vascEntryId to set
*/
public void setVascEntryId(String vascEntryId) {
this.vascEntryId = vascEntryId;
}
/**
* @return the vascLinkEntryType
*/
public VascLinkEntryType getVascLinkEntryType() {
return vascLinkEntryType;
}
/**
* @param vascLinkEntryType the vascLinkEntryType to set
*/
public void setVascLinkEntryType(VascLinkEntryType vascLinkEntryType) {
this.vascLinkEntryType = vascLinkEntryType;
}
/**
* @return the doActionId
*/
public String getDoActionId() {
return doActionId;
}
/**
* @param doActionId the doActionId to set
*/
public void setDoActionId(String doActionId) {
this.doActionId = doActionId;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
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()
*/
@Override
public VascLinkEntry clone() throws CloneNotSupportedException {
DefaultVascLinkEntry result = new DefaultVascLinkEntry();
result.doActionId=doActionId;
result.vascLinkEntryType=vascLinkEntryType;
result.vascEntryId=vascEntryId;
result.entryParameterFieldIds=entryParameterFieldIds;
result.entryCreateFieldValues=entryCreateFieldValues;
result.id=id;
result.name=name;
result.helpId=helpId;
return result;
}
}

View file

@ -1,103 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.impl;
import java.util.ArrayList;
import java.util.List;
import net.forwardfire.vasc.core.VascUserRoleController;
/**
* Simple default user controller for wrapping user info into vasc
*
*
* @author Willem Cazander
* @version 1.0 Mar 13, 2009
*/
public class DefaultVascUserRoleController implements VascUserRoleController {
private Long userId = null;
private String userName = null;
private List<String> userRoles = null;
public DefaultVascUserRoleController(Long userId,String userName) {
if (userId==null) {
throw new NullPointerException("userId may not be null.");
}
if (userName==null) {
throw new NullPointerException("userName may not be null");
}
this.userId=userId;
this.userName=userName;
userRoles = new ArrayList<String>(10);
}
public DefaultVascUserRoleController(Long userId,String userName,String...roles) {
this(userId,userName);
for (String role:roles) {
userRoles.add(role);
}
}
/**
* @see net.forwardfire.vasc.core.VascUserRoleController#getUserId()
*/
public Long getUserId() {
return userId;
}
/**
* @see net.forwardfire.vasc.core.VascUserRoleController#getUserName()
*/
public String getUserName() {
return userName;
}
/**
* @see net.forwardfire.vasc.core.VascUserRoleController#getUserRoles()
*/
public List<String> getUserRoles() {
return userRoles;
}
/**
* @see net.forwardfire.vasc.core.VascUserRoleController#hasRole(java.lang.String)
*/
public boolean hasRole(String roles) {
if (roles==null) {
return false;
}
// input: admin|superAdmin
// input: (admin|superAdmin)&login
String[] r = roles.split("|");
for (String rr:r) {
if (userRoles.contains(rr)) {
return true;
}
}
return false;
}
}

View file

@ -1,66 +0,0 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.impl.x4o;
import net.forwardfire.vasc.core.VascLinkEntry;
import net.forwardfire.vasc.impl.ui.VascSelectItemModelEntry;
import org.x4o.xml.element.AbstractElement;
import org.x4o.xml.element.ElementException;
/**
* Adds the link is paramets
*
* @author Willem Cazander
* @version 1.0 Jun 09, 2009
*/
public class VascLinkEntryParameterElement extends AbstractElement {
/**
* @see org.x4o.xml.element.AbstractElement#doElementRun()
*/
@Override
public void doElementRun() throws ElementException {
String valueFieldId = getAttributes().get("valueFieldId");
String parameterName = getAttributes().get("name");
String selectedFieldId = getAttributes().get("selectedFieldId");
if (getParent().getElementObject() instanceof VascSelectItemModelEntry) {
VascSelectItemModelEntry m = (VascSelectItemModelEntry)getParent().getElementObject();
m.addEntryParameterFieldId(parameterName, valueFieldId);
return;
}
if (getParent().getElementObject() instanceof VascLinkEntry) {
VascLinkEntry link = (VascLinkEntry)getParent().getElementObject();
if (parameterName!=null) {
// normal parameter
link.addEntryParameterFieldId(parameterName, valueFieldId);
} else {
link.addEntryCreateFieldValue(valueFieldId,selectedFieldId);
}
return;
}
throw new ElementException("Unsupported parent object: "+getParent().getElementObject());
}
}