From b3635cf64d6245ae74e29a305fe72b99999ef513 Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Fri, 11 Jan 2013 23:48:36 +0100 Subject: [PATCH] Switch to new meta model,fixed small bugs and made demo work pretty oke. --- pom.xml | 18 +- todo.txt | 13 - .../jpa/XpqlHibernateVascBackend.java | 2 +- .../jpa/XpqlPersistanceVascBackend.java | 2 +- .../META-INF/vasc/vasc-backend-jpa.eld | 2 +- .../vasc/backend/ldap/LdapVascBackend.java | 63 ++-- .../MetaModelDataContextMongodb.java | 10 +- .../metamodel/MetaModelSchemaAutoEntry.java | 166 ++++++--- .../metamodel/MetaModelVascBackend.java | 30 +- .../MongoDbDataContextSchemaDetector.java | 11 +- .../crud/AbstractCrudDataContext.java | 185 ++++------ .../metamodel/crud/AbstractUpdateableRow.java | 8 +- .../metamodel/crud/CrudDataContextImpl.java | 11 +- .../metamodel/crud/UpdateableRowMapImpl.java | 8 + .../jndi/JndiReadOnlyDataContext.java | 9 + .../loader/JndiMongodbDataContextLoader.java | 26 +- .../frontend/VascFrontendDataSelector.java | 20 +- .../frontend/DefaultVascFrontendActions.java | 25 +- .../DefaultVascFrontendDataSelector.java | 64 ++-- .../resources/META-INF/vasc/vasc-lang.eld | 6 +- .../main/directory/conf/vasc.d/tech-admin.xml | 15 +- .../demo/server/ui/ServerGuiApplication.java | 45 ++- .../vasc/demo/server/ui/load/JLoadDialog.java | 61 ++-- .../server/ui/load/JLoadStepWriteFile.java | 2 +- .../server/ui/load/LoadVascXmlWriter.java | 13 + .../server/ui/resources/laf-colors.properties | 26 +- .../client/swing/VascDemoSwingClient.java | 110 ++++-- .../client/swing/VascDemoUserLoginDialog.java | 58 +-- .../resources/VascDemoSwingClient.properties | 3 +- .../vasc/demo/client/swing/resources/icon.png | Bin 0 -> 264 bytes .../swing/resources/laf-colors.properties | 18 + .../vasc/demo/client/swing/resources/logo.png | Bin 0 -> 12691 bytes .../demo/tech/web/beans/I18nController.java | 106 ++++++ .../src/main/webapp/WEB-INF/faces-config.xml | 9 + .../jr4o/JRDynamicDataSourceVascEntry.java | 12 +- .../web/jsf/JSFVascEntryEventListener.java | 6 +- .../web/jsf/JSFVascEntrySupportBean.java | 18 - .../web/jsf/JSFVascFrontendRenderer.java | 22 +- .../frontend/web/jsf/JSFVascUIComponent.java | 160 ++++----- .../web/jsf/JSFVascUIComponentRenderer.java | 4 +- .../frontend/web/jsf/VascDataBackendBean.java | 3 +- .../web/jsf/VascRequestFacesFilter.java | 21 +- .../test/i18n/VascBundleCheckEntryKeys.java | 19 +- .../META-INF/vasc/vasc-xpql-ejb3.eld | 2 +- .../vasc/xpql/ejb3/XpqlQueryManagerImpl.java | 329 +++++++++--------- .../resources/META-INF/vasc/vasc-xpql.eld | 2 +- 46 files changed, 1055 insertions(+), 688 deletions(-) create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/icon.png create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/laf-colors.properties create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/logo.png create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/I18nController.java diff --git a/pom.xml b/pom.xml index 29d04c3..415a019 100644 --- a/pom.xml +++ b/pom.xml @@ -86,7 +86,7 @@ 4.3 - 3.1.3-SNAPSHOT + 3.2.5 2.7.3 @@ -107,18 +107,18 @@ 4.5.1 - 1.0.3 - 1.0.3 + 1.0.9 + 1.0.9 1.6.4 1.6.4 - 2.3 + 2.4 1.9.2 - 9.1-901.jdbc4 - 5.1.20 - 1.3.167 - 10.8.2.2 + 9.1-901-1.jdbc4 + 5.1.22 + 1.3.170 + 10.9.1.0 3.1.0.CR1 @@ -148,7 +148,7 @@ 2.2.1-b04 1.6.3 3.0.0.CR2 - 1.5.1-SNAPSHOT + 1.5.1 9.1.0.8 diff --git a/todo.txt b/todo.txt index aaa9bdd..c51961a 100644 --- a/todo.txt +++ b/todo.txt @@ -8,21 +8,8 @@ - demo menu - demo wiki -- hotdeploy - null list option mongo query -- sql conn limit - mongo backend limit - -Build layout: -lib/ -demo/ -deploy/ -config/ -workdir/ -logs/ - -- remote ejb3 - - encodeing select model - lcoale select model - x4o template diff --git a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlHibernateVascBackend.java b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlHibernateVascBackend.java index d710dca..f293bc3 100644 --- a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlHibernateVascBackend.java +++ b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlHibernateVascBackend.java @@ -102,7 +102,7 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend { i++; } if (isPageable() && state.getPageSize()>0) { - q.setFirstResult(state.getPageIndex()); + q.setFirstResult(state.getPageIndex()*state.getPageSize()); q.setMaxResults(state.getPageSize()); } List data = q.list(); diff --git a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlPersistanceVascBackend.java b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlPersistanceVascBackend.java index 384c853..23ec150 100644 --- a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlPersistanceVascBackend.java +++ b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlPersistanceVascBackend.java @@ -102,7 +102,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend i++; } if (isPageable() && state.getPageSize()>0) { - q.setFirstResult(state.getPageIndex()); + q.setFirstResult(state.getPageIndex()*state.getPageSize()); q.setMaxResults(state.getPageSize()); } if (emTransaction) { diff --git a/vasc-backend/vasc-backend-jpa/src/main/resources/META-INF/vasc/vasc-backend-jpa.eld b/vasc-backend/vasc-backend-jpa/src/main/resources/META-INF/vasc/vasc-backend-jpa.eld index 674e65b..7acd82e 100644 --- a/vasc-backend/vasc-backend-jpa/src/main/resources/META-INF/vasc/vasc-backend-jpa.eld +++ b/vasc-backend/vasc-backend-jpa/src/main/resources/META-INF/vasc/vasc-backend-jpa.eld @@ -7,7 +7,7 @@ xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd" providerName="vasc.forwardfire.net" name="Vasc Backend JPA" - id="mod-vasc-backend-jpa" + id="vasc-backend-jpa" > Provides VASC JPA backend support. result = new ArrayList(50); try { - LDAPSearchConstraints cons = new LDAPSearchConstraints(); cons.setBatchSize( 0 ); - cons.setTimeLimit( 10000 ) ; - cons.setReferralFollowing(true); + cons.setTimeLimit(getTimeLimit() ) ; + cons.setReferralFollowing(isReferralFollowing()); connection.setConstraints(cons); int searchScope = LDAPConnection.SCOPE_ONE; String searchBase = baseDN; - //System.out.println("Reading object :" + searchBase + " with filter: " + ldapFilter); LDAPSearchResults searchResults = connection.search( - searchBase, // object to read - searchScope, // scope - read single object - ldapFilter, // search filter - null, // return all attributes - false); // return attrs and values + searchBase, // object to read + searchScope, // scope - read single object + getLdapFilter(), // search filter + null, // return all attributes + false); // return attrs and values while (searchResults.hasMore()) { LDAPEntry entry = searchResults.next(); @@ -114,7 +111,6 @@ public class LdapVascBackend extends AbstractVascBackend { Iterator i = attributeSet.iterator(); while (i.hasNext()) { LDAPAttribute attr = i.next(); - //System.out.println("ATTR: "+attr.getName()+" value: "+attr.getStringValue()); String[] s = attr.getStringValueArray(); if (s.length==1) { map.put(attr.getName(), attr.getStringValue()); @@ -149,14 +145,12 @@ public class LdapVascBackend extends AbstractVascBackend { String keyValue = (String)map.get(keyAttribute); LDAPSearchConstraints cons = new LDAPSearchConstraints(); cons.setBatchSize( 0 ); - cons.setTimeLimit( 10000 ) ; - cons.setReferralFollowing(true); + cons.setTimeLimit(getTimeLimit() ) ; + cons.setReferralFollowing(isReferralFollowing()); connection.setConstraints(cons); - int searchScope = LDAPConnection.SCOPE_ONE; String searchBase = baseDN; - String filter = "(&("+keyAttribute+"="+keyValue+"))"; - System.out.println("ldap filter: "+filter); + String filter = "(&"+ldapFilter+"("+keyAttribute+"="+keyValue+"))"; LDAPSearchResults searchResults = connection.search( searchBase, // object to read searchScope, // scope - read single object @@ -210,8 +204,9 @@ public class LdapVascBackend extends AbstractVascBackend { } LDAPModification[] m = new LDAPModification[mods.size()]; - mods.toArray(m); + m = mods.toArray(m); connection.modify(entry.getDN(), m); + return object; } catch (Exception e) { throw new VascException(e); @@ -270,7 +265,7 @@ public class LdapVascBackend extends AbstractVascBackend { String keyValue = (String)map.get(keyAttribute); int searchScope = LDAPConnection.SCOPE_ONE; String searchBase = baseDN; - String filter = "(&("+ldapFilter+")("+keyAttribute+"="+keyValue+"))"; + String filter = "(&"+ldapFilter+"("+keyAttribute+"="+keyValue+"))"; LDAPSearchResults searchResults = connection.search( searchBase, // object to read searchScope, // scope - read single object @@ -362,4 +357,32 @@ public class LdapVascBackend extends AbstractVascBackend { public void setCreateObjectClass(String createObjectClass) { this.createObjectClass = createObjectClass; } + + /** + * @return the timeLimit + */ + public int getTimeLimit() { + return timeLimit; + } + + /** + * @param timeLimit the timeLimit to set + */ + public void setTimeLimit(int timeLimit) { + this.timeLimit = timeLimit; + } + + /** + * @return the referralFollowing + */ + public boolean isReferralFollowing() { + return referralFollowing; + } + + /** + * @param referralFollowing the referralFollowing to set + */ + public void setReferralFollowing(boolean referralFollowing) { + this.referralFollowing = referralFollowing; + } } \ No newline at end of file diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextMongodb.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextMongodb.java index ee27275..becdbf6 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextMongodb.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextMongodb.java @@ -26,7 +26,6 @@ import java.net.UnknownHostException; import org.eobjects.metamodel.DataContext; import org.eobjects.metamodel.mongodb.MongoDbDataContext; -import org.eobjects.metamodel.mongodb.MongoDbDataContextBean; import com.mongodb.DB; import com.mongodb.Mongo; @@ -51,13 +50,16 @@ public class MetaModelDataContextMongodb implements MetaModelDataContextProvider protected Mongo mongo = null; public DataContext getDataContext() { - MongoDbDataContextBean dataContext = new MongoDbDataContextBean(getMongodbConnection()); - dataContext.setRegisterMBean(true); - dataContext.start(); + //MongoDbDataContextBean dataContext = new MongoDbDataContextBean(getMongodbConnection()); + ///dataContext.setRegisterMBean(true); + //dataContext.start(); + //MongoDbDataContextSchemaDetector detector = new MongoDbDataContextSchemaDetector(); //detector.setDataCheckSize(10); //detector.setSearchReference(true); //DataContext dataContext = detector.new MongoDbDataContextExtended(getMongodbConnection(),detector); + + DataContext dataContext = new MongoDbDataContext(getMongodbConnection()); return dataContext; } diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelSchemaAutoEntry.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelSchemaAutoEntry.java index aaed3cc..5cc39ce 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelSchemaAutoEntry.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelSchemaAutoEntry.java @@ -23,7 +23,9 @@ package net.forwardfire.vasc.backend.metamodel; import java.util.ArrayList; -import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -67,6 +69,8 @@ public class MetaModelSchemaAutoEntry { private String tableExclude = null; private String entryPrefix = null; private String vascGroupId = null; + private String veLinkPostfix = "_velink"; + private String veListPostfix = "_velist"; private Map resultEntries = null; private Map resultEntryGroups = null; @@ -160,11 +164,9 @@ public class MetaModelSchemaAutoEntry { if (tableName.equals(rs.getForeignTable().getName())==false) { logger.finer("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName()); createLinkEntry(rs,ve,metaTable); - //createLinkEntry(rs,ve,metaTable,id+"_"+rs.getForeignTable().getName()+"_"+rs.getForeignColumns()[0].getName()+"_link"); } else { logger.finer("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName()); createListEntry(rs,ve,metaTable); - //createListEntry(rs,ve,metaTable,id+"_"+rs.getPrimaryTable().getName()+"_"+rs.getPrimaryColumns()[0].getName()+"_list"); } } @@ -173,7 +175,7 @@ public class MetaModelSchemaAutoEntry { } private void createLinkEntry(Relationship rs2,VascEntryLocal ve,Table metaTable) { - String id = getEntryPrefix()+"_"+metaTable.getName()+"_link"; + String id = getEntryPrefix()+"_"+rs2.getForeignTable().getName()+getVeLinkPostfix(); MetaModelVascBackend backendLink = new MetaModelVascBackend(); backendLink.setId(id+"_backend"); backendLink.setDataContextProvider(getDataContextProvider()); @@ -195,26 +197,25 @@ public class MetaModelSchemaAutoEntry { veLink.setBackendId(id+"_backend"); veLink.setPrimaryKeyFieldId(backendLink.getTableId()); veLink.setVascGroupId(getVascGroupId()); - veLink.setAccessType(VascEntryAccessType.ENTRY_LIST); + veLink.setAccessType(VascEntryAccessType.ENTRY_LINK); createFields(veLink,cols); + if (resultBackends.containsKey(backendLink.getId())==false) { + resultBackends.put(backendLink.getId(),backendLink); + resultEntries.put(veLink.getId(),veLink); + } + for (Relationship rs:rs2.getForeignTable().getRelationships()) { logger.finer("Found relation FT: "+rs.getForeignTable().getName()+" PT: "+rs.getPrimaryTable().getName()); if (rs2.getForeignTable().getName().equals(rs.getForeignTable().getName())==false) { //logger.info("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName()); - //createLinkEntry(rs,ve,rs2.getForeignTable(),id+"_"+rs.getForeignTable().getName()+"_"+rs.getForeignColumns()[0].getName()+"_link"); + //createLinkEntry(rs,veLink,rs2.getForeignTable()); } else { logger.fine("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName()); createListEntry(rs,veLink,rs2.getForeignTable()); - //createListEntry(rs,veLink,rs2.getForeignTable(),id+"_"+rs.getPrimaryTable().getName()+"_"+rs.getPrimaryColumns()[0].getName()+"_list"); } } - if (resultBackends.containsKey(backendLink.getId())==false) { - resultBackends.put(backendLink.getId(),backendLink); - resultEntries.put(veLink.getId(),veLink); - } - DefaultVascEntryLink vle = new DefaultVascEntryLink(); vle.setId(id+"Link"); vle.setVascEntryLinkType(VascEntryLinkType.DEFAULT_TYPE); @@ -225,7 +226,7 @@ public class MetaModelSchemaAutoEntry { } private void createListEntry(Relationship rs,VascEntry ve,Table metaTable) { - String id = getEntryPrefix()+"_"+metaTable.getName()+"_list"; + String id = getEntryPrefix()+"_"+rs.getPrimaryTable().getName()+getVeListPostfix(); MetaModelVascBackend backendList = new MetaModelVascBackend(); backendList.setId(id+"_backend"); backendList.setDataContextProvider(getDataContextProvider()); @@ -263,27 +264,34 @@ public class MetaModelSchemaAutoEntry { VascSelectItemModelEntry itemModel = new VascSelectItemModelEntry(); itemModel.setEntryId(veList.getId()); - itemModel.setDisplayFieldId(veList.getDisplayNameFieldId()); + if (veList.getDisplayNameFieldId()==null) { + itemModel.setDisplayFieldId(veList.getPrimaryKeyFieldId()); // display can be null see createFields(), in vasc display is not null but defaulted on primary id. + } else { + itemModel.setDisplayFieldId(veList.getDisplayNameFieldId()); + } + vef.getVascEntryFieldType().setDataObject(itemModel); } private void createFields(VascEntryLocal ve,Column[] cols) { for (Column c:cols) { + String name = c.getName().toLowerCase(); DefaultVascEntryField vef = new DefaultVascEntryField(); vef.setId(c.getName()); vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeByClass(c.getType().getJavaEquivalentClass())); if (vef.getId().equals(ve.getPrimaryKeyFieldId())) { vef.setEditReadOnly(true); - // vef.setCreate(false); mmm + vef.setCreate(false); } if (vef.getVascEntryFieldType()==null || "TextField".equals(vef.getVascEntryFieldType().getId())) { - if (c.getName().toLowerCase().contains("desc") || c.getName().toLowerCase().contains("text")) { + if (name.contains("desc") || name.contains("text") || name.contains("comment") || name.contains("memo") ) { vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("TextAreaField")); } - if (c.getName().toLowerCase().contains("active")) { + if (name.contains("active")) { + vef.setDefaultValue("true"); vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("BooleanField")); } /* todo if (c.getName().toLowerCase().contains("email")) { @@ -293,25 +301,55 @@ public class MetaModelSchemaAutoEntry { vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("URLField")); } */ } + + if (vef.getVascEntryFieldType()!=null && vef.getVascEntryFieldType().getAutoDetectClass()==Date.class) { + vef.setDefaultValue("now()"); + if (name.contains("create") || name.contains("modified")) { + vef.setEdit(false); + vef.setCreate(false); + } + if (name.contains("update")) { + vef.setCreate(false); + } + } + ve.addVascEntryField(vef); if (ve.getDisplayNameFieldId()==null && c.getName().equals(ve.getPrimaryKeyFieldId())==false && c.getType().getJavaEquivalentClass()==String.class) { ve.setDisplayNameFieldId(c.getName()); } } + // Disable lists when id contains; + for (VascEntryField vef:ve.getVascEntryFields()) { + String id = vef.getId().toLowerCase(); + if (ve.getDisplayNameFieldId()!=null && ve.getDisplayNameFieldId().equals(vef.getId())) { + continue; + } + if (ve.getPrimaryKeyFieldId()!=null && ve.getPrimaryKeyFieldId().equals(vef.getId())) { + continue; + } + if (vef.getList()!=null && vef.getList()==false) { + continue; + } + if ( id.contains("email") | + id.contains("phone") | + id.contains("data") | + id.contains("value") | + id.contains("create") | + id.contains("update") | + id.contains("delete") | + id.contains("classname") | + id.contains("description") + ) { + vef.setList(false); + } + } + // Some auto detection on fields so default imported list view looks oke on 8++ columns. - if (ve.getVascEntryFields().size()>8) { + if (ve.getVascEntryFields().size()>10) { List vefListIds = new ArrayList(20); + int max = 0; for (VascEntryField vef:ve.getVascEntryFields()) { - String id = vef.getId().toLowerCase(); - if ( id.contains("create") | - id.contains("update") | - id.contains("delete") | - id.contains("classname") | - id.contains("description") - ) { - vef.setList(false); - } if (ve.getDisplayNameFieldId()!=null && ve.getDisplayNameFieldId().equals(vef.getId())) { continue; } @@ -322,14 +360,15 @@ public class MetaModelSchemaAutoEntry { continue; } vefListIds.add(vef.getId()); - } - if (vefListIds.size()<8) { - List vefListFalseIds = vefListIds.subList(8-1, vefListIds.size()); - for (String key:vefListFalseIds) { - VascEntryField vef = ve.getVascEntryFieldById(key); - vef.setList(false); + max++; + if (max>8) { + break; } } + for (String key:vefListIds) { + VascEntryField vef = ve.getVascEntryFieldById(key); + vef.setList(false); + } } } @@ -406,22 +445,43 @@ public class MetaModelSchemaAutoEntry { /** * @return the resultEntries */ - public Collection getResultEntries() { - return resultEntries.values(); + public List getResultEntries() { + List result = new ArrayList(resultEntries.values()); + Collections.sort(result, new Comparator() { + @Override + public int compare(VascEntryLocal o1, VascEntryLocal o2) { + return o1.getId().compareTo(o2.getId()); + } + }); + return result; } /** * @return the resultEntryGroups */ - public Collection getResultEntryGroups() { - return resultEntryGroups.values(); + public List getResultEntryGroups() { + List result = new ArrayList(resultEntryGroups.values()); + Collections.sort(result, new Comparator() { + @Override + public int compare(VascEntryGroupLocal o1, VascEntryGroupLocal o2) { + return o1.getId().compareTo(o2.getId()); + } + }); + return result; } /** * @return the resultBackends */ - public Collection getResultBackends() { - return resultBackends.values(); + public List getResultBackends() { + List result = new ArrayList(resultBackends.values()); + Collections.sort(result, new Comparator() { + @Override + public int compare(MetaModelVascBackend o1, MetaModelVascBackend o2) { + return o1.getId().compareTo(o2.getId()); + } + }); + return result; } /** @@ -437,4 +497,32 @@ public class MetaModelSchemaAutoEntry { public void removeTable(String table) { tables.remove(table); } + + /** + * @return the veLinkPostfix + */ + public String getVeLinkPostfix() { + return veLinkPostfix; + } + + /** + * @param veLinkPostfix the veLinkPostfix to set + */ + public void setVeLinkPostfix(String veLinkPostfix) { + this.veLinkPostfix = veLinkPostfix; + } + + /** + * @return the veListPostfix + */ + public String getVeListPostfix() { + return veListPostfix; + } + + /** + * @param veListPostfix the veListPostfix to set + */ + public void setVeListPostfix(String veListPostfix) { + this.veListPostfix = veListPostfix; + } } diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java index 7c4f61d..27a5c12 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java @@ -32,10 +32,13 @@ import org.eobjects.metamodel.DataContext; import org.eobjects.metamodel.UpdateableDataContext; import org.eobjects.metamodel.data.DataSet; import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.jdbc.JdbcDataContext; +import org.eobjects.metamodel.query.OrderByItem.Direction; import org.eobjects.metamodel.query.Query; import org.eobjects.metamodel.query.SelectItem; import org.eobjects.metamodel.query.builder.SatisfiedQueryBuilder; import org.eobjects.metamodel.query.builder.SatisfiedWhereBuilder; +import org.eobjects.metamodel.schema.Column; import org.eobjects.metamodel.schema.Schema; import org.eobjects.metamodel.schema.Table; @@ -131,6 +134,14 @@ public class MetaModelVascBackend extends AbstractVascBackend { return true; } + /** + * @see net.forwardfire.vasc.backend.AbstractVascBackend#isSortable() + */ + @Override + public boolean isSortable() { + return true; + } + /** * @see net.forwardfire.vasc.backend.AbstractVascBackend#fetchTotalExecuteSize(net.forwardfire.vasc.backend.VascBackendState) */ @@ -208,8 +219,23 @@ public class MetaModelVascBackend extends AbstractVascBackend { throw new VascException("Could not get meta table for: '"+table+"'."); } Query q = createFilterQuery(state,t,false); + if (isSortable() && state.getSortField() != null) { + Column orderColumn = t.getColumnByName(state.getSortField()); + if (state.isSortAscending()) { + q.orderBy(orderColumn,Direction.ASC); + } else { + q.orderBy(orderColumn,Direction.DESC); + } + } if (isPageable() && state.getPageSize()>0) { - q.setFirstRow(state.getPageIndex()+1); // +1 for mm ? + if (state.getPageIndex()>0) { + q.setFirstRow((state.getPageIndex()*state.getPageSize())+1); // MM is 1 based ?? + + // workaround for bug in MM in jdbc/pg mode which is zero based. + if (dataContext instanceof JdbcDataContext) { + q.setFirstRow((state.getPageIndex()*state.getPageSize())+0); // MM is 1 based but sql is 0 based + } + } q.setMaxRows(state.getPageSize()); } if (crudDataContext!=null) { @@ -227,7 +253,7 @@ public class MetaModelVascBackend extends AbstractVascBackend { SelectItem[] cols = row.getSelectItems(); List keys = new ArrayList(1); keys.add(cols[0].getColumn().getName()); - UpdateableRowMapImpl rowMM = new UpdateableRowMapImpl(dataContext.getDefaultSchema().getTableByName(table),keys); + UpdateableRowMapImpl rowMM = new UpdateableRowMapImpl(dataContext.getDefaultSchema().getTableByName(table),keys,cols); for (SelectItem col:cols) { Object value = row.getValue(col); rowMM.setValue(col, value); diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MongoDbDataContextSchemaDetector.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MongoDbDataContextSchemaDetector.java index dff0b31..223eead 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MongoDbDataContextSchemaDetector.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MongoDbDataContextSchemaDetector.java @@ -46,7 +46,7 @@ public class MongoDbDataContextSchemaDetector /* implements MetaModelSchemaDetec private int dataCheckSize = 100; private boolean searchReference = true; - public MongoDbDataContextSchemaDetector() { + private MongoDbDataContextSchemaDetector() { } public class MongoDbDataContextExtended extends QueryPostprocessDataContext /* MongoDbDataContext */ { @@ -153,8 +153,10 @@ public class MongoDbDataContextSchemaDetector /* implements MetaModelSchemaDetec private boolean _closed; private volatile DBObject _dbObject; - public MongoDbDataSet(DBCursor cursor, Column[] columns, - boolean queryPostProcessed) { + public MongoDbDataSet(DBCursor cursor, Column[] columns,boolean queryPostProcessed) { + + super(columns); // create header + _cursor = cursor; _selectItems = new SelectItem[columns.length]; for (int i = 0; i < columns.length; i++) { @@ -211,7 +213,7 @@ public class MongoDbDataContextSchemaDetector /* implements MetaModelSchemaDetec Object value = _dbObject.get(key); values[i] = toValue(_selectItems[i].getColumn(), value); } - return new DefaultRow(_selectItems, values); + return new DefaultRow(getHeader(), values); } private Object toValue(Column column, Object value) { @@ -440,6 +442,7 @@ public class MongoDbDataContextSchemaDetector /* implements MetaModelSchemaDetec // Override to make public class PublicTable extends MutableTable { + private static final long serialVersionUID = 1L; public PublicTable(String name,TableType type) { super(name,type); } diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractCrudDataContext.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractCrudDataContext.java index b23f7e4..9396060 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractCrudDataContext.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractCrudDataContext.java @@ -2,7 +2,6 @@ package net.forwardfire.vasc.backend.metamodel.crud; import java.util.ArrayList; import java.util.Collections; -import java.util.Date; import java.util.List; import org.eobjects.metamodel.DataContext; @@ -45,15 +44,15 @@ abstract public class AbstractCrudDataContext implements CrudDataContext { public void persist(final UpdateableRow row) { UpdateableDataContext dataContext = abstractProviderUpdateableDataContext(); dataContext.executeUpdate(new UpdateScript() { - public void run(UpdateCallback backendImpl) { - RowInsertionBuilder query = backendImpl.insertInto(row.getTable()); - for (int i=0;i primaryKeyColumns = new ArrayList(30); Collections.addAll(primaryKeyColumns, row.getPrimaryKeys()); - for (String column:primaryKeyColumns) { - Object value = row.getValue(column); - queryWhereBuilderUpdate(qWhere,column,value,first); - first = false; - } - List columns = new ArrayList(30); + for (String column:primaryKeyColumns) { + Object value = row.getValue(column); + queryWhereBuilderUpdate(qWhere,column,value,first); + first = false; + } + List columns = new ArrayList(30); Collections.addAll(columns, row.getTable().getColumnNames()); columns.removeAll(primaryKeyColumns); for (String column:columns) { - Object value = row.getValue(column); - ((RowUpdationBuilder)qWhere).value(column, value); - } + Object value = row.getValue(column); + ((RowUpdationBuilder)qWhere).value(column, value); + } if (first==false) { ((RowUpdationBuilder)qWhere).execute(); } else { @@ -92,18 +91,18 @@ abstract public class AbstractCrudDataContext implements CrudDataContext { Object qWhere = dataContext.query().from(row.getTable()).select(row.getTable().getColumns()); boolean first = true; - for (String column:row.getPrimaryKeys()) { - Object value = row.getValue(column); - queryWhereBuilder(qWhere,column,value,first); - first = false; - } - Query mergeSelectQuery = ((SatisfiedQueryBuilder)qWhere).toQuery(); - DataSet ds = dataContext.executeQuery(mergeSelectQuery); - if (ds.next()==false) { - ds.close(); - throw new IllegalStateException("Could not fetch row after merging."); - } - UpdateableRow rowResult = wrapOrCreateToUpdateableRow(ds.getRow(),row.getTable()); + for (String column:row.getPrimaryKeys()) { + Object value = row.getValue(column); + queryWhereBuilder(qWhere,column,value,first); + first = false; + } + Query mergeSelectQuery = ((SatisfiedQueryBuilder)qWhere).toQuery(); + DataSet ds = dataContext.executeQuery(mergeSelectQuery); + if (ds.next()==false) { + ds.close(); + throw new IllegalStateException("Could not fetch row after merging."); + } + UpdateableRow rowResult = wrapOrCreateToUpdateableRow(ds.getRow(),row.getTable()); ds.close(); return rowResult; } @@ -111,131 +110,71 @@ abstract public class AbstractCrudDataContext implements CrudDataContext { public void delete(final UpdateableRow row) { UpdateableDataContext dataContext = abstractProviderUpdateableDataContext(); dataContext.executeUpdate(new UpdateScript() { - public void run(UpdateCallback backendImpl) { - Object qWhere = backendImpl.deleteFrom(row.getTable()); - boolean first = true; - for (String column:row.getPrimaryKeys()) { - Object value = row.getValue(column); - queryWhereBuilderDelete(qWhere,column,value,first); - first = false; - } - if (first==false) { - ((RowDeletionBuilder)qWhere).execute(); - } else { - ///logger.warning no where clause - } - } + public void run(UpdateCallback backendImpl) { + Object qWhere = backendImpl.deleteFrom(row.getTable()); + boolean first = true; + for (String column:row.getPrimaryKeys()) { + Object value = row.getValue(column); + queryWhereBuilderDelete(qWhere,column,value,first); + first = false; + } + if (first==false) { + ((RowDeletionBuilder)qWhere).execute(); + } else { + ///logger.warning no where clause + } + } }); } // TODO: redo these queryWhereBuilder methods to cleaner code protected Object queryWhereBuilder(Object qWhere,String key,Object value,boolean first) { - if (value instanceof Number) { - if (first) { - qWhere = ((SatisfiedQueryBuilder)qWhere).where(key).equals((Number)value); - } else { - qWhere = ((SatisfiedWhereBuilder)qWhere).and(key).equals((Number)value); - } - } else if (value instanceof Date) { + if (value==null) { if (first) { - qWhere = ((SatisfiedQueryBuilder)qWhere).where(key).equals((Date)value); + qWhere = ((SatisfiedQueryBuilder)qWhere).where(key).isNull(); } else { - qWhere = ((SatisfiedWhereBuilder)qWhere).and(key).equals((Date)value); - } - } else if (value instanceof Boolean) { - if (first) { - qWhere = ((SatisfiedQueryBuilder)qWhere).where(key).equals((Boolean)value); - } else { - qWhere = ((SatisfiedWhereBuilder)qWhere).and(key).equals((Boolean)value); + qWhere = ((SatisfiedWhereBuilder)qWhere).and(key).isNull(); } } else { - if (value==null) { - if (first) { - qWhere = ((SatisfiedQueryBuilder)qWhere).where(key).isNull(); - } else { - qWhere = ((SatisfiedWhereBuilder)qWhere).and(key).isNull(); - } + if (first) { + qWhere = ((SatisfiedQueryBuilder)qWhere).where(key).isEquals(value); } else { - if (first) { - qWhere = ((SatisfiedQueryBuilder)qWhere).where(key).equals(value.toString()); - } else { - qWhere = ((SatisfiedWhereBuilder)qWhere).and(key).equals(value.toString()); - } + qWhere = ((SatisfiedWhereBuilder)qWhere).and(key).isEquals(value); } } return qWhere; } protected Object queryWhereBuilderUpdate(Object qWhere,String key,Object value,boolean first) { - if (value instanceof Number) { - if (first) { - qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Number)value); - } else { - qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Number)value); - } - } else if (value instanceof Date) { + if (value==null) { if (first) { - qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Date)value); + qWhere = ((RowUpdationBuilder)qWhere).where(key).isNull(); } else { - qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Date)value); - } - } else if (value instanceof Boolean) { - if (first) { - qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Boolean)value); - } else { - qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Boolean)value); + qWhere = ((RowUpdationBuilder)qWhere).where(key).isNull(); } } else { - if (value==null) { - if (first) { - qWhere = ((RowUpdationBuilder)qWhere).where(key).isNull(); - } else { - qWhere = ((RowUpdationBuilder)qWhere).where(key).isNull(); - } + if (first) { + qWhere = ((RowUpdationBuilder)qWhere).where(key).isEquals(value); } else { - if (first) { - qWhere = ((RowUpdationBuilder)qWhere).where(key).equals(value.toString()); - } else { - qWhere = ((RowUpdationBuilder)qWhere).where(key).equals(value.toString()); - } + qWhere = ((RowUpdationBuilder)qWhere).where(key).isEquals(value); } } return qWhere; } protected Object queryWhereBuilderDelete(Object qWhere,String key,Object value,boolean first) { - if (value instanceof Number) { - if (first) { - qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Number)value); - } else { - qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Number)value); - } - } else if (value instanceof Date) { + if (value==null) { if (first) { - qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Date)value); + qWhere = ((RowDeletionBuilder)qWhere).where(key).isNull(); } else { - qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Date)value); - } - } else if (value instanceof Boolean) { - if (first) { - qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Boolean)value); - } else { - qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Boolean)value); + qWhere = ((RowDeletionBuilder)qWhere).where(key).isNull(); } } else { - if (value==null) { - if (first) { - qWhere = ((RowDeletionBuilder)qWhere).where(key).isNull(); - } else { - qWhere = ((RowDeletionBuilder)qWhere).where(key).isNull(); - } + if (first) { + qWhere = ((RowDeletionBuilder)qWhere).where(key).isEquals(value); } else { - if (first) { - qWhere = ((RowDeletionBuilder)qWhere).where(key).equals(value.toString()); - } else { - qWhere = ((RowDeletionBuilder)qWhere).where(key).equals(value.toString()); - } + qWhere = ((RowDeletionBuilder)qWhere).where(key).isEquals(value); } } return qWhere; diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractUpdateableRow.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractUpdateableRow.java index 131deeb..bc355e3 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractUpdateableRow.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/AbstractUpdateableRow.java @@ -22,7 +22,8 @@ abstract public class AbstractUpdateableRow extends AbstractRow implements Updat } public int indexOf(String columnName) { if (columnName==null) { - return UpdateableRow.INDEX_NOT_FOUND; + throw new NullPointerException("Can't search for null column name."); + //return UpdateableRow.INDEX_NOT_FOUND; } int index = 0; for (SelectItem si:getIndexedSelectItemList()) { @@ -31,7 +32,8 @@ abstract public class AbstractUpdateableRow extends AbstractRow implements Updat } index++; } - return UpdateableRow.INDEX_NOT_FOUND; + throw new IndexOutOfBoundsException("Can't find key of column: "+columnName); + ////return UpdateableRow.INDEX_NOT_FOUND; } public void setValue(Row row) { @@ -66,7 +68,7 @@ abstract public class AbstractUpdateableRow extends AbstractRow implements Updat if (selectItem.getSubQuerySelectItem() != null) { value = getValue(selectItem.getSubQuerySelectItem()); - style = getStyle(selectItem.getSubQuerySelectItem()); + style = getStyle(selectItem.getSubQuerySelectItem()); } if (value == null) { value = getValue(selectItem); diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/CrudDataContextImpl.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/CrudDataContextImpl.java index 09f428f..c66d947 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/CrudDataContextImpl.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/CrudDataContextImpl.java @@ -11,6 +11,7 @@ import org.eobjects.metamodel.UpdateScript; import org.eobjects.metamodel.UpdateableDataContext; import org.eobjects.metamodel.data.DataSet; import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.query.CompiledQuery; import org.eobjects.metamodel.query.Query; import org.eobjects.metamodel.query.builder.InitFromBuilder; import org.eobjects.metamodel.query.builder.InitFromBuilderImpl; @@ -81,7 +82,7 @@ public class CrudDataContextImpl extends AbstractCrudDataContext implements Abst if (row==null) { result.addSelectItems(table.getColumns()); // create new when row is null } else { - result.addSelectItems(row.getSelectItems()); + result.addSelectItems(row.getSelectItems()); result.setValue(row); // copy all values to impl } return result; @@ -205,4 +206,12 @@ public class CrudDataContextImpl extends AbstractCrudDataContext implements Abst public DataSet executeQuery(String queryString) throws MetaModelException { return dataContextDelegate.executeQuery(queryString); } + + public CompiledQuery compileQuery(Query q) throws MetaModelException { + return dataContextDelegate.compileQuery(q); + } + + public DataSet executeQuery(CompiledQuery cq, Object... args) { + return dataContextDelegate.executeQuery(cq, args); + } } diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/UpdateableRowMapImpl.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/UpdateableRowMapImpl.java index 569e4a0..84920b4 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/UpdateableRowMapImpl.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/crud/UpdateableRowMapImpl.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.eobjects.metamodel.data.DataSetHeader; import org.eobjects.metamodel.data.Row; import org.eobjects.metamodel.query.SelectItem; import org.eobjects.metamodel.schema.Table; @@ -47,6 +48,9 @@ public class UpdateableRowMapImpl extends AbstractUpdateableRow { } public void setValue(int index, Object value) throws IndexOutOfBoundsException { + if (index == UpdateableRow.INDEX_NOT_FOUND) { + throw new IndexOutOfBoundsException("Can't save value without key index: "+UpdateableRow.INDEX_NOT_FOUND+" value:"+value); + } dataMap.put(index, value); } @@ -57,4 +61,8 @@ public class UpdateableRowMapImpl extends AbstractUpdateableRow { public Row getSubSelection(SelectItem[] selectItems) { return getSubSelectionFromImpl(new UpdateableRowMapImpl(table,primaryKeys,selectItems),selectItems); } + + public Row getSubSelection(DataSetHeader header) { + return getSubSelection(header.getSelectItems()); + } } diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/JndiReadOnlyDataContext.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/JndiReadOnlyDataContext.java index 464aacb..afdcace 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/JndiReadOnlyDataContext.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/JndiReadOnlyDataContext.java @@ -3,6 +3,7 @@ package net.forwardfire.vasc.backend.metamodel.jndi; import org.eobjects.metamodel.DataContext; import org.eobjects.metamodel.MetaModelException; import org.eobjects.metamodel.data.DataSet; +import org.eobjects.metamodel.query.CompiledQuery; import org.eobjects.metamodel.query.Query; import org.eobjects.metamodel.query.builder.InitFromBuilder; import org.eobjects.metamodel.schema.Column; @@ -53,4 +54,12 @@ public class JndiReadOnlyDataContext /* extends DataContextProxy */ implements D public DataSet executeQuery(String queryString) throws MetaModelException { return proxyDataContext.executeQuery(queryString); } + @Override + public CompiledQuery compileQuery(Query q) throws MetaModelException { + return proxyDataContext.compileQuery(q); + } + @Override + public DataSet executeQuery(CompiledQuery cq, Object... args) { + return proxyDataContext.executeQuery(cq, args); + } } diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiMongodbDataContextLoader.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiMongodbDataContextLoader.java index 6279def..9532d47 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiMongodbDataContextLoader.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/jndi/loader/JndiMongodbDataContextLoader.java @@ -7,7 +7,6 @@ import javax.naming.NamingException; import org.eobjects.metamodel.DataContext; import org.eobjects.metamodel.mongodb.MongoDbDataContext; -import org.eobjects.metamodel.mongodb.MongoDbDataContextBean; import com.mongodb.DB; import com.mongodb.Mongo; @@ -31,27 +30,38 @@ public class JndiMongodbDataContextLoader implements JndiDataContextLoader { } public DataContext loadDataContext(JndiDataContextLoaderConfig config) { - MongoDbDataContextBean result = null; + //MongoDbDataContextBean result = null; + DB mongoDb = null; if (useJndiResource) { config.checkBackendUrl(); - result = new MongoDbDataContextBean(getMongodbJdni(config.getJndiObjectName(),config.getBackendUrl())); + //result = new MongoDbDataContextBean(,)); + mongoDb = getMongodbJdni(config.getJndiObjectName(),config.getBackendUrl()); + } else { int mongoPort = 27017; if (config.getBackendPort()!=null && config.getBackendPort().isEmpty()==false) { mongoPort = new Integer(config.getBackendPort()); } - result = new MongoDbDataContextBean(getMongodbConnection( + mongoDb = getMongodbConnection( config.getJndiObjectName(), config.getBackendHost(), mongoPort, config.getBackendDatabase(), config.getBackendUsername(), config.getBackendPassword() - )); + ); } - result.setRegisterMBean(true); // TODO: make flag - result.start(); - return result; + //MongoDbDataContextSchemaDetector detector = new MongoDbDataContextSchemaDetector(); + //detector.setDataCheckSize(10); + //detector.setSearchReference(true); + //DataContext dataContext = detector.new MongoDbDataContextExtended(mongoDb,detector); + + DataContext dataContext = new MongoDbDataContext(mongoDb); + return dataContext; + + //result.setRegisterMBean(true); // TODO: make flag + //result.start(); + //return result; } protected DB getMongodbJdni(String objectName,String jndiName) { diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendDataSelector.java b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendDataSelector.java index 59d0910..0c52d83 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendDataSelector.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/frontend/VascFrontendDataSelector.java @@ -45,9 +45,23 @@ public interface VascFrontendDataSelector extends VascFrontendEntry { public boolean isFieldEditReadOnly(VascEntryField field); public boolean isFieldList(VascEntryField field); - public List getFieldsList(); + public enum EntrySelectType { + VIEW, + LINK + } - public List getFieldsCreate(); + public enum EntryFieldSelectType { + CREATE, + LIST, + EDIT, + + ALL, + + EXPORT, + GRAPH, + SUM, + SORT + } - public List getFieldsEdit(); + public List getFields(EntryFieldSelectType type); } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java index f6308ad..852301d 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java @@ -155,6 +155,8 @@ public class DefaultVascFrontendActions implements VascFrontendActions { // save object on backend if (persist) { entry.getVascFrontendController().getVascEntryState().getVascBackend().persist(object); + result = object; // TODO: fix persist + entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(1+entry.getVascFrontendController().getVascEntryState().getTotalBackendRecords()); } else { result = entry.getVascFrontendController().getVascEntryState().getVascBackend().merge(object); } @@ -185,6 +187,7 @@ public class DefaultVascFrontendActions implements VascFrontendActions { removeObjectFromDataList(object); entry.getVascFrontendController().getVascEntryState().setEntryDataObject(null); + entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(entry.getVascFrontendController().getVascEntryState().getTotalBackendRecords()-1); entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_DELETE, object); } catch (VascException ve) { throw new VascFrontendException(ve); @@ -195,6 +198,8 @@ public class DefaultVascFrontendActions implements VascFrontendActions { * @see net.forwardfire.vasc.frontend.VascFrontendHelper#refreshData(net.forwardfire.vasc.core.VascEntry) */ public void refreshData() throws VascFrontendException { + + // Fire pre read event entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_READ, null); entry.getVascFrontendController().getVascEntryState().setEntryDataObject(null); VascBackendState backendState = entry.getVascFrontendController().getVascEntryState().getVascBackendState(); @@ -213,21 +218,21 @@ public class DefaultVascFrontendActions implements VascFrontendActions { } } - // Update total every time first + // Always update total records Long total = entry.getVascFrontendController().getVascEntryState().getVascBackend().fetchTotalExecuteSize(backendState); entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(total); + // check if we need to change the current page if table size if changed in between + int pages = new Long(total/backendState.getPageSize()).intValue(); + if (backendState.getPageIndex() > pages) { + backendState.setPageIndex(pages); + } + try { // Execute to get data. entry.getVascFrontendController().getVascEntryState().setEntryDataList(entry.getVascFrontendController().getVascEntryState().getVascBackend().execute(backendState)); - // check if we need to change the current page - int pages = new Long(total/backendState.getPageSize()).intValue(); - if (backendState.getPageIndex() > pages) { - backendState.setPageIndex(pages); - entry.getVascFrontendController().getVascEntryState().setEntryDataList(entry.getVascFrontendController().getVascEntryState().getVascBackend().execute(backendState)); - } - + // Fire event post read entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, null); } catch (VascException ve) { throw new VascFrontendException(ve); @@ -251,12 +256,10 @@ public class DefaultVascFrontendActions implements VascFrontendActions { public void searchAction(String searchString) throws VascFrontendException { entry.getVascFrontendController().getVascEntryState().getVascBackendState().setSearchString(searchString); - entry.getVascFrontendController().getVascEntryState().getVascBackendState().setSortField(null); entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(0); entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.SEARCH, searchString); - - refreshData(); + refreshData(); entry.getVascFrontendController().getVascFrontend().renderView(); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendDataSelector.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendDataSelector.java index 86fe94f..bb83b4e 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendDataSelector.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendDataSelector.java @@ -23,13 +23,15 @@ package net.forwardfire.vasc.impl.frontend; import java.util.ArrayList; -import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.actions.VascAction; import net.forwardfire.vasc.frontend.VascFrontendDataSelector; +import net.forwardfire.vasc.frontend.VascFrontendDataSelector.EntryFieldSelectType; /** @@ -38,7 +40,7 @@ import net.forwardfire.vasc.frontend.VascFrontendDataSelector; * @author Willem Cazander * @version 1.0 Jun 1, 2012 */ -public class DefaultVascFrontendDataSelector implements VascFrontendDataSelector { +public class DefaultVascFrontendDataSelector implements VascFrontendDataSelector { private VascEntry entry = null; @@ -126,30 +128,48 @@ public class DefaultVascFrontendDataSelector implements VascFrontendDataSelector */ - private List filter() { + + public List getFields(final EntryFieldSelectType type) { List result = new ArrayList(50); - for (VascEntryField vef:entry.getVascEntryFields()) { - + for (VascEntryField field:entry.getVascEntryFields()) { + + if (EntryFieldSelectType.CREATE.equals(type)) { + + if (field.getCreate()!=null && field.getCreate()==false) { + continue; + } + + } else if (EntryFieldSelectType.EDIT.equals(type)) { + + if (field.getEdit()!=null && field.getEdit()==false) { + continue; + } + + } else if (EntryFieldSelectType.LIST.equals(type)) { + + if (field.getList()!=null && field.getList()==false) { + continue; + } + } + result.add(field); } + Collections.sort(result,new Comparator() { + @Override + public int compare(VascEntryField o1, VascEntryField o2) { + + if (EntryFieldSelectType.CREATE.equals(type)) { + return o1.getOrderCreate().compareTo(o2.getOrderCreate()); + } else if (EntryFieldSelectType.EDIT.equals(type)) { + return o1.getOrderEdit().compareTo(o2.getOrderEdit()); + } else { + // List is default + return o1.getOrderList().compareTo(o2.getOrderList()); + } + } + }); return result; } - public List getFieldsList() { - List result = new ArrayList(50); - result.addAll(entry.getVascEntryFields()); - return result; - } - - public List getFieldsCreate() { - List result = new ArrayList(50); - result.addAll(entry.getVascEntryFields()); - return result; - } - - public List getFieldsEdit() { - List result = new ArrayList(50); - result.addAll(entry.getVascEntryFields()); - return result; - } + } \ No newline at end of file diff --git a/vasc-core/src/main/resources/META-INF/vasc/vasc-lang.eld b/vasc-core/src/main/resources/META-INF/vasc/vasc-lang.eld index 7335096..538777a 100644 --- a/vasc-core/src/main/resources/META-INF/vasc/vasc-lang.eld +++ b/vasc-core/src/main/resources/META-INF/vasc/vasc-lang.eld @@ -7,7 +7,7 @@ xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd" providerName="vasc.forwardfire.net" name="Vasc Config Language" - id="mod-vasc-lang" + id="vasc-lang" > @@ -22,6 +22,7 @@ + + + @@ -115,6 +118,7 @@ + diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/tech-admin.xml b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/tech-admin.xml index fb4fe1b..f2e4403 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/tech-admin.xml +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/tech-admin.xml @@ -57,27 +57,36 @@ - - + + + + + + + + + + + - + diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/ServerGuiApplication.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/ServerGuiApplication.java index 1b16850..0c682b9 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/ServerGuiApplication.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/ServerGuiApplication.java @@ -24,6 +24,7 @@ package net.forwardfire.vasc.demo.server.ui; import java.awt.AWTException; import java.awt.Color; +import java.awt.Cursor; import java.awt.Dimension; import java.awt.Font; import java.awt.MenuItem; @@ -35,7 +36,9 @@ import java.awt.event.ActionListener; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.util.ArrayList; import java.util.EventObject; +import java.util.List; import java.util.Properties; import java.util.logging.Logger; @@ -74,7 +77,8 @@ public class ServerGuiApplication extends SingleFrameApplication { mainView.setComponent(statusPanel); mainView.getFrame().setMinimumSize(new Dimension(640,480)); mainView.getFrame().setMaximumSize(new Dimension(800,600)); - + mainView.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + show(mainView); startSystemTray(); @@ -124,7 +128,11 @@ public class ServerGuiApplication extends SingleFrameApplication { } public void startupDone() { - statusPanel.startupDone(); + try { + statusPanel.startupDone(); + } finally { + getMainFrame().setCursor(Cursor.getDefaultCursor()); + } } /** @@ -231,6 +239,39 @@ public class ServerGuiApplication extends SingleFrameApplication { } catch (IOException e) { } } + + // Invert focus painters + List keys = new ArrayList(UIManager.getLookAndFeelDefaults().keySet()); + for (Object keyObj:keys) { + if ((keyObj instanceof String)==false) { + continue; + } + String key = (String)keyObj; + + if (key.endsWith("[Focused].backgroundPainter")==false & key.endsWith("[Focused].iconPainter")==false) { + continue; + } + String preKey = key.substring(0,key.indexOf("[")); + String postKey = "backgroundPainter"; + if (key.contains("iconPainter")) { + postKey = "iconPainter"; + } + + logger.finer("Flipping painters of key: "+preKey); + + Object focusPainter = UIManager.getLookAndFeelDefaults().get(preKey+"[Focused]."+postKey); + Object mouseOverPainter = UIManager.getLookAndFeelDefaults().get(preKey+"[MouseOver]."+postKey); + UIManager.getLookAndFeelDefaults().put(preKey+"[Focused]."+postKey,mouseOverPainter); + UIManager.getLookAndFeelDefaults().put(preKey+"[MouseOver]."+postKey,focusPainter); + + if (key.contains("iconPainter")) { + Object focusPainterSelected = UIManager.getLookAndFeelDefaults().get(preKey+"[Focused+Selected]."+postKey); + Object mouseOverPainterSelected = UIManager.getLookAndFeelDefaults().get(preKey+"[MouseOver+Selected]."+postKey); + UIManager.getLookAndFeelDefaults().put(preKey+"[Focused+Selected]."+postKey,mouseOverPainterSelected); + UIManager.getLookAndFeelDefaults().put(preKey+"[MouseOver+Selected]."+postKey,focusPainterSelected); + } + } + return colorName; } } diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadDialog.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadDialog.java index 363342b..87e7043 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadDialog.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadDialog.java @@ -23,6 +23,7 @@ package net.forwardfire.vasc.demo.server.ui.load; import java.awt.BorderLayout; +import java.awt.Cursor; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Frame; @@ -194,17 +195,22 @@ public class JLoadDialog extends JDialog implements ActionListener { if (currentStep <= 0) { return; } - currentStep--; - centerPanel.removeAll(); - LoadStep step = steps.get(currentStep); - centerPanel.add(step.getPanel()); - topLabel.setText(step.getStepTitle()); - step.setupStep(model); - SwingUtilities.updateComponentTreeUI(centerPanel); - if (currentStep==0) { - prev.setEnabled(false); + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + try { + currentStep--; + centerPanel.removeAll(); + LoadStep step = steps.get(currentStep); + centerPanel.add(step.getPanel()); + topLabel.setText(step.getStepTitle()); + step.setupStep(model); + SwingUtilities.updateComponentTreeUI(centerPanel); + if (currentStep==0) { + prev.setEnabled(false); + } + next.setText("Next"); + } finally { + setCursor(Cursor.getDefaultCursor()); } - next.setText("Next"); } public void gotoStepNext() { @@ -221,21 +227,26 @@ public class JLoadDialog extends JDialog implements ActionListener { if (currentStep > steps.size()-1) { return; } - LoadStep step = steps.get(currentStep); - boolean result = step.performStep(model); - if (result==false) { - return; + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + try { + LoadStep step = steps.get(currentStep); + boolean result = step.performStep(model); + if (result==false) { + return; + } + currentStep++; + centerPanel.removeAll(); + step = steps.get(currentStep); + centerPanel.add(step.getPanel()); + topLabel.setText(step.getStepTitle()); + step.setupStep(model); + SwingUtilities.updateComponentTreeUI(centerPanel); + if (currentStep==steps.size()-1) { + next.setText("Finish"); + } + prev.setEnabled(true); + } finally { + setCursor(Cursor.getDefaultCursor()); } - currentStep++; - centerPanel.removeAll(); - step = steps.get(currentStep); - centerPanel.add(step.getPanel()); - topLabel.setText(step.getStepTitle()); - step.setupStep(model); - SwingUtilities.updateComponentTreeUI(centerPanel); - if (currentStep==steps.size()-1) { - next.setText("Finish"); - } - prev.setEnabled(true); } } diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepWriteFile.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepWriteFile.java index 93c54bb..6527d31 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepWriteFile.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepWriteFile.java @@ -62,7 +62,7 @@ public class JLoadStepWriteFile extends JPanel implements LoadStep,ActionListene } public String getStepTitle() { - return "Select Tables"; + return "Write xml to file."; } public JPanel getPanel() { diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadVascXmlWriter.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadVascXmlWriter.java index 5f8c031..0e80e39 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadVascXmlWriter.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadVascXmlWriter.java @@ -223,6 +223,19 @@ public class LoadVascXmlWriter { if (f.getEditReadOnly()!=null) { atts.addAttribute ("", "editReadOnly", "", "", ""+f.getEditReadOnly()); } + if (f.getDefaultValue()!=null) { + atts.addAttribute ("", "defaultValue", "", "", ""+f.getDefaultValue()); + } + if (f.getList()!=null) { + atts.addAttribute ("", "list", "", "", ""+f.getList()); + } + if (f.getEdit()!=null) { + atts.addAttribute ("", "edit", "", "", ""+f.getEdit()); + } + if (f.getCreate()!=null) { + atts.addAttribute ("", "create", "", "", ""+f.getCreate()); + } + //atts.addAttribute ("", "vascGroupId", "", "", model.groupId); xmlWriter.startElement (URI_VASC_LANG, "field", "", atts); diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/laf-colors.properties b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/laf-colors.properties index 78b4673..dc4a3c2 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/laf-colors.properties +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/laf-colors.properties @@ -1,12 +1,18 @@ + # -# Default dark red color thema for pulsefire +# yellow-purple color schema from pulsefire. # -text=#DF0A0A -info=#370A00 -control=#0A1428 -nimbusBase=#00050A -nimbusFocus=#0A6428 -nimbusOrange=#00960A -nimbusBorder=#34415E -nimbusDisabledText=#850F0F -nimbusLightBackground=#050A28 +text=#FF9900 +info=#9F3B00 +control=#5B084C +nimbusBase=#3A0053 +nimbusDisabledText=#3A0053 +nimbusFocus=#FF6600 +nimbusLightBackground=#47184D +nimbusSelectedText=#47184D +nimbusBlueGrey=#661C7D +nimbusGreen=#D2C122 +nimbusBorder=#A018D8 +nimbusSelectionBackground=#BF6204 +ComboBox.background=#380030 +TabbedPane.background=#380030 diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoSwingClient.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoSwingClient.java index e2bcad2..0cf8bcf 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoSwingClient.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoSwingClient.java @@ -22,6 +22,10 @@ package net.forwardfire.vasc.demo.client.swing; +import java.awt.Color; +import java.awt.Font; +import java.io.IOException; +import java.io.InputStream; import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; @@ -36,6 +40,7 @@ import javax.naming.InitialContext; import javax.security.auth.login.LoginContext; import javax.swing.JFrame; import javax.swing.JOptionPane; +import javax.swing.UIManager; import net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuController; import net.forwardfire.vasc.demo.tech.ejb3.user.ClientUserController; @@ -70,6 +75,7 @@ public class VascDemoSwingClient extends SingleFrameApplication { protected void startup() { logger = Logger.getLogger(VascDemoSwingClient.class.getName()); + installColorsLaF(); doLogin(); VascServiceManager vc = null; @@ -187,14 +193,81 @@ public class VascDemoSwingClient extends SingleFrameApplication { return false; } catch (Exception e) { JOptionPane.showMessageDialog(null, "Server error: "+e.getMessage()); - e.printStackTrace(); + //e.printStackTrace(); return false; } } + private String installColorsLaF() { + UIManager.put("TabbedPane.font", Font.decode("SansSerif-BOLD-12")); + UIManager.put("TitledBorder.font", Font.decode("SansSerif-BOLD-16")); + UIManager.put("FireDial.font", Font.decode("SansSerif-9")); + + String colorName = "laf-colors"; + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl==null) { + cl = this.getClass().getClassLoader(); + } + InputStream in = cl.getResourceAsStream("net/forwardfire/vasc/demo/client/swing/resources/"+colorName+".properties"); + if (in==null) { + logger.warning("Color schema not found: "+colorName); + return "unknown"; + } + try { + Properties p = new Properties(); + p.load(in); + for (Object key:p.keySet()) { + String value = p.getProperty(key.toString()); + Color colorValue = Color.decode(value); + UIManager.put(key,colorValue); + } + } catch (IOException e) { + logger.warning("Could not load color schema: "+colorName+" error: "+e.getMessage()); + } finally { + try { + in.close(); + } catch (IOException e) { + } + } + + // Invert focus painters + List keys = new ArrayList(UIManager.getLookAndFeelDefaults().keySet()); + for (Object keyObj:keys) { + if ((keyObj instanceof String)==false) { + continue; + } + String key = (String)keyObj; + + if (key.endsWith("[Focused].backgroundPainter")==false & key.endsWith("[Focused].iconPainter")==false) { + continue; + } + String preKey = key.substring(0,key.indexOf("[")); + String postKey = "backgroundPainter"; + if (key.contains("iconPainter")) { + postKey = "iconPainter"; + } + + logger.finer("Flipping painters of key: "+preKey); + + Object focusPainter = UIManager.getLookAndFeelDefaults().get(preKey+"[Focused]."+postKey); + Object mouseOverPainter = UIManager.getLookAndFeelDefaults().get(preKey+"[MouseOver]."+postKey); + UIManager.getLookAndFeelDefaults().put(preKey+"[Focused]."+postKey,mouseOverPainter); + UIManager.getLookAndFeelDefaults().put(preKey+"[MouseOver]."+postKey,focusPainter); + + if (key.contains("iconPainter")) { + Object focusPainterSelected = UIManager.getLookAndFeelDefaults().get(preKey+"[Focused+Selected]."+postKey); + Object mouseOverPainterSelected = UIManager.getLookAndFeelDefaults().get(preKey+"[MouseOver+Selected]."+postKey); + UIManager.getLookAndFeelDefaults().put(preKey+"[Focused+Selected]."+postKey,mouseOverPainterSelected); + UIManager.getLookAndFeelDefaults().put(preKey+"[MouseOver+Selected]."+postKey,focusPainterSelected); + } + } + + return colorName; + } + public String i18n(Object obj,String key,Object...params) { - if(obj==null) { throw new NullPointerException("Can't get key of null obj"); } - if (key==null) { throw new NullPointerException("key may not be null"); } + if(obj==null) { throw new NullPointerException("Can't get key of null obj"); } + if (key==null) { throw new NullPointerException("key may not be null"); } if(obj instanceof Class) { key=((Class)obj).getName()+"."+key; } else { @@ -203,23 +276,16 @@ public class VascDemoSwingClient extends SingleFrameApplication { return i18n(key,params); } - /** - * Some simple hardcoded i18n function here - * - * @param key - * @param params - * @return - */ - public String i18n(String key,Object...params) { - try { - String text = ResourceBundle.getBundle(RootApplicationBundle.class.getName()).getString(key); - if (params != null) { - MessageFormat mf = new MessageFormat(text); - text = mf.format(params, new StringBuffer(), null).toString(); - } - return text; - } catch(MissingResourceException e){ - return key; - } - } + public String i18n(String key,Object...params) { + try { + String text = ResourceBundle.getBundle(RootApplicationBundle.class.getName()).getString(key); + if (params != null) { + MessageFormat mf = new MessageFormat(text); + text = mf.format(params, new StringBuffer(), null).toString(); + } + return text; + } catch(MissingResourceException e){ + return key; + } + } } diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoUserLoginDialog.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoUserLoginDialog.java index 4688e7f..e6ed9e6 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoUserLoginDialog.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoUserLoginDialog.java @@ -23,7 +23,6 @@ package net.forwardfire.vasc.demo.client.swing; import java.awt.Color; -import java.awt.Component; import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics; @@ -43,6 +42,7 @@ import java.util.TimerTask; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; +import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JOptionPane; @@ -51,47 +51,19 @@ import javax.swing.JPasswordField; import javax.swing.JTextField; /** - * Zwaar gehacke jaas login dialog - * added features: - * - name remebering - * - focus on name field - * - alway on top - * - logo stuff - * - message field - * - *

- * Uses a Swing dialog window to query the user for answers to authentication - * questions. This can be used by a JAAS application to instantiate a - * CallbackHandler + * VascDemoUserLoginDialog used be be true jaas auth module but now only dialog. * - * @see javax.security.auth.callback + * @author Willem Cazander + * @version 1.0 Nov 10, 2012 */ public class VascDemoUserLoginDialog { - private Component parentComponent; private static final int JPasswordFieldLen = 8; private int loginTry = 0; private String connectUrl = null; private String username = null; private String password = null; - /** - * Creates a callback dialog with the default parent window. - */ - public VascDemoUserLoginDialog() { - } - - /** - * Creates a callback dialog and specify the parent window. - * - * @param parentComponent - * the parent window -- specify null for the - * default parent - */ - public VascDemoUserLoginDialog(Component parentComponent) { - this.parentComponent = parentComponent; - } - /** * An interface for recording actions to carry out if the user clicks OK for * the dialog. @@ -105,10 +77,9 @@ public class VascDemoUserLoginDialog { */ public void handle() { this.loginTry++; - /* Collect messages to display in the dialog */ final JPanel loginDesign = new JPanel(); loginDesign.setLayout(new BoxLayout(loginDesign, BoxLayout.PAGE_AXIS)); - //final Image logoImage = Toolkit.getDefaultToolkit().createImage(getClass().getResource("/resources/images/logos/logo.png")); + final Image logoImage = Toolkit.getDefaultToolkit().createImage(getClass().getResource("/net/forwardfire/vasc/demo/client/swing/resources/logo.png")); final JPanel logoPanel = new JPanel() { private static final long serialVersionUID = 10l; protected void paintComponent(Graphics g) { @@ -119,20 +90,14 @@ public class VascDemoUserLoginDialog { // Paint the default look of the panel. super.paintComponent(g2d); - - int offsetX = 0; // for windows systems - boolean isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows") != -1; - if (isWindows) { - offsetX += 25; - } g2d.setColor(Color.BLACK); g2d.fillRect(0,0,getWidth(),getHeight()); g2d.setColor(new Color(238,212,1)); - - //int w = (getWidth()/2)-(logoImage.getWidth(null)/2); - //int h = (getHeight()/2)-(logoImage.getHeight(null)/2); - //g2d.drawImage(logoImage, w, h, this); + + int w = (getWidth()/2)-(logoImage.getWidth(null)/2); + int h = (getHeight()/2)-(logoImage.getHeight(null)/2); + g2d.drawImage(logoImage, w, h, this); } }; logoPanel.setPreferredSize(new Dimension(200, 170)); @@ -146,13 +111,11 @@ public class VascDemoUserLoginDialog { loginDesign.add(namePanel); loginDesign.add(Box.createVerticalStrut(5)); + final List okActions = new ArrayList(2); final GridLayout messagesLayout = new GridLayout(3,2); final JPanel messages = new JPanel(); messages.setLayout(messagesLayout); - /* Collection actions to perform if the user clicks OK */ - final List okActions = new ArrayList(2); - // Add server field JLabel serverName = new JLabel("Server:"); final JTextField serverField = new JTextField(getConnectUrl()); @@ -225,6 +188,7 @@ public class VascDemoUserLoginDialog { /// JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options, Object initialValue) JOptionPane jop = new JOptionPane(loginDesign, JOptionPane.PLAIN_MESSAGE,JOptionPane.OK_CANCEL_OPTION,null,options,name); + JComponent parentComponent = null; JDialog dialog = jop.createDialog(parentComponent,"Vasc Demo Login"); // We alway request focus after the windows gets focus diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/VascDemoSwingClient.properties b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/VascDemoSwingClient.properties index 003c074..28e1472 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/VascDemoSwingClient.properties +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/VascDemoSwingClient.properties @@ -29,4 +29,5 @@ Application.homepage = http://vasc.forwardfire.org/ Application.vendorId = vasc Application.id = vascdemotech Application.lookAndFeel = com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel -#Application.icon = images/icon.png +Application.icon = icon.png + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/icon.png b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3acf3fccad0aa44f3c39d2baf60ffe16c13396d8 GIT binary patch literal 264 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPax1@l&g)GOnYM{_mPZ!4!i_>c-1@awM;BlTGZC5ty z-hY`l2EU{B&R?3OYcL~?Q&9B;pWg%d6E~j5cArkVqk^WinPs927RV<6QE--B^w(GUJ zujHewwO4cLP2HZTju+QI-rOg2W15Ql#?3pK!V+p3r#ksp3g3Em6X-w&Pgg&ebxsLQ E03b$Q)c^nh literal 0 HcmV?d00001 diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/laf-colors.properties b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/laf-colors.properties new file mode 100644 index 0000000..dc4a3c2 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/laf-colors.properties @@ -0,0 +1,18 @@ + +# +# yellow-purple color schema from pulsefire. +# +text=#FF9900 +info=#9F3B00 +control=#5B084C +nimbusBase=#3A0053 +nimbusDisabledText=#3A0053 +nimbusFocus=#FF6600 +nimbusLightBackground=#47184D +nimbusSelectedText=#47184D +nimbusBlueGrey=#661C7D +nimbusGreen=#D2C122 +nimbusBorder=#A018D8 +nimbusSelectionBackground=#BF6204 +ComboBox.background=#380030 +TabbedPane.background=#380030 diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/logo.png b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..7ca618189b2109726c16dfe4a392aa195e502229 GIT binary patch literal 12691 zcmZvDRZtvE6YTb;x1!x(& zn35?tSUPm%iuVBkWB^$SQ4No^b6?K@BF*NV?_&ytqgRC$V$41wuBQ5 zDQz|+qD_z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t`*rA3U9{K~A0+AuFK^z3uo1+v2ayHM zxtUsT#W*#hbOsDg!L>9E5&BmCiUpbyR7oK}frnu#z94fu4iE-{Sk=`$H`7%C%v&0r z8mvmJZdU~%c7ZXfgc$JO+9H5-O=QmFi9mM?>inzfa8%(yZ*!)6ZIMSTyd0o+xh&QM zSj^5+MN-JX!F3?O&~JHkM+PqEL9<&QkF4v{i*uO^sX|YxR)6blIU^#(5Tc9L*vK@0 z8aizkkN7I5>*F^~e@G8ssM%?drZlDY{yPg$9%4P1h4V}Vvt|?BtVG^3E?&TwbII6* zpJz6&AY)Vqe$E6pcm~*M?gm2XieOqJJbkd8(@`R49NZsAKCha2C2zwnzvk-snxy`y z@{mK3L+F=N(5&!t(I$cew8UVITXy;r<1lT%+1LsH zgBd1J$aWy-e=N-9azh#3X_ EA9=M3wEzGB literal 0 HcmV?d00001 diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/I18nController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/I18nController.java new file mode 100644 index 0000000..77f4386 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/I18nController.java @@ -0,0 +1,106 @@ +/* + * Copyright 2009-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.demo.tech.web.beans; + +import java.util.Collection; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.Set; + +import javax.faces.context.FacesContext; + +/** + * I18nController wraps to root application bundle to skip jsf cache. + * + * @author Willem Cazander + * @version 1.0 Jan 7, 2013 + */ +public class I18nController implements Map { + + public ResourceBundle getBundle() { + Locale locale = null; + FacesContext context = FacesContext.getCurrentInstance(); + locale = context.getApplication().getDefaultLocale(); + ResourceBundle bundle = ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle", locale); + return bundle; + } + + @Override + public void clear() { + } + + @Override + public boolean containsKey(Object key) { + return getBundle().containsKey((String)key); + } + + @Override + public boolean containsValue(Object value) { + return false; + } + + @Override + public Set> entrySet() { + return null; + } + + @Override + public String get(Object key) { + return getBundle().getString((String)key); + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public Set keySet() { + return getBundle().keySet(); + } + + @Override + public String put(String key, String value) { + return value; + } + + @Override + public void putAll(Map arg0) { + } + + @Override + public String remove(Object key) { + return (String)key; + } + + @Override + public int size() { + return getBundle().keySet().size(); + } + + @Override + public Collection values() { + return null; + } +} \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/faces-config.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/faces-config.xml index 5c870f8..c61a596 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/faces-config.xml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/faces-config.xml @@ -7,10 +7,12 @@ > + en @@ -20,6 +22,13 @@ + + I18n map bean as workaround for jsf caching. + i18n + net.forwardfire.vasc.demo.tech.web.beans.I18nController + application + + Fixes the context path for root vs non-root deployments. contextPathController diff --git a/vasc-export/vasc-export-jr4o/src/main/java/net/forwardfire/vasc/export/jr4o/JRDynamicDataSourceVascEntry.java b/vasc-export/vasc-export-jr4o/src/main/java/net/forwardfire/vasc/export/jr4o/JRDynamicDataSourceVascEntry.java index b12be28..f996c7e 100644 --- a/vasc-export/vasc-export-jr4o/src/main/java/net/forwardfire/vasc/export/jr4o/JRDynamicDataSourceVascEntry.java +++ b/vasc-export/vasc-export-jr4o/src/main/java/net/forwardfire/vasc/export/jr4o/JRDynamicDataSourceVascEntry.java @@ -30,6 +30,7 @@ import java.util.Map; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascException; +import net.forwardfire.vasc.frontend.VascFrontendDataSelector.EntryFieldSelectType; import net.forwardfire.vasc.lib.jr4o.data.AbstractJRDynamicDataSource; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JRField; @@ -46,6 +47,7 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource { private VascEntry vascEntry = null; + private List fields = null; private long total = -1; private int index = -1; private static final String PREFIX_COLUMN = "COLUMN_"; @@ -61,6 +63,8 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource { this.vascEntry = vascEntry; total = vascEntry.getVascFrontendController().getVascEntryState().getTotalBackendRecords(); + fields = vascEntry.getVascFrontendController().getVascFrontendDataSelector().getFields(EntryFieldSelectType.EXPORT); + // hackje until calc index to page and row. try { data = new ArrayList>(1000); @@ -70,7 +74,7 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource { vascEntry.getVascFrontendController().getVascFrontendActions().refreshData(); for (Object o:vascEntry.getVascFrontendController().getVascEntryState().getEntryDataList()) { List row = new ArrayList(30); - for (VascEntryField c:vascEntry.getVascEntryFields()) { + for (VascEntryField c:fields) { row.add(c.getVascEntryFieldValue().getDisplayValue(c, o)); } data.add(row); @@ -90,10 +94,8 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource { return data.get(index).get(Integer.parseInt(fieldName.substring(7))); } if (fieldName.startsWith(PREFIX_HEADER)) { - return "todo"; // TODO: fixme - //List fields = vascEntry.getVascEntryFields(); - //VascEntryField field = fields.get(Integer.parseInt(fieldName.substring(7))); - //return vascEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(field.getName()); + VascEntryField field = fields.get(Integer.parseInt(fieldName.substring(7))); + return vascEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(field.getName()); } throw new JRException("Unknown column name : " + fieldName); } diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntryEventListener.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntryEventListener.java index 826c08c..d2617d9 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntryEventListener.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntryEventListener.java @@ -51,7 +51,11 @@ public class JSFVascEntryEventListener implements VascEntryFrontendEventListener * @see net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener#getEventTypes() */ public VascFrontendEventType[] getEventTypes() { - VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.POST_READ}; + VascFrontendEventType[] result = { + VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, + VascEntryFrontendEventListener.VascFrontendEventType.POST_DELETE, + VascEntryFrontendEventListener.VascFrontendEventType.POST_UPDATE + }; return result; } diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntrySupportBean.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntrySupportBean.java index 2cc4d61..d63a118 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntrySupportBean.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascEntrySupportBean.java @@ -87,8 +87,6 @@ public class JSFVascEntrySupportBean implements Serializable { private Boolean backendMoveable = null; private Boolean backendSearchable = null; private Boolean backendPageable = null; - private Boolean sortOrder = null; - private String sortField = null; private VascEntryExport selectedExporter = null; private String selectedExporterAction = "null"; private String selectedDirectPage = "null"; @@ -441,8 +439,6 @@ public class JSFVascEntrySupportBean implements Serializable { VascEntry entry = comp.getVascEntry(); VascEntryField field = entry.getVascEntryFieldById(fieldIdString); entry.getVascFrontendController().getVascFrontendActions().sortAction(field); - sortOrder = entry.getVascFrontendController().getVascEntryState().getVascBackendState().isSortAscending(); - sortField = field.getId(); } public boolean getRenderBackAction() { @@ -855,20 +851,6 @@ public class JSFVascEntrySupportBean implements Serializable { return tablePagesDataModel; } - /** - * @return the sortOrder - */ - public Boolean getSortOrder() { - return sortOrder; - } - - /** - * @return the sortField - */ - public String getSortField() { - return sortField; - } - /** * @return the selectedExporter */ diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascFrontendRenderer.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascFrontendRenderer.java index f1fe2b1..87cdb44 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascFrontendRenderer.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascFrontendRenderer.java @@ -38,8 +38,6 @@ import net.forwardfire.vasc.frontend.web.jsf.ui.JSFList; import net.forwardfire.vasc.frontend.web.jsf.ui.JSFText; import net.forwardfire.vasc.frontend.web.jsf.ui.JSFTextArea; - - /** * Given the jsf vasc renderer its own class * @@ -56,8 +54,6 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser logger = Logger.getLogger(JSFVascFrontendRenderer.class.getName()); } - // Frontend Stuff - /** * @see net.forwardfire.vasc.frontend.VascFrontend#getFrontendType() */ @@ -65,10 +61,9 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser return "jsf"; } - protected void addUiComponents() { VascFrontendController vfd = getVascEntry().getVascFrontendController(); - + // required UI components vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_LABEL,JSFLabel.class.getName()); vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_TEXT, JSFText.class.getName()); @@ -82,7 +77,7 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser //vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_COLOR , JSFColorChooser.class.getName()); } - + /** * @see net.forwardfire.vasc.frontend.VascFrontend#renderDelete(java.lang.Object) */ @@ -92,7 +87,7 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId()); comp.setRenderFacetState("deleteView"); } - + /** * @see net.forwardfire.vasc.frontend.VascFrontend#renderEdit(java.lang.Object) */ @@ -114,7 +109,7 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser comp.getSupportBean().setSelected(selBean); } - + /** * @see net.forwardfire.vasc.frontend.VascFrontend#renderExport(net.forwardfire.vasc.core.entry.VascEntryExport) */ @@ -125,7 +120,7 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser comp.setRenderFacetState("exportView"); comp.getSupportBean().setSelectedExporter(exporter); } - + /** * @see net.forwardfire.vasc.frontend.VascFrontend#renderView() */ @@ -134,10 +129,5 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot(); JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId()); comp.setRenderFacetState("listView"); - - //if (comp.getSupportBean().getSelected()!=null) { - // comp.getSupportBean().getSelected().setRealValue(false); - // comp.getSupportBean().setSelected(null); - //} } -} \ No newline at end of file +} diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponent.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponent.java index f5662ed..83d2624 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponent.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponent.java @@ -26,7 +26,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.Locale; import java.util.logging.Logger; import javax.el.ValueExpression; @@ -57,63 +56,62 @@ import net.forwardfire.vasc.frontend.web.jsf.ui.JSFListModel; */ public class JSFVascUIComponent extends UIComponentBase { - public static final String FAMILY = "vasc.jsf.component.family"; - public static final String ENTRY_SUPPORT_VAR_KEY = "entrySupportVar"; - public static final String TABLE_RECORD_VAR_KEY = "tableRecordVar"; - public static final String INJECT_EDIT_FIELDS_ID = "injectEditFieldsId"; - public static final String INJECT_TABLE_OPTIONS_ID = "injectTableOptionsId"; - public static final String INJECT_TABLE_COLUMNS_ID = "injectTableColumnsId"; - public static final String DISABLE_LINK_COLUMNS = "disableLinkColumns"; - public static final String INJECT_TABLE_OPTIONS_ON_CHANGE = "injectTableOptionOnChange"; - - private JSFVascFrontendRenderer renderer = null; - private JSFVascEntrySupportBean supportBean = null; - private String renderFacetState = null; - private VascEntryLink link = null; - private VascEntryState linkState = null; - private VascEntryState state = null; - private Object stateEditId = null; - private Logger logger = null; - private Boolean initClear = null; - private String injectTableOptionOnChange = null; - - public JSFVascUIComponent() { - logger = Logger.getLogger(JSFVascUIComponent.class.getName()); - } - - public String getFamily() { - return FAMILY; - } + public static final String FAMILY = "vasc.jsf.component.family"; + public static final String ENTRY_SUPPORT_VAR_KEY = "entrySupportVar"; + public static final String TABLE_RECORD_VAR_KEY = "tableRecordVar"; + public static final String INJECT_EDIT_FIELDS_ID = "injectEditFieldsId"; + public static final String INJECT_TABLE_OPTIONS_ID = "injectTableOptionsId"; + public static final String INJECT_TABLE_COLUMNS_ID = "injectTableColumnsId"; + public static final String DISABLE_LINK_COLUMNS = "disableLinkColumns"; + public static final String INJECT_TABLE_OPTIONS_ON_CHANGE = "injectTableOptionOnChange"; + + private JSFVascFrontendRenderer renderer = null; + private JSFVascEntrySupportBean supportBean = null; + private String renderFacetState = null; + private VascEntryLink link = null; + private VascEntryState linkState = null; + private VascEntryState state = null; + private Object stateEditId = null; + private Logger logger = null; + private Boolean initClear = null; + private String injectTableOptionOnChange = null; + + public JSFVascUIComponent() { + logger = Logger.getLogger(JSFVascUIComponent.class.getName()); + } + + public String getFamily() { + return FAMILY; + } + + @Override + public Object saveState(FacesContext facesContext) { + logger.fine("Save State"); + Object values[] = new Object[5]; + values[0] = super.saveState(facesContext); + values[1] = renderer; + values[2] = supportBean; + values[3] = renderFacetState; + values[4] = this.getAttributes().get(INJECT_TABLE_OPTIONS_ON_CHANGE); + return values; + } - @Override - public Object saveState(FacesContext facesContext) { - logger.fine("Save State"); - Object values[] = new Object[5]; - values[0] = super.saveState(facesContext); - values[1] = renderer; - values[2] = supportBean; - values[3] = renderFacetState; - values[4] = this.getAttributes().get(INJECT_TABLE_OPTIONS_ON_CHANGE); - return values; + @Override + public void restoreState(FacesContext facesContext, Object state) { + logger.fine("Resotre State"); + Object values[] = (Object[])state; + super.restoreState(facesContext, values[0]); + renderer = (JSFVascFrontendRenderer) values[1]; + supportBean = (JSFVascEntrySupportBean) values[2]; + renderFacetState = (String) values[3]; + injectTableOptionOnChange = (String) values[4]; - } - - @Override - public void restoreState(FacesContext facesContext, Object state) { - logger.fine("Resotre State"); - Object values[] = (Object[])state; - super.restoreState(facesContext, values[0]); - renderer = (JSFVascFrontendRenderer) values[1]; - supportBean = (JSFVascEntrySupportBean) values[2]; - renderFacetState = (String) values[3]; - injectTableOptionOnChange = (String) values[4]; - - // TODO: check if we can move this some day... + // TODO: check if we can move this some day... String entrySupportVar = (String)getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY); ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+"}", Object.class); ve2.setValue(FacesContext.getCurrentInstance().getELContext(), getSupportBean()); - } - + } + static public JSFVascUIComponent findVascParent(UIComponent comp) { if (comp==null) { return null; @@ -146,7 +144,7 @@ public class JSFVascUIComponent extends UIComponentBase { } return null; } - + /** * Finds component with the given id */ @@ -229,7 +227,7 @@ public class JSFVascUIComponent extends UIComponentBase { // edit action copyed try { - VascEntry entry = supportBean.getVascEntry(); + VascEntry entry = supportBean.getVascEntry(); entry.getVascFrontendController().getVascEntryState().setEditCreate(false); entry.getVascFrontendController().fireVascFrontendEvent(entry, VascFrontendEventType.SELECT, rowObject); entry.getVascFrontendController().getVascEntryState().setEntryDataObject(rowObject); @@ -263,46 +261,44 @@ public class JSFVascUIComponent extends UIComponentBase { super.encodeBegin(context); } - public UIComponent getCurrentView() { - UIComponent result = getFacet(renderFacetState); - if (result==null) { - throw new IllegalArgumentException("Could not get facet: "+renderFacetState); - } - return result; - } - - public JSFVascEntrySupportBean getSupportBean() { - return supportBean; - } - - public void setRenderFacetState(String renderFacetState) { - this.renderFacetState=renderFacetState; - } - - public String getRenderFacetState() { - return renderFacetState; - } - + public UIComponent getCurrentView() { + UIComponent result = getFacet(renderFacetState); + if (result==null) { + throw new IllegalArgumentException("Could not get facet: "+renderFacetState); + } + return result; + } + + public JSFVascEntrySupportBean getSupportBean() { + return supportBean; + } + + public void setRenderFacetState(String renderFacetState) { + this.renderFacetState=renderFacetState; + } + + public String getRenderFacetState() { + return renderFacetState; + } + /** * @return the injectTableOptionOnChange */ public String getInjectTableOptionOnChange() { return injectTableOptionOnChange; } - + /** * @param injectTableOptionOnChange the injectTableOptionOnChange to set */ public void setInjectTableOptionOnChange(String injectTableOptionOnChange) { this.injectTableOptionOnChange = injectTableOptionOnChange; } - + public VascEntry createClonedVascEntry() { - - VascController vascController = (VascController)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(VascRequestFacesFilter.REQ_VASC_CONTOLLER); String entryId = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(VascRequestFacesFilter.REQ_VASC_ENTRY_ID); - + if (link!=null) { entryId = link.getVascEntryId(); } @@ -314,8 +310,6 @@ public class JSFVascUIComponent extends UIComponentBase { if (entry==null) { throw new NullPointerException("Could not get '"+entryId+"' from : "+vascController); } - - try { vascController.getVascEntryConfigController().configVascFrontendController(vascController, entry); } catch (Exception e1) { @@ -410,4 +404,4 @@ public class JSFVascUIComponent extends UIComponentBase { } } } -} \ No newline at end of file +} diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponentRenderer.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponentRenderer.java index e6e7804..0339f04 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponentRenderer.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/JSFVascUIComponentRenderer.java @@ -419,14 +419,14 @@ public class JSFVascUIComponentRenderer extends Renderer { orderUp.setId(viewRoot.createUniqueId()); orderUp.setEscape(false); orderUp.setValue("↑"); // ↑ - ValueExpression ren2 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".sortOrder==true and "+entrySupportVar+".sortField=='"+c.getId()+"'}", Boolean.class); + ValueExpression ren2 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".vascEntry.vascFrontendController.vascEntryState.vascBackendState.sortAscending==true and "+entrySupportVar+".vascEntry.vascFrontendController.vascEntryState.vascBackendState.sortField=='"+c.getId()+"'}", Boolean.class); orderUp.setValueExpression("rendered", ren2); HtmlOutputText orderDown = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE); orderDown.setId(viewRoot.createUniqueId()); orderDown.setEscape(false); orderDown.setValue("↓"); // ↓ - ValueExpression ren3 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".sortOrder==false and "+entrySupportVar+".sortField=='"+c.getId()+"'}", Boolean.class); + ValueExpression ren3 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".vascEntry.vascFrontendController.vascEntryState.vascBackendState.sortAscending==false and "+entrySupportVar+".vascEntry.vascFrontendController.vascEntryState.vascBackendState.sortField=='"+c.getId()+"'}", Boolean.class); orderDown.setValueExpression("rendered", ren3); link.getChildren().add(out2); diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascDataBackendBean.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascDataBackendBean.java index fc15bb5..23712c9 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascDataBackendBean.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascDataBackendBean.java @@ -29,6 +29,7 @@ import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.entry.VascEntryFieldValue; import net.forwardfire.vasc.core.VascException; +import net.forwardfire.vasc.frontend.VascFrontendDataSelector.EntryFieldSelectType; @@ -63,7 +64,7 @@ public class VascDataBackendBean implements Serializable { if (index>entry.getVascEntryFields().size()) { throw new IllegalArgumentException("Index is bigger then total field size: "+index); } - return entry.getVascFrontendController().getVascFrontendDataSelector().getFieldsList().get(index); + return entry.getVascFrontendController().getVascFrontendDataSelector().getFields(EntryFieldSelectType.ALL).get(index); } static public int getIndexId(VascEntryField field) { diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascRequestFacesFilter.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascRequestFacesFilter.java index 9ec938c..6154477 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascRequestFacesFilter.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/VascRequestFacesFilter.java @@ -94,20 +94,19 @@ public class VascRequestFacesFilter implements Filter { className = className.substring(atIndex+1); } try { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - if (cl == null) { - cl = className.getClass().getClassLoader(); - } - Class clazz = cl.loadClass(className); - if (classArgument==null) { - vascControllerProvider = (VascControllerProvider)clazz.newInstance(); - } else { - vascControllerProvider = (VascControllerProvider)clazz.getConstructor(String.class).newInstance(classArgument); - } + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl == null) { + cl = className.getClass().getClassLoader(); + } + Class clazz = cl.loadClass(className); + if (classArgument==null) { + vascControllerProvider = (VascControllerProvider)clazz.newInstance(); + } else { + vascControllerProvider = (VascControllerProvider)clazz.getConstructor(String.class).newInstance(classArgument); + } } catch (Exception e) { throw new ServletException("Could not create VascControllerProvider: "+e.getMessage(),e); } - } /** diff --git a/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java b/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java index 05ed4db..874ba7d 100644 --- a/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java +++ b/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java @@ -56,16 +56,25 @@ public class VascBundleCheckEntryKeys { } public Map collectVascKeys(VascEntry ve) { + String value = ve.getId(); + if (ve.getVascGroupId()!=null) { + if (value.toLowerCase().startsWith(ve.getVascGroupId().toLowerCase())) { + value = value.substring(ve.getVascGroupId().length()); + if (Character.isLetterOrDigit(value.charAt(0))==false) { + value = value.substring(1); + } + } + } Map keys = new HashMap(300); - keys.put(ve.getName(), ve.getId()); + keys.put(ve.getName(), value); keys.put(ve.getImage(), ve.getId()); - keys.put(ve.getListDescription(), ve.getId()); + keys.put(ve.getListDescription(), "View list of "+value); keys.put(ve.getListImage(), imagePrefix+ve.getId()+imagePostfix); - keys.put(ve.getEditDescription(), ve.getId()); + keys.put(ve.getEditDescription(), "Edit your "+value); keys.put(ve.getEditImage(), imagePrefix+ve.getId()+imagePostfix); - keys.put(ve.getDeleteDescription(), ve.getId()); + keys.put(ve.getDeleteDescription(), "Delete this "+value); keys.put(ve.getDeleteImage(), imagePrefix+ve.getId()+imagePostfix); - keys.put(ve.getCreateDescription(), ve.getId()); + keys.put(ve.getCreateDescription(), "Create new "+value); keys.put(ve.getCreateImage(), imagePrefix+ve.getId()+imagePostfix); for (VascEntryField vef:ve.getVascEntryFields()) { keys.put(vef.getName(), vef.getId()); diff --git a/vasc-xpql-ejb3-client/src/main/resources/META-INF/vasc/vasc-xpql-ejb3.eld b/vasc-xpql-ejb3-client/src/main/resources/META-INF/vasc/vasc-xpql-ejb3.eld index 1655f1d..725a6cb 100644 --- a/vasc-xpql-ejb3-client/src/main/resources/META-INF/vasc/vasc-xpql-ejb3.eld +++ b/vasc-xpql-ejb3-client/src/main/resources/META-INF/vasc/vasc-xpql-ejb3.eld @@ -6,7 +6,7 @@ xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd" providerName="vasc.forwardfire.net" name="Vasc EJB3 Xpql query loading" - id="mod-vasc-xpql-ejb3" + id="vasc-xpql-ejb3" > queries = new HashMap(100); @PostConstruct @@ -73,117 +73,114 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa long s = System.currentTimeMillis(); Map keys = loadKeys(); - for (String key:keys.keySet()) { - String value = keys.get(key); - if (key.startsWith("load")) { - loadResource(value); - } - if ("persistenceUnit".equals(key)) { - logger.fine("getting EntityManager: "+value); - entityManager = (EntityManager)new InitialContext().lookup(value); - } - } + for (String key:keys.keySet()) { + String value = keys.get(key); + if (key.startsWith("load")) { + loadResource(value); + } + if ("persistenceUnit".equals(key)) { + logger.fine("getting EntityManager: "+value); + entityManager = (EntityManager)new InitialContext().lookup(value); + } + } long t = System.currentTimeMillis()-s; logger.info("Total loaded xpql queries: "+queries.size()+" in "+t+" ms."); } catch (Exception e) { throw new RuntimeException("Error while load xpql resources error: "+e.getMessage(),e); } } - - /** - * Loads xtes-xpql-ejb3.xml from meta-inf and gives the keys - */ - protected Map loadKeys() throws IOException { - - Properties properties = new Properties(); - - logger.fine("Getting urls"); - Enumeration e = Thread.currentThread().getContextClassLoader().getResources("META-INF/xtes-xpql-ejb3.xml"); - while(e.hasMoreElements()) { - URL u = e.nextElement(); - logger.finer("Loading reletive namespaces of: "+u+" for: META-INF/xtes-xpql-ejb3.xml"); - InputStream in = u.openStream(); - try { - properties.loadFromXML(in); - } finally { - if (in!=null) { - in.close(); - } - } - } - - - e = Thread.currentThread().getContextClassLoader().getResources("/META-INF/xtes-xpql-ejb3.xml"); - while(e.hasMoreElements()) { - URL u = e.nextElement(); - logger.finer("Loading root namespaces of: "+u+" for: /META-INF/xtes-xpql-ejb3.xml"); - InputStream in = u.openStream(); - try { - properties.loadFromXML(in); - } finally { - if (in!=null) { - in.close(); - } - } - } - logger.fine("done loading"); - - Map result = new HashMap(20); - for (Object key:properties.keySet()) { - if (key instanceof String) { - String key2 = (String) key; - String value = properties.getProperty(key2); - result.put(key2, value); - } - } - return result; - } + /** + * Loads xtes-xpql-ejb3.xml from meta-inf and gives the keys + */ + protected Map loadKeys() throws IOException { + + Properties properties = new Properties(); + logger.fine("Getting urls"); + Enumeration e = Thread.currentThread().getContextClassLoader().getResources("META-INF/xtes-xpql-ejb3.xml"); + while(e.hasMoreElements()) { + URL u = e.nextElement(); + logger.finer("Loading reletive namespaces of: "+u+" for: META-INF/xtes-xpql-ejb3.xml"); + InputStream in = u.openStream(); + try { + properties.loadFromXML(in); + } finally { + if (in!=null) { + in.close(); + } + } + } + + e = Thread.currentThread().getContextClassLoader().getResources("/META-INF/xtes-xpql-ejb3.xml"); + while(e.hasMoreElements()) { + URL u = e.nextElement(); + logger.finer("Loading root namespaces of: "+u+" for: /META-INF/xtes-xpql-ejb3.xml"); + InputStream in = u.openStream(); + try { + properties.loadFromXML(in); + } finally { + if (in!=null) { + in.close(); + } + } + } + logger.fine("done loading"); + + Map result = new HashMap(20); + for (Object key:properties.keySet()) { + if (key instanceof String) { + String key2 = (String) key; + String value = properties.getProperty(key2); + result.put(key2, value); + } + } + return result; + } - private void loadResource(String resource) { - XPQLParser parser = new XPQLParser(); - logger.fine("Try loading: "+resource); - try { + private void loadResource(String resource) { + XPQLParser parser = new XPQLParser(); + logger.fine("Try loading: "+resource); + try { parser.parseResource(resource); } catch (Exception e) { throw new RuntimeException("Could not load xpql resource: "+resource+" error: "+e.getMessage(),e); } - QueryStore store = parser.getQueryStore(); - - for (String key:store.getQueryNames()) { - Query q = store.getQuery(key); - + QueryStore store = parser.getQueryStore(); + + for (String key:store.getQueryNames()) { + Query q = store.getQuery(key); + queries.put(q.getName(),q); - String out = "\n\n=========== SQL: "+q.getName()+"\n"; - //out +=q.toSQL(q); - out +="=========== XML: "+q.getName()+"\n"; - out +=q.toXML(q); - //out +="=========== Edit: "+q.getName()+"\n"; - //out +=q.toEdit(q); - out +="=========== Prepard: "+q.getName()+"\n"; - out +=q.toPreparedSQL(q)+"\n"; - logger.finer("FOUND Query: "+out); - } - } + String out = "\n\n=========== SQL: "+q.getName()+"\n"; + //out +=q.toSQL(q); + out +="=========== XML: "+q.getName()+"\n"; + out +=q.toXML(q); + //out +="=========== Edit: "+q.getName()+"\n"; + //out +=q.toEdit(q); + out +="=========== Prepard: "+q.getName()+"\n"; + out +=q.toPreparedSQL(q)+"\n"; + logger.finer("FOUND Query: "+out); + } + } - public Query getQuery(String name) { - Query q = queries.get(name); - return q; - } - - @SuppressWarnings("unchecked") + public Query getQuery(String name) { + Query q = queries.get(name); + return q; + } + + @SuppressWarnings("unchecked") public List execute(Query query) { - String sql = query.toPreparedSQL(query); - logger.finer("Executing: "+query.getName()+" sql: "+sql); - javax.persistence.Query q2 = null; - if (Query.QueryType.hql==query.getType()) { - q2 = entityManager.createQuery(sql); - } - if (Query.QueryType.sql==query.getType()) { - q2 = entityManager.createNativeQuery(sql); - } - + String sql = query.toPreparedSQL(query); + logger.finer("Executing: "+query.getName()+" sql: "+sql); + javax.persistence.Query q2 = null; + if (Query.QueryType.hql==query.getType()) { + q2 = entityManager.createQuery(sql); + } + if (Query.QueryType.sql==query.getType()) { + q2 = entityManager.createNativeQuery(sql); + } + // TODO: move this hack to xtest xpql if (query.getProperty("limit")!=null) { int max = new Integer(query.getPropertyString("limit")); @@ -193,9 +190,8 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa int offset = new Integer(query.getPropertyString("offset")); q2.setFirstResult(offset); } - - - List options = query.getOrderQueryParameterValues(); + + List options = query.getOrderQueryParameterValues(); int i=1; for ( QueryParameterValue value : options ) { Object para = value.getValue(); @@ -208,20 +204,19 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa } return q2.getResultList(); } - - @SuppressWarnings("unchecked") + + @SuppressWarnings("unchecked") public Object executeObject(Query query) { - String sql = query.toPreparedSQL(query); - logger.finer("Executing: "+query.getName()+" sql: "+sql); - javax.persistence.Query q2 = null; - if (Query.QueryType.hql==query.getType()) { - q2 = entityManager.createQuery(sql); - } - if (Query.QueryType.sql==query.getType()) { - q2 = entityManager.createNativeQuery(sql); - } - - + String sql = query.toPreparedSQL(query); + logger.finer("Executing: "+query.getName()+" sql: "+sql); + javax.persistence.Query q2 = null; + if (Query.QueryType.hql==query.getType()) { + q2 = entityManager.createQuery(sql); + } + if (Query.QueryType.sql==query.getType()) { + q2 = entityManager.createNativeQuery(sql); + } + // TODO: move this hack to xtest xpql if (query.getProperty("limit")!=null) { int max = new Integer(query.getPropertyString("limit")); @@ -231,8 +226,8 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa int offset = new Integer(query.getPropertyString("offset")); q2.setFirstResult(offset); } - - List options = query.getOrderQueryParameterValues(); + + List options = query.getOrderQueryParameterValues(); int i=1; for ( QueryParameterValue value : options ) { Object para = value.getValue(); @@ -255,9 +250,9 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa } } return result; - } catch (Exception se) { - throw new RuntimeException("Transaction error: "+se.getMessage(),se); - } + } catch (Exception se) { + throw new RuntimeException("Transaction error: "+se.getMessage(),se); + } } public List execute(String name,Map parameters) { @@ -283,59 +278,59 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa } public Integer executeUpdate(Query query) { - String sql = query.toPreparedSQL(query); - logger.fine("Executing: "+query.getName()+" sql: "+sql); - try { - javax.persistence.Query q2 = null; - if (Query.QueryType.hql==query.getType()) { - q2 = entityManager.createQuery(sql); - List options = query.getOrderQueryParameterValues(); - int i=1; - for ( QueryParameterValue value : options ) { - Object para = value.getValue(); - if(para==null) { - para = value.getDefaultValue(); - } - logger.finest( "nr: " + i + " value: " + para+" name: "+value.getName()); - q2.setParameter(i,para); - i++; - } - utx.begin(); - Integer result = q2.executeUpdate(); - utx.commit(); - return result; - } - - if (Query.QueryType.sql==query.getType()) { - q2 = entityManager.createNativeQuery(sql); - List options = query.getOrderQueryParameterValues(); - int i=1; - for ( QueryParameterValue value : options ) { - Object para = value.getValue(); - if(para==null) { - para = value.getDefaultValue(); - } - logger.finest( "nr: " + i + " value: " + para+" name: "+value.getName()); - q2.setParameter(i,para); - i++; - } - utx.begin(); - Integer result = q2.executeUpdate(); + String sql = query.toPreparedSQL(query); + logger.fine("Executing: "+query.getName()+" sql: "+sql); + try { + javax.persistence.Query q2 = null; + if (Query.QueryType.hql==query.getType()) { + q2 = entityManager.createQuery(sql); + List options = query.getOrderQueryParameterValues(); + int i=1; + for ( QueryParameterValue value : options ) { + Object para = value.getValue(); + if(para==null) { + para = value.getDefaultValue(); + } + logger.finest( "nr: " + i + " value: " + para+" name: "+value.getName()); + q2.setParameter(i,para); + i++; + } + utx.begin(); + Integer result = q2.executeUpdate(); utx.commit(); - return result; - } - } catch (Exception se) { - throw new RuntimeException("Transaction error: "+se.getMessage(),se); - } - throw new IllegalStateException("unknow query type"); + return result; + } + + if (Query.QueryType.sql==query.getType()) { + q2 = entityManager.createNativeQuery(sql); + List options = query.getOrderQueryParameterValues(); + int i=1; + for ( QueryParameterValue value : options ) { + Object para = value.getValue(); + if(para==null) { + para = value.getDefaultValue(); + } + logger.finest( "nr: " + i + " value: " + para+" name: "+value.getName()); + q2.setParameter(i,para); + i++; + } + utx.begin(); + Integer result = q2.executeUpdate(); + utx.commit(); + return result; + } + } catch (Exception se) { + throw new RuntimeException("Transaction error: "+se.getMessage(),se); + } + throw new IllegalStateException("unknow query type"); } public Integer executeUpdate(String name,Map parameters) { Query query = getQuery(name); for (String key:parameters.keySet()) { - Object value = parameters.get(key); - query.setQueryParameter(key, value); - } + Object value = parameters.get(key); + query.setQueryParameter(key, value); + } return executeUpdate(query); } } diff --git a/vasc-xpql/src/main/resources/META-INF/vasc/vasc-xpql.eld b/vasc-xpql/src/main/resources/META-INF/vasc/vasc-xpql.eld index 0f11ea6..43752f3 100644 --- a/vasc-xpql/src/main/resources/META-INF/vasc/vasc-xpql.eld +++ b/vasc-xpql/src/main/resources/META-INF/vasc/vasc-xpql.eld @@ -6,7 +6,7 @@ xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd" providerName="vasc.forwardfire.net" name="Xpql query loading" - id="mod-vasc-xpql" + id="vasc-xpql" >