diff --git a/.externalToolBuilders/org.eclipse.wst.validation.validationbuilder.launch b/.externalToolBuilders/org.eclipse.wst.validation.validationbuilder.launch deleted file mode 100644 index 6ef634c..0000000 --- a/.externalToolBuilders/org.eclipse.wst.validation.validationbuilder.launch +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/.mymetadata b/.mymetadata deleted file mode 100644 index 0054d57..0000000 --- a/.mymetadata +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - diff --git a/.settings/com.genuitec.eclipse.core.prefs b/.settings/com.genuitec.eclipse.core.prefs deleted file mode 100644 index fc7c45b..0000000 --- a/.settings/com.genuitec.eclipse.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Jan 08 18:05:54 CET 2009 -eclipse.preferences.version=1 -validator.Checked=target -validator.Unchecked= diff --git a/.settings/com.genuitec.eclipse.j2eedt.core.prefs b/.settings/com.genuitec.eclipse.j2eedt.core.prefs deleted file mode 100644 index 80cf3e4..0000000 --- a/.settings/com.genuitec.eclipse.j2eedt.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Jan 15 07:20:11 CET 2009 -defaultTldInfo=f\=http\://java.sun.com/jsf/core;http\://java.sun.com/jsf/html\=h;http\://struts.apache.org/tags-bean\=bean;http\://java.sun.com/jsp/jstl/fmt\=fmt;bean\=http\://struts.apache.org/tags-bean;nested\=http\://struts.apache.org/tags-nested;http\://java.sun.com/jsp/jstl/sql\=sql;fmt\=http\://java.sun.com/jsp/jstl/fmt;c\=http\://java.sun.com/jsp/jstl/core;http\://struts.apache.org/tags-logic\=logic;http\://java.sun.com/jsp/jstl/xml\=x;http\://java.sun.com/jsp/jstl/core\=c;logic\=http\://struts.apache.org/tags-logic;h\=http\://java.sun.com/jsf/html;http\://struts.apache.org/tags-tiles\=tiles;http\://java.sun.com/jsp/jstl/functions\=fn;tiles\=http\://struts.apache.org/tags-tiles;sql\=http\://java.sun.com/jsp/jstl/sql;http\://struts.apache.org/tags-html\=html;html\=http\://struts.apache.org/tags-html;http\://struts.apache.org/tags-nested\=nested;http\://java.sun.com/jsf/core\=f;fn\=http\://java.sun.com/jsp/jstl/functions;x\=http\://java.sun.com/jsp/jstl/xml -eclipse.preferences.version=1 -j2ee.deployment.web.archive_dependent_projects=always diff --git a/.settings/com.genuitec.eclipse.ws.blue.prefs b/.settings/com.genuitec.eclipse.ws.blue.prefs deleted file mode 100644 index 284916e..0000000 --- a/.settings/com.genuitec.eclipse.ws.blue.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Jan 15 07:20:11 CET 2009 -blue.framework.id= -blue.target.server= -eclipse.preferences.version=1 diff --git a/doc/README.txt b/doc/README.txt deleted file mode 100644 index 6464584..0000000 --- a/doc/README.txt +++ /dev/null @@ -1,267 +0,0 @@ - - -eclipse 3.2 - -To build/run the swt stuff you need the Visual Editor plug in installed from the calisto site. - -eclipse 3.3 - -Down load http://www.ehecht.com/eclipse_ve/ve.html (lin_mac version) - -Unzip and move the plug ins and features into the plug in and features directory of eclipse. - -Swing will run by default. - --- XyReasscan ? - -zie tables statline.cbs.nl voor bs asielverzoeken nl - - ----- Object tree: - -3 layers - -- Data Backend - - JPA or Hibernate - - Meta Query - - LDAP - # List via geparametered xql query - # Save - # Merge - # Delete - # Create ? - FilteringDataSource - PagingDataSource - FilteringPagingDataSource - Ordering - Parameter - -- Data Source Controller - - Data Access Controller - # User ACL on data items/columns - # Create new entry hooks - -- Table Controller - - User Settings - - -- Data Frontends - - Extjs - - Swing - - WS - - SWT via SwingWT - - JSF (met utr plugin) - - - -- default view field -- Admin fields and order -- Admin field groups -> 'collapse -- List filters auto by type -- search fields - -verbose_name_plural -The plural name for the object: -verbose_name_plural = "stories" -If this isn’t given, Django will use verbose_name + "s" - -List of Magic Field Names - - * created_at - * created_on - * updated_at - * updated_on - * lock_version - * type - * id - * #{table_name}_count - * position - * parent_id - * lft - * rgt - * quote_value (is used for quoting) - * template - - - -- plural -- ordering -- order_with_respect_to - -# admin -- date_hierarchy -- fields = ( - (None, { - 'fields': ('url', 'title', 'content', 'sites') - }), - ('Advanced options', { - 'classes': 'collapse', - 'fields' : ('enable_comments', 'registration_required', 'template_name') - 'description' : 'sdf' - }), - ) -- JS -- list_display_links -- list_filter = BooleanField, DateField, DateTimeField or ForeignKey. -- list_per_page -- ordering def -- save_as -- search_fields - -@Entity -@VascAdmin(list=true,edit=true,create=true,delete=false) -public class BlogPost { - - @VascPrimaryKey - @VascName(key="generic.id.name") - @VascDescription(key="generic.id.name") - @VascHelpId(key="generic.id.help") - @VascImage(key="generid.id.image"); - Integer id; - - @Column(columnName="title") - @VascDisplayName - @VascUserRoles(list="(floormanager&sitemanager)|admin" editViewOnly="floormanager" edit="sitemanager|admin") - String title; - - @VascEditorType(type="slugField") - String slug; - - @VascChoices() - @VascDefaultValue(key="") - String tags; - - @VascRegex(regex="<(.*)>" key="generic.regex.html.tagsNotAllowed") - String content; - - @VascEditorType(type="floatField" hints="max_digits=3,decimal_places=2") - @VascFieldOptions - @VascColumnWidth(width=130) - Float price; - - @VascModelReference - @VascDefaultValue - @VascObjectNotNull - BlogStatus blogStatus; - - @VascEditorType(type="dateField" hints="auto_now=true,auto_now_add=true") - @VascDefaultValue(key="new_date") - @VascUserRoles(list="admin") - Date createdDate - - @VascEventChannel(channel="BlogPost.modifiedDate" create=true) - Date modifiedDate - - @VascDateFuture - Date publicedDate -} - - - - - vasc - - admin=true - backend=extjs - path=/js/extjs/* - - - vasc - /vasc/* - - - -EmployeeDataSource dataSource = new EmployeeDataSource(); -dataSource.setJdbcTemplate(new JdbcTemplate(employeeDataSource())); - FilteringPaginator filteringPaginator = new FilteringPaginator(dataSource, EmployeeReportObject.class); - JsfCrudAdapter adapter = new JsfCrudAdapter(filteringPaginator, (CrudController)empCrud().getController()){ - public Serializable getEntity() { - Object object = ((Row)getModel().getRowData()).getObject(); - EmployeeReportObject employeeReportObject = (EmployeeReportObject) object; - Employee employee = new Employee(); - employee.setId(employeeReportObject.getId()); - return employee; - } - }; - - return adapter; - -EVt; - - - - - - - - - - - - - - - - - - - -@SuppressWarnings({ "unchecked", "serial" }) -@Bean(scope = DefaultScopes.SESSION) -public JsfCrudAdapter empRecordCrud() { - EmployeeDataSource dataSource = new EmployeeDataSource(); - dataSource.setJdbcTemplate(new JdbcTemplate(employeeDataSource())); - FilteringPaginator filteringPaginator = new FilteringPaginator(dataSource, EmployeeReportObject.class); - JsfCrudAdapter adapter = new JsfCrudAdapter(filteringPaginator, (CrudController)empCrud().getController()){ - public Serializable getEntity() { - Object object = ((Row)getModel().getRowData()).getObject(); - EmployeeReportObject employeeReportObject = (EmployeeReportObject) object; - Employee employee = new Employee(); - employee.setId(employeeReportObject.getId()); - return employee; - } - }; - - return adapter; -} - - - - - - - - - - - - - - - - - - - - diff --git a/src/site/apt/features.apt b/src/site/apt/features.apt index de064ef..dc9e8d1 100644 --- a/src/site/apt/features.apt +++ b/src/site/apt/features.apt @@ -3,4 +3,276 @@ VASC Features * Mulple Type of Frontend rendering supported * Different Type of Backend data is supported - \ No newline at end of file + +OLD README: + ++-- + + +eclipse 3.2 + +To build/run the swt stuff you need the Visual Editor plug in installed from the calisto site. + +eclipse 3.3 + +Down load http://www.ehecht.com/eclipse_ve/ve.html (lin_mac version) + +Unzip and move the plug ins and features into the plug in and features directory of eclipse. + +Swing will run by default. + +-- XyReasscan ? + +zie tables statline.cbs.nl voor bs asielverzoeken nl + + +---- Object tree: + +3 layers + +- Data Backend + - JPA or Hibernate + - Meta Query + - LDAP + # List via geparametered xql query + # Save + # Merge + # Delete + # Create ? + FilteringDataSource + PagingDataSource + FilteringPagingDataSource + Ordering + Parameter + +- Data Source Controller + - Data Access Controller + # User ACL on data items/columns + # Create new entry hooks + +- Table Controller + - User Settings + + +- Data Frontends + - Extjs + - Swing + - WS + - SWT via SwingWT + - JSF (met utr plugin) + + + +- default view field +- Admin fields and order +- Admin field groups -> 'collapse +- List filters auto by type +- search fields + +verbose_name_plural +The plural name for the object: +verbose_name_plural = "stories" +If this isn’t given, Django will use verbose_name + "s" + +List of Magic Field Names + + * created_at + * created_on + * updated_at + * updated_on + * lock_version + * type + * id + * #{table_name}_count + * position + * parent_id + * lft + * rgt + * quote_value (is used for quoting) + * template + + + +- plural +- ordering +- order_with_respect_to + +# admin +- date_hierarchy +- fields = ( + (None, { + 'fields': ('url', 'title', 'content', 'sites') + }), + ('Advanced options', { + 'classes': 'collapse', + 'fields' : ('enable_comments', 'registration_required', 'template_name') + 'description' : 'sdf' + }), + ) +- JS +- list_display_links +- list_filter = BooleanField, DateField, DateTimeField or ForeignKey. +- list_per_page +- ordering def +- save_as +- search_fields + +@Entity +@VascAdmin(list=true,edit=true,create=true,delete=false) +public class BlogPost { + + @VascPrimaryKey + @VascName(key="generic.id.name") + @VascDescription(key="generic.id.name") + @VascHelpId(key="generic.id.help") + @VascImage(key="generid.id.image"); + Integer id; + + @Column(columnName="title") + @VascDisplayName + @VascUserRoles(list="(floormanager&sitemanager)|admin" editViewOnly="floormanager" edit="sitemanager|admin") + String title; + + @VascEditorType(type="slugField") + String slug; + + @VascChoices() + @VascDefaultValue(key="") + String tags; + + @VascRegex(regex="<(.*)>" key="generic.regex.html.tagsNotAllowed") + String content; + + @VascEditorType(type="floatField" hints="max_digits=3,decimal_places=2") + @VascFieldOptions + @VascColumnWidth(width=130) + Float price; + + @VascModelReference + @VascDefaultValue + @VascObjectNotNull + BlogStatus blogStatus; + + @VascEditorType(type="dateField" hints="auto_now=true,auto_now_add=true") + @VascDefaultValue(key="new_date") + @VascUserRoles(list="admin") + Date createdDate + + @VascEventChannel(channel="BlogPost.modifiedDate" create=true) + Date modifiedDate + + @VascDateFuture + Date publicedDate +} + + + + + vasc + + admin=true + backend=extjs + path=/js/extjs/* + + + vasc + /vasc/* + + + +EmployeeDataSource dataSource = new EmployeeDataSource(); +dataSource.setJdbcTemplate(new JdbcTemplate(employeeDataSource())); + FilteringPaginator filteringPaginator = new FilteringPaginator(dataSource, EmployeeReportObject.class); + JsfCrudAdapter adapter = new JsfCrudAdapter(filteringPaginator, (CrudController)empCrud().getController()){ + public Serializable getEntity() { + Object object = ((Row)getModel().getRowData()).getObject(); + EmployeeReportObject employeeReportObject = (EmployeeReportObject) object; + Employee employee = new Employee(); + employee.setId(employeeReportObject.getId()); + return employee; + } + }; + + return adapter; + +EVt; + + + + + + + + + + + + + + + + + + + +@SuppressWarnings({ "unchecked", "serial" }) +@Bean(scope = DefaultScopes.SESSION) +public JsfCrudAdapter empRecordCrud() { + EmployeeDataSource dataSource = new EmployeeDataSource(); + dataSource.setJdbcTemplate(new JdbcTemplate(employeeDataSource())); + FilteringPaginator filteringPaginator = new FilteringPaginator(dataSource, EmployeeReportObject.class); + JsfCrudAdapter adapter = new JsfCrudAdapter(filteringPaginator, (CrudController)empCrud().getController()){ + public Serializable getEntity() { + Object object = ((Row)getModel().getRowData()).getObject(); + EmployeeReportObject employeeReportObject = (EmployeeReportObject) object; + Employee employee = new Employee(); + employee.setId(employeeReportObject.getId()); + return employee; + } + }; + + return adapter; +} + + + + + + + + + + + + + + + + + + + + + ++-- \ No newline at end of file diff --git a/doc/TODO.txt b/src/site/apt/todo.apt similarity index 97% rename from doc/TODO.txt rename to src/site/apt/todo.apt index 97cff65..b567db0 100644 --- a/doc/TODO.txt +++ b/src/site/apt/todo.apt @@ -1,3 +1,6 @@ +TODO LIST + ++-- - (30%) X4O client/server config @@ -28,3 +31,5 @@ === DONE === + ++-- diff --git a/vasc-backend-jpa/src/main/resources/.empty b/vasc-backend-jpa/src/main/resources/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-backend-jpa/src/test/java/.empty b/vasc-backend-jpa/src/test/java/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-backend-jpa/src/test/resources/.empty b/vasc-backend-jpa/src/test/resources/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-backend-ldap/src/main/resources/.empty b/vasc-backend-ldap/src/main/resources/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-backend-ldap/src/test/java/.empty b/vasc-backend-ldap/src/test/java/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-backend-ldap/src/test/resources/.empty b/vasc-backend-ldap/src/test/resources/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-core/src/main/java/com/idcanet/vasc/annotations/VascEventListener.java b/vasc-core/src/main/java/com/idcanet/vasc/annotations/VascEventListener.java index 9e99e6a..1d8646c 100644 --- a/vasc-core/src/main/java/com/idcanet/vasc/annotations/VascEventListener.java +++ b/vasc-core/src/main/java/com/idcanet/vasc/annotations/VascEventListener.java @@ -41,5 +41,6 @@ import java.lang.annotation.Target; @Target(ElementType.TYPE) public @interface VascEventListener { - Class[] listeners(); + String[] backendEventListeners(); + String[] frontendEventListeners(); } \ No newline at end of file diff --git a/vasc-core/src/main/java/com/idcanet/vasc/core/VascEntry.java b/vasc-core/src/main/java/com/idcanet/vasc/core/VascEntry.java index 70cff2d..d7e2b51 100644 --- a/vasc-core/src/main/java/com/idcanet/vasc/core/VascEntry.java +++ b/vasc-core/src/main/java/com/idcanet/vasc/core/VascEntry.java @@ -32,9 +32,7 @@ import java.util.List; 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.entry.VascEntryBackendEventListener; import com.idcanet.vasc.core.entry.VascEntryFieldEventChannel; -import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener; /** * The main vasc entry @@ -383,25 +381,25 @@ public interface VascEntry extends Cloneable,Serializable { * Added an VascEntryBackendEventListener * @param listener The class of the event listener. */ - public void addVascEntryBackendEventListener(Class listener); + public void addVascEntryBackendEventListener(String listener); /** * Returns the list of VascEntryBackendEventListener * @return */ - public List> getVascEntryBackendEventListeners(); + public List getVascEntryBackendEventListeners(); /** * Added an VascEntryFrontendEventListener * @param listener The class of the event listener. */ - public void addVascEntryFrontendEventListener(Class listener); + public void addVascEntryFrontendEventListener(String listener); /** * Returns the list of VascEntryFrontendEventListener * @return */ - public List> getVascEntryFrontendEventListeners(); + public List getVascEntryFrontendEventListeners(); public void addListOption(VascEntryField listOption); diff --git a/vasc-core/src/main/java/com/idcanet/vasc/core/entry/VascEntryBackendEventListener.java b/vasc-core/src/main/java/com/idcanet/vasc/core/entry/VascEntryBackendEventListener.java index e4fa447..668346f 100644 --- a/vasc-core/src/main/java/com/idcanet/vasc/core/entry/VascEntryBackendEventListener.java +++ b/vasc-core/src/main/java/com/idcanet/vasc/core/entry/VascEntryBackendEventListener.java @@ -39,18 +39,28 @@ import com.idcanet.vasc.core.VascEntry; public interface VascEntryBackendEventListener extends Serializable { public enum VascBackendEventType { - EXECUTE, - PERSIST, - MERGE, - DELETE, - PROVIDE_FIELD_VALUE, - PROVIDE_RECORD_CREATOR, - TOTAL_EXECUTE_SIZE, - MOVE_DOWN, - MOVE_UP + PRE_EXECUTE, + PRE_PERSIST, + PRE_MERGE, + PRE_DELETE, + PRE_PROVIDE_FIELD_VALUE, + PRE_PROVIDE_RECORD_CREATOR, + PRE_TOTAL_EXECUTE_SIZE, + PRE_MOVE_DOWN, + PRE_MOVE_UP, + + POST_EXECUTE, + POST_PERSIST, + POST_MERGE, + POST_DELETE, + POST_PROVIDE_FIELD_VALUE, + POST_PROVIDE_RECORD_CREATOR, + POST_TOTAL_EXECUTE_SIZE, + POST_MOVE_DOWN, + POST_MOVE_UP } - public VascBackendEventType getEventType(); + public VascBackendEventType[] getEventType(); /** * Is executed when the type of event is fired. diff --git a/vasc-core/src/main/java/com/idcanet/vasc/core/entry/VascEntryFrontendEventListener.java b/vasc-core/src/main/java/com/idcanet/vasc/core/entry/VascEntryFrontendEventListener.java index 63351ce..b8ba926 100644 --- a/vasc-core/src/main/java/com/idcanet/vasc/core/entry/VascEntryFrontendEventListener.java +++ b/vasc-core/src/main/java/com/idcanet/vasc/core/entry/VascEntryFrontendEventListener.java @@ -41,17 +41,19 @@ public interface VascEntryFrontendEventListener extends Serializable { public enum VascFrontendEventType { EXCEPTION, - DATA_CREATE, - DATA_READ, - DATA_SELECT, - DATA_PRE_UPDATE, - DATA_POST_UPDATE, - DATA_DELETE, - DATA_LIST_UPDATE, + PRE_CREATE, + POST_CREATE, + PRE_READ, + POST_READ, + PRE_UPDATE, + POST_UPDATE, + PRE_DELETE, + POST_DELETE, - DATA_SORT, - DATA_PAGE, - DATA_SEARCH, + SELECT, + SORT, + PAGE, + SEARCH, OPTION_UPDATE, } diff --git a/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascEntry.java b/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascEntry.java index c8f9ddb..d1566a5 100644 --- a/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascEntry.java +++ b/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascEntry.java @@ -87,8 +87,8 @@ public class DefaultVascEntry implements VascEntry { private List vascLinkEntries = null; private Map entryParameters = null; private VascEntryFieldEventChannel vascEntryFieldEventChannel = null; - private List> eventEntryFrontendEventListeners = null; - private List> eventEntryBackendEventListeners = null; + private List eventEntryFrontendEventListeners = null; + private List eventEntryBackendEventListeners = null; private List listOptions = null; private List backendFilters = null; @@ -109,8 +109,8 @@ public class DefaultVascEntry implements VascEntry { vascLinkEntries = new ArrayList(10); entryParameters = new HashMap(10); - eventEntryFrontendEventListeners = new ArrayList>(10); - eventEntryBackendEventListeners = new ArrayList>(10); + eventEntryFrontendEventListeners = new ArrayList(10); + eventEntryBackendEventListeners = new ArrayList(10); listOptions = new ArrayList(5); backendFilters = new ArrayList(3); } @@ -720,7 +720,7 @@ public class DefaultVascEntry implements VascEntry { * Added an VascEntryBackendEventListener * @param listener The class of the event listener. */ - public void addVascEntryBackendEventListener(Class listener) { + public void addVascEntryBackendEventListener(String listener) { eventEntryBackendEventListeners.add(listener); } @@ -728,7 +728,7 @@ public class DefaultVascEntry implements VascEntry { * Returns the list of VascEntryBackendEventListener * @return */ - public List> getVascEntryBackendEventListeners() { + public List getVascEntryBackendEventListeners() { return eventEntryBackendEventListeners; } @@ -736,7 +736,7 @@ public class DefaultVascEntry implements VascEntry { * Added an VascEntryFrontendEventListener * @param listener The class of the event listener. */ - public void addVascEntryFrontendEventListener(Class listener) { + public void addVascEntryFrontendEventListener(String listener) { eventEntryFrontendEventListeners.add(listener); } @@ -744,7 +744,7 @@ public class DefaultVascEntry implements VascEntry { * Returns the list of VascEntryFrontendEventListener * @return */ - public List> getVascEntryFrontendEventListeners() { + public List getVascEntryFrontendEventListeners() { return eventEntryFrontendEventListeners; } diff --git a/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFactory.java b/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFactory.java index f92d266..fb4af8f 100644 --- a/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFactory.java +++ b/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFactory.java @@ -35,6 +35,7 @@ import com.idcanet.vasc.core.VascController; import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.VascException; import com.idcanet.vasc.core.VascFrontendData; +import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener; import com.idcanet.vasc.impl.entry.DefaultVascEntryResourceResolver; import com.idcanet.vasc.impl.entry.VascValidatorsValidatorService; import com.idcanet.vasc.impl.type.DefaultVascEntryFieldTypeController; @@ -86,8 +87,13 @@ public class DefaultVascFactory { return vascFrontendData; } + /** + * Gets a backend of the backend controller and addes all the proxy classes. + * @param entry + * @return + */ static public VascBackend getProxyVascBackend(VascEntry entry) { - // Get the real backend + // Get the 'real' backend VascBackend backend = entry.getVascFrontendData().getVascController().getVascBackendController().getVascBackendById(entry.getBackendId()); // logs all actions log logger @@ -109,6 +115,11 @@ public class DefaultVascFactory { if (backend.isPageable()==false) { backend = new VascBackendProxyPaged(backend,entry); } + + // execute backend event listeners + backend = new VascBackendProxyEventExecutor(backend,entry); + + // return the configed backend. return backend; } } \ No newline at end of file diff --git a/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFrontendData.java b/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFrontendData.java index a0d6be7..ca30fd8 100644 --- a/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFrontendData.java +++ b/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFrontendData.java @@ -248,8 +248,17 @@ public class DefaultVascFrontendData implements VascFrontendData { public void initFrontendListeners(VascEntry entry) throws InstantiationException, IllegalAccessException { - for (Class clazz:entry.getVascEntryFrontendEventListeners()) { - VascEntryFrontendEventListener listener = clazz.newInstance(); + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl==null) { + cl = entry.getClass().getClassLoader(); + } + for (String clazz:entry.getVascEntryFrontendEventListeners()) { + VascEntryFrontendEventListener listener; + try { + listener = (VascEntryFrontendEventListener)cl.loadClass(clazz).newInstance(); + } catch (ClassNotFoundException e) { + throw new RuntimeException("Could not load VascEntryFrontendEventListener of: "+clazz); + } addVascEntryFrontendEventListener(listener); } } diff --git a/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFrontendHelper.java b/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFrontendHelper.java index 2466d1d..f0aee14 100644 --- a/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFrontendHelper.java +++ b/vasc-core/src/main/java/com/idcanet/vasc/impl/DefaultVascFrontendHelper.java @@ -230,6 +230,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper { */ public Object createObject(VascEntry entry) { try { + fireVascEvent(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."); @@ -252,7 +253,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper { logger.finer("Setting default value for: "+field.getName()+" def: "+defaultValue); field.getVascEntryFieldValue().setValue(field, object, defaultValue); } - fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_CREATE, object); + fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_CREATE, object); return object; } catch (Exception e) { handleException(entry,e); @@ -301,7 +302,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper { Object object = entry.getVascFrontendData().getVascEntryState().getEntryDataObject(); Object result = null; try { - fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_PRE_UPDATE,object); + fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_UPDATE,object); int index = removeObjectFromDataList(entry,object); // merge object on backend @@ -315,8 +316,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper { // put object back in list entry.getVascFrontendData().getVascEntryState().getEntryDataList().add(index, result); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null); - fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_POST_UPDATE,result); - fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_LIST_UPDATE,result); + fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_UPDATE,result); } catch (Exception e) { handleException(entry,e); } @@ -330,6 +330,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper { */ public void deleteObject(VascEntry entry) { Object object = entry.getVascFrontendData().getVascEntryState().getEntryDataObject(); + fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_DELETE, object); try { entry.getVascFrontendData().getVascEntryState().getVascBackend().delete(object); } catch (Exception e) { @@ -337,14 +338,14 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper { } removeObjectFromDataList(entry,object); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null); - fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_DELETE, object); - fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_LIST_UPDATE, object); + fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_DELETE, object); } /** * @see com.idcanet.vasc.core.VascFrontendHelper#refreshData(com.idcanet.vasc.core.VascEntry) */ public void refreshData(VascEntry entry) { + fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_READ, null); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null); try { // check and correct max page size @@ -364,8 +365,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper { } catch (Exception e) { handleException(entry, e); } - fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_READ, null); - fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_LIST_UPDATE, null); + fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, null); } public void headerOptionsCreatedFillData(VascEntry entry) { @@ -474,7 +474,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper { String sortID = field.getBackendName(); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortField(sortID); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(0); - fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_SORT, field); + fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.SORT, field); refreshData(entry); } @@ -483,7 +483,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper { entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSearchString(searchString); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setSortField(null); entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(0); - fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_SEARCH, searchString); + fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.SEARCH, searchString); refreshData(entry); } @@ -498,7 +498,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper { } entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageIndex(pageIndex); - fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.DATA_PAGE, pageIndex); + fireVascEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PAGE, pageIndex); // lets load data; refreshData(entry); diff --git a/vasc-core/src/main/java/com/idcanet/vasc/impl/VascBackendProxyEventExecutor.java b/vasc-core/src/main/java/com/idcanet/vasc/impl/VascBackendProxyEventExecutor.java new file mode 100644 index 0000000..9d68bee --- /dev/null +++ b/vasc-core/src/main/java/com/idcanet/vasc/impl/VascBackendProxyEventExecutor.java @@ -0,0 +1,152 @@ +/* + * Copyright 2004-2010 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.VascBackendState; +import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.core.VascException; +import com.idcanet.vasc.core.entry.VascEntryBackendEventListener; +import com.idcanet.vasc.core.entry.VascEntryBackendEventListener.VascBackendEventType; + + +/** +* Holds !! and fires the backend event listeners. +* +* @author Willem Cazander +* @version 1.0 Sep 21, 2010 +*/ +public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { + + private List listeners = null; + private VascEntry entry = null; + + public VascBackendProxyEventExecutor(VascBackend backend,VascEntry entry) { + super(backend); + this.entry=entry; + this.listeners=new ArrayList(10); + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl==null) { + cl = entry.getClass().getClassLoader(); + } + for (String clazz:entry.getVascEntryBackendEventListeners()) { + VascEntryBackendEventListener listener; + try { + listener = (VascEntryBackendEventListener)cl.loadClass(clazz).newInstance(); + } catch (Exception e) { + throw new RuntimeException("Could not load VascEntryBackendEventListener of: "+clazz); + } + listeners.add(listener); + } + } + + private void fireVascEvent(VascBackendEventType type, Object data) { + for (int i=0;i execute(VascBackendState state) throws VascException { + fireVascEvent(VascBackendEventType.PRE_EXECUTE,state); + List result = super.execute(state); + fireVascEvent(VascBackendEventType.POST_EXECUTE,result); + return result; + } + + /** + * @see com.idcanet.vasc.core.AbstractVascBackendProxy#fetchTotalExecuteSize(com.idcanet.vasc.core.VascBackendState) + */ + @Override + public long fetchTotalExecuteSize(VascBackendState state) { + fireVascEvent(VascBackendEventType.PRE_TOTAL_EXECUTE_SIZE,state); + Long result = super.fetchTotalExecuteSize(state); + fireVascEvent(VascBackendEventType.POST_TOTAL_EXECUTE_SIZE,result); + return result; + } + + /** + * @see com.idcanet.vasc.core.AbstractVascBackendProxy#merge(java.lang.Object) + */ + @Override + public Object merge(Object object) throws VascException { + fireVascEvent(VascBackendEventType.PRE_MERGE,object); + Object result = super.merge(object); + fireVascEvent(VascBackendEventType.POST_MERGE,result); + return result; + } + + /** + * @see com.idcanet.vasc.core.AbstractVascBackendProxy#persist(java.lang.Object) + */ + @Override + public void persist(Object object) throws VascException { + fireVascEvent(VascBackendEventType.PRE_PERSIST,object); + super.persist(object); + fireVascEvent(VascBackendEventType.POST_PERSIST,object); + } +} \ No newline at end of file diff --git a/vasc-core/src/main/java/com/idcanet/vasc/impl/actions/EditRowAction.java b/vasc-core/src/main/java/com/idcanet/vasc/impl/actions/EditRowAction.java index 27549f6..4aae191 100644 --- a/vasc-core/src/main/java/com/idcanet/vasc/impl/actions/EditRowAction.java +++ b/vasc-core/src/main/java/com/idcanet/vasc/impl/actions/EditRowAction.java @@ -51,7 +51,7 @@ public class EditRowAction extends AbstractVascAction implements RowVascAction { return; // nothing selected } entry.getVascFrontendData().getVascEntryState().setEditCreate(false); - entry.getVascFrontendData().getVascFrontendHelper().fireVascEvent(entry, VascFrontendEventType.DATA_SELECT, rowObject); + entry.getVascFrontendData().getVascFrontendHelper().fireVascEvent(entry, VascFrontendEventType.SELECT, rowObject); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject); entry.getVascFrontendData().getVascFrontend().renderEdit(); } diff --git a/vasc-core/src/main/java/com/idcanet/vasc/impl/x4o/AnnotationParserElement.java b/vasc-core/src/main/java/com/idcanet/vasc/impl/x4o/AnnotationParserElement.java index 07cb203..94ef6a2 100644 --- a/vasc-core/src/main/java/com/idcanet/vasc/impl/x4o/AnnotationParserElement.java +++ b/vasc-core/src/main/java/com/idcanet/vasc/impl/x4o/AnnotationParserElement.java @@ -45,8 +45,6 @@ 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.core.entry.VascEntryBackendEventListener; -import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener; import com.idcanet.vasc.impl.DefaultVascEntryField; import com.idcanet.vasc.validators.VascValidator; import com.idcanet.vasc.validators.VascValidatorClassParser; @@ -104,7 +102,6 @@ public class AnnotationParserElement extends AbstractElement { } } - @SuppressWarnings("unchecked") private void fillEntry(VascEntry entry,Class modelClass,VascAnnotationParser parser) throws ElementException { @@ -114,15 +111,11 @@ public class AnnotationParserElement extends AbstractElement { VascEventListener vc = parser.getVascEventListener(modelClass); if (vc!=null) { - int i = 0; - for (Class listener:vc.listeners()) { - if (listener.isAssignableFrom(VascEntryFrontendEventListener.class)) { - entry.addVascEntryFrontendEventListener((Class)listener); - } - if (listener.isAssignableFrom(VascEntryBackendEventListener.class)) { - entry.addVascEntryBackendEventListener((Class)listener); - } - i++; + for (String listener:vc.frontendEventListeners()) { + entry.addVascEntryFrontendEventListener(listener); + } + for (String listener:vc.backendEventListeners()) { + entry.addVascEntryBackendEventListener(listener); } } diff --git a/vasc-core/src/test/resources/.empty b/vasc-core/src/test/resources/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-ejb3/src/main/resources/.empty b/vasc-ejb3/src/main/resources/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-ejb3/src/test/java/.empty b/vasc-ejb3/src/test/java/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-ejb3/src/test/resources/.empty b/vasc-ejb3/src/test/resources/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-frontend-swing/src/main/java/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java b/vasc-frontend-swing/src/main/java/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java index c414091..e98bc5b 100644 --- a/vasc-frontend-swing/src/main/java/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java +++ b/vasc-frontend-swing/src/main/java/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java @@ -653,7 +653,7 @@ public class SwingVascFrontend extends AbstractVascFrontend { } public VascFrontendEventType[] getEventTypes() { - VascFrontendEventType[] result = {VascFrontendEventType.DATA_LIST_UPDATE}; + VascFrontendEventType[] result = {VascFrontendEventType.POST_UPDATE}; return result; } } diff --git a/vasc-frontend-swing/src/main/resources/.empty b/vasc-frontend-swing/src/main/resources/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-frontend-swing/src/test/resources/.empty b/vasc-frontend-swing/src/test/resources/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-frontend-swt/src/main/java/com/idcanet/vasc/frontends/swt/SwtVascFrontend.java b/vasc-frontend-swt/src/main/java/com/idcanet/vasc/frontends/swt/SwtVascFrontend.java index f441d68..8ff9b26 100644 --- a/vasc-frontend-swt/src/main/java/com/idcanet/vasc/frontends/swt/SwtVascFrontend.java +++ b/vasc-frontend-swt/src/main/java/com/idcanet/vasc/frontends/swt/SwtVascFrontend.java @@ -442,7 +442,7 @@ public class SwtVascFrontend extends AbstractVascFrontend { entry.getVascFrontendData().addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() { public VascFrontendEventType[] getEventTypes() { - VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.DATA_LIST_UPDATE}; + VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.POST_READ}; return result; } public void vascEvent(VascEntry entry,Object data) { diff --git a/vasc-frontend-swt/src/main/resources/.empty b/vasc-frontend-swt/src/main/resources/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-frontend-swt/src/test/resources/.empty b/vasc-frontend-swt/src/test/resources/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-frontend-web-jsf/pom.xml b/vasc-frontend-web-jsf/pom.xml index a1c3e0c..b8769b2 100644 --- a/vasc-frontend-web-jsf/pom.xml +++ b/vasc-frontend-web-jsf/pom.xml @@ -13,6 +13,12 @@ com.idcanet.vasc vasc-core ${project.version} + + + com.idcanet.vasc + vasc-ejb3 + ${project.version} + provided javax.faces diff --git a/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/AbstractJSFVascFacesController.java b/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/AbstractJSFVascFacesController.java new file mode 100644 index 0000000..0529757 --- /dev/null +++ b/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/AbstractJSFVascFacesController.java @@ -0,0 +1,405 @@ +/* + * 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.frontends.web.jsf; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.faces.context.FacesContext; +import javax.naming.Context; +import javax.naming.InitialContext; + +import com.idcanet.vasc.core.VascBackend; +import com.idcanet.vasc.core.VascBackendControllerLocal; +import com.idcanet.vasc.core.VascBackendState; +import com.idcanet.vasc.core.VascController; +import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.core.VascEntryControllerLocal; +import com.idcanet.vasc.core.VascEntryField; +import com.idcanet.vasc.core.VascException; +import com.idcanet.vasc.core.VascFrontendData; +import com.idcanet.vasc.core.entry.VascEntryFieldValue; +import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener; +import com.idcanet.vasc.core.entry.VascEntryRecordCreator; +import com.idcanet.vasc.ejb3.VascServiceManager; +import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer; +import com.idcanet.vasc.impl.DefaultVascFactory; +import com.idcanet.vasc.impl.entry.DefaultVascEntryResourceResolver; + +/** + * Base faces session object for managing vasc entries. + * + * @author Willem Cazander + * @version 1.0 Sep 21, 2010 + */ +abstract public class AbstractJSFVascFacesController { + + private VascController vascController = null; + + abstract public String getVascSericeManagerJNDI(); + abstract public String getResourceBundleWEB(); + abstract public boolean getDisableI18N(); + abstract public VascUserInfo getVascUserInfo(); + + public class VascUserInfo { + Long userId; + String username; + String[] roles; + public VascUserInfo(Long userId,String username,String[] roles) { + this.userId=userId; + this.username=username; + this.roles=roles; + } + } + + /* + class RefreshObjectForLazyPropertiesListener implements VascEntryFrontendEventListener { + public VascFrontendEventType[] getEventTypes() { + VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.POST_UPDATE}; + return result; + } + public void vascEvent(VascEntry entry,Object data) { + if (data.getClass().getName().startsWith("com.idcanet.logstats.ejb.models")==false) { + return; // only refresh model classes + } + + // TODO: mmm rewrite events to change to different object to use ejb3++ solution ? + // Use hiberbate session to attach a detected object again. (note: this is not possible with EJB3, uses merge() which returns a new object) + //((Session)entityManager.getDelegate()).refresh(data); + } + } + */ + + class MergedResourceBundle extends ResourceBundle { + Map data = new HashMap(500); + + public void addDateMap(Map dataMap) { + data.putAll(dataMap); + } + public void addDataBundle(ResourceBundle bundle) { + for (String key:bundle.keySet()) { + String value = bundle.getString(key); + data.put(key, value); + } + } + public Object handleGetObject(String key) { + return data.get(key); + } + + public Enumeration getKeys() { + return Collections.enumeration(data.keySet()); + } + } + + /** + * Config vasc frontend data object for jsf component to use. + * + * @return + */ + public VascFrontendData getNewVascFrontendData() { + Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); + MergedResourceBundle bundle = new MergedResourceBundle(); + bundle.addDataBundle(ResourceBundle.getBundle(getResourceBundleWEB(), locale)); + + try { + Context context = new InitialContext(); + VascServiceManager vascManager = (VascServiceManager)context.lookup(getVascSericeManagerJNDI()); + Map remoteI18n = vascManager.getResourceBundle(locale.toString()); + bundle.addDateMap(remoteI18n); + } catch (Exception e) { + throw new RuntimeException("Could not get the ejb resource bundle: "+e.getMessage(),e); + } + + VascFrontendData vascFrontendData = DefaultVascFactory.getDefaultVascFrontendData(bundle); + vascFrontendData.addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() { + private static final long serialVersionUID = 1L; + public VascFrontendEventType[] getEventTypes() { + VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.EXCEPTION}; + return result; + } + public void vascEvent(VascEntry entry, Object data) { + if (data instanceof Exception) { + ((Exception)data).printStackTrace(); + } + } + }); + + // config frontend data for ISF usage + if (getDisableI18N()) { + vascFrontendData.setVascEntryResourceResolver(new DefaultVascEntryResourceResolver()); + } else { + vascFrontendData.setVascEntryResourceResolver(new DefaultVascEntryResourceResolver(bundle)); + } + return vascFrontendData; + } + + /** + * + */ + public List executeVascList(String entryId,Map para) { + try { + // plug all object + VascEntry entry = getVascController().getVascEntryController().getVascEntryById(entryId); + entry.setVascFrontendData(getNewVascFrontendData()); + entry.getVascFrontendData().setVascController(getVascController()); + + // copy para + if (para!=null) { + for (String key:para.keySet()) { + entry.setEntryParameter(key, para.get(key)); + } + } + + // done, execute and return data. + entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry); + return entry.getVascFrontendData().getVascEntryState().getEntryDataList(); + } catch (Exception e) { + e.printStackTrace(); + return new ArrayList(0); + } + } + + class RemoteVascBackend implements VascBackend { + + private String backendId = null; + private VascServiceManager vascManager = null; + + public RemoteVascBackend(String backendId,VascServiceManager vascManager) { + this.backendId=backendId; + this.vascManager=vascManager; + } + + public void delete(Object object) throws VascException { + Object[] args = new Object[1]; + args[0]=object; + vascManager.invokeBackendMethod(backendId, "delete", args); + } + + public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascException { + Object[] args = new Object[2]; + args[0]=state; + args[1]=primaryId; + Object result = vascManager.invokeBackendMethod(backendId, "doRecordMoveDownById", args); + return (Long)result; + } + + public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascException { + Object[] args = new Object[2]; + args[0]=state; + args[1]=primaryId; + Object result = vascManager.invokeBackendMethod(backendId, "doRecordMoveUpById", args); + return (Long)result; + } + + @SuppressWarnings("unchecked") + public List execute(VascBackendState state) throws VascException { + Object[] args = new Object[1]; + args[0]=state; + Object result = vascManager.invokeBackendMethod(backendId, "execute", args); + return (List)result; + } + + public long fetchTotalExecuteSize(VascBackendState state) { + Object[] args = new Object[1]; + args[0]=state; + Object result = vascManager.invokeBackendMethod(backendId, "fetchTotalExecuteSize", args); + return (Long)result; + } + + public String getId() { + return backendId; + } + + public boolean isPageable() { + Object[] args = new Object[0]; + Object result = vascManager.invokeBackendMethod(backendId, "isPageable", args); + return (Boolean)result; + } + + public boolean isRecordMoveable() { + Object[] args = new Object[0]; + Object result = vascManager.invokeBackendMethod(backendId, "isRecordMoveable", args); + return (Boolean)result; + } + + public boolean isSearchable() { + Object[] args = new Object[0]; + Object result = vascManager.invokeBackendMethod(backendId, "isSearchable", args); + return (Boolean)result; + } + + public boolean isSortable() { + Object[] args = new Object[0]; + Object result = vascManager.invokeBackendMethod(backendId, "isSortable", args); + return (Boolean)result; + } + + public Object merge(Object object) throws VascException { + Object[] args = new Object[1]; + args[0]=object; + Object result = vascManager.invokeBackendMethod(backendId, "merge", args); + return result; + } + + public void persist(Object object) throws VascException { + Object[] args = new Object[1]; + args[0]=object; + vascManager.invokeBackendMethod(backendId, "delete", args); + } + + public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) { + /* + try { + ByteArrayOutputStream dataArray = new ByteArrayOutputStream(256); // it grows when needed + ObjectOutputStream objOutstream = new ObjectOutputStream(dataArray); + objOutstream.writeObject(field); + objOutstream.close(); + int objectSize = dataArray.size(); + System.out.println("Writing obj to field: "+objectSize); + } catch (IOException e) { + throw new RuntimeException(e); + } + */ + Object[] args = new Object[1]; + args[0]=field; + Object result = vascManager.invokeBackendMethod(backendId, "provideVascEntryFieldValue", args); + return (VascEntryFieldValue)result; + } + + public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) { + VascEntry clone = null; + try { + clone = vascEntry.clone(); + clone.setVascFrontendData(null); + clone.setVascEntryFieldEventChannel(null); + } catch (CloneNotSupportedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try { + ByteArrayOutputStream dataArray = new ByteArrayOutputStream(256); // it grows when needed + ObjectOutputStream objOutstream = new ObjectOutputStream(dataArray); + objOutstream.writeObject(clone); + objOutstream.close(); + //int objectSize = dataArray.size(); + //System.out.println("Writing obj to entry: "+objectSize); + } catch (IOException e) { + throw new RuntimeException(e); + } + Object[] args = new Object[1]; + args[0]=clone; + Object result = vascManager.invokeBackendMethod(backendId, "provideVascEntryRecordCreator", args); + return (VascEntryRecordCreator)result; + } + + public void setId(String id) { + // we cant change id + } + + public Map executePageSummary() { + return null; + } + + public Map executeTotalSummary() { + return null; + } + + public boolean isPageSummary() { + Object[] args = new Object[0]; + Object result = vascManager.invokeBackendMethod(backendId, "isPageSummary", args); + return (Boolean)result; + } + + public boolean isTotalSummary() { + Object[] args = new Object[0]; + Object result = vascManager.invokeBackendMethod(backendId, "isTotalSummary", args); + return (Boolean)result; + } + } + + /** + * @return the vascController + */ + public VascController getVascController() { + if (vascController!=null) { + return vascController; + } + try { + VascUserInfo vui = getVascUserInfo(); + + + // get local jvm plugging controller + VascController c = DefaultVascFactory.getDefaultVascController(vui.userId, vui.username, vui.roles); + + /* + DefaultVascEntryController con = new DefaultVascEntryController() { + public VascEntry getVascEntryById(String id) { + VascEntry ve = super.getVascEntryById(id); + // add global listener to make sure we have all LAZY properties of a bean before we goto edit mode. + ve.addVascEntryEventListener(VascEventType.DATA_SELECT, new RefreshObjectForLazyPropertiesListener()); + return ve; + } + }; + ((DefaultVascController)c).setVascEntryController(con); + */ + + Context context = new InitialContext(); + VascServiceManager vascManager = (VascServiceManager)context.lookup(getVascSericeManagerJNDI()); + List entryIds = vascManager.getVascEntryIds(); + + VascEntryControllerLocal localEntryController = (VascEntryControllerLocal)c.getVascEntryController(); + VascBackendControllerLocal localBackendController = (VascBackendControllerLocal)c.getVascBackendController(); + for (String id:entryIds) { + VascEntry ve = vascManager.getVascEntry(id); + String backendId = ve.getBackendId(); + VascBackend vb = new RemoteVascBackend(backendId,vascManager); + localBackendController.addVascBackend(vb); + + DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer(); + ve = f.finalizeVascEntry(ve,c); + + localEntryController.addVascEntry(ve, c); + } + vascController = c; + return vascController; + } catch (Exception e) { + throw new RuntimeException("Could not create remote based vasc controller; "+e.getMessage(),e); + } + } + + public void setVascController(VascController vascController) { + } +} diff --git a/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/JSFVascEntryEventListener.java b/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/JSFVascEntryEventListener.java index ad3045b..9b89f0d 100644 --- a/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/JSFVascEntryEventListener.java +++ b/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/JSFVascEntryEventListener.java @@ -31,7 +31,7 @@ public class JSFVascEntryEventListener implements VascEntryFrontendEventListener * @see com.idcanet.vasc.core.entry.VascEntryFrontendEventListener#getEventTypes() */ public VascFrontendEventType[] getEventTypes() { - VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.DATA_LIST_UPDATE}; + VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.POST_READ}; return result; } diff --git a/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/JSFVascUIComponent.java b/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/JSFVascUIComponent.java index 8493750..7a7107b 100644 --- a/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/JSFVascUIComponent.java +++ b/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/JSFVascUIComponent.java @@ -239,7 +239,7 @@ public class JSFVascUIComponent extends UIComponentBase { try { VascEntry entry = supportBean.getVascEntry(); entry.getVascFrontendData().getVascEntryState().setEditCreate(false); - entry.getVascFrontendData().getVascFrontendHelper().fireVascEvent(entry, VascFrontendEventType.DATA_SELECT, rowObject); + entry.getVascFrontendData().getVascFrontendHelper().fireVascEvent(entry, VascFrontendEventType.SELECT, rowObject); entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject); entry.getVascFrontendData().getVascFrontend().renderEdit(); } catch (Exception e) { @@ -408,7 +408,7 @@ public class JSFVascUIComponent extends UIComponentBase { this.value=value; } public VascFrontendEventType[] getEventTypes() { - VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.DATA_CREATE}; + VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.PRE_CREATE}; return result; } public void vascEvent(VascEntry entry,Object data) { diff --git a/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/OldVascUIComponent.java b/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/OldVascUIComponent.java index 10a3355..8dcbfe9 100644 --- a/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/OldVascUIComponent.java +++ b/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/OldVascUIComponent.java @@ -239,7 +239,7 @@ public class OldVascUIComponent extends UIComponentBase { entry.getVascFrontendData().addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() { private static final long serialVersionUID = 1L; public VascFrontendEventType[] getEventTypes() { - VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.DATA_LIST_UPDATE}; + VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.POST_READ}; return result; } public void vascEvent(VascEntry entry, Object dataNotUsed) { @@ -496,7 +496,7 @@ public class OldVascUIComponent extends UIComponentBase { this.value=value; } public VascFrontendEventType[] getEventTypes() { - VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.DATA_CREATE}; + VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.PRE_CREATE}; return result; } public void vascEvent(VascEntry entry,Object data) { diff --git a/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/VascRequestFacesFilter.java b/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/VascRequestFacesFilter.java index 62d55e7..bb6ab95 100644 --- a/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/VascRequestFacesFilter.java +++ b/vasc-frontend-web-jsf/src/main/java/com/idcanet/vasc/frontends/web/jsf/VascRequestFacesFilter.java @@ -162,11 +162,17 @@ public class VascRequestFacesFilter implements Filter { // Set page title Locale locale = facesContext.getViewRoot().getLocale(); if (locale==null) { - locale = Locale.getDefault(); + logger.info("Failling back to defualt."); + locale = new Locale("nl"); + } + try { + ResourceBundle i18n = ResourceBundle.getBundle(resourceBundle,locale); + String titleI18n = i18n.getString("vasc.entry."+entityName+".name"); + request.setAttribute("requestScopeVascEntityNameI18n" ,titleI18n); + } catch (Exception e) { + e.printStackTrace(); + request.setAttribute("requestScopeVascEntityNameI18n" ,entityName); } - ResourceBundle i18n = ResourceBundle.getBundle(resourceBundle,locale); - String titleI18n = i18n.getString("vasc.entry."+entityName+".name"); - request.setAttribute("requestScopeVascEntityNameI18n" ,titleI18n); try { request.getRequestDispatcher(templateFile).forward(request, response); diff --git a/vasc-frontend-web-jsf/src/test/java/.empty b/vasc-frontend-web-jsf/src/test/java/.empty new file mode 100644 index 0000000..e69de29 diff --git a/vasc-frontend-web-jsf/src/test/resources/.empty b/vasc-frontend-web-jsf/src/test/resources/.empty new file mode 100644 index 0000000..e69de29