2
0
Fork 0

[svn r380] added all kinds of objects

This commit is contained in:
willemc 2009-04-13 19:19:48 +02:00
parent a9520b3804
commit 37fdf22282
140 changed files with 7679 additions and 901 deletions

View file

@ -26,6 +26,9 @@
package com.idcanet.vasc.impl;
import java.util.Collections;
import java.util.Comparator;
import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntry;
@ -89,12 +92,6 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
}
// entry fields
if (entry.getName()==null) {
entry.setName("vasc.entry."+id+".name");
}
if (entry.getDescription()==null) {
entry.setDescription("vasc.entry."+id+".description");
}
if (entry.getImage()==null) {
entry.setImage("vasc.entry."+id+".image");
}
@ -150,6 +147,7 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
// Check fields
int orderIndex = 0;
for (VascEntryField vef:entry.getVascEntryFields()) {
String vid = vef.getId();
@ -161,6 +159,12 @@ 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");
@ -185,10 +189,6 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
// vef.setDefaultValue("vasc.entry."+id+"."+vid+".defaultValue");
//}
if (vef.getVascEntryFieldEventChannel()==null) {
//vef.setStyleList("vasc.entry."+id+"."+vid+".styleEdit");
}
if (vef.getVascEntryFieldValue()==null) {
VascBackend back2 = vascController.getVascBackendControllerResolver().getVascBackendController().getVascBackendById( entry.getBackendId() );
vef.setVascEntryFieldValue(back2.provideVascEntryFieldValue(vef));
@ -217,11 +217,33 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
//for (VascValidator vv:vef.getVascValidators()) {
//}
}
Collections.sort(entry.getVascEntryFields(),new Comparator() {
public int compare(Object o1, Object o2) {
VascEntryField v1 = (VascEntryField)o1;
VascEntryField v2 = (VascEntryField)o2;
return v1.getOrderIndex().compareTo(v2.getOrderIndex());
}
});
// place primary key in front
int index = 0;
for (VascEntryField vef:entry.getVascEntryFields()) {
if (entry.getPrimaryKeyFieldId().equals(vef.getId())) {
break;
}
index++;
}
VascEntryField idField = entry.getVascEntryFields().remove(index);
entry.getVascEntryFields().add(0, idField);
// Check if link entries excists
for (VascLinkEntry vle:entry.getVascLinkEntries()) {
vle.getVascEntryName();
// check id
String vid = vle.getId();
if (vid==null) {
throw new IllegalArgumentException("All VascLinkEntry need an id");
}
}

View file

@ -49,7 +49,7 @@ public class DefaultVascBackendController implements VascBackendControllerLocal
/**
* @see com.idcanet.vasc.core.VascBackendController#getVascBackendById(java.lang.String)
*/
public VascBackend getVascBackendById(String id) {
public VascBackend getVascBackendById(String id) {
return backends.get(id);
}

View file

@ -57,8 +57,7 @@ public class DefaultVascController implements VascController {
/**
* @param vascEventChannelControllerResolver the vascEventChannelControllerResolver to set
*/
public void setVascEventChannelControllerResolver(
VascEventChannelControllerResolver vascEventChannelControllerResolver) {
public void setVascEventChannelControllerResolver(VascEventChannelControllerResolver vascEventChannelControllerResolver) {
this.vascEventChannelControllerResolver = vascEventChannelControllerResolver;
}
@ -114,8 +113,7 @@ public class DefaultVascController implements VascController {
/**
* @param vascUserRoleControllerResolver the vascUserRoleControllerResolver to set
*/
public void setVascUserRoleControllerResolver(
VascUserRoleControllerResolver vascUserRoleControllerResolver) {
public void setVascUserRoleControllerResolver(VascUserRoleControllerResolver vascUserRoleControllerResolver) {
this.vascUserRoleControllerResolver = vascUserRoleControllerResolver;
}
}

View file

@ -39,6 +39,8 @@ import com.idcanet.vasc.core.VascLinkEntry;
import com.idcanet.vasc.core.actions.ColumnVascAction;
import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.actions.VascAction;
import com.idcanet.vasc.core.entry.VascEntryFieldEventChannel;
/**
* VascEntry
@ -50,8 +52,6 @@ public class DefaultVascEntry implements VascEntry {
private String id = null;
private String name = null;
private String description = null;
private String helpId = null;
private String image = null;
@ -62,10 +62,11 @@ public class DefaultVascEntry implements VascEntry {
private String primaryKeyFieldId = null;
private String displayNameFieldId = null;
private boolean vascAdmimList = true;
private boolean vascAdmimEdit = true;
private boolean vascAdmimCreate = true;
private boolean vascAdmimDelete = true;
private boolean vascDisplayOnly = false;
private boolean vascAdminList = true;
private boolean vascAdminEdit = true;
private boolean vascAdminCreate = true;
private boolean vascAdminDelete = true;
private List<VascEntryField> vascFields = null;
@ -76,6 +77,7 @@ public class DefaultVascEntry implements VascEntry {
private List<VascEntryFieldSet> vascEntryFieldSets = null;
private List<VascLinkEntry> vascLinkEntries = null;
private Map<String,Object> entryParameters = null;
private VascEntryFieldEventChannel vascEntryFieldEventChannel = null;
private String backendId = null;
private VascFrontendData vascFrontendData = null;
@ -99,8 +101,53 @@ public class DefaultVascEntry implements VascEntry {
* @see java.lang.Object#clone()
*/
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
public VascEntry clone() throws CloneNotSupportedException {
DefaultVascEntry result = new DefaultVascEntry();
result.id=id;
result.helpId=helpId;
result.image=image;
result.headerName=headerName;
result.headerDescription=headerDescription;
result.headerImage=headerImage;
result.primaryKeyFieldId=primaryKeyFieldId;
result.displayNameFieldId=displayNameFieldId;
result.vascDisplayOnly=vascDisplayOnly;
result.vascAdminList=vascAdminList;
result.vascAdminCreate=vascAdminCreate;
result.vascAdminEdit=vascAdminEdit;
result.vascAdminDelete=vascAdminDelete;
result.backendId=backendId;
result.vascEntryFieldEventChannel=vascEntryFieldEventChannel;
// skipping 'vascFrontendData' because it should always be null when cloning happens.
for (VascEntryField f:vascFields) {
VascEntryField ff = f.clone();
ff.setVascEntry(result); // mmm remove this ?
result.vascFields.add(ff);
}
for (VascAction a:rowActions) {
result.rowActions.add((RowVascAction)a.clone());
}
for (VascAction a:columnActions) {
result.columnActions.add((ColumnVascAction)a.clone());
}
for (VascAction a:globalActions) {
result.globalActions.add((GlobalVascAction)a.clone());
}
for (VascEntryFieldSet s:vascEntryFieldSets) {
result.vascEntryFieldSets.add(s.clone());
}
for (VascLinkEntry l:vascLinkEntries) {
result.vascLinkEntries.add(l.clone());
}
// no cloning of the values here ?
for (String key:entryParameters.keySet()) {
Object value = entryParameters.get(key);
result.setEntryParameter(key, value);
}
return result;
}
@ -120,34 +167,6 @@ public class DefaultVascEntry implements VascEntry {
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 the description to set
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return the helpId
*/
@ -247,59 +266,59 @@ public class DefaultVascEntry implements VascEntry {
}
/**
* @return the vascAdmimList
* @return the vascAdminList
*/
public boolean isVascAdmimList() {
return vascAdmimList;
public boolean isVascAdminList() {
return vascAdminList;
}
/**
* @param vascAdmimList the vascAdmimList to set
* @param vascAdminList the vascAdminList to set
*/
public void setVascAdmimList(boolean vascAdmimList) {
this.vascAdmimList = vascAdmimList;
public void setVascAdminList(boolean vascAdminList) {
this.vascAdminList = vascAdminList;
}
/**
* @return the vascAdmimEdit
* @return the vascAdminEdit
*/
public boolean isVascAdmimEdit() {
return vascAdmimEdit;
public boolean isVascAdminEdit() {
return vascAdminEdit;
}
/**
* @param vascAdmimEdit the vascAdmimEdit to set
* @param vascAdminEdit the vascAdminEdit to set
*/
public void setVascAdmimEdit(boolean vascAdmimEdit) {
this.vascAdmimEdit = vascAdmimEdit;
public void setVascAdminEdit(boolean vascAdminEdit) {
this.vascAdminEdit = vascAdminEdit;
}
/**
* @return the vascAdmimCreate
* @return the vascAdminCreate
*/
public boolean isVascAdmimCreate() {
return vascAdmimCreate;
public boolean isVascAdminCreate() {
return vascAdminCreate;
}
/**
* @param vascAdmimCreate the vascAdmimCreate to set
* @param vascAdminCreate the vascAdminCreate to set
*/
public void setVascAdmimCreate(boolean vascAdmimCreate) {
this.vascAdmimCreate = vascAdmimCreate;
public void setVascAdminCreate(boolean vascAdminCreate) {
this.vascAdminCreate = vascAdminCreate;
}
/**
* @return the vascAdmimDelete
* @return the vascAdminDelete
*/
public boolean isVascAdmimDelete() {
return vascAdmimDelete;
public boolean isVascAdminDelete() {
return vascAdminDelete;
}
/**
* @param vascAdmimDelete the vascAdmimDelete to set
* @param vascAdminDelete the vascAdminDelete to set
*/
public void setVascAdmimDelete(boolean vascAdmimDelete) {
this.vascAdmimDelete = vascAdmimDelete;
public void setVascAdminDelete(boolean vascAdminDelete) {
this.vascAdminDelete = vascAdminDelete;
}
/**
@ -332,7 +351,7 @@ public class DefaultVascEntry implements VascEntry {
return v;
}
}
throw new IllegalArgumentException("Id not found as field");
return null;
}
/**
@ -488,4 +507,32 @@ public class DefaultVascEntry implements VascEntry {
public void setBackendId(String backendId) {
this.backendId = backendId;
}
/**
* @return the vascDisplayOnly
*/
public boolean isVascDisplayOnly() {
return vascDisplayOnly;
}
/**
* @param vascDisplayOnly the vascDisplayOnly to set
*/
public void setVascDisplayOnly(boolean vascDisplayOnly) {
this.vascDisplayOnly = vascDisplayOnly;
}
/**
* @return the vascEntryFieldEventChannel
*/
public VascEntryFieldEventChannel getVascEntryFieldEventChannel() {
return vascEntryFieldEventChannel;
}
/**
* @param vascEntryFieldEventChannel the vascEntryFieldEventChannel to set
*/
public void setVascEntryFieldEventChannel(VascEntryFieldEventChannel vascEntryFieldEventChannel) {
this.vascEntryFieldEventChannel = vascEntryFieldEventChannel;
}
}

View file

@ -27,6 +27,7 @@
package com.idcanet.vasc.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -60,14 +61,27 @@ public class DefaultVascEntryController implements VascEntryControllerLocal {
* @see com.idcanet.vasc.core.VascEntryController#getVascEntryById(java.lang.String)
*/
public VascEntry getVascEntryById(String id) {
return entries.get(id);
VascEntry entry = entries.get(id);
try {
return entry.clone();
} catch (CloneNotSupportedException e) {
throw new NullPointerException("Could not clone entry: "+e.getMessage());
}
}
public VascEntry getRealVascEntryById(String id) {
VascEntry entry = entries.get(id);
return entry;
}
/**
* @see com.idcanet.vasc.core.VascEntryController#getVascEntryIds()
*/
public List<String> getVascEntryIds() {
return new ArrayList<String>(entries.keySet());
List<String> result = new ArrayList<String>(entries.keySet());
Collections.sort(result); // lets do abc for consistance behauvior.
return result;
}
/**
@ -76,10 +90,11 @@ public class DefaultVascEntryController implements VascEntryControllerLocal {
public List<String> getVascEntryAdminIds() {
List<String> adminIds = new ArrayList<String>(30);
for (VascEntry e:entries.values()) {
if (Boolean.TRUE.equals(e.isVascAdmimList())) {
if (Boolean.TRUE.equals(e.isVascAdminList())) {
adminIds.add(e.getId());
}
}
Collections.sort(adminIds); // lets do abc for consistance behauvior.
return adminIds;
}
}

View file

@ -32,7 +32,6 @@ import java.util.List;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryFieldType;
import com.idcanet.vasc.core.entry.VascEntryFieldEventChannel;
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
import com.idcanet.vasc.validators.VascValidator;
@ -45,44 +44,40 @@ import com.idcanet.vasc.validators.VascValidator;
public class DefaultVascEntryField implements VascEntryField {
private VascEntry vascEntry = null;
/** The vasc id for this field */
private String id = null;
/** The vasc Field Type for this field entry. */
private VascEntryFieldType vascEntryFieldType = null;
/** The backendName, default to the name. **/
private String backendName = null;
private String id = null;
private String backendName = null;
private String displayName = null;
private VascEntryFieldType vascEntryFieldType = null;
private VascEntryFieldValue vascEntryFieldValue = null;
private VascEntryFieldEventChannel vascEntryFieldEventChannel = null;
private List<VascValidator> vascValidators = null;
/** Some VascField fields**/
private String name = null;
private String description = null;
private String helpId = null;
private String image = null;
private Integer orderIndex = null;
private Object defaultValue = null;
private Integer sizeList = null;
private Integer sizeEdit = null;
private String styleList = null;
private String styleEdit = null;
private String choices = null;
private Boolean choicesAsRadio = null;
/** Defines if this columns is used in interface list,create,edit **/
private boolean view = true;
private boolean optional = false;
private Boolean view = null;
private Boolean optional = null;
/** Defines per view state of this field **/
private boolean create = true;
private boolean edit = true;
private boolean editReadOnly = false;
private boolean list = true;
private Boolean create = null;
private Boolean edit = null;
private Boolean editReadOnly = null;
private Boolean editBlank = null;
private Boolean list = null;
/** Defines the roles stuff if all up is true **/
private String rolesCreate = null;
@ -90,6 +85,10 @@ public class DefaultVascEntryField implements VascEntryField {
private String rolesEditReadOnly = null;
private String rolesList = null;
private Boolean sortable = null;
private Boolean sumable = null;
private Boolean graphable = null;
public DefaultVascEntryField() {
vascValidators = new ArrayList<VascValidator>(5);
}
@ -99,6 +98,52 @@ public class DefaultVascEntryField implements VascEntryField {
setId(id);
}
/**
* @see java.lang.Object#clone()
*/
@Override
public VascEntryField clone() throws CloneNotSupportedException {
DefaultVascEntryField result = new DefaultVascEntryField();
result.id=id;
result.backendName=backendName;
result.displayName=displayName;
result.vascEntryFieldType=vascEntryFieldType;
result.name=name;
result.description=description;
result.helpId=helpId;
result.image=image;
result.defaultValue=defaultValue;
result.orderIndex=orderIndex;
result.sizeList=sizeList;
result.sizeEdit=sizeEdit;
result.styleList=styleList;
result.styleEdit=styleEdit;
result.choices=choices;
result.choicesAsRadio=choicesAsRadio;
result.view=view;
result.optional=optional;
result.create=create;
result.edit=edit;
result.editReadOnly=editReadOnly;
result.editBlank=editBlank;
result.list=list;
result.rolesCreate=rolesCreate;
result.rolesEdit=rolesEdit;
result.rolesEditReadOnly=rolesEditReadOnly;
result.rolesList=rolesList;
result.sortable=sortable;
result.sumable=sumable;
result.graphable=graphable;
result.vascEntryFieldValue=vascEntryFieldValue;
result.vascValidators.addAll(vascValidators);
return result;
}
public VascEntry getVascEntry() {
return vascEntry;
}
@ -162,21 +207,7 @@ public class DefaultVascEntryField implements VascEntryField {
public void setVascEntryFieldValue(VascEntryFieldValue vascEntryFieldValue) {
this.vascEntryFieldValue = vascEntryFieldValue;
}
/**
* @return the vascEntryFieldEventChannel
*/
public VascEntryFieldEventChannel getVascEntryFieldEventChannel() {
return vascEntryFieldEventChannel;
}
/**
* @param vascEntryFieldEventChannel the vascEntryFieldEventChannel to set
*/
public void setVascEntryFieldEventChannel(VascEntryFieldEventChannel vascEntryFieldEventChannel) {
this.vascEntryFieldEventChannel = vascEntryFieldEventChannel;
}
/**
* @return the vascValidators
*/
@ -341,84 +372,84 @@ public class DefaultVascEntryField implements VascEntryField {
/**
* @return the view
*/
public boolean isView() {
public Boolean getView() {
return view;
}
/**
* @param view the view to set
*/
public void setView(boolean view) {
public void setView(Boolean view) {
this.view = view;
}
/**
* @return the optional
*/
public boolean isOptional() {
public Boolean getOptional() {
return optional;
}
/**
* @param optional the optional to set
*/
public void setOptional(boolean optional) {
public void setOptional(Boolean optional) {
this.optional = optional;
}
/**
* @return the create
*/
public boolean isCreate() {
public Boolean getCreate() {
return create;
}
/**
* @param create the create to set
*/
public void setCreate(boolean create) {
public void setCreate(Boolean create) {
this.create = create;
}
/**
* @return the edit
*/
public boolean isEdit() {
public Boolean getEdit() {
return edit;
}
/**
* @param edit the edit to set
*/
public void setEdit(boolean edit) {
public void setEdit(Boolean edit) {
this.edit = edit;
}
/**
* @return the editReadOnly
*/
public boolean isEditReadOnly() {
public Boolean getEditReadOnly() {
return editReadOnly;
}
/**
* @param editReadOnly the editReadOnly to set
*/
public void setEditReadOnly(boolean editReadOnly) {
public void setEditReadOnly(Boolean editReadOnly) {
this.editReadOnly = editReadOnly;
}
/**
* @return the list
*/
public boolean isList() {
public Boolean getList() {
return list;
}
/**
* @param list the list to set
*/
public void setList(boolean list) {
public void setList(Boolean list) {
this.list = list;
}
@ -477,4 +508,102 @@ public class DefaultVascEntryField implements VascEntryField {
public void setRolesList(String rolesList) {
this.rolesList = rolesList;
}
/**
* @return the choicesAsRadio
*/
public Boolean getChoicesAsRadio() {
return choicesAsRadio;
}
/**
* @param choicesAsRadio the choicesAsRadio to set
*/
public void setChoicesAsRadio(Boolean choicesAsRadio) {
this.choicesAsRadio = choicesAsRadio;
}
/**
* @return the editBlank
*/
public Boolean getEditBlank() {
return editBlank;
}
/**
* @param editBlank the editBlank to set
*/
public void setEditBlank(Boolean editBlank) {
this.editBlank = editBlank;
}
/**
* @return the displayName
*/
public String getDisplayName() {
return displayName;
}
/**
* @param displayName the displayName to set
*/
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
/**
* @return the orderIndex
*/
public Integer getOrderIndex() {
return orderIndex;
}
/**
* @param orderIndex the orderIndex to set
*/
public void setOrderIndex(Integer orderIndex) {
this.orderIndex = orderIndex;
}
/**
* @return the sortable
*/
public Boolean getSortable() {
return sortable;
}
/**
* @param sortable the sortable to set
*/
public void setSortable(Boolean sortable) {
this.sortable = sortable;
}
/**
* @return the sumable
*/
public Boolean getSumable() {
return sumable;
}
/**
* @param sumable the sumable to set
*/
public void setSumable(Boolean sumable) {
this.sumable = sumable;
}
/**
* @return the graphable
*/
public Boolean getGraphable() {
return graphable;
}
/**
* @param graphable the graphable to set
*/
public void setGraphable(Boolean graphable) {
this.graphable = graphable;
}
}

View file

@ -57,6 +57,26 @@ public class DefaultVascEntryFieldSet implements VascEntryFieldSet {
vascEntryFieldIds = new ArrayList<String>(10);
}
/**
* @see java.lang.Object#clone()
*/
@Override
public VascEntryFieldSet clone() throws CloneNotSupportedException {
DefaultVascEntryFieldSet result = new DefaultVascEntryFieldSet();
result.id=id;
result.name=name;
result.description=description;
result.helpId=helpId;
result.image=image;
result.styleList=styleList;
result.styleEdit=styleEdit;
result.collapsed=collapsed;
result.optional=optional;
result.vascEntryFieldIds.addAll(vascEntryFieldIds);
return result;
}
/**
* @return the id
*/

View file

@ -31,6 +31,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryFinalizer;
@ -52,6 +53,7 @@ public class DefaultVascFrontendData implements VascFrontendData {
private List<Object> entryDataList = null;
private Object entryDataObject = null;
private VascFrontend vascFrontend = null;
private VascBackend vascBackend = null;
private VascEntryFinalizer vascEntryFinalizer = null;
private VascFrontendHelper vascFrontendHelper = null;
private VascEntryResourceResolver vascEntryResourceResolver = null;
@ -160,6 +162,12 @@ public class DefaultVascFrontendData implements VascFrontendData {
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);
}
@ -219,4 +227,18 @@ public class DefaultVascFrontendData implements VascFrontendData {
public VascUIComponent getFieldVascUIComponent(VascEntryField field) {
return fieldComps.get(field);
}
/**
* @return the vascBackend
*/
public VascBackend getVascBackend() {
return vascBackend;
}
/**
* @param vascBackend the vascBackend to set
*/
public void setVascBackend(VascBackend vascBackend) {
this.vascBackend = vascBackend;
}
}

View file

@ -32,6 +32,9 @@ import java.util.logging.Logger;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascFrontendHelper;
import com.idcanet.vasc.core.VascUserRoleController;
import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
import com.idcanet.vasc.core.ui.VascUIComponent;
@ -55,6 +58,98 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
//exceptionListeners = new ArrayList<VascExceptionListener>(2);
}
/**
* @see com.idcanet.vasc.core.VascFrontendHelper#renderView(com.idcanet.vasc.core.VascEntryField)
*/
public boolean renderView(VascEntryField field) {
if (field.getView()==false) {
return false;
}
return true;
}
/**
* @see com.idcanet.vasc.core.VascFrontendHelper#renderCreate(com.idcanet.vasc.core.VascEntryField)
*/
public boolean renderCreate(VascEntryField field) {
if (renderView(field)==false) {
return false;
}
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleControllerResolver().getVascUserRoleController();
if (field.getRolesCreate()!=null && u.hasRole(field.getRolesCreate())) {
return true;
}
if (field.getCreate()) {
return true;
}
return false;
}
/**
* @see com.idcanet.vasc.core.VascFrontendHelper#renderEdit(com.idcanet.vasc.core.VascEntryField)
*/
public boolean renderEdit(VascEntryField field) {
if (renderView(field)==false) {
return false;
}
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleControllerResolver().getVascUserRoleController();
if (field.getRolesEdit()!=null && u.hasRole(field.getRolesEdit())) {
return true;
}
if (field.getEdit()) {
return true;
}
return false;
}
/**
* @see com.idcanet.vasc.core.VascFrontendHelper#renderEditReadOnly(com.idcanet.vasc.core.VascEntryField)
*/
public boolean renderEditReadOnly(VascEntryField field) {
if (renderView(field)==false) {
return false;
}
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleControllerResolver().getVascUserRoleController();
if (field.getRolesEditReadOnly()!=null && u.hasRole(field.getRolesEditReadOnly())) {
return true;
}
if (field.getEditReadOnly()) {
return true;
}
return false;
}
/**
* @see com.idcanet.vasc.core.VascFrontendHelper#renderList(com.idcanet.vasc.core.VascEntryField)
*/
public boolean renderList(VascEntryField field) {
if (renderView(field)==false) {
return false;
}
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleControllerResolver().getVascUserRoleController();
if (field.getRolesList()!=null && u.hasRole(field.getRolesList())) {
return true;
}
if (field.getList()) {
return true;
}
return false;
}
/**
* @see com.idcanet.vasc.core.VascFrontendHelper#renderGlobalVascAction(com.idcanet.vasc.core.actions.GlobalVascAction)
*/
public boolean renderGlobalVascAction(GlobalVascAction action) {
return true;
}
/**
* @see com.idcanet.vasc.core.VascFrontendHelper#renderRowVascAction(com.idcanet.vasc.core.actions.RowVascAction)
*/
public boolean renderRowVascAction(RowVascAction action) {
return true;
}
/**
* @see com.idcanet.vasc.core.VascFrontendHelper#addEventListener(com.idcanet.vasc.core.entry.VascEntryEventListener)
*/
@ -119,7 +214,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
if (object!=null) {
return object;
}
object = entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(entry.getBackendId()).provideVascEntryRecordCreator(entry).newRecord(entry);
object = entry.getVascFrontendData().getVascBackend().provideVascEntryRecordCreator(entry).newRecord(entry);
//fireVascEvent(VascEventListener.VascEventType.BEAN_INIT, object);
return object;
}
@ -145,7 +240,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
public Object mergeObject(VascEntry entry, Object object) {
Object result = null;
try {
object = entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(entry.getBackendId()).merge(object);
object = entry.getVascFrontendData().getVascBackend().merge(object);
//fireVascEvent(VascEventListener.VascEventType.BEAN_MERGE,object);
// todo: make faster
// add to table at position old old object
@ -164,7 +259,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
*/
public void refreshData(VascEntry entry) throws Exception {
entry.getVascFrontendData().setEntryDataObject(null);
entry.getVascFrontendData().setEntryDataList(entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(entry.getBackendId()).execute());
entry.getVascFrontendData().setEntryDataList(entry.getVascFrontendData().getVascBackend().execute());
//fireVascEvent(VascEventListener.VascEventType.DATA_UPDATE, null);
}
@ -189,7 +284,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
*/
public boolean setUIComponentsBeanErrors(VascEntry entry, Object bean) {
boolean error = false;
if(bean==null) {
if (bean==null) {
logger.finest("No bean to check.");
return true; // nothing to check
}
@ -198,7 +293,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
//InvalidValue[] ival = val.getInvalidValues(bean);
//logger.fine("Got invaliled value: "+ival.length);
for(VascEntryField col:entry.getVascEntryFields()) {
for (VascEntryField col:entry.getVascEntryFields()) {
try {
Object object = col.getVascEntryFieldValue().getValue(col, bean);
@ -256,57 +351,8 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
}
*/
/*
public void finalizeVascColumns(VascTable table) throws Exception {
VascAnnotationParser vap = new VascAnnotationParser();
for(VascTableColumn c:table.getTableColumns()) {
if (c instanceof VascAnnotationTableColumn) {
VascAnnotationTableColumn column = (VascAnnotationTableColumn)c;
if (c.getName()==null) {
c.setName(vap.getVascNameKey(table.getVascRecordCreator().getObjectClass(), column.getBeanProperty()));
}
if (c.getToolTip()==null) {
c.setToolTip(vap.getVascToolTipKey(table.getVascRecordCreator().getObjectClass(), column.getBeanProperty()));
}
if (c.getDefaultValue()==null) {
c.setDefaultValue(vap.getVascDefaultValue(table.getVascRecordCreator().getObjectClass(), column.getBeanProperty()));
}
if (c.getWidth()==null) {
Object obj = vap.getVascColumnWidth(table.getVascRecordCreator().getObjectClass(), column.getBeanProperty());
if (obj instanceof Integer) {
c.setWidth((Integer)obj);
}
c.setWidth(100);
// get KEY
}
if (c.getHelpId()==null) {
c.setHelpId(vap.getVascHelpId(table.getVascRecordCreator().getObjectClass(), column.getBeanProperty()));
}
if (c.getVascColumnValue()==null) {
c.setVascColumnValue(new BeanPropertyVascColumnValue(column.getBeanProperty()));
}
if (c.getImage()==null) {
c.setImage(vap.getVascImage(table.getVascRecordCreator().getObjectClass(),column.getBeanProperty()));
}
}
if (c.getVascUIComponent()==null) {
if (c.getDefaultValue() instanceof Boolean) {
c.setVascUIComponent(new VascToggle());
} else if (c.getDefaultValue() instanceof Date) {
c.setVascUIComponent(new VascDate());
} else {
c.setVascUIComponent(new VascTextField());
}
}
if (c.getVascColumnRenderer()==null) {
//c.setVascColumnRenderer(new DefaultVascColumnRenderer());
}
}
}
/*
public void addEventListener(VascEventListener e) {
eventListeners.add(e);
}

View file

@ -36,20 +36,94 @@ import com.idcanet.vasc.core.VascLinkEntry;
* @version 1.0 Oct 27, 2007
*/
public class DefaultVascLinkEntry implements VascLinkEntry {
private String vascEntryName = null;
private String id;
private String vascEntryId = null;
private String parameterName = null;
private String valueFieldId = null;
private Boolean viewAsDetail = null;
/**
* @return the vascEntryName
* @return the id
*/
public String getVascEntryName() {
return vascEntryName;
public String getId() {
return id;
}
/**
* @param vascEntryName the vascEntryName to set
* @param id the id to set
*/
public void setVascEntryName(String vascEntryName) {
this.vascEntryName = vascEntryName;
public void setId(String id) {
this.id = id;
}
/**
* @return the parameterName
*/
public String getParameterName() {
return parameterName;
}
/**
* @param parameterName the parameterName to set
*/
public void setParameterName(String parameterName) {
this.parameterName = parameterName;
}
/**
* @return the valueFieldId
*/
public String getValueFieldId() {
return valueFieldId;
}
/**
* @param valueFieldId the valueFieldId to set
*/
public void setValueFieldId(String valueFieldId) {
this.valueFieldId = valueFieldId;
}
/**
* @return the vascEntryId
*/
public String getVascEntryId() {
return vascEntryId;
}
/**
* @param vascEntryId the vascEntryId to set
*/
public void setVascEntryId(String vascEntryId) {
this.vascEntryId = vascEntryId;
}
/**
* @return the viewAsDetail
*/
public Boolean getViewAsDetail() {
return viewAsDetail;
}
/**
* @param viewAsDetail the viewAsDetail to set
*/
public void setViewAsDetail(Boolean viewAsDetail) {
this.viewAsDetail = viewAsDetail;
}
/**
* @see java.lang.Object#clone()
*/
@Override
public VascLinkEntry clone() throws CloneNotSupportedException {
DefaultVascLinkEntry result = new DefaultVascLinkEntry();
result.viewAsDetail=viewAsDetail;
result.vascEntryId=vascEntryId;
result.parameterName=parameterName;
result.valueFieldId=valueFieldId;
result.id=id;
return result;
}
}

View file

@ -0,0 +1,126 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.vasc.impl;
import java.util.ArrayList;
import java.util.List;
import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.ui.VascSelectItem;
import com.idcanet.vasc.core.ui.VascSelectItemModel;
/**
* The DefaultVascLinkEntry
*
* @author Willem Cazander
* @version 1.0 Oct 27, 2007
*/
public class DefaultVascSelectItemModel implements VascSelectItemModel {
private String entryId = null;
private String keyFieldId = null;
private String displayFieldId = null;
/**
* @see com.idcanet.vasc.core.ui.VascSelectItemModel#getVascSelectItems(com.idcanet.vasc.core.VascEntry)
*/
public List<VascSelectItem> getVascSelectItems(VascEntry entry) throws VascException {
List<VascSelectItem> result = new ArrayList<VascSelectItem>(100);
VascEntry ve = entry.getVascFrontendData().getVascController().getVascEntryControllerResolver().getVascEntryController().getVascEntryById(entryId);
VascEntryField key = ve.getVascEntryFieldById(keyFieldId);
VascEntryField dis = ve.getVascEntryFieldById(displayFieldId);
if (key==null) {
throw new VascException("Could not find: "+keyFieldId+" from: "+ve.getId());
}
if (dis==null) {
throw new VascException("Could not find: "+displayFieldId+" from: "+ve.getId());
}
VascBackend back = entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(ve.getBackendId());
try {
for (Object o:back.execute()) {
String keyId = ""+key.getVascEntryFieldValue().getValue(key, o);
// hackje
if (dis.getDisplayName()!=null && "".equals(dis.getDisplayName())==false) {
dis.setBackendName(dis.getDisplayName());
}
String nameId = ""+dis.getVascEntryFieldValue().getValue(dis, o);
VascSelectItem item = new VascSelectItem(nameId,o,keyId);
result.add(item);
}
} catch (Exception e) {
throw new VascException(e);
}
return result;
}
/**
* @return the entryId
*/
public String getEntryId() {
return entryId;
}
/**
* @param entryId the entryId to set
*/
public void setEntryId(String entryId) {
this.entryId = entryId;
}
/**
* @return the keyFieldId
*/
public String getKeyFieldId() {
return keyFieldId;
}
/**
* @param keyFieldId the keyFieldId to set
*/
public void setKeyFieldId(String keyFieldId) {
this.keyFieldId = keyFieldId;
}
/**
* @return the displayFieldId
*/
public String getDisplayFieldId() {
return displayFieldId;
}
/**
* @param displayFieldId the displayFieldId to set
*/
public void setDisplayFieldId(String displayFieldId) {
this.displayFieldId = displayFieldId;
}
}

View file

@ -0,0 +1,106 @@
/*
* Copyright 2004-2007 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.vasc.impl;
import java.util.ArrayList;
import java.util.List;
import com.idcanet.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 com.idcanet.vasc.core.VascUserRoleController#getUserId()
*/
public Long getUserId() {
return userId;
}
/**
* @see com.idcanet.vasc.core.VascUserRoleController#getUserName()
*/
public String getUserName() {
return userName;
}
/**
* @see com.idcanet.vasc.core.VascUserRoleController#getUserRoles()
*/
public List<String> getUserRoles() {
return userRoles;
}
/**
* @see com.idcanet.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

@ -48,8 +48,7 @@ public class DefaultVascUserRoleControllerResolver implements VascUserRoleContro
/**
* @param vascUserRoleController the vascUserRoleController to set
*/
public void setVascUserRoleController(
VascUserRoleController vascUserRoleController) {
public void setVascUserRoleController(VascUserRoleController vascUserRoleController) {
this.vascUserRoleController = vascUserRoleController;
}
}
}

View file

@ -0,0 +1,83 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.vasc.impl;
import java.util.ArrayList;
import java.util.List;
import com.idcanet.vasc.core.AbstractVascBackendProxy;
import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascEntry;
/**
* Simulates a real pages backend.
*
* @author Willem Cazander
* @version 1.0 Oct 27, 2007
*/
public class VascBackendProxyPaged extends AbstractVascBackendProxy {
private long records = 0;
public VascBackendProxyPaged(VascBackend backend,VascEntry entry) {
super(backend);
}
/**
* @see com.idcanet.vasc.core.VascBackend#isPageable()
*/
@Override
public boolean isPageable() {
return true;
}
/**
* @see com.idcanet.vasc.core.VascBackend#execute()
*/
@Override
public List<Object> execute() throws Exception {
List<Object> allData = backend.execute();
List<Object> paged = new ArrayList<Object>(getPageSize());
int off = getPageIndex()*getPageSize();
int offMax = off+getPageSize();
for (int i=off;i<offMax;i++) {
if (i>=allData.size()) {
break;
}
Object o = allData.get(i);
paged.add(o);
}
records = allData.size();
return paged;
}
@Override
public long getPagesTotalRecords() {
return records;
}
}

View file

@ -0,0 +1,125 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.vasc.impl;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.idcanet.vasc.core.AbstractVascBackendProxy;
import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascBackendPageNumber;
import com.idcanet.vasc.core.VascEntry;
/**
* Simple text search
*
* @author Willem Cazander
* @version 1.0 Oct 27, 2007
*/
public class VascBackendProxySearch extends AbstractVascBackendProxy {
private long records = 0;
public VascBackendProxySearch(VascBackend backend,VascEntry entry) {
super(backend);
}
/**
* @see com.idcanet.vasc.core.VascBackend#isSearchable()
*/
@Override
public boolean isSearchable() {
return true;
}
/**
* @see com.idcanet.vasc.core.VascBackend#execute()
*/
@Override
public List<Object> execute() throws Exception {
List<Object> result = backend.execute();
if (getSearchString()==null) {
records = backend.getPagesTotalRecords();
return result;
}
String searchString = getSearchString().toLowerCase();
List<Object> search = new ArrayList<Object>(result.size()/4);
for (Object o:result) {
for (Method method:o.getClass().getMethods()) {
if (method.getName().startsWith("get")==false) { //a bit durty
continue;
}
if (method.getName().equals("getClass")) {
continue;
}
if (method.getReturnType().isAssignableFrom(Collection.class)) {
continue;
}
if (method.getReturnType().isAssignableFrom(List.class)) {
continue;
}
if (method.getReturnType().isAssignableFrom(Set.class)) {
continue;
}
if (method.getReturnType().isAssignableFrom(Map.class)) {
continue;
}
Object res = method.invoke(o,null);
if (res==null) {
continue;
}
String r = res.toString().toLowerCase();
if (r.contains(searchString)) {
search.add(o);
break;
}
}
}
records = search.size();
return search;
}
@Override
public long getPagesTotalRecords() {
return records;
}
@Override
public List<VascBackendPageNumber> getVascBackendPageNumbers() {
if (getSearchString()==null) {
return backend.getVascBackendPageNumbers();
}
// limit the pages to the number of search results.
List<VascBackendPageNumber> r = backend.getVascBackendPageNumbers();
int pages = new Long(getPagesTotalRecords()/getPageSize()).intValue();
return r.subList(0, pages);
}
}

View file

@ -0,0 +1,88 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.vasc.impl;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import com.idcanet.vasc.core.AbstractVascBackendProxy;
import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascException;
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
/**
* Add an sortware sort an a backend
*
* @author Willem Cazander
* @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;
}
// sort stuff
/**
* @see com.idcanet.vasc.core.VascBackend#execute()
*/
@SuppressWarnings("unchecked")
@Override
public List<Object> execute() throws Exception {
List<Object> result = backend.execute();
if (getSortField()==null) {
return result;
}
final VascEntryField field = entry.getVascEntryFieldById(getSortField());
final VascEntryFieldValue fieldValue = backend.provideVascEntryFieldValue(field);
Collections.sort(result, new Comparator() {
public int compare(Object o1, Object o2) {
try {
Comparable c1 = (Comparable)fieldValue.getValue(field, o1);
Comparable c2 = (Comparable)fieldValue.getValue(field, o2);
if (isSortAscending()) {
return c1.compareTo(c2);
} else {
return c2.compareTo(c1);
}
} catch (VascException e) {
e.printStackTrace();
return 0;
}
}
});
return result;
}
}

View file

@ -38,6 +38,7 @@ import com.idcanet.vasc.core.actions.RowVascAction;
public class AddRowAction extends AbstractVascAction implements RowVascAction {
public AddRowAction() {
setId("addRowAction");
setName("vasc.action.add.name");
setToolTip("vasc.action.add.tooltip");
setImage("vasc.action.add.image");
@ -46,4 +47,11 @@ public class AddRowAction extends AbstractVascAction implements RowVascAction {
public void doRowAction(VascEntry enty,Object rowObject) throws Exception {
enty.getVascFrontendData().getVascFrontend().renderEdit(null);
}
/**
* @see com.idcanet.vasc.core.actions.RowVascAction#isMultiRowAction()
*/
public boolean isMultiRowAction() {
return false;
}
}

View file

@ -43,6 +43,7 @@ import com.idcanet.vasc.core.actions.GlobalVascAction;
public class CSVExportGlobalAction extends AbstractVascAction implements GlobalVascAction,VascEntryExporter {
public CSVExportGlobalAction() {
setId("CSVExportGlobalAction");
setName("vasc.action.csv.name");
setToolTip("vasc.action.csv.tooltip");
setImage("vasc.action.csv.image");
@ -71,7 +72,7 @@ public class CSVExportGlobalAction extends AbstractVascAction implements GlobalV
}
public String getMineType() {
return "csv";
return "text/csv";
}
public String getType() {

View file

@ -38,6 +38,7 @@ import com.idcanet.vasc.core.actions.RowVascAction;
public class DeleteRowAction extends AbstractVascAction implements RowVascAction {
public DeleteRowAction() {
setId("deleteRowAction");
setName("vasc.action.del.name");
setToolTip("vasc.action.del.tooltip");
setImage("vasc.action.del.image");
@ -49,4 +50,11 @@ public class DeleteRowAction extends AbstractVascAction implements RowVascAction
}
entry.getVascFrontendData().getVascFrontend().renderDelete(rowObject);
}
/**
* @see com.idcanet.vasc.core.actions.RowVascAction#isMultiRowAction()
*/
public boolean isMultiRowAction() {
return true;
}
}

View file

@ -38,6 +38,7 @@ import com.idcanet.vasc.core.actions.RowVascAction;
public class EditRowAction extends AbstractVascAction implements RowVascAction {
public EditRowAction() {
setId("editRowAction");
setName("vasc.action.edit.name");
setToolTip("vasc.action.edit.tooltip");
setImage("vasc.action.edit.image");
@ -50,4 +51,12 @@ public class EditRowAction extends AbstractVascAction implements RowVascAction {
}
entry.getVascFrontendData().getVascFrontend().renderEdit(rowObject);
}
/**
* @see com.idcanet.vasc.core.actions.RowVascAction#isMultiRowAction()
*/
public boolean isMultiRowAction() {
return false;
}
}

View file

@ -38,6 +38,7 @@ import com.idcanet.vasc.core.actions.GlobalVascAction;
public class RefreshDataGlobalAction extends AbstractVascAction implements GlobalVascAction {
public RefreshDataGlobalAction() {
setId("refreshDataGlobalAction");
setName("vasc.action.refresh.name");
setToolTip("vasc.action.refresh.tooltip");
setImage("vasc.action.refresh.image");

View file

@ -43,6 +43,7 @@ import com.idcanet.vasc.core.entry.VascEntryExporter;
public class XMLExportGlobalAction extends AbstractVascAction implements GlobalVascAction,VascEntryExporter {
public XMLExportGlobalAction() {
setId("XMLExportGlobalAction");
setName("vasc.action.xml.name");
setToolTip("vasc.action.xml.tooltip");
setImage("vasc.action.xml.image");
@ -58,9 +59,9 @@ public class XMLExportGlobalAction extends AbstractVascAction implements GlobalV
p.write("<data>\n");
for (Object o:entry.getVascFrontendData().getEntryDataList()) {
for (VascEntryField c:entry.getVascEntryFields()) {
p.write("<column name=\""+c.getName()+"\">");
p.write("<column name=\""+c.getName()+"\"><![CDATA[");
p.write(""+c.getVascEntryFieldValue().getValue(c, o));
p.write("</column>\n");
p.write("]]></column>\n");
}
p.flush();
}

View file

@ -26,6 +26,11 @@
package com.idcanet.vasc.impl.entry;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import com.idcanet.vasc.core.entry.VascEntryResourceResolver;
/**
@ -35,11 +40,56 @@ import com.idcanet.vasc.core.entry.VascEntryResourceResolver;
*/
public class DefaultVascEntryResourceResolver implements VascEntryResourceResolver {
protected ResourceBundle resourceBundle = null;
public DefaultVascEntryResourceResolver() {
}
public DefaultVascEntryResourceResolver(ResourceBundle resourceBundle) {
setResourceBundle(resourceBundle);
}
public DefaultVascEntryResourceResolver(String baseName,Locale locale) {
this(ResourceBundle.getBundle(baseName, locale));
}
public String getKeyMapping(String key) {
return key;
if (resourceBundle==null) {
return key;
} else {
return resourceBundle.getString(key);
}
}
public String getTextValue(String text,Object...params) {
return text;
if (resourceBundle==null) {
return text;
} else {
String textValue = null;
try {
textValue = resourceBundle.getString(text);
} catch (MissingResourceException mre) {
return text;
}
if (params.length>0) {
textValue = MessageFormat.format(textValue, params);
}
return textValue;
}
}
/**
* @return the resourceBundle
*/
public ResourceBundle getResourceBundle() {
return resourceBundle;
}
/**
* @param resourceBundle the resourceBundle to set
*/
public void setResourceBundle(ResourceBundle resourceBundle) {
this.resourceBundle = resourceBundle;
}
}

View file

@ -28,12 +28,29 @@ package com.idcanet.vasc.impl.type;
import com.idcanet.vasc.core.AbstractVascEntryFieldType;
import com.idcanet.vasc.core.VascEntryFieldType;
/**
* Only knows how to clone its self.
*
*
* @author Willem Cazander
* @version 1.0 Sep 8, 2008
*/
public class DefaultVascEntryFieldType extends AbstractVascEntryFieldType {
public class DefaultVascEntryFieldType extends AbstractVascEntryFieldType {
@Override
public VascEntryFieldType clone() throws CloneNotSupportedException {
DefaultVascEntryFieldType clone = new DefaultVascEntryFieldType();
clone.id=id;
clone.autoDetectClass=autoDetectClass;
clone.uiComponentId=uiComponentId;
clone.inputMask=inputMask;
for (String key:properties.keySet()) {
clone.properties.put(key,properties.get(key));
}
// mmm
clone.vascValidators.addAll(vascValidators);
return clone;
}
}

View file

@ -27,46 +27,80 @@
package com.idcanet.vasc.impl.type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.idcanet.vasc.core.VascEntryFieldType;
import com.idcanet.vasc.core.VascEntryFieldTypeController;
import com.idcanet.vasc.core.VascEntryFieldTypeControllerLocal;
import com.idcanet.vasc.core.VascException;
/**
*
* @author Willem Cazander
* @version 1.0 Sep 14, 2008
*/
public class DefaultVascEntryFieldTypeController implements VascEntryFieldTypeController {
public class DefaultVascEntryFieldTypeController implements VascEntryFieldTypeControllerLocal {
FieldTypeParser parser = null;
private Map<String,VascEntryFieldType> vascEntryFieldTypes = null;
public DefaultVascEntryFieldTypeController() throws Exception {
parser = new FieldTypeParser();
parser.parseVascFieldTypes();
public DefaultVascEntryFieldTypeController() throws VascException {
try {
FieldTypeParser parser = new FieldTypeParser();
parser.parseVascFieldTypes();
vascEntryFieldTypes = new HashMap<String,VascEntryFieldType>(35);
for(VascEntryFieldType v:parser.getTypes()) {
vascEntryFieldTypes.put(v.getId(),v);
}
} catch (Exception e) {
throw new VascException(e);
}
}
/**
*
*/
public void addVascEntryFieldType(VascEntryFieldType vascEntryFieldType) {
if (vascEntryFieldType==null) {
throw new NullPointerException("Can't add null vascEntryFieldType.");
}
vascEntryFieldTypes.put(vascEntryFieldType.getId(),vascEntryFieldType);
}
/**
* @see com.idcanet.vasc.core.VascEntryFieldTypeController#getVascEntryFieldTypeById(java.lang.String)
*/
public VascEntryFieldType getVascEntryFieldTypeById(String name) {
for(VascEntryFieldType v:parser.getTypes()) {
if (v.getId().equals(name)) {
return v;
}
public VascEntryFieldType getVascEntryFieldTypeById(String id) {
VascEntryFieldType result = vascEntryFieldTypes.get(id);
if (result==null) {
throw new IllegalArgumentException("Field not found: "+id);
}
try {
return result.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalArgumentException("FieldType not clonable: "+e.getMessage());
}
throw new IllegalArgumentException("Field not found: "+name);
}
public VascEntryFieldType getRealVascEntryFieldTypeById(String id) {
VascEntryFieldType result = vascEntryFieldTypes.get(id);
if (result==null) {
throw new IllegalArgumentException("Field not found: "+id);
}
return result;
}
/**
* @see com.idcanet.vasc.core.VascEntryFieldTypeController#getVascEntryFieldTypeIds()
*/
public List<String> getVascEntryFieldTypeIds() {
List<String> result = new ArrayList<String>(5);
for(VascEntryFieldType v:parser.getTypes()) {
result.add(v.getId());
}
result.addAll(vascEntryFieldTypes.keySet());
Collections.sort(result); // lets do abc for consistance behauvior.
return result;
}
}

View file

@ -28,6 +28,7 @@ package com.idcanet.vasc.impl.type;
import java.io.IOException;
import java.util.ArrayList;
import java.util.InvalidPropertiesFormatException;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
@ -51,9 +52,11 @@ public class FieldTypeParser extends X4OParser {
/**
*
* @param language
* @throws IOException
* @throws InvalidPropertiesFormatException
* @throws Exception
*/
public FieldTypeParser() throws Exception {
public FieldTypeParser() throws InvalidPropertiesFormatException, IOException {
super(FIELD_TYPE_LANGUAGE);
}
@ -63,7 +66,7 @@ public class FieldTypeParser extends X4OParser {
public List<VascEntryFieldType> getTypes() {
List<VascEntryFieldType> result = new ArrayList<VascEntryFieldType>(4);
for (Element e:getElementContext().getRootElements()) {
for (Element e:getElementContext().getRootElement().getChilderen()) {
VascEntryFieldType a = (VascEntryFieldType)e.getElementObject();
result.add(a);
}

View file

@ -0,0 +1,318 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.vasc.impl.x4o;
import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import com.idcanet.vasc.annotations.VascAnnotationParser;
import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryFieldType;
import com.idcanet.vasc.impl.DefaultVascEntryField;
import com.idcanet.vasc.validators.VascValidator;
import com.idcanet.vasc.validators.VascValidatorClassParser;
import com.idcanet.x4o.core.X4OParser;
import com.idcanet.x4o.element.AbstractElement;
import com.idcanet.x4o.element.ElementException;
/**
* Parses the xml element for auto adding field or defaults of fields.
*
* @author Willem Cazander
* @version 1.0 Mar 24, 2009
*/
public class AnnotationParserElement extends AbstractElement {
/**
* @see com.idcanet.x4o.element.AbstractElement#doElementRun()
*/
@Override
public void doElementRun() throws ElementException {
try {
String className = getAttributes().get("className");
String addFields = getAttributes().get("addFields");
Object parentObject = getParent().getElementObject();
Class<?> modelClass;
try {
modelClass = X4OParser.loadClass(className);
} catch (ClassNotFoundException e) {
throw new ElementException(e);
}
VascAnnotationParser parser = new VascAnnotationParser();
if (parentObject instanceof VascEntry) {
VascEntry entry = (VascEntry)parentObject;
if (addFields!=null && "false".equals(addFields)) {
// when false we don't add the fields.
} else {
addFields(entry,modelClass);
}
for (VascEntryField field:entry.getVascEntryFields()) {
fillField(field,modelClass,parser);
}
entry.setDisplayNameFieldId(parser.getVascDisplayName(modelClass));
entry.setPrimaryKeyFieldId(parser.getVascPrimaryKey(modelClass));
} else if (parentObject instanceof VascEntryField) {
VascEntryField field = (VascEntryField)parentObject;
fillField(field,modelClass,parser);
} else {
throw new ElementException("Unknow parent object type: "+parentObject);
}
} catch (Exception e) {
e.printStackTrace();
throw new ElementException(e);
}
}
private void fillEntry(VascEntry entry,Class<?> modelClass,VascAnnotationParser parser) {
if (entry.getId()==null) {
}
if (entry.getHeaderName()==null) {
}
if (entry.getHeaderDescription()==null) {
}
if (entry.getHeaderImage()==null) {
}
}
private void fillField(VascEntryField field,Class<?> modelClass,VascAnnotationParser parser) {
String value = null;
value = parser.getVascFieldBackendName(modelClass, field.getId());
if (value!=null && "".equals(value)==false) {
field.setBackendName(value);
}
if (field.getDisplayName()==null) {
field.setDisplayName( parser.getVascDisplayName (modelClass, field.getId()));
}
if (field.getName()==null) {
field.setName( parser.getVascI18nName (modelClass, field.getId()));
}
if (field.getDescription()==null) {
field.setDescription( parser.getVascI18nDescription (modelClass, field.getId()));
}
if (field.getImage()==null) {
field.setImage( parser.getVascI18nImage (modelClass, field.getId()));
}
if (field.getHelpId()==null) {
field.setHelpId( parser.getVascI18nHelpId (modelClass, field.getId()));
}
if (field.getOrderIndex()==null) {
field.setOrderIndex( parser.getVascOrderIndex (modelClass, field.getId()));
}
if (field.getCreate()==null) {
field.setCreate( parser.getVascFieldCreate (modelClass, field.getId()));
}
if (field.getEdit()==null) {
field.setEdit( parser.getVascFieldEdit (modelClass, field.getId()));
}
if (field.getEditReadOnly()==null) {
field.setEditReadOnly( parser.getVascFieldEditReadOnly (modelClass, field.getId()));
}
if (field.getEditBlank()==null) {
field.setEditBlank( parser.getVascFieldEditBlank (modelClass, field.getId()));
}
if (field.getList()==null) {
field.setList( parser.getVascFieldList (modelClass, field.getId()));
}
if (field.getView()==null) {
field.setView( parser.getVascFieldView (modelClass, field.getId()));
}
if (field.getOptional()==null) {
field.setOptional( parser.getVascFieldOptional (modelClass, field.getId()));
}
if (field.getRolesCreate()==null) {
field.setRolesCreate( parser.getVascRolesCreate (modelClass, field.getId()));
}
if (field.getRolesEdit()==null) {
field.setRolesEdit( parser.getVascRolesEdit (modelClass, field.getId()));
}
if (field.getRolesEditReadOnly()==null) {
field.setRolesEditReadOnly(parser.getVascRolesEditReadOnly (modelClass, field.getId()));
}
if (field.getRolesList()==null) {
field.setRolesList( parser.getVascRolesList (modelClass, field.getId()));
}
if (field.getSizeEdit()==null) {
field.setSizeEdit( parser.getVascStyleSizeEdit (modelClass, field.getId()));
}
if (field.getSizeList()==null) {
field.setSizeList( parser.getVascStyleSizeList (modelClass, field.getId()));
}
if (field.getStyleEdit()==null) {
field.setStyleEdit( parser.getVascStyleStyleEdit (modelClass, field.getId()));
}
if (field.getStyleList()==null) {
field.setStyleList( parser.getVascStyleStyleList (modelClass, field.getId()));
}
VascValidatorClassParser validatorParser = new VascValidatorClassParser();
List<VascValidator> val = validatorParser.getValidatorsByPropertyName(modelClass, field.getId());
for (VascValidator v:val) {
field.addVascValidator(v);
}
VascController vascController = VascParser.getVascController(this.getElementContext());
if (field.getVascEntryFieldType()==null) {
String fieldType = parser.getVascFieldType (modelClass, field.getId());
if (fieldType!=null) {
VascEntryFieldType type = vascController.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById(fieldType);
field.setVascEntryFieldType(type);
// copy properties
String[] prop = parser.getVascFieldTypeProperties (modelClass, field.getId());
if (prop!=null) {
Properties properties = new Properties();
for (String p:prop) {
try {
// let properties class parse the key=value pairs.
properties.load(new StringReader(p));
} catch (IOException e) {
e.printStackTrace();
}
}
for (Object key:properties.keySet()) {
type.setProperty((String)key, (String)properties.get(key));
}
}
}
}
if (field.getVascEntryFieldType()==null) {
Method methodCall = null;
// note: model references properties are not resolved yet.
// search for method on bean.
for (Method method:modelClass.getMethods()) {
if (method.getName().startsWith("get")==false) { //a bit durty
continue;
}
if (method.getName().equals("getClass")) {
continue;
}
if (field.getBackendName()==null) {
if (method.getName().equalsIgnoreCase("get"+field.getId())) {
methodCall = method;
break;
}
} else {
if (method.getName().equalsIgnoreCase("get"+field.getBackendName())) {
methodCall = method;
break;
}
}
}
// System.out.println("Found method: "+methodCall);
// search for type
if (methodCall!=null) {
Class<?> retType = methodCall.getReturnType();
for (String typeId: vascController.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeIds()) {
VascEntryFieldType type = vascController.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById(typeId);
//String auto = "";
//if (type.getAutoDetectClass()!=null) {
// auto = type.getAutoDetectClass().getName();
//}
//System.out.println("Check ret: "+retType.getName()+" type: "+type.getId()+" auto: "+auto);
if (type.getAutoDetectClass()!=null) {
if (type.getAutoDetectClass().isAssignableFrom(retType)) {
field.setVascEntryFieldType(type);
break;
}
}
}
}
}
}
private void addFields(VascEntry entry,Class<?> modelClass) {
for (Method method:modelClass.getMethods()) {
if (method.getName().startsWith("get")==false) { //a bit durty
continue;
}
if (method.getName().equals("getClass")) {
continue;
}
if (method.getReturnType().isAssignableFrom(Collection.class)) {
continue;
}
if (method.getReturnType().isAssignableFrom(List.class)) {
continue;
}
if (method.getReturnType().isAssignableFrom(Set.class)) {
continue;
}
if (method.getReturnType().isAssignableFrom(Map.class)) {
continue;
}
String fieldId = method.getName().substring(3,4).toLowerCase()+method.getName().substring(4);
VascEntryField field = new DefaultVascEntryField();
field.setId(fieldId);
if (method.getName().equals("getId")) {
field.setEditReadOnly(true);
}
if (entry.getVascEntryFieldById(fieldId)==null) {
entry.addVascEntryField(field);
} else {
continue; // already set in xml
}
}
}
}

View file

@ -0,0 +1,75 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.vasc.impl.x4o;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryFieldType;
import com.idcanet.vasc.core.ui.VascSelectItemModel;
import com.idcanet.x4o.element.AbstractElementBindingHandler;
import com.idcanet.x4o.element.Element;
import com.idcanet.x4o.element.ElementBindingException;
/**
* Binds SelectItems
*
*
* @author Willem Cazander
* @version 1.0 Apr 02, 2009
*/
public class SelectItemModelBindingHandler extends AbstractElementBindingHandler {
/**
* @see com.idcanet.x4o.element.ElementBindingHandler#canBind(com.idcanet.x4o.element.Element)
*/
public boolean canBind(Element element) {
if (element.getParent()==null) {
return false;
}
Object parent = element.getParent().getElementObject();
Object child = element.getElementObject();
boolean p = false;
boolean c = false;
if (parent instanceof VascEntryField) { p=true; }
if (child instanceof VascSelectItemModel) { c=true; }
if (p&c) { return true; } else { return false; }
}
/**
* @see com.idcanet.x4o.element.ElementBindingHandler#doBind(com.idcanet.x4o.element.Element)
*/
public void doBind(Element element) throws ElementBindingException {
Object child = element.getElementObject();
Object parentObject = element.getParent().getElementObject();
if (parentObject instanceof VascEntryField) {
VascEntryField parent = (VascEntryField)parentObject;
if (child instanceof VascSelectItemModel) {
VascEntryFieldType type = parent.getVascEntryFieldType();
type.setDataObject(child);
}
}
}
}

View file

@ -0,0 +1,96 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.vasc.impl.x4o;
import java.util.logging.Logger;
import com.idcanet.vasc.core.VascBackend;
import com.idcanet.vasc.core.VascController;
import com.idcanet.x4o.element.AbstractElement;
import com.idcanet.x4o.element.ElementException;
/**
*
*
* @author Willem Cazander
* @version 1.0 Mar 24, 2009
*/
public class SetParameterElement extends AbstractElement {
private Logger logger = Logger.getLogger(SetParameterElement.class.getName());
/**
* @see com.idcanet.x4o.element.AbstractElement#doElementRun()
*/
@Override
public void doElementRun() throws ElementException {
String name = getAttributes().get("name");
String value = getAttributes().get("value");
String type = getAttributes().get("type");
VascBackend back = (VascBackend)getParent().getElementObject();
VascController cont = VascParser.getVascController(getElementContext());
logger.info("Setting parameter name: "+name+" value: "+value+" type: "+type);
if ("setUserParameter".equals(getElementClass().getTag())) {
if (value==null) {
value="id";
}
if ("id".equals(value)) {
if ("int".equals(type)) {
Long userId = cont.getVascUserRoleControllerResolver().getVascUserRoleController().getUserId();
back.setDataParameter(name, userId.intValue());
} else {
Long userId = cont.getVascUserRoleControllerResolver().getVascUserRoleController().getUserId();
back.setDataParameter(name, userId);
}
} else {
String userName = cont.getVascUserRoleControllerResolver().getVascUserRoleController().getUserName();
back.setDataParameter(name, userName);
}
return;
}
if (type==null) {
back.setDataParameter(name, value);
return;
}
if ("long".equalsIgnoreCase(type)) {
back.setDataParameter(name, new Long(value));
return;
}
if ("int".equalsIgnoreCase(type)) {
back.setDataParameter(name, new Integer(value));
return;
}
throw new ElementException("Could not set dataParameter: "+name+" with type: "+type);
}
}

View file

@ -43,12 +43,11 @@ import com.idcanet.x4o.element.ElementConfiguratorException;
* @version 1.0 Nov 16, 2008
*/
public class VascBackendElementConfigurator extends AbstractElementConfigurator {
/**
* @see com.idcanet.x4o.element.AbstractElementConfigurator#doConfigEndTag(com.idcanet.x4o.element.Element)
*/
@Override
public void doConfigEndTag(Element element) throws ElementConfiguratorException {
public void doConfigElement(Element element) throws ElementConfiguratorException {
VascBackend backend = (VascBackend)element.getElementObject();

View file

@ -43,12 +43,11 @@ import com.idcanet.x4o.element.ElementConfiguratorException;
* @version 1.0 Nov 16, 2008
*/
public class VascEntryElementConfigurator extends AbstractElementConfigurator {
/**
* @see com.idcanet.x4o.element.AbstractElementConfigurator#doConfigEndTag(com.idcanet.x4o.element.Element)
*/
@Override
public void doConfigEndTag(Element element) throws ElementConfiguratorException {
public void doConfigElement(Element element) throws ElementConfiguratorException {
VascEntry entry = (VascEntry)element.getElementObject();

View file

@ -0,0 +1,66 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.vasc.impl.x4o;
import java.util.logging.Logger;
import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.x4o.element.AbstractElement;
import com.idcanet.x4o.element.ElementException;
/**
*
*
* @author Willem Cazander
* @version 1.0 Mar 27, 2009
*/
public class VascEntryFieldElement extends AbstractElement {
private Logger logger = Logger.getLogger(VascEntryFieldElement.class.getName());
/**
* @see com.idcanet.x4o.element.AbstractElement#doElementRun()
*/
@Override
public void doElementRun() throws ElementException {
String id = getAttributes().get("id");
VascEntry back = (VascEntry)getParent().getElementObject();
VascEntryField field = back.getVascEntryFieldById(id);
if (field==null) {
return;
}
if (field==getElementObject()) {
return; // is the same object
}
logger.fine("ReSetting elementObject: "+field.getId());
setElementObject(field);
}
}

View file

@ -43,7 +43,6 @@ public class VascEntryFieldSetParameterConverter extends AbstractElementParamete
/**
* @see com.idcanet.x4o.element.AbstractElementParameterConverter#doConvertParameter(com.idcanet.x4o.element.Element, java.lang.Object)
*/
@Override
public Object doConvertParameter(Element element, Object parameterValue) throws ElementParameterConverterException {
if (parameterValue==null) {

View file

@ -0,0 +1,64 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.vasc.impl.x4o;
import java.util.logging.Logger;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryFieldType;
import com.idcanet.x4o.core.X4OPhase;
import com.idcanet.x4o.element.AbstractElement;
import com.idcanet.x4o.element.ElementException;
/**
*
*
* @author Willem Cazander
* @version 1.0 Mar 27, 2009
*/
public class VascEntryFieldTypeElement extends AbstractElement {
private Logger logger = Logger.getLogger(VascEntryFieldTypeElement.class.getName());
/**
* @see com.idcanet.x4o.element.AbstractElement#doElementRun()
*/
@Override
public void doElementRun() throws ElementException {
if (getElementObject()!=null) {
return; // already done.
}
VascEntryField field = (VascEntryField)getParent().getElementObject();
VascEntryFieldType type = field.getVascEntryFieldType();
setElementObject(type);
logger.info("Readding the element for reparsing");
getElementContext().addDirtyElement(this, X4OPhase.startX4OPhase);
}
}

View file

@ -43,7 +43,6 @@ public class VascEntryFieldTypeParameterConverter extends AbstractElementParamet
/**
* @see com.idcanet.x4o.element.AbstractElementParameterConverter#doConvertParameter(com.idcanet.x4o.element.Element, java.lang.Object)
*/
@Override
public Object doConvertParameter(Element element, Object parameterValue) throws ElementParameterConverterException {
if (parameterValue==null) {

View file

@ -26,13 +26,15 @@
package com.idcanet.vasc.impl.x4o;
import java.io.IOException;
import javax.el.ValueExpression;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import com.idcanet.vasc.core.VascController;
import com.idcanet.x4o.core.AbstractX4OPhaseHandler;
import com.idcanet.x4o.core.X4OParser;
import com.idcanet.x4o.core.X4OPhaseException;
import com.idcanet.x4o.core.X4OPhaseHandler;
import com.idcanet.x4o.core.X4OPhase;
import com.idcanet.x4o.element.Element;
import com.idcanet.x4o.element.ElementContext;
/**
@ -69,11 +71,26 @@ public class VascParser extends X4OParser {
return con;
}
protected void preStartParsing() throws ParserConfigurationException,SAXException,IOException {
super.preStartParsing();
// Add the controller to EL
ValueExpression ee = getElementContext().getExpressionFactory().createValueExpression(getElementContext().getELContext(),"${vascController}", VascController.class);
ee.setValue(getElementContext().getELContext(), vascController);
/**
*
*/
@Override
protected X4OPhaseHandler getConfigOptionalPhase() {
X4OPhaseHandler result = new AbstractX4OPhaseHandler() {
protected void setX4OPhase() {
phase = X4OPhase.configOptionalPhase;
}
public boolean isElementPhase() {
return false;
}
public void runElementPhase(Element element) throws X4OPhaseException {
}
public void runPhase(ElementContext elementContext) throws X4OPhaseException {
// Add the controller to EL
ValueExpression ee = getElementContext().getExpressionFactory().createValueExpression(getElementContext().getELContext(),"${vascController}", VascController.class);
ee.setValue(getElementContext().getELContext(), vascController);
}
};
return result;
}
}