2
0
Fork 0

Switch to new meta model,fixed small bugs and made demo work pretty oke.

This commit is contained in:
Willem Cazander 2013-01-11 23:48:36 +01:00
parent afd821c360
commit b3635cf64d
46 changed files with 1055 additions and 688 deletions

18
pom.xml
View file

@ -86,7 +86,7 @@
<jldap.version>4.3</jldap.version> <jldap.version>4.3</jldap.version>
<!-- vasc-backend-metamodel --> <!-- vasc-backend-metamodel -->
<metamodel.version>3.1.3-SNAPSHOT</metamodel.version> <metamodel.version>3.2.5</metamodel.version>
<!-- vasc-backend-mongo --> <!-- vasc-backend-mongo -->
<mongo-java-driver.version>2.7.3</mongo-java-driver.version> <mongo-java-driver.version>2.7.3</mongo-java-driver.version>
@ -107,18 +107,18 @@
<jasperreports.version>4.5.1</jasperreports.version> <jasperreports.version>4.5.1</jasperreports.version>
<!-- vasc-demo-tech-core --> <!-- vasc-demo-tech-core -->
<logback-access.version>1.0.3</logback-access.version> <logback-access.version>1.0.9</logback-access.version>
<logback-classic.version>1.0.3</logback-classic.version> <logback-classic.version>1.0.9</logback-classic.version>
<jul-to-slf4j.version>1.6.4</jul-to-slf4j.version> <jul-to-slf4j.version>1.6.4</jul-to-slf4j.version>
<log4j-over-slf4j.version>1.6.4</log4j-over-slf4j.version> <log4j-over-slf4j.version>1.6.4</log4j-over-slf4j.version>
<commons-io.version>2.3</commons-io.version> <commons-io.version>2.4</commons-io.version>
<bsaf.version>1.9.2</bsaf.version> <bsaf.version>1.9.2</bsaf.version>
<!-- vasc-demo-tech-core jdbc drivers --> <!-- vasc-demo-tech-core jdbc drivers -->
<postgresql.version>9.1-901.jdbc4</postgresql.version> <postgresql.version>9.1-901-1.jdbc4</postgresql.version>
<mysql-connector-java.version>5.1.20</mysql-connector-java.version> <mysql-connector-java.version>5.1.22</mysql-connector-java.version>
<h2.version>1.3.167</h2.version> <h2.version>1.3.170</h2.version>
<derby.version>10.8.2.2</derby.version> <derby.version>10.9.1.0</derby.version>
<!-- Vasc Hibernate integration --> <!-- Vasc Hibernate integration -->
<hibernate-validator.version>3.1.0.CR1</hibernate-validator.version> <hibernate-validator.version>3.1.0.CR1</hibernate-validator.version>
@ -148,7 +148,7 @@
<el-api.version>2.2.1-b04</el-api.version> <el-api.version>2.2.1-b04</el-api.version>
<quartz.version>1.6.3</quartz.version> <quartz.version>1.6.3</quartz.version>
<jbosssx-client.version>3.0.0.CR2</jbosssx-client.version> <jbosssx-client.version>3.0.0.CR2</jbosssx-client.version>
<tomee.version>1.5.1-SNAPSHOT</tomee.version> <tomee.version>1.5.1</tomee.version>
<!-- XML deps --> <!-- XML deps -->
<saxon.version>9.1.0.8</saxon.version> <saxon.version>9.1.0.8</saxon.version>

View file

@ -8,21 +8,8 @@
- demo menu - demo menu
- demo wiki - demo wiki
- hotdeploy
- null list option mongo query - null list option mongo query
- sql conn limit
- mongo backend limit - mongo backend limit
Build layout:
lib/
demo/
deploy/
config/
workdir/
logs/
- remote ejb3
- encodeing select model - encodeing select model
- lcoale select model - lcoale select model
- x4o template - x4o template

View file

@ -102,7 +102,7 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
i++; i++;
} }
if (isPageable() && state.getPageSize()>0) { if (isPageable() && state.getPageSize()>0) {
q.setFirstResult(state.getPageIndex()); q.setFirstResult(state.getPageIndex()*state.getPageSize());
q.setMaxResults(state.getPageSize()); q.setMaxResults(state.getPageSize());
} }
List<Object> data = q.list(); List<Object> data = q.list();

View file

@ -102,7 +102,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
i++; i++;
} }
if (isPageable() && state.getPageSize()>0) { if (isPageable() && state.getPageSize()>0) {
q.setFirstResult(state.getPageIndex()); q.setFirstResult(state.getPageIndex()*state.getPageSize());
q.setMaxResults(state.getPageSize()); q.setMaxResults(state.getPageSize());
} }
if (emTransaction) { if (emTransaction) {

View file

@ -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" 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" providerName="vasc.forwardfire.net"
name="Vasc Backend JPA" name="Vasc Backend JPA"
id="mod-vasc-backend-jpa" id="vasc-backend-jpa"
> >
<description>Provides VASC JPA backend support.</description> <description>Provides VASC JPA backend support.</description>
<namespace uri="http://vasc.forwardfire.net/xml/ns/vasc-backend-jpa" <namespace uri="http://vasc.forwardfire.net/xml/ns/vasc-backend-jpa"

View file

@ -61,6 +61,8 @@ public class LdapVascBackend extends AbstractVascBackend {
private String keyAttribute = null; private String keyAttribute = null;
private String ldapFilter = null; private String ldapFilter = null;
private String createObjectClass = null; private String createObjectClass = null;
private int timeLimit = 10000;
private boolean referralFollowing = true;
/** /**
* @return the ldapConnectionProvider * @return the ldapConnectionProvider
@ -75,9 +77,6 @@ public class LdapVascBackend extends AbstractVascBackend {
public void setLdapConnectionProvider(LdapConnectionProvider ldapConnectionProvider) { public void setLdapConnectionProvider(LdapConnectionProvider ldapConnectionProvider) {
this.ldapConnectionProvider = ldapConnectionProvider; this.ldapConnectionProvider = ldapConnectionProvider;
} }
/** /**
* @see net.forwardfire.vasc.backend.VascBackend#execute() * @see net.forwardfire.vasc.backend.VascBackend#execute()
@ -88,23 +87,21 @@ public class LdapVascBackend extends AbstractVascBackend {
List<Object> result = new ArrayList<Object>(50); List<Object> result = new ArrayList<Object>(50);
try { try {
LDAPSearchConstraints cons = new LDAPSearchConstraints(); LDAPSearchConstraints cons = new LDAPSearchConstraints();
cons.setBatchSize( 0 ); cons.setBatchSize( 0 );
cons.setTimeLimit( 10000 ) ; cons.setTimeLimit(getTimeLimit() ) ;
cons.setReferralFollowing(true); cons.setReferralFollowing(isReferralFollowing());
connection.setConstraints(cons); connection.setConstraints(cons);
int searchScope = LDAPConnection.SCOPE_ONE; int searchScope = LDAPConnection.SCOPE_ONE;
String searchBase = baseDN; String searchBase = baseDN;
//System.out.println("Reading object :" + searchBase + " with filter: " + ldapFilter);
LDAPSearchResults searchResults = connection.search( LDAPSearchResults searchResults = connection.search(
searchBase, // object to read searchBase, // object to read
searchScope, // scope - read single object searchScope, // scope - read single object
ldapFilter, // search filter getLdapFilter(), // search filter
null, // return all attributes null, // return all attributes
false); // return attrs and values false); // return attrs and values
while (searchResults.hasMore()) { while (searchResults.hasMore()) {
LDAPEntry entry = searchResults.next(); LDAPEntry entry = searchResults.next();
@ -114,7 +111,6 @@ public class LdapVascBackend extends AbstractVascBackend {
Iterator<LDAPAttribute> i = attributeSet.iterator(); Iterator<LDAPAttribute> i = attributeSet.iterator();
while (i.hasNext()) { while (i.hasNext()) {
LDAPAttribute attr = i.next(); LDAPAttribute attr = i.next();
//System.out.println("ATTR: "+attr.getName()+" value: "+attr.getStringValue());
String[] s = attr.getStringValueArray(); String[] s = attr.getStringValueArray();
if (s.length==1) { if (s.length==1) {
map.put(attr.getName(), attr.getStringValue()); map.put(attr.getName(), attr.getStringValue());
@ -149,14 +145,12 @@ public class LdapVascBackend extends AbstractVascBackend {
String keyValue = (String)map.get(keyAttribute); String keyValue = (String)map.get(keyAttribute);
LDAPSearchConstraints cons = new LDAPSearchConstraints(); LDAPSearchConstraints cons = new LDAPSearchConstraints();
cons.setBatchSize( 0 ); cons.setBatchSize( 0 );
cons.setTimeLimit( 10000 ) ; cons.setTimeLimit(getTimeLimit() ) ;
cons.setReferralFollowing(true); cons.setReferralFollowing(isReferralFollowing());
connection.setConstraints(cons); connection.setConstraints(cons);
int searchScope = LDAPConnection.SCOPE_ONE; int searchScope = LDAPConnection.SCOPE_ONE;
String searchBase = baseDN; String searchBase = baseDN;
String filter = "(&("+keyAttribute+"="+keyValue+"))"; String filter = "(&"+ldapFilter+"("+keyAttribute+"="+keyValue+"))";
System.out.println("ldap filter: "+filter);
LDAPSearchResults searchResults = connection.search( LDAPSearchResults searchResults = connection.search(
searchBase, // object to read searchBase, // object to read
searchScope, // scope - read single object searchScope, // scope - read single object
@ -210,8 +204,9 @@ public class LdapVascBackend extends AbstractVascBackend {
} }
LDAPModification[] m = new LDAPModification[mods.size()]; LDAPModification[] m = new LDAPModification[mods.size()];
mods.toArray(m); m = mods.toArray(m);
connection.modify(entry.getDN(), m); connection.modify(entry.getDN(), m);
return object; return object;
} catch (Exception e) { } catch (Exception e) {
throw new VascException(e); throw new VascException(e);
@ -270,7 +265,7 @@ public class LdapVascBackend extends AbstractVascBackend {
String keyValue = (String)map.get(keyAttribute); String keyValue = (String)map.get(keyAttribute);
int searchScope = LDAPConnection.SCOPE_ONE; int searchScope = LDAPConnection.SCOPE_ONE;
String searchBase = baseDN; String searchBase = baseDN;
String filter = "(&("+ldapFilter+")("+keyAttribute+"="+keyValue+"))"; String filter = "(&"+ldapFilter+"("+keyAttribute+"="+keyValue+"))";
LDAPSearchResults searchResults = connection.search( LDAPSearchResults searchResults = connection.search(
searchBase, // object to read searchBase, // object to read
searchScope, // scope - read single object searchScope, // scope - read single object
@ -362,4 +357,32 @@ public class LdapVascBackend extends AbstractVascBackend {
public void setCreateObjectClass(String createObjectClass) { public void setCreateObjectClass(String createObjectClass) {
this.createObjectClass = 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;
}
} }

View file

@ -26,7 +26,6 @@ import java.net.UnknownHostException;
import org.eobjects.metamodel.DataContext; import org.eobjects.metamodel.DataContext;
import org.eobjects.metamodel.mongodb.MongoDbDataContext; import org.eobjects.metamodel.mongodb.MongoDbDataContext;
import org.eobjects.metamodel.mongodb.MongoDbDataContextBean;
import com.mongodb.DB; import com.mongodb.DB;
import com.mongodb.Mongo; import com.mongodb.Mongo;
@ -51,13 +50,16 @@ public class MetaModelDataContextMongodb implements MetaModelDataContextProvider
protected Mongo mongo = null; protected Mongo mongo = null;
public DataContext getDataContext() { public DataContext getDataContext() {
MongoDbDataContextBean dataContext = new MongoDbDataContextBean(getMongodbConnection()); //MongoDbDataContextBean dataContext = new MongoDbDataContextBean(getMongodbConnection());
dataContext.setRegisterMBean(true); ///dataContext.setRegisterMBean(true);
dataContext.start(); //dataContext.start();
//MongoDbDataContextSchemaDetector detector = new MongoDbDataContextSchemaDetector(); //MongoDbDataContextSchemaDetector detector = new MongoDbDataContextSchemaDetector();
//detector.setDataCheckSize(10); //detector.setDataCheckSize(10);
//detector.setSearchReference(true); //detector.setSearchReference(true);
//DataContext dataContext = detector.new MongoDbDataContextExtended(getMongodbConnection(),detector); //DataContext dataContext = detector.new MongoDbDataContextExtended(getMongodbConnection(),detector);
DataContext dataContext = new MongoDbDataContext(getMongodbConnection());
return dataContext; return dataContext;
} }

View file

@ -23,7 +23,9 @@
package net.forwardfire.vasc.backend.metamodel; package net.forwardfire.vasc.backend.metamodel;
import java.util.ArrayList; 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.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -67,6 +69,8 @@ public class MetaModelSchemaAutoEntry {
private String tableExclude = null; private String tableExclude = null;
private String entryPrefix = null; private String entryPrefix = null;
private String vascGroupId = null; private String vascGroupId = null;
private String veLinkPostfix = "_velink";
private String veListPostfix = "_velist";
private Map<String,VascEntryLocal> resultEntries = null; private Map<String,VascEntryLocal> resultEntries = null;
private Map<String,VascEntryGroupLocal> resultEntryGroups = null; private Map<String,VascEntryGroupLocal> resultEntryGroups = null;
@ -160,11 +164,9 @@ public class MetaModelSchemaAutoEntry {
if (tableName.equals(rs.getForeignTable().getName())==false) { if (tableName.equals(rs.getForeignTable().getName())==false) {
logger.finer("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName()); logger.finer("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName());
createLinkEntry(rs,ve,metaTable); createLinkEntry(rs,ve,metaTable);
//createLinkEntry(rs,ve,metaTable,id+"_"+rs.getForeignTable().getName()+"_"+rs.getForeignColumns()[0].getName()+"_link");
} else { } else {
logger.finer("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName()); logger.finer("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName());
createListEntry(rs,ve,metaTable); 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) { 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(); MetaModelVascBackend backendLink = new MetaModelVascBackend();
backendLink.setId(id+"_backend"); backendLink.setId(id+"_backend");
backendLink.setDataContextProvider(getDataContextProvider()); backendLink.setDataContextProvider(getDataContextProvider());
@ -195,26 +197,25 @@ public class MetaModelSchemaAutoEntry {
veLink.setBackendId(id+"_backend"); veLink.setBackendId(id+"_backend");
veLink.setPrimaryKeyFieldId(backendLink.getTableId()); veLink.setPrimaryKeyFieldId(backendLink.getTableId());
veLink.setVascGroupId(getVascGroupId()); veLink.setVascGroupId(getVascGroupId());
veLink.setAccessType(VascEntryAccessType.ENTRY_LIST); veLink.setAccessType(VascEntryAccessType.ENTRY_LINK);
createFields(veLink,cols); 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()) { for (Relationship rs:rs2.getForeignTable().getRelationships()) {
logger.finer("Found relation FT: "+rs.getForeignTable().getName()+" PT: "+rs.getPrimaryTable().getName()); logger.finer("Found relation FT: "+rs.getForeignTable().getName()+" PT: "+rs.getPrimaryTable().getName());
if (rs2.getForeignTable().getName().equals(rs.getForeignTable().getName())==false) { if (rs2.getForeignTable().getName().equals(rs.getForeignTable().getName())==false) {
//logger.info("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName()); //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 { } else {
logger.fine("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName()); 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());
//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(); DefaultVascEntryLink vle = new DefaultVascEntryLink();
vle.setId(id+"Link"); vle.setId(id+"Link");
vle.setVascEntryLinkType(VascEntryLinkType.DEFAULT_TYPE); vle.setVascEntryLinkType(VascEntryLinkType.DEFAULT_TYPE);
@ -225,7 +226,7 @@ public class MetaModelSchemaAutoEntry {
} }
private void createListEntry(Relationship rs,VascEntry ve,Table metaTable) { 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(); MetaModelVascBackend backendList = new MetaModelVascBackend();
backendList.setId(id+"_backend"); backendList.setId(id+"_backend");
backendList.setDataContextProvider(getDataContextProvider()); backendList.setDataContextProvider(getDataContextProvider());
@ -263,27 +264,34 @@ public class MetaModelSchemaAutoEntry {
VascSelectItemModelEntry itemModel = new VascSelectItemModelEntry(); VascSelectItemModelEntry itemModel = new VascSelectItemModelEntry();
itemModel.setEntryId(veList.getId()); 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); vef.getVascEntryFieldType().setDataObject(itemModel);
} }
private void createFields(VascEntryLocal ve,Column[] cols) { private void createFields(VascEntryLocal ve,Column[] cols) {
for (Column c:cols) { for (Column c:cols) {
String name = c.getName().toLowerCase();
DefaultVascEntryField vef = new DefaultVascEntryField(); DefaultVascEntryField vef = new DefaultVascEntryField();
vef.setId(c.getName()); vef.setId(c.getName());
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeByClass(c.getType().getJavaEquivalentClass())); vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeByClass(c.getType().getJavaEquivalentClass()));
if (vef.getId().equals(ve.getPrimaryKeyFieldId())) { if (vef.getId().equals(ve.getPrimaryKeyFieldId())) {
vef.setEditReadOnly(true); vef.setEditReadOnly(true);
// vef.setCreate(false); mmm vef.setCreate(false);
} }
if (vef.getVascEntryFieldType()==null || "TextField".equals(vef.getVascEntryFieldType().getId())) { 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")); 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")); vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("BooleanField"));
} /* todo } /* todo
if (c.getName().toLowerCase().contains("email")) { if (c.getName().toLowerCase().contains("email")) {
@ -293,25 +301,55 @@ public class MetaModelSchemaAutoEntry {
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("URLField")); 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); ve.addVascEntryField(vef);
if (ve.getDisplayNameFieldId()==null && c.getName().equals(ve.getPrimaryKeyFieldId())==false && c.getType().getJavaEquivalentClass()==String.class) { if (ve.getDisplayNameFieldId()==null && c.getName().equals(ve.getPrimaryKeyFieldId())==false && c.getType().getJavaEquivalentClass()==String.class) {
ve.setDisplayNameFieldId(c.getName()); 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. // 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<String> vefListIds = new ArrayList<String>(20); List<String> vefListIds = new ArrayList<String>(20);
int max = 0;
for (VascEntryField vef:ve.getVascEntryFields()) { 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())) { if (ve.getDisplayNameFieldId()!=null && ve.getDisplayNameFieldId().equals(vef.getId())) {
continue; continue;
} }
@ -322,14 +360,15 @@ public class MetaModelSchemaAutoEntry {
continue; continue;
} }
vefListIds.add(vef.getId()); vefListIds.add(vef.getId());
} max++;
if (vefListIds.size()<8) { if (max>8) {
List<String> vefListFalseIds = vefListIds.subList(8-1, vefListIds.size()); break;
for (String key:vefListFalseIds) {
VascEntryField vef = ve.getVascEntryFieldById(key);
vef.setList(false);
} }
} }
for (String key:vefListIds) {
VascEntryField vef = ve.getVascEntryFieldById(key);
vef.setList(false);
}
} }
} }
@ -406,22 +445,43 @@ public class MetaModelSchemaAutoEntry {
/** /**
* @return the resultEntries * @return the resultEntries
*/ */
public Collection<VascEntryLocal> getResultEntries() { public List<VascEntryLocal> getResultEntries() {
return resultEntries.values(); List<VascEntryLocal> result = new ArrayList<VascEntryLocal>(resultEntries.values());
Collections.sort(result, new Comparator<VascEntryLocal>() {
@Override
public int compare(VascEntryLocal o1, VascEntryLocal o2) {
return o1.getId().compareTo(o2.getId());
}
});
return result;
} }
/** /**
* @return the resultEntryGroups * @return the resultEntryGroups
*/ */
public Collection<VascEntryGroupLocal> getResultEntryGroups() { public List<VascEntryGroupLocal> getResultEntryGroups() {
return resultEntryGroups.values(); List<VascEntryGroupLocal> result = new ArrayList<VascEntryGroupLocal>(resultEntryGroups.values());
Collections.sort(result, new Comparator<VascEntryGroupLocal>() {
@Override
public int compare(VascEntryGroupLocal o1, VascEntryGroupLocal o2) {
return o1.getId().compareTo(o2.getId());
}
});
return result;
} }
/** /**
* @return the resultBackends * @return the resultBackends
*/ */
public Collection<MetaModelVascBackend> getResultBackends() { public List<MetaModelVascBackend> getResultBackends() {
return resultBackends.values(); List<MetaModelVascBackend> result = new ArrayList<MetaModelVascBackend>(resultBackends.values());
Collections.sort(result, new Comparator<MetaModelVascBackend>() {
@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) { public void removeTable(String table) {
tables.remove(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;
}
} }

View file

@ -32,10 +32,13 @@ import org.eobjects.metamodel.DataContext;
import org.eobjects.metamodel.UpdateableDataContext; import org.eobjects.metamodel.UpdateableDataContext;
import org.eobjects.metamodel.data.DataSet; import org.eobjects.metamodel.data.DataSet;
import org.eobjects.metamodel.data.Row; 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.Query;
import org.eobjects.metamodel.query.SelectItem; import org.eobjects.metamodel.query.SelectItem;
import org.eobjects.metamodel.query.builder.SatisfiedQueryBuilder; import org.eobjects.metamodel.query.builder.SatisfiedQueryBuilder;
import org.eobjects.metamodel.query.builder.SatisfiedWhereBuilder; import org.eobjects.metamodel.query.builder.SatisfiedWhereBuilder;
import org.eobjects.metamodel.schema.Column;
import org.eobjects.metamodel.schema.Schema; import org.eobjects.metamodel.schema.Schema;
import org.eobjects.metamodel.schema.Table; import org.eobjects.metamodel.schema.Table;
@ -131,6 +134,14 @@ public class MetaModelVascBackend extends AbstractVascBackend {
return true; 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) * @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+"'."); throw new VascException("Could not get meta table for: '"+table+"'.");
} }
Query q = createFilterQuery(state,t,false); 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) { 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()); q.setMaxRows(state.getPageSize());
} }
if (crudDataContext!=null) { if (crudDataContext!=null) {
@ -227,7 +253,7 @@ public class MetaModelVascBackend extends AbstractVascBackend {
SelectItem[] cols = row.getSelectItems(); SelectItem[] cols = row.getSelectItems();
List<String> keys = new ArrayList<String>(1); List<String> keys = new ArrayList<String>(1);
keys.add(cols[0].getColumn().getName()); 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) { for (SelectItem col:cols) {
Object value = row.getValue(col); Object value = row.getValue(col);
rowMM.setValue(col, value); rowMM.setValue(col, value);

View file

@ -46,7 +46,7 @@ public class MongoDbDataContextSchemaDetector /* implements MetaModelSchemaDetec
private int dataCheckSize = 100; private int dataCheckSize = 100;
private boolean searchReference = true; private boolean searchReference = true;
public MongoDbDataContextSchemaDetector() { private MongoDbDataContextSchemaDetector() {
} }
public class MongoDbDataContextExtended extends QueryPostprocessDataContext /* MongoDbDataContext */ { public class MongoDbDataContextExtended extends QueryPostprocessDataContext /* MongoDbDataContext */ {
@ -153,8 +153,10 @@ public class MongoDbDataContextSchemaDetector /* implements MetaModelSchemaDetec
private boolean _closed; private boolean _closed;
private volatile DBObject _dbObject; private volatile DBObject _dbObject;
public MongoDbDataSet(DBCursor cursor, Column[] columns, public MongoDbDataSet(DBCursor cursor, Column[] columns,boolean queryPostProcessed) {
boolean queryPostProcessed) {
super(columns); // create header
_cursor = cursor; _cursor = cursor;
_selectItems = new SelectItem[columns.length]; _selectItems = new SelectItem[columns.length];
for (int i = 0; i < columns.length; i++) { for (int i = 0; i < columns.length; i++) {
@ -211,7 +213,7 @@ public class MongoDbDataContextSchemaDetector /* implements MetaModelSchemaDetec
Object value = _dbObject.get(key); Object value = _dbObject.get(key);
values[i] = toValue(_selectItems[i].getColumn(), value); values[i] = toValue(_selectItems[i].getColumn(), value);
} }
return new DefaultRow(_selectItems, values); return new DefaultRow(getHeader(), values);
} }
private Object toValue(Column column, Object value) { private Object toValue(Column column, Object value) {
@ -440,6 +442,7 @@ public class MongoDbDataContextSchemaDetector /* implements MetaModelSchemaDetec
// Override to make public // Override to make public
class PublicTable extends MutableTable { class PublicTable extends MutableTable {
private static final long serialVersionUID = 1L;
public PublicTable(String name,TableType type) { public PublicTable(String name,TableType type) {
super(name,type); super(name,type);
} }

View file

@ -2,7 +2,6 @@ package net.forwardfire.vasc.backend.metamodel.crud;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.List; import java.util.List;
import org.eobjects.metamodel.DataContext; import org.eobjects.metamodel.DataContext;
@ -45,15 +44,15 @@ abstract public class AbstractCrudDataContext implements CrudDataContext {
public void persist(final UpdateableRow row) { public void persist(final UpdateableRow row) {
UpdateableDataContext dataContext = abstractProviderUpdateableDataContext(); UpdateableDataContext dataContext = abstractProviderUpdateableDataContext();
dataContext.executeUpdate(new UpdateScript() { dataContext.executeUpdate(new UpdateScript() {
public void run(UpdateCallback backendImpl) { public void run(UpdateCallback backendImpl) {
RowInsertionBuilder query = backendImpl.insertInto(row.getTable()); RowInsertionBuilder query = backendImpl.insertInto(row.getTable());
for (int i=0;i<row.size();i++) { for (int i=0;i<row.size();i++) {
SelectItem si = row.getSelectItem(i); SelectItem si = row.getSelectItem(i);
Object value = row.getValue(i); Object value = row.getValue(i);
query.value(si.getColumn(), value); query.value(si.getColumn(), value);
} }
query.execute(); query.execute();
} }
}); });
} }
@ -70,18 +69,18 @@ abstract public class AbstractCrudDataContext implements CrudDataContext {
boolean first = true; boolean first = true;
List<String> primaryKeyColumns = new ArrayList<String>(30); List<String> primaryKeyColumns = new ArrayList<String>(30);
Collections.addAll(primaryKeyColumns, row.getPrimaryKeys()); Collections.addAll(primaryKeyColumns, row.getPrimaryKeys());
for (String column:primaryKeyColumns) { for (String column:primaryKeyColumns) {
Object value = row.getValue(column); Object value = row.getValue(column);
queryWhereBuilderUpdate(qWhere,column,value,first); queryWhereBuilderUpdate(qWhere,column,value,first);
first = false; first = false;
} }
List<String> columns = new ArrayList<String>(30); List<String> columns = new ArrayList<String>(30);
Collections.addAll(columns, row.getTable().getColumnNames()); Collections.addAll(columns, row.getTable().getColumnNames());
columns.removeAll(primaryKeyColumns); columns.removeAll(primaryKeyColumns);
for (String column:columns) { for (String column:columns) {
Object value = row.getValue(column); Object value = row.getValue(column);
((RowUpdationBuilder)qWhere).value(column, value); ((RowUpdationBuilder)qWhere).value(column, value);
} }
if (first==false) { if (first==false) {
((RowUpdationBuilder)qWhere).execute(); ((RowUpdationBuilder)qWhere).execute();
} else { } else {
@ -92,18 +91,18 @@ abstract public class AbstractCrudDataContext implements CrudDataContext {
Object qWhere = dataContext.query().from(row.getTable()).select(row.getTable().getColumns()); Object qWhere = dataContext.query().from(row.getTable()).select(row.getTable().getColumns());
boolean first = true; boolean first = true;
for (String column:row.getPrimaryKeys()) { for (String column:row.getPrimaryKeys()) {
Object value = row.getValue(column); Object value = row.getValue(column);
queryWhereBuilder(qWhere,column,value,first); queryWhereBuilder(qWhere,column,value,first);
first = false; first = false;
} }
Query mergeSelectQuery = ((SatisfiedQueryBuilder<?>)qWhere).toQuery(); Query mergeSelectQuery = ((SatisfiedQueryBuilder<?>)qWhere).toQuery();
DataSet ds = dataContext.executeQuery(mergeSelectQuery); DataSet ds = dataContext.executeQuery(mergeSelectQuery);
if (ds.next()==false) { if (ds.next()==false) {
ds.close(); ds.close();
throw new IllegalStateException("Could not fetch row after merging."); throw new IllegalStateException("Could not fetch row after merging.");
} }
UpdateableRow rowResult = wrapOrCreateToUpdateableRow(ds.getRow(),row.getTable()); UpdateableRow rowResult = wrapOrCreateToUpdateableRow(ds.getRow(),row.getTable());
ds.close(); ds.close();
return rowResult; return rowResult;
} }
@ -111,131 +110,71 @@ abstract public class AbstractCrudDataContext implements CrudDataContext {
public void delete(final UpdateableRow row) { public void delete(final UpdateableRow row) {
UpdateableDataContext dataContext = abstractProviderUpdateableDataContext(); UpdateableDataContext dataContext = abstractProviderUpdateableDataContext();
dataContext.executeUpdate(new UpdateScript() { dataContext.executeUpdate(new UpdateScript() {
public void run(UpdateCallback backendImpl) { public void run(UpdateCallback backendImpl) {
Object qWhere = backendImpl.deleteFrom(row.getTable()); Object qWhere = backendImpl.deleteFrom(row.getTable());
boolean first = true; boolean first = true;
for (String column:row.getPrimaryKeys()) { for (String column:row.getPrimaryKeys()) {
Object value = row.getValue(column); Object value = row.getValue(column);
queryWhereBuilderDelete(qWhere,column,value,first); queryWhereBuilderDelete(qWhere,column,value,first);
first = false; first = false;
} }
if (first==false) { if (first==false) {
((RowDeletionBuilder)qWhere).execute(); ((RowDeletionBuilder)qWhere).execute();
} else { } else {
///logger.warning no where clause ///logger.warning no where clause
} }
} }
}); });
} }
// TODO: redo these queryWhereBuilder methods to cleaner code // TODO: redo these queryWhereBuilder methods to cleaner code
protected Object queryWhereBuilder(Object qWhere,String key,Object value,boolean first) { protected Object queryWhereBuilder(Object qWhere,String key,Object value,boolean first) {
if (value instanceof Number) { if (value==null) {
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 (first) { if (first) {
qWhere = ((SatisfiedQueryBuilder<?>)qWhere).where(key).equals((Date)value); qWhere = ((SatisfiedQueryBuilder<?>)qWhere).where(key).isNull();
} else { } else {
qWhere = ((SatisfiedWhereBuilder<?>)qWhere).and(key).equals((Date)value); qWhere = ((SatisfiedWhereBuilder<?>)qWhere).and(key).isNull();
}
} else if (value instanceof Boolean) {
if (first) {
qWhere = ((SatisfiedQueryBuilder<?>)qWhere).where(key).equals((Boolean)value);
} else {
qWhere = ((SatisfiedWhereBuilder<?>)qWhere).and(key).equals((Boolean)value);
} }
} else { } else {
if (value==null) { if (first) {
if (first) { qWhere = ((SatisfiedQueryBuilder<?>)qWhere).where(key).isEquals(value);
qWhere = ((SatisfiedQueryBuilder<?>)qWhere).where(key).isNull();
} else {
qWhere = ((SatisfiedWhereBuilder<?>)qWhere).and(key).isNull();
}
} else { } else {
if (first) { qWhere = ((SatisfiedWhereBuilder<?>)qWhere).and(key).isEquals(value);
qWhere = ((SatisfiedQueryBuilder<?>)qWhere).where(key).equals(value.toString());
} else {
qWhere = ((SatisfiedWhereBuilder<?>)qWhere).and(key).equals(value.toString());
}
} }
} }
return qWhere; return qWhere;
} }
protected Object queryWhereBuilderUpdate(Object qWhere,String key,Object value,boolean first) { protected Object queryWhereBuilderUpdate(Object qWhere,String key,Object value,boolean first) {
if (value instanceof Number) { if (value==null) {
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 (first) { if (first) {
qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Date)value); qWhere = ((RowUpdationBuilder)qWhere).where(key).isNull();
} else { } else {
qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Date)value); qWhere = ((RowUpdationBuilder)qWhere).where(key).isNull();
}
} else if (value instanceof Boolean) {
if (first) {
qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Boolean)value);
} else {
qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Boolean)value);
} }
} else { } else {
if (value==null) { if (first) {
if (first) { qWhere = ((RowUpdationBuilder)qWhere).where(key).isEquals(value);
qWhere = ((RowUpdationBuilder)qWhere).where(key).isNull();
} else {
qWhere = ((RowUpdationBuilder)qWhere).where(key).isNull();
}
} else { } else {
if (first) { qWhere = ((RowUpdationBuilder)qWhere).where(key).isEquals(value);
qWhere = ((RowUpdationBuilder)qWhere).where(key).equals(value.toString());
} else {
qWhere = ((RowUpdationBuilder)qWhere).where(key).equals(value.toString());
}
} }
} }
return qWhere; return qWhere;
} }
protected Object queryWhereBuilderDelete(Object qWhere,String key,Object value,boolean first) { protected Object queryWhereBuilderDelete(Object qWhere,String key,Object value,boolean first) {
if (value instanceof Number) { if (value==null) {
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 (first) { if (first) {
qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Date)value); qWhere = ((RowDeletionBuilder)qWhere).where(key).isNull();
} else { } else {
qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Date)value); qWhere = ((RowDeletionBuilder)qWhere).where(key).isNull();
}
} else if (value instanceof Boolean) {
if (first) {
qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Boolean)value);
} else {
qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Boolean)value);
} }
} else { } else {
if (value==null) { if (first) {
if (first) { qWhere = ((RowDeletionBuilder)qWhere).where(key).isEquals(value);
qWhere = ((RowDeletionBuilder)qWhere).where(key).isNull();
} else {
qWhere = ((RowDeletionBuilder)qWhere).where(key).isNull();
}
} else { } else {
if (first) { qWhere = ((RowDeletionBuilder)qWhere).where(key).isEquals(value);
qWhere = ((RowDeletionBuilder)qWhere).where(key).equals(value.toString());
} else {
qWhere = ((RowDeletionBuilder)qWhere).where(key).equals(value.toString());
}
} }
} }
return qWhere; return qWhere;

View file

@ -22,7 +22,8 @@ abstract public class AbstractUpdateableRow extends AbstractRow implements Updat
} }
public int indexOf(String columnName) { public int indexOf(String columnName) {
if (columnName==null) { 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; int index = 0;
for (SelectItem si:getIndexedSelectItemList()) { for (SelectItem si:getIndexedSelectItemList()) {
@ -31,7 +32,8 @@ abstract public class AbstractUpdateableRow extends AbstractRow implements Updat
} }
index++; 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) { public void setValue(Row row) {
@ -66,7 +68,7 @@ abstract public class AbstractUpdateableRow extends AbstractRow implements Updat
if (selectItem.getSubQuerySelectItem() != null) { if (selectItem.getSubQuerySelectItem() != null) {
value = getValue(selectItem.getSubQuerySelectItem()); value = getValue(selectItem.getSubQuerySelectItem());
style = getStyle(selectItem.getSubQuerySelectItem()); style = getStyle(selectItem.getSubQuerySelectItem());
} }
if (value == null) { if (value == null) {
value = getValue(selectItem); value = getValue(selectItem);

View file

@ -11,6 +11,7 @@ import org.eobjects.metamodel.UpdateScript;
import org.eobjects.metamodel.UpdateableDataContext; import org.eobjects.metamodel.UpdateableDataContext;
import org.eobjects.metamodel.data.DataSet; import org.eobjects.metamodel.data.DataSet;
import org.eobjects.metamodel.data.Row; import org.eobjects.metamodel.data.Row;
import org.eobjects.metamodel.query.CompiledQuery;
import org.eobjects.metamodel.query.Query; import org.eobjects.metamodel.query.Query;
import org.eobjects.metamodel.query.builder.InitFromBuilder; import org.eobjects.metamodel.query.builder.InitFromBuilder;
import org.eobjects.metamodel.query.builder.InitFromBuilderImpl; import org.eobjects.metamodel.query.builder.InitFromBuilderImpl;
@ -81,7 +82,7 @@ public class CrudDataContextImpl extends AbstractCrudDataContext implements Abst
if (row==null) { if (row==null) {
result.addSelectItems(table.getColumns()); // create new when row is null result.addSelectItems(table.getColumns()); // create new when row is null
} else { } else {
result.addSelectItems(row.getSelectItems()); result.addSelectItems(row.getSelectItems());
result.setValue(row); // copy all values to impl result.setValue(row); // copy all values to impl
} }
return result; return result;
@ -205,4 +206,12 @@ public class CrudDataContextImpl extends AbstractCrudDataContext implements Abst
public DataSet executeQuery(String queryString) throws MetaModelException { public DataSet executeQuery(String queryString) throws MetaModelException {
return dataContextDelegate.executeQuery(queryString); 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);
}
} }

View file

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eobjects.metamodel.data.DataSetHeader;
import org.eobjects.metamodel.data.Row; import org.eobjects.metamodel.data.Row;
import org.eobjects.metamodel.query.SelectItem; import org.eobjects.metamodel.query.SelectItem;
import org.eobjects.metamodel.schema.Table; import org.eobjects.metamodel.schema.Table;
@ -47,6 +48,9 @@ public class UpdateableRowMapImpl extends AbstractUpdateableRow {
} }
public void setValue(int index, Object value) throws IndexOutOfBoundsException { 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); dataMap.put(index, value);
} }
@ -57,4 +61,8 @@ public class UpdateableRowMapImpl extends AbstractUpdateableRow {
public Row getSubSelection(SelectItem[] selectItems) { public Row getSubSelection(SelectItem[] selectItems) {
return getSubSelectionFromImpl(new UpdateableRowMapImpl(table,primaryKeys,selectItems),selectItems); return getSubSelectionFromImpl(new UpdateableRowMapImpl(table,primaryKeys,selectItems),selectItems);
} }
public Row getSubSelection(DataSetHeader header) {
return getSubSelection(header.getSelectItems());
}
} }

View file

@ -3,6 +3,7 @@ package net.forwardfire.vasc.backend.metamodel.jndi;
import org.eobjects.metamodel.DataContext; import org.eobjects.metamodel.DataContext;
import org.eobjects.metamodel.MetaModelException; import org.eobjects.metamodel.MetaModelException;
import org.eobjects.metamodel.data.DataSet; import org.eobjects.metamodel.data.DataSet;
import org.eobjects.metamodel.query.CompiledQuery;
import org.eobjects.metamodel.query.Query; import org.eobjects.metamodel.query.Query;
import org.eobjects.metamodel.query.builder.InitFromBuilder; import org.eobjects.metamodel.query.builder.InitFromBuilder;
import org.eobjects.metamodel.schema.Column; import org.eobjects.metamodel.schema.Column;
@ -53,4 +54,12 @@ public class JndiReadOnlyDataContext /* extends DataContextProxy */ implements D
public DataSet executeQuery(String queryString) throws MetaModelException { public DataSet executeQuery(String queryString) throws MetaModelException {
return proxyDataContext.executeQuery(queryString); 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);
}
} }

View file

@ -7,7 +7,6 @@ import javax.naming.NamingException;
import org.eobjects.metamodel.DataContext; import org.eobjects.metamodel.DataContext;
import org.eobjects.metamodel.mongodb.MongoDbDataContext; import org.eobjects.metamodel.mongodb.MongoDbDataContext;
import org.eobjects.metamodel.mongodb.MongoDbDataContextBean;
import com.mongodb.DB; import com.mongodb.DB;
import com.mongodb.Mongo; import com.mongodb.Mongo;
@ -31,27 +30,38 @@ public class JndiMongodbDataContextLoader implements JndiDataContextLoader {
} }
public DataContext loadDataContext(JndiDataContextLoaderConfig config) { public DataContext loadDataContext(JndiDataContextLoaderConfig config) {
MongoDbDataContextBean result = null; //MongoDbDataContextBean result = null;
DB mongoDb = null;
if (useJndiResource) { if (useJndiResource) {
config.checkBackendUrl(); config.checkBackendUrl();
result = new MongoDbDataContextBean(getMongodbJdni(config.getJndiObjectName(),config.getBackendUrl())); //result = new MongoDbDataContextBean(,));
mongoDb = getMongodbJdni(config.getJndiObjectName(),config.getBackendUrl());
} else { } else {
int mongoPort = 27017; int mongoPort = 27017;
if (config.getBackendPort()!=null && config.getBackendPort().isEmpty()==false) { if (config.getBackendPort()!=null && config.getBackendPort().isEmpty()==false) {
mongoPort = new Integer(config.getBackendPort()); mongoPort = new Integer(config.getBackendPort());
} }
result = new MongoDbDataContextBean(getMongodbConnection( mongoDb = getMongodbConnection(
config.getJndiObjectName(), config.getJndiObjectName(),
config.getBackendHost(), config.getBackendHost(),
mongoPort, mongoPort,
config.getBackendDatabase(), config.getBackendDatabase(),
config.getBackendUsername(), config.getBackendUsername(),
config.getBackendPassword() config.getBackendPassword()
)); );
} }
result.setRegisterMBean(true); // TODO: make flag //MongoDbDataContextSchemaDetector detector = new MongoDbDataContextSchemaDetector();
result.start(); //detector.setDataCheckSize(10);
return result; //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) { protected DB getMongodbJdni(String objectName,String jndiName) {

View file

@ -45,9 +45,23 @@ public interface VascFrontendDataSelector extends VascFrontendEntry {
public boolean isFieldEditReadOnly(VascEntryField field); public boolean isFieldEditReadOnly(VascEntryField field);
public boolean isFieldList(VascEntryField field); public boolean isFieldList(VascEntryField field);
public List<VascEntryField> getFieldsList(); public enum EntrySelectType {
VIEW,
LINK
}
public List<VascEntryField> getFieldsCreate(); public enum EntryFieldSelectType {
CREATE,
LIST,
EDIT,
ALL,
EXPORT,
GRAPH,
SUM,
SORT
}
public List<VascEntryField> getFieldsEdit(); public List<VascEntryField> getFields(EntryFieldSelectType type);
} }

View file

@ -155,6 +155,8 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
// save object on backend // save object on backend
if (persist) { if (persist) {
entry.getVascFrontendController().getVascEntryState().getVascBackend().persist(object); entry.getVascFrontendController().getVascEntryState().getVascBackend().persist(object);
result = object; // TODO: fix persist
entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(1+entry.getVascFrontendController().getVascEntryState().getTotalBackendRecords());
} else { } else {
result = entry.getVascFrontendController().getVascEntryState().getVascBackend().merge(object); result = entry.getVascFrontendController().getVascEntryState().getVascBackend().merge(object);
} }
@ -185,6 +187,7 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
removeObjectFromDataList(object); removeObjectFromDataList(object);
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(null); entry.getVascFrontendController().getVascEntryState().setEntryDataObject(null);
entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(entry.getVascFrontendController().getVascEntryState().getTotalBackendRecords()-1);
entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_DELETE, object); entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_DELETE, object);
} catch (VascException ve) { } catch (VascException ve) {
throw new VascFrontendException(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) * @see net.forwardfire.vasc.frontend.VascFrontendHelper#refreshData(net.forwardfire.vasc.core.VascEntry)
*/ */
public void refreshData() throws VascFrontendException { public void refreshData() throws VascFrontendException {
// Fire pre read event
entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_READ, null); entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_READ, null);
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(null); entry.getVascFrontendController().getVascEntryState().setEntryDataObject(null);
VascBackendState backendState = entry.getVascFrontendController().getVascEntryState().getVascBackendState(); 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); Long total = entry.getVascFrontendController().getVascEntryState().getVascBackend().fetchTotalExecuteSize(backendState);
entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(total); 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 { try {
// Execute to get data. // Execute to get data.
entry.getVascFrontendController().getVascEntryState().setEntryDataList(entry.getVascFrontendController().getVascEntryState().getVascBackend().execute(backendState)); entry.getVascFrontendController().getVascEntryState().setEntryDataList(entry.getVascFrontendController().getVascEntryState().getVascBackend().execute(backendState));
// check if we need to change the current page // Fire event post read
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));
}
entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, null); entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, null);
} catch (VascException ve) { } catch (VascException ve) {
throw new VascFrontendException(ve); throw new VascFrontendException(ve);
@ -251,12 +256,10 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
public void searchAction(String searchString) throws VascFrontendException { public void searchAction(String searchString) throws VascFrontendException {
entry.getVascFrontendController().getVascEntryState().getVascBackendState().setSearchString(searchString); entry.getVascFrontendController().getVascEntryState().getVascBackendState().setSearchString(searchString);
entry.getVascFrontendController().getVascEntryState().getVascBackendState().setSortField(null);
entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(0); entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(0);
entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.SEARCH, searchString); entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.SEARCH, searchString);
refreshData();
refreshData();
entry.getVascFrontendController().getVascFrontend().renderView(); entry.getVascFrontendController().getVascFrontend().renderView();
} }

View file

@ -23,13 +23,15 @@
package net.forwardfire.vasc.impl.frontend; package net.forwardfire.vasc.impl.frontend;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.actions.VascAction; import net.forwardfire.vasc.core.actions.VascAction;
import net.forwardfire.vasc.frontend.VascFrontendDataSelector; 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 * @author Willem Cazander
* @version 1.0 Jun 1, 2012 * @version 1.0 Jun 1, 2012
*/ */
public class DefaultVascFrontendDataSelector implements VascFrontendDataSelector { public class DefaultVascFrontendDataSelector implements VascFrontendDataSelector {
private VascEntry entry = null; private VascEntry entry = null;
@ -126,30 +128,48 @@ public class DefaultVascFrontendDataSelector implements VascFrontendDataSelector
*/ */
private List<VascEntryField> filter() {
public List<VascEntryField> getFields(final EntryFieldSelectType type) {
List<VascEntryField> result = new ArrayList<VascEntryField>(50); List<VascEntryField> result = new ArrayList<VascEntryField>(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<VascEntryField>() {
@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; return result;
} }
public List<VascEntryField> getFieldsList() {
List<VascEntryField> result = new ArrayList<VascEntryField>(50);
result.addAll(entry.getVascEntryFields());
return result;
}
public List<VascEntryField> getFieldsCreate() {
List<VascEntryField> result = new ArrayList<VascEntryField>(50);
result.addAll(entry.getVascEntryFields());
return result;
}
public List<VascEntryField> getFieldsEdit() {
List<VascEntryField> result = new ArrayList<VascEntryField>(50);
result.addAll(entry.getVascEntryFields());
return result;
}
} }

View file

@ -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" 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" providerName="vasc.forwardfire.net"
name="Vasc Config Language" name="Vasc Config Language"
id="mod-vasc-lang" id="vasc-lang"
> >
<eld:classBindingHandler id="VascEntryLocal-VascEntryFieldSet" parentClass="net.forwardfire.vasc.core.VascEntryLocal" childClass="net.forwardfire.vasc.core.VascEntryFieldSet" method="addVascEntryFieldSet"/> <eld:classBindingHandler id="VascEntryLocal-VascEntryFieldSet" parentClass="net.forwardfire.vasc.core.VascEntryLocal" childClass="net.forwardfire.vasc.core.VascEntryFieldSet" method="addVascEntryFieldSet"/>
@ -22,6 +22,7 @@
<eld:elementInterface id="VascBackend" interfaceClass="net.forwardfire.vasc.backend.VascBackend"> <eld:elementInterface id="VascBackend" interfaceClass="net.forwardfire.vasc.backend.VascBackend">
<eld:configurator id="VascBackendElementConfigurator" bean.class="net.forwardfire.vasc.impl.x4o.VascBackendElementConfigurator" configAction="true"/> <eld:configurator id="VascBackendElementConfigurator" bean.class="net.forwardfire.vasc.impl.x4o.VascBackendElementConfigurator" configAction="true"/>
<eld:elementParent tag="root" uri="http://vasc.forwardfire.net/xml/ns/vasc-root"/>
</eld:elementInterface> </eld:elementInterface>
<eld:namespace <eld:namespace
@ -49,12 +50,14 @@
<!-- Object for building an entry --> <!-- Object for building an entry -->
<eld:element tag="entryGroup" objectClass="net.forwardfire.vasc.impl.DefaultVascEntryGroup" > <eld:element tag="entryGroup" objectClass="net.forwardfire.vasc.impl.DefaultVascEntryGroup" >
<eld:configurator id="entryGroup-VascEntryElementConfigurator" bean.class="net.forwardfire.vasc.impl.x4o.VascEntryElementConfigurator" configAction="true"/> <eld:configurator id="entryGroup-VascEntryElementConfigurator" bean.class="net.forwardfire.vasc.impl.x4o.VascEntryElementConfigurator" configAction="true"/>
<eld:elementParent tag="root" uri="http://vasc.forwardfire.net/xml/ns/vasc-root"/>
</eld:element> </eld:element>
<eld:element tag="entry" objectClass="net.forwardfire.vasc.impl.DefaultVascEntry" > <eld:element tag="entry" objectClass="net.forwardfire.vasc.impl.DefaultVascEntry" >
<eld:configurator id="entry-VascEntryElementConfigurator" bean.class="net.forwardfire.vasc.impl.x4o.VascEntryElementConfigurator" configAction="true"/> <eld:configurator id="entry-VascEntryElementConfigurator" bean.class="net.forwardfire.vasc.impl.x4o.VascEntryElementConfigurator" configAction="true"/>
<eld:attribute name="accessType"> <eld:attribute name="accessType">
<conv:enumConverter enumClass="net.forwardfire.vasc.core.VascEntryAccessType"/> <conv:enumConverter enumClass="net.forwardfire.vasc.core.VascEntryAccessType"/>
</eld:attribute> </eld:attribute>
<eld:elementParent tag="root" uri="http://vasc.forwardfire.net/xml/ns/vasc-root"/>
</eld:element> </eld:element>
<eld:element tag="field" objectClass="net.forwardfire.vasc.impl.DefaultVascEntryField" elementClass="net.forwardfire.vasc.impl.x4o.VascEntryFieldElement"> <eld:element tag="field" objectClass="net.forwardfire.vasc.impl.DefaultVascEntryField" elementClass="net.forwardfire.vasc.impl.x4o.VascEntryFieldElement">
<eld:attribute name="vascEntryFieldType" runBeanFill="false"/> <eld:attribute name="vascEntryFieldType" runBeanFill="false"/>
@ -115,6 +118,7 @@
<eld:element tag="virtualVascBackend" objectClass="net.forwardfire.vasc.backend.VirtualVascBackend"> <eld:element tag="virtualVascBackend" objectClass="net.forwardfire.vasc.backend.VirtualVascBackend">
<eld:configurator id="virtualVascBackend-VascBackendElementConfigurator" bean.class="net.forwardfire.vasc.impl.x4o.VascBackendElementConfigurator" configAction="true"/> <eld:configurator id="virtualVascBackend-VascBackendElementConfigurator" bean.class="net.forwardfire.vasc.impl.x4o.VascBackendElementConfigurator" configAction="true"/>
<eld:elementParent tag="root" uri="http://vasc.forwardfire.net/xml/ns/vasc-root"/>
</eld:element> </eld:element>
</eld:namespace> </eld:namespace>

View file

@ -57,27 +57,36 @@
<v:field id="id" backendName="ID" list="false" editReadOnly="true" create="false"/> <v:field id="id" backendName="ID" list="false" editReadOnly="true" create="false"/>
<v:field id="slug" backendName="SLUG"/> <v:field id="slug" backendName="SLUG"/>
<v:field id="title" backendName="TITLE"/> <v:field id="title" backendName="TITLE"/>
<v:field id="i18n_key" backendName="I18N_KEY" vascEntryFieldType="BooleanField"/> <v:field id="active" backendName="ACTIVE" vascEntryFieldType="BooleanField"/>
<!-- <v:field id="active" backendName="ACTIVE" vascEntryFieldType="BooleanField"/> -->
<v:field id="sitemap" backendName="SITEMAP" vascEntryFieldType="BooleanField"/> <v:field id="sitemap" backendName="SITEMAP" vascEntryFieldType="BooleanField"/>
<v:field id="roles" backendName="ROLES" list="false"/>
<v:link id="AdminVascPagePartLink" vascEntryId="AdminVascPagePart">
<v:linkParameter name="page_id" valueFieldId="id"/>
</v:link>
</v:entry> </v:entry>
<mm:metaModelBackend id="AdminVascPagePartBackend" dataContextProvider="${DemoManagerDataDC}" table="VASC_PAGE_PART" tableId="ID" /> <mm:metaModelBackend id="AdminVascPagePartBackend" dataContextProvider="${DemoManagerDataDC}" table="VASC_PAGE_PART" tableId="ID" />
<v:entry id="AdminVascPagePart" backendId="AdminVascPagePartBackend" vascGroupId="tech-admin"> <v:entry id="AdminVascPagePart" backendId="AdminVascPagePartBackend" vascGroupId="tech-admin">
<v:listOption id="part_type" backendName="PART_TYPE" vascEntryFieldType="ListField" optional="true">
<v:vascSelectItemModelEnum enumClass="net.forwardfire.vasc.demo.tech.web.pages.model.VascPagePartType" nullLabel="All"/>
</v:listOption>
<v:listOption id="active" backendName="ACTIVE" vascEntryFieldType="ListField" optional="true">
<v:vascSelectItemModelString nullLabel="All" data="TRUE,FALSE"/>
</v:listOption>
<v:field id="id" backendName="ID" list="false" editReadOnly="true" create="false"/> <v:field id="id" backendName="ID" list="false" editReadOnly="true" create="false"/>
<v:field id="page_id" backendName="PAGE_ID" vascEntryFieldType="ListField"> <v:field id="page_id" backendName="PAGE_ID" vascEntryFieldType="ListField">
<v:vascSelectItemModel entryId="AdminVascPage" keyFieldId="id" displayFieldId="slug"/> <v:vascSelectItemModel entryId="AdminVascPage" keyFieldId="id" displayFieldId="slug"/>
</v:field> </v:field>
<v:field id="title" backendName="TITLE"/> <v:field id="title" backendName="TITLE"/>
<v:field id="text" backendName="TEXT"/> <v:field id="text" backendName="TEXT"/>
<v:field id="i18n_key" backendName="I18N_KEY" vascEntryFieldType="BooleanField"/>
<v:field id="active" backendName="ACTIVE" vascEntryFieldType="BooleanField"/> <v:field id="active" backendName="ACTIVE" vascEntryFieldType="BooleanField"/>
<v:field id="sitemap" backendName="SITEMAP" vascEntryFieldType="BooleanField"/> <v:field id="sitemap" backendName="SITEMAP" vascEntryFieldType="BooleanField"/>
<v:field id="part_order" backendName="PART_ORDER" vascEntryFieldType="IntegerField"/> <v:field id="part_order" backendName="PART_ORDER" vascEntryFieldType="IntegerField"/>
<v:field id="part_type" backendName="PART_TYPE" vascEntryFieldType="ListField"> <v:field id="part_type" backendName="PART_TYPE" vascEntryFieldType="ListField">
<v:vascSelectItemModelEnum enumClass="net.forwardfire.vasc.demo.tech.web.pages.model.VascPagePartType"/> <v:vascSelectItemModelEnum enumClass="net.forwardfire.vasc.demo.tech.web.pages.model.VascPagePartType"/>
</v:field> </v:field>
<v:field id="roles" backendName="ROLES" list="false"/>
</v:entry> </v:entry>

View file

@ -24,6 +24,7 @@ package net.forwardfire.vasc.demo.server.ui;
import java.awt.AWTException; import java.awt.AWTException;
import java.awt.Color; import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
import java.awt.MenuItem; import java.awt.MenuItem;
@ -35,7 +36,9 @@ import java.awt.event.ActionListener;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.util.ArrayList;
import java.util.EventObject; import java.util.EventObject;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -74,7 +77,8 @@ public class ServerGuiApplication extends SingleFrameApplication {
mainView.setComponent(statusPanel); mainView.setComponent(statusPanel);
mainView.getFrame().setMinimumSize(new Dimension(640,480)); mainView.getFrame().setMinimumSize(new Dimension(640,480));
mainView.getFrame().setMaximumSize(new Dimension(800,600)); mainView.getFrame().setMaximumSize(new Dimension(800,600));
mainView.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
show(mainView); show(mainView);
startSystemTray(); startSystemTray();
@ -124,7 +128,11 @@ public class ServerGuiApplication extends SingleFrameApplication {
} }
public void startupDone() { 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) { } catch (IOException e) {
} }
} }
// Invert focus painters
List<Object> keys = new ArrayList<Object>(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; return colorName;
} }
} }

View file

@ -23,6 +23,7 @@
package net.forwardfire.vasc.demo.server.ui.load; package net.forwardfire.vasc.demo.server.ui.load;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Frame; import java.awt.Frame;
@ -194,17 +195,22 @@ public class JLoadDialog extends JDialog implements ActionListener {
if (currentStep <= 0) { if (currentStep <= 0) {
return; return;
} }
currentStep--; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
centerPanel.removeAll(); try {
LoadStep step = steps.get(currentStep); currentStep--;
centerPanel.add(step.getPanel()); centerPanel.removeAll();
topLabel.setText(step.getStepTitle()); LoadStep step = steps.get(currentStep);
step.setupStep(model); centerPanel.add(step.getPanel());
SwingUtilities.updateComponentTreeUI(centerPanel); topLabel.setText(step.getStepTitle());
if (currentStep==0) { step.setupStep(model);
prev.setEnabled(false); SwingUtilities.updateComponentTreeUI(centerPanel);
if (currentStep==0) {
prev.setEnabled(false);
}
next.setText("Next");
} finally {
setCursor(Cursor.getDefaultCursor());
} }
next.setText("Next");
} }
public void gotoStepNext() { public void gotoStepNext() {
@ -221,21 +227,26 @@ public class JLoadDialog extends JDialog implements ActionListener {
if (currentStep > steps.size()-1) { if (currentStep > steps.size()-1) {
return; return;
} }
LoadStep step = steps.get(currentStep); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
boolean result = step.performStep(model); try {
if (result==false) { LoadStep step = steps.get(currentStep);
return; 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);
} }
} }

View file

@ -62,7 +62,7 @@ public class JLoadStepWriteFile extends JPanel implements LoadStep,ActionListene
} }
public String getStepTitle() { public String getStepTitle() {
return "Select Tables"; return "Write xml to file.";
} }
public JPanel getPanel() { public JPanel getPanel() {

View file

@ -223,6 +223,19 @@ public class LoadVascXmlWriter {
if (f.getEditReadOnly()!=null) { if (f.getEditReadOnly()!=null) {
atts.addAttribute ("", "editReadOnly", "", "", ""+f.getEditReadOnly()); 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); //atts.addAttribute ("", "vascGroupId", "", "", model.groupId);
xmlWriter.startElement (URI_VASC_LANG, "field", "", atts); xmlWriter.startElement (URI_VASC_LANG, "field", "", atts);

View file

@ -1,12 +1,18 @@
# #
# Default dark red color thema for pulsefire # yellow-purple color schema from pulsefire.
# #
text=#DF0A0A text=#FF9900
info=#370A00 info=#9F3B00
control=#0A1428 control=#5B084C
nimbusBase=#00050A nimbusBase=#3A0053
nimbusFocus=#0A6428 nimbusDisabledText=#3A0053
nimbusOrange=#00960A nimbusFocus=#FF6600
nimbusBorder=#34415E nimbusLightBackground=#47184D
nimbusDisabledText=#850F0F nimbusSelectedText=#47184D
nimbusLightBackground=#050A28 nimbusBlueGrey=#661C7D
nimbusGreen=#D2C122
nimbusBorder=#A018D8
nimbusSelectionBackground=#BF6204
ComboBox.background=#380030
TabbedPane.background=#380030

View file

@ -22,6 +22,10 @@
package net.forwardfire.vasc.demo.client.swing; 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.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -36,6 +40,7 @@ import javax.naming.InitialContext;
import javax.security.auth.login.LoginContext; import javax.security.auth.login.LoginContext;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.UIManager;
import net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuController; import net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuController;
import net.forwardfire.vasc.demo.tech.ejb3.user.ClientUserController; import net.forwardfire.vasc.demo.tech.ejb3.user.ClientUserController;
@ -70,6 +75,7 @@ public class VascDemoSwingClient extends SingleFrameApplication {
protected void startup() { protected void startup() {
logger = Logger.getLogger(VascDemoSwingClient.class.getName()); logger = Logger.getLogger(VascDemoSwingClient.class.getName());
installColorsLaF();
doLogin(); doLogin();
VascServiceManager vc = null; VascServiceManager vc = null;
@ -187,14 +193,81 @@ public class VascDemoSwingClient extends SingleFrameApplication {
return false; return false;
} catch (Exception e) { } catch (Exception e) {
JOptionPane.showMessageDialog(null, "Server error: "+e.getMessage()); JOptionPane.showMessageDialog(null, "Server error: "+e.getMessage());
e.printStackTrace(); //e.printStackTrace();
return false; 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<Object> keys = new ArrayList<Object>(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) { public String i18n(Object obj,String key,Object...params) {
if(obj==null) { throw new NullPointerException("Can't get key of null obj"); } 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 (key==null) { throw new NullPointerException("key may not be null"); }
if(obj instanceof Class) { if(obj instanceof Class) {
key=((Class<?>)obj).getName()+"."+key; key=((Class<?>)obj).getName()+"."+key;
} else { } else {
@ -203,23 +276,16 @@ public class VascDemoSwingClient extends SingleFrameApplication {
return i18n(key,params); return i18n(key,params);
} }
/** public String i18n(String key,Object...params) {
* Some simple hardcoded i18n function here try {
* String text = ResourceBundle.getBundle(RootApplicationBundle.class.getName()).getString(key);
* @param key if (params != null) {
* @param params MessageFormat mf = new MessageFormat(text);
* @return text = mf.format(params, new StringBuffer(), null).toString();
*/ }
public String i18n(String key,Object...params) { return text;
try { } catch(MissingResourceException e){
String text = ResourceBundle.getBundle(RootApplicationBundle.class.getName()).getString(key); return key;
if (params != null) { }
MessageFormat mf = new MessageFormat(text); }
text = mf.format(params, new StringBuffer(), null).toString();
}
return text;
} catch(MissingResourceException e){
return key;
}
}
} }

View file

@ -23,7 +23,6 @@
package net.forwardfire.vasc.demo.client.swing; package net.forwardfire.vasc.demo.client.swing;
import java.awt.Color; import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
import java.awt.Graphics; import java.awt.Graphics;
@ -43,6 +42,7 @@ import java.util.TimerTask;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Box; import javax.swing.Box;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -51,47 +51,19 @@ import javax.swing.JPasswordField;
import javax.swing.JTextField; import javax.swing.JTextField;
/** /**
* Zwaar gehacke jaas login dialog * VascDemoUserLoginDialog used be be true jaas auth module but now only dialog.
* added features:
* - name remebering
* - focus on name field
* - alway on top
* - logo stuff
* - message field
*
* <p>
* 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
* *
* @see javax.security.auth.callback * @author Willem Cazander
* @version 1.0 Nov 10, 2012
*/ */
public class VascDemoUserLoginDialog { public class VascDemoUserLoginDialog {
private Component parentComponent;
private static final int JPasswordFieldLen = 8; private static final int JPasswordFieldLen = 8;
private int loginTry = 0; private int loginTry = 0;
private String connectUrl = null; private String connectUrl = null;
private String username = null; private String username = null;
private String password = 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 <code>null</code> 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 * An interface for recording actions to carry out if the user clicks OK for
* the dialog. * the dialog.
@ -105,10 +77,9 @@ public class VascDemoUserLoginDialog {
*/ */
public void handle() { public void handle() {
this.loginTry++; this.loginTry++;
/* Collect messages to display in the dialog */
final JPanel loginDesign = new JPanel(); final JPanel loginDesign = new JPanel();
loginDesign.setLayout(new BoxLayout(loginDesign, BoxLayout.PAGE_AXIS)); 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() { final JPanel logoPanel = new JPanel() {
private static final long serialVersionUID = 10l; private static final long serialVersionUID = 10l;
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
@ -119,20 +90,14 @@ public class VascDemoUserLoginDialog {
// Paint the default look of the panel. // Paint the default look of the panel.
super.paintComponent(g2d); 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.setColor(Color.BLACK);
g2d.fillRect(0,0,getWidth(),getHeight()); g2d.fillRect(0,0,getWidth(),getHeight());
g2d.setColor(new Color(238,212,1)); g2d.setColor(new Color(238,212,1));
//int w = (getWidth()/2)-(logoImage.getWidth(null)/2); int w = (getWidth()/2)-(logoImage.getWidth(null)/2);
//int h = (getHeight()/2)-(logoImage.getHeight(null)/2); int h = (getHeight()/2)-(logoImage.getHeight(null)/2);
//g2d.drawImage(logoImage, w, h, this); g2d.drawImage(logoImage, w, h, this);
} }
}; };
logoPanel.setPreferredSize(new Dimension(200, 170)); logoPanel.setPreferredSize(new Dimension(200, 170));
@ -146,13 +111,11 @@ public class VascDemoUserLoginDialog {
loginDesign.add(namePanel); loginDesign.add(namePanel);
loginDesign.add(Box.createVerticalStrut(5)); loginDesign.add(Box.createVerticalStrut(5));
final List<Action> okActions = new ArrayList<Action>(2);
final GridLayout messagesLayout = new GridLayout(3,2); final GridLayout messagesLayout = new GridLayout(3,2);
final JPanel messages = new JPanel(); final JPanel messages = new JPanel();
messages.setLayout(messagesLayout); messages.setLayout(messagesLayout);
/* Collection actions to perform if the user clicks OK */
final List<Action> okActions = new ArrayList<Action>(2);
// Add server field // Add server field
JLabel serverName = new JLabel("Server:"); JLabel serverName = new JLabel("Server:");
final JTextField serverField = new JTextField(getConnectUrl()); 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(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); 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"); JDialog dialog = jop.createDialog(parentComponent,"Vasc Demo Login");
// We alway request focus after the windows gets focus // We alway request focus after the windows gets focus

View file

@ -29,4 +29,5 @@ Application.homepage = http://vasc.forwardfire.org/
Application.vendorId = vasc Application.vendorId = vasc
Application.id = vascdemotech Application.id = vascdemotech
Application.lookAndFeel = com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel Application.lookAndFeel = com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel
#Application.icon = images/icon.png Application.icon = icon.png

View file

@ -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

View file

@ -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<String,String> {
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<java.util.Map.Entry<String, String>> entrySet() {
return null;
}
@Override
public String get(Object key) {
return getBundle().getString((String)key);
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public Set<String> keySet() {
return getBundle().keySet();
}
@Override
public String put(String key, String value) {
return value;
}
@Override
public void putAll(Map<? extends String, ? extends String> arg0) {
}
@Override
public String remove(Object key) {
return (String)key;
}
@Override
public int size() {
return getBundle().keySet().size();
}
@Override
public Collection<String> values() {
return null;
}
}

View file

@ -7,10 +7,12 @@
> >
<application> <application>
<!-- moved to I18nController because of hard caching resources in jsf impl.
<resource-bundle> <resource-bundle>
<base-name>net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle</base-name> <base-name>net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle</base-name>
<var>i18n</var> <var>i18n</var>
</resource-bundle> </resource-bundle>
-->
<locale-config> <locale-config>
<default-locale>en</default-locale> <default-locale>en</default-locale>
</locale-config> </locale-config>
@ -20,6 +22,13 @@
</system-event-listener> </system-event-listener>
</application> </application>
<managed-bean>
<description>I18n map bean as workaround for jsf caching.</description>
<managed-bean-name>i18n</managed-bean-name>
<managed-bean-class>net.forwardfire.vasc.demo.tech.web.beans.I18nController</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
<managed-bean> <managed-bean>
<description>Fixes the context path for root vs non-root deployments.</description> <description>Fixes the context path for root vs non-root deployments.</description>
<managed-bean-name>contextPathController</managed-bean-name> <managed-bean-name>contextPathController</managed-bean-name>

View file

@ -30,6 +30,7 @@ import java.util.Map;
import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.core.VascException;
import net.forwardfire.vasc.frontend.VascFrontendDataSelector.EntryFieldSelectType;
import net.forwardfire.vasc.lib.jr4o.data.AbstractJRDynamicDataSource; import net.forwardfire.vasc.lib.jr4o.data.AbstractJRDynamicDataSource;
import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField; import net.sf.jasperreports.engine.JRField;
@ -46,6 +47,7 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource {
private VascEntry vascEntry = null; private VascEntry vascEntry = null;
private List<VascEntryField> fields = null;
private long total = -1; private long total = -1;
private int index = -1; private int index = -1;
private static final String PREFIX_COLUMN = "COLUMN_"; private static final String PREFIX_COLUMN = "COLUMN_";
@ -61,6 +63,8 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource {
this.vascEntry = vascEntry; this.vascEntry = vascEntry;
total = vascEntry.getVascFrontendController().getVascEntryState().getTotalBackendRecords(); total = vascEntry.getVascFrontendController().getVascEntryState().getTotalBackendRecords();
fields = vascEntry.getVascFrontendController().getVascFrontendDataSelector().getFields(EntryFieldSelectType.EXPORT);
// hackje until calc index to page and row. // hackje until calc index to page and row.
try { try {
data = new ArrayList<List<String>>(1000); data = new ArrayList<List<String>>(1000);
@ -70,7 +74,7 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource {
vascEntry.getVascFrontendController().getVascFrontendActions().refreshData(); vascEntry.getVascFrontendController().getVascFrontendActions().refreshData();
for (Object o:vascEntry.getVascFrontendController().getVascEntryState().getEntryDataList()) { for (Object o:vascEntry.getVascFrontendController().getVascEntryState().getEntryDataList()) {
List<String> row = new ArrayList<String>(30); List<String> row = new ArrayList<String>(30);
for (VascEntryField c:vascEntry.getVascEntryFields()) { for (VascEntryField c:fields) {
row.add(c.getVascEntryFieldValue().getDisplayValue(c, o)); row.add(c.getVascEntryFieldValue().getDisplayValue(c, o));
} }
data.add(row); data.add(row);
@ -90,10 +94,8 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource {
return data.get(index).get(Integer.parseInt(fieldName.substring(7))); return data.get(index).get(Integer.parseInt(fieldName.substring(7)));
} }
if (fieldName.startsWith(PREFIX_HEADER)) { if (fieldName.startsWith(PREFIX_HEADER)) {
return "todo"; // TODO: fixme VascEntryField field = fields.get(Integer.parseInt(fieldName.substring(7)));
//List<VascEntryField> fields = vascEntry.getVascEntryFields(); 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); throw new JRException("Unknown column name : " + fieldName);
} }

View file

@ -51,7 +51,11 @@ public class JSFVascEntryEventListener implements VascEntryFrontendEventListener
* @see net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener#getEventTypes() * @see net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener#getEventTypes()
*/ */
public VascFrontendEventType[] 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; return result;
} }

View file

@ -87,8 +87,6 @@ public class JSFVascEntrySupportBean implements Serializable {
private Boolean backendMoveable = null; private Boolean backendMoveable = null;
private Boolean backendSearchable = null; private Boolean backendSearchable = null;
private Boolean backendPageable = null; private Boolean backendPageable = null;
private Boolean sortOrder = null;
private String sortField = null;
private VascEntryExport selectedExporter = null; private VascEntryExport selectedExporter = null;
private String selectedExporterAction = "null"; private String selectedExporterAction = "null";
private String selectedDirectPage = "null"; private String selectedDirectPage = "null";
@ -441,8 +439,6 @@ public class JSFVascEntrySupportBean implements Serializable {
VascEntry entry = comp.getVascEntry(); VascEntry entry = comp.getVascEntry();
VascEntryField field = entry.getVascEntryFieldById(fieldIdString); VascEntryField field = entry.getVascEntryFieldById(fieldIdString);
entry.getVascFrontendController().getVascFrontendActions().sortAction(field); entry.getVascFrontendController().getVascFrontendActions().sortAction(field);
sortOrder = entry.getVascFrontendController().getVascEntryState().getVascBackendState().isSortAscending();
sortField = field.getId();
} }
public boolean getRenderBackAction() { public boolean getRenderBackAction() {
@ -855,20 +851,6 @@ public class JSFVascEntrySupportBean implements Serializable {
return tablePagesDataModel; return tablePagesDataModel;
} }
/**
* @return the sortOrder
*/
public Boolean getSortOrder() {
return sortOrder;
}
/**
* @return the sortField
*/
public String getSortField() {
return sortField;
}
/** /**
* @return the selectedExporter * @return the selectedExporter
*/ */

View file

@ -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.JSFText;
import net.forwardfire.vasc.frontend.web.jsf.ui.JSFTextArea; import net.forwardfire.vasc.frontend.web.jsf.ui.JSFTextArea;
/** /**
* Given the jsf vasc renderer its own class * 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()); logger = Logger.getLogger(JSFVascFrontendRenderer.class.getName());
} }
// Frontend Stuff
/** /**
* @see net.forwardfire.vasc.frontend.VascFrontend#getFrontendType() * @see net.forwardfire.vasc.frontend.VascFrontend#getFrontendType()
*/ */
@ -65,10 +61,9 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser
return "jsf"; return "jsf";
} }
protected void addUiComponents() { protected void addUiComponents() {
VascFrontendController vfd = getVascEntry().getVascFrontendController(); VascFrontendController vfd = getVascEntry().getVascFrontendController();
// required UI components // 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_LABEL,JSFLabel.class.getName());
vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_TEXT, JSFText.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()); //vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_COLOR , JSFColorChooser.class.getName());
} }
/** /**
* @see net.forwardfire.vasc.frontend.VascFrontend#renderDelete(java.lang.Object) * @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()); JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId());
comp.setRenderFacetState("deleteView"); comp.setRenderFacetState("deleteView");
} }
/** /**
* @see net.forwardfire.vasc.frontend.VascFrontend#renderEdit(java.lang.Object) * @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); comp.getSupportBean().setSelected(selBean);
} }
/** /**
* @see net.forwardfire.vasc.frontend.VascFrontend#renderExport(net.forwardfire.vasc.core.entry.VascEntryExport) * @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.setRenderFacetState("exportView");
comp.getSupportBean().setSelectedExporter(exporter); comp.getSupportBean().setSelectedExporter(exporter);
} }
/** /**
* @see net.forwardfire.vasc.frontend.VascFrontend#renderView() * @see net.forwardfire.vasc.frontend.VascFrontend#renderView()
*/ */
@ -134,10 +129,5 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot(); UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId()); JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId());
comp.setRenderFacetState("listView"); comp.setRenderFacetState("listView");
//if (comp.getSupportBean().getSelected()!=null) {
// comp.getSupportBean().getSelected().setRealValue(false);
// comp.getSupportBean().setSelected(null);
//}
} }
} }

View file

@ -26,7 +26,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.el.ValueExpression; import javax.el.ValueExpression;
@ -57,63 +56,62 @@ import net.forwardfire.vasc.frontend.web.jsf.ui.JSFListModel;
*/ */
public class JSFVascUIComponent extends UIComponentBase { public class JSFVascUIComponent extends UIComponentBase {
public static final String FAMILY = "vasc.jsf.component.family"; public static final String FAMILY = "vasc.jsf.component.family";
public static final String ENTRY_SUPPORT_VAR_KEY = "entrySupportVar"; public static final String ENTRY_SUPPORT_VAR_KEY = "entrySupportVar";
public static final String TABLE_RECORD_VAR_KEY = "tableRecordVar"; public static final String TABLE_RECORD_VAR_KEY = "tableRecordVar";
public static final String INJECT_EDIT_FIELDS_ID = "injectEditFieldsId"; public static final String INJECT_EDIT_FIELDS_ID = "injectEditFieldsId";
public static final String INJECT_TABLE_OPTIONS_ID = "injectTableOptionsId"; public static final String INJECT_TABLE_OPTIONS_ID = "injectTableOptionsId";
public static final String INJECT_TABLE_COLUMNS_ID = "injectTableColumnsId"; public static final String INJECT_TABLE_COLUMNS_ID = "injectTableColumnsId";
public static final String DISABLE_LINK_COLUMNS = "disableLinkColumns"; public static final String DISABLE_LINK_COLUMNS = "disableLinkColumns";
public static final String INJECT_TABLE_OPTIONS_ON_CHANGE = "injectTableOptionOnChange"; public static final String INJECT_TABLE_OPTIONS_ON_CHANGE = "injectTableOptionOnChange";
private JSFVascFrontendRenderer renderer = null; private JSFVascFrontendRenderer renderer = null;
private JSFVascEntrySupportBean supportBean = null; private JSFVascEntrySupportBean supportBean = null;
private String renderFacetState = null; private String renderFacetState = null;
private VascEntryLink link = null; private VascEntryLink link = null;
private VascEntryState linkState = null; private VascEntryState linkState = null;
private VascEntryState state = null; private VascEntryState state = null;
private Object stateEditId = null; private Object stateEditId = null;
private Logger logger = null; private Logger logger = null;
private Boolean initClear = null; private Boolean initClear = null;
private String injectTableOptionOnChange = null; private String injectTableOptionOnChange = null;
public JSFVascUIComponent() { public JSFVascUIComponent() {
logger = Logger.getLogger(JSFVascUIComponent.class.getName()); logger = Logger.getLogger(JSFVascUIComponent.class.getName());
} }
public String getFamily() { public String getFamily() {
return FAMILY; 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 @Override
public Object saveState(FacesContext facesContext) { public void restoreState(FacesContext facesContext, Object state) {
logger.fine("Save State"); logger.fine("Resotre State");
Object values[] = new Object[5]; Object values[] = (Object[])state;
values[0] = super.saveState(facesContext); super.restoreState(facesContext, values[0]);
values[1] = renderer; renderer = (JSFVascFrontendRenderer) values[1];
values[2] = supportBean; supportBean = (JSFVascEntrySupportBean) values[2];
values[3] = renderFacetState; renderFacetState = (String) values[3];
values[4] = this.getAttributes().get(INJECT_TABLE_OPTIONS_ON_CHANGE); injectTableOptionOnChange = (String) values[4];
return values;
} // TODO: check if we can move this some day...
@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...
String entrySupportVar = (String)getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY); String entrySupportVar = (String)getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+"}", Object.class); ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+"}", Object.class);
ve2.setValue(FacesContext.getCurrentInstance().getELContext(), getSupportBean()); ve2.setValue(FacesContext.getCurrentInstance().getELContext(), getSupportBean());
} }
static public JSFVascUIComponent findVascParent(UIComponent comp) { static public JSFVascUIComponent findVascParent(UIComponent comp) {
if (comp==null) { if (comp==null) {
return null; return null;
@ -146,7 +144,7 @@ public class JSFVascUIComponent extends UIComponentBase {
} }
return null; return null;
} }
/** /**
* Finds component with the given id * Finds component with the given id
*/ */
@ -229,7 +227,7 @@ public class JSFVascUIComponent extends UIComponentBase {
// edit action copyed // edit action copyed
try { try {
VascEntry entry = supportBean.getVascEntry(); VascEntry entry = supportBean.getVascEntry();
entry.getVascFrontendController().getVascEntryState().setEditCreate(false); entry.getVascFrontendController().getVascEntryState().setEditCreate(false);
entry.getVascFrontendController().fireVascFrontendEvent(entry, VascFrontendEventType.SELECT, rowObject); entry.getVascFrontendController().fireVascFrontendEvent(entry, VascFrontendEventType.SELECT, rowObject);
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(rowObject); entry.getVascFrontendController().getVascEntryState().setEntryDataObject(rowObject);
@ -263,46 +261,44 @@ public class JSFVascUIComponent extends UIComponentBase {
super.encodeBegin(context); super.encodeBegin(context);
} }
public UIComponent getCurrentView() { public UIComponent getCurrentView() {
UIComponent result = getFacet(renderFacetState); UIComponent result = getFacet(renderFacetState);
if (result==null) { if (result==null) {
throw new IllegalArgumentException("Could not get facet: "+renderFacetState); throw new IllegalArgumentException("Could not get facet: "+renderFacetState);
} }
return result; return result;
} }
public JSFVascEntrySupportBean getSupportBean() { public JSFVascEntrySupportBean getSupportBean() {
return supportBean; return supportBean;
} }
public void setRenderFacetState(String renderFacetState) { public void setRenderFacetState(String renderFacetState) {
this.renderFacetState=renderFacetState; this.renderFacetState=renderFacetState;
} }
public String getRenderFacetState() { public String getRenderFacetState() {
return renderFacetState; return renderFacetState;
} }
/** /**
* @return the injectTableOptionOnChange * @return the injectTableOptionOnChange
*/ */
public String getInjectTableOptionOnChange() { public String getInjectTableOptionOnChange() {
return injectTableOptionOnChange; return injectTableOptionOnChange;
} }
/** /**
* @param injectTableOptionOnChange the injectTableOptionOnChange to set * @param injectTableOptionOnChange the injectTableOptionOnChange to set
*/ */
public void setInjectTableOptionOnChange(String injectTableOptionOnChange) { public void setInjectTableOptionOnChange(String injectTableOptionOnChange) {
this.injectTableOptionOnChange = injectTableOptionOnChange; this.injectTableOptionOnChange = injectTableOptionOnChange;
} }
public VascEntry createClonedVascEntry() { public VascEntry createClonedVascEntry() {
VascController vascController = (VascController)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(VascRequestFacesFilter.REQ_VASC_CONTOLLER); 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); String entryId = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(VascRequestFacesFilter.REQ_VASC_ENTRY_ID);
if (link!=null) { if (link!=null) {
entryId = link.getVascEntryId(); entryId = link.getVascEntryId();
} }
@ -314,8 +310,6 @@ public class JSFVascUIComponent extends UIComponentBase {
if (entry==null) { if (entry==null) {
throw new NullPointerException("Could not get '"+entryId+"' from : "+vascController); throw new NullPointerException("Could not get '"+entryId+"' from : "+vascController);
} }
try { try {
vascController.getVascEntryConfigController().configVascFrontendController(vascController, entry); vascController.getVascEntryConfigController().configVascFrontendController(vascController, entry);
} catch (Exception e1) { } catch (Exception e1) {
@ -410,4 +404,4 @@ public class JSFVascUIComponent extends UIComponentBase {
} }
} }
} }
} }

View file

@ -419,14 +419,14 @@ public class JSFVascUIComponentRenderer extends Renderer {
orderUp.setId(viewRoot.createUniqueId()); orderUp.setId(viewRoot.createUniqueId());
orderUp.setEscape(false); orderUp.setEscape(false);
orderUp.setValue("&#x2191;"); // orderUp.setValue("&#x2191;"); //
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); orderUp.setValueExpression("rendered", ren2);
HtmlOutputText orderDown = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE); HtmlOutputText orderDown = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
orderDown.setId(viewRoot.createUniqueId()); orderDown.setId(viewRoot.createUniqueId());
orderDown.setEscape(false); orderDown.setEscape(false);
orderDown.setValue("&#x2193;"); // orderDown.setValue("&#x2193;"); //
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); orderDown.setValueExpression("rendered", ren3);
link.getChildren().add(out2); link.getChildren().add(out2);

View file

@ -29,6 +29,7 @@ import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.entry.VascEntryFieldValue; import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
import net.forwardfire.vasc.core.VascException; 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()) { if (index>entry.getVascEntryFields().size()) {
throw new IllegalArgumentException("Index is bigger then total field size: "+index); 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) { static public int getIndexId(VascEntryField field) {

View file

@ -94,20 +94,19 @@ public class VascRequestFacesFilter implements Filter {
className = className.substring(atIndex+1); className = className.substring(atIndex+1);
} }
try { try {
ClassLoader cl = Thread.currentThread().getContextClassLoader(); ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl == null) { if (cl == null) {
cl = className.getClass().getClassLoader(); cl = className.getClass().getClassLoader();
} }
Class<?> clazz = cl.loadClass(className); Class<?> clazz = cl.loadClass(className);
if (classArgument==null) { if (classArgument==null) {
vascControllerProvider = (VascControllerProvider)clazz.newInstance(); vascControllerProvider = (VascControllerProvider)clazz.newInstance();
} else { } else {
vascControllerProvider = (VascControllerProvider)clazz.getConstructor(String.class).newInstance(classArgument); vascControllerProvider = (VascControllerProvider)clazz.getConstructor(String.class).newInstance(classArgument);
} }
} catch (Exception e) { } catch (Exception e) {
throw new ServletException("Could not create VascControllerProvider: "+e.getMessage(),e); throw new ServletException("Could not create VascControllerProvider: "+e.getMessage(),e);
} }
} }
/** /**

View file

@ -56,16 +56,25 @@ public class VascBundleCheckEntryKeys {
} }
public Map<String,String> collectVascKeys(VascEntry ve) { public Map<String,String> 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<String,String> keys = new HashMap<String,String>(300); Map<String,String> keys = new HashMap<String,String>(300);
keys.put(ve.getName(), ve.getId()); keys.put(ve.getName(), value);
keys.put(ve.getImage(), ve.getId()); 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.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.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.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); keys.put(ve.getCreateImage(), imagePrefix+ve.getId()+imagePostfix);
for (VascEntryField vef:ve.getVascEntryFields()) { for (VascEntryField vef:ve.getVascEntryFields()) {
keys.put(vef.getName(), vef.getId()); keys.put(vef.getName(), vef.getId());

View file

@ -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" 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" providerName="vasc.forwardfire.net"
name="Vasc EJB3 Xpql query loading" name="Vasc EJB3 Xpql query loading"
id="mod-vasc-xpql-ejb3" id="vasc-xpql-ejb3"
> >
<namespace uri="http://vasc.forwardfire.net/xml/ns/xpql-ejb3" <namespace uri="http://vasc.forwardfire.net/xml/ns/xpql-ejb3"
schemaUri="http://vasc.forwardfire.net/xml/ns/xpql-ejb3-1.0.xsd" schemaUri="http://vasc.forwardfire.net/xml/ns/xpql-ejb3-1.0.xsd"

View file

@ -49,6 +49,7 @@ import net.forwardfire.vasc.xpql.query.QueryParameterValue;
/** /**
* XpqlQueryManagerImpl
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 16 Jul 2007 * @version 1.0 16 Jul 2007
@ -58,12 +59,11 @@ import net.forwardfire.vasc.xpql.query.QueryParameterValue;
public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryManager.IRemote { public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryManager.IRemote {
private static final Logger logger = Logger.getLogger(XpqlQueryManagerImpl.class.getName()); private static final Logger logger = Logger.getLogger(XpqlQueryManagerImpl.class.getName());
private EntityManager entityManager; private EntityManager entityManager;
@Resource @Resource
private UserTransaction utx; private UserTransaction utx;
private Map<String,Query> queries = new HashMap<String,Query>(100); private Map<String,Query> queries = new HashMap<String,Query>(100);
@PostConstruct @PostConstruct
@ -73,117 +73,114 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
Map<String,String> keys = loadKeys(); Map<String,String> keys = loadKeys();
for (String key:keys.keySet()) { for (String key:keys.keySet()) {
String value = keys.get(key); String value = keys.get(key);
if (key.startsWith("load")) { if (key.startsWith("load")) {
loadResource(value); loadResource(value);
} }
if ("persistenceUnit".equals(key)) { if ("persistenceUnit".equals(key)) {
logger.fine("getting EntityManager: "+value); logger.fine("getting EntityManager: "+value);
entityManager = (EntityManager)new InitialContext().lookup(value); entityManager = (EntityManager)new InitialContext().lookup(value);
} }
} }
long t = System.currentTimeMillis()-s; long t = System.currentTimeMillis()-s;
logger.info("Total loaded xpql queries: "+queries.size()+" in "+t+" ms."); logger.info("Total loaded xpql queries: "+queries.size()+" in "+t+" ms.");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Error while load xpql resources error: "+e.getMessage(),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<String,String> loadKeys() throws IOException {
Properties properties = new Properties();
logger.fine("Getting urls");
Enumeration<URL> 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<String,String> result = new HashMap<String,String>(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<String,String> loadKeys() throws IOException {
Properties properties = new Properties();
logger.fine("Getting urls");
Enumeration<URL> 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<String,String> result = new HashMap<String,String>(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) { private void loadResource(String resource) {
XPQLParser parser = new XPQLParser(); XPQLParser parser = new XPQLParser();
logger.fine("Try loading: "+resource); logger.fine("Try loading: "+resource);
try { try {
parser.parseResource(resource); parser.parseResource(resource);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Could not load xpql resource: "+resource+" error: "+e.getMessage(),e); throw new RuntimeException("Could not load xpql resource: "+resource+" error: "+e.getMessage(),e);
} }
QueryStore store = parser.getQueryStore(); QueryStore store = parser.getQueryStore();
for (String key:store.getQueryNames()) { for (String key:store.getQueryNames()) {
Query q = store.getQuery(key); Query q = store.getQuery(key);
queries.put(q.getName(),q); queries.put(q.getName(),q);
String out = "\n\n=========== SQL: "+q.getName()+"\n"; String out = "\n\n=========== SQL: "+q.getName()+"\n";
//out +=q.toSQL(q); //out +=q.toSQL(q);
out +="=========== XML: "+q.getName()+"\n"; out +="=========== XML: "+q.getName()+"\n";
out +=q.toXML(q); out +=q.toXML(q);
//out +="=========== Edit: "+q.getName()+"\n"; //out +="=========== Edit: "+q.getName()+"\n";
//out +=q.toEdit(q); //out +=q.toEdit(q);
out +="=========== Prepard: "+q.getName()+"\n"; out +="=========== Prepard: "+q.getName()+"\n";
out +=q.toPreparedSQL(q)+"\n"; out +=q.toPreparedSQL(q)+"\n";
logger.finer("FOUND Query: "+out); logger.finer("FOUND Query: "+out);
} }
} }
public Query getQuery(String name) { public Query getQuery(String name) {
Query q = queries.get(name); Query q = queries.get(name);
return q; return q;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<Object> execute(Query query) { public List<Object> execute(Query query) {
String sql = query.toPreparedSQL(query); String sql = query.toPreparedSQL(query);
logger.finer("Executing: "+query.getName()+" sql: "+sql); logger.finer("Executing: "+query.getName()+" sql: "+sql);
javax.persistence.Query q2 = null; javax.persistence.Query q2 = null;
if (Query.QueryType.hql==query.getType()) { if (Query.QueryType.hql==query.getType()) {
q2 = entityManager.createQuery(sql); q2 = entityManager.createQuery(sql);
} }
if (Query.QueryType.sql==query.getType()) { if (Query.QueryType.sql==query.getType()) {
q2 = entityManager.createNativeQuery(sql); q2 = entityManager.createNativeQuery(sql);
} }
// TODO: move this hack to xtest xpql // TODO: move this hack to xtest xpql
if (query.getProperty("limit")!=null) { if (query.getProperty("limit")!=null) {
int max = new Integer(query.getPropertyString("limit")); 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")); int offset = new Integer(query.getPropertyString("offset"));
q2.setFirstResult(offset); q2.setFirstResult(offset);
} }
List<QueryParameterValue> options = query.getOrderQueryParameterValues();
List<QueryParameterValue> options = query.getOrderQueryParameterValues();
int i=1; int i=1;
for ( QueryParameterValue value : options ) { for ( QueryParameterValue value : options ) {
Object para = value.getValue(); Object para = value.getValue();
@ -208,20 +204,19 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa
} }
return q2.getResultList(); return q2.getResultList();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Object executeObject(Query query) { public Object executeObject(Query query) {
String sql = query.toPreparedSQL(query); String sql = query.toPreparedSQL(query);
logger.finer("Executing: "+query.getName()+" sql: "+sql); logger.finer("Executing: "+query.getName()+" sql: "+sql);
javax.persistence.Query q2 = null; javax.persistence.Query q2 = null;
if (Query.QueryType.hql==query.getType()) { if (Query.QueryType.hql==query.getType()) {
q2 = entityManager.createQuery(sql); q2 = entityManager.createQuery(sql);
} }
if (Query.QueryType.sql==query.getType()) { if (Query.QueryType.sql==query.getType()) {
q2 = entityManager.createNativeQuery(sql); q2 = entityManager.createNativeQuery(sql);
} }
// TODO: move this hack to xtest xpql // TODO: move this hack to xtest xpql
if (query.getProperty("limit")!=null) { if (query.getProperty("limit")!=null) {
int max = new Integer(query.getPropertyString("limit")); 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")); int offset = new Integer(query.getPropertyString("offset"));
q2.setFirstResult(offset); q2.setFirstResult(offset);
} }
List<QueryParameterValue> options = query.getOrderQueryParameterValues(); List<QueryParameterValue> options = query.getOrderQueryParameterValues();
int i=1; int i=1;
for ( QueryParameterValue value : options ) { for ( QueryParameterValue value : options ) {
Object para = value.getValue(); Object para = value.getValue();
@ -255,9 +250,9 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa
} }
} }
return result; return result;
} catch (Exception se) { } catch (Exception se) {
throw new RuntimeException("Transaction error: "+se.getMessage(),se); throw new RuntimeException("Transaction error: "+se.getMessage(),se);
} }
} }
public List<Object> execute(String name,Map<String,Object> parameters) { public List<Object> execute(String name,Map<String,Object> parameters) {
@ -283,59 +278,59 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa
} }
public Integer executeUpdate(Query query) { public Integer executeUpdate(Query query) {
String sql = query.toPreparedSQL(query); String sql = query.toPreparedSQL(query);
logger.fine("Executing: "+query.getName()+" sql: "+sql); logger.fine("Executing: "+query.getName()+" sql: "+sql);
try { try {
javax.persistence.Query q2 = null; javax.persistence.Query q2 = null;
if (Query.QueryType.hql==query.getType()) { if (Query.QueryType.hql==query.getType()) {
q2 = entityManager.createQuery(sql); q2 = entityManager.createQuery(sql);
List<QueryParameterValue> options = query.getOrderQueryParameterValues(); List<QueryParameterValue> options = query.getOrderQueryParameterValues();
int i=1; int i=1;
for ( QueryParameterValue value : options ) { for ( QueryParameterValue value : options ) {
Object para = value.getValue(); Object para = value.getValue();
if(para==null) { if(para==null) {
para = value.getDefaultValue(); para = value.getDefaultValue();
} }
logger.finest( "nr: " + i + " value: " + para+" name: "+value.getName()); logger.finest( "nr: " + i + " value: " + para+" name: "+value.getName());
q2.setParameter(i,para); q2.setParameter(i,para);
i++; i++;
} }
utx.begin(); utx.begin();
Integer result = q2.executeUpdate(); Integer result = q2.executeUpdate();
utx.commit();
return result;
}
if (Query.QueryType.sql==query.getType()) {
q2 = entityManager.createNativeQuery(sql);
List<QueryParameterValue> 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(); utx.commit();
return result; return result;
} }
} catch (Exception se) {
throw new RuntimeException("Transaction error: "+se.getMessage(),se); if (Query.QueryType.sql==query.getType()) {
} q2 = entityManager.createNativeQuery(sql);
throw new IllegalStateException("unknow query type"); List<QueryParameterValue> 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<String, Object> parameters) { public Integer executeUpdate(String name,Map<String, Object> parameters) {
Query query = getQuery(name); Query query = getQuery(name);
for (String key:parameters.keySet()) { for (String key:parameters.keySet()) {
Object value = parameters.get(key); Object value = parameters.get(key);
query.setQueryParameter(key, value); query.setQueryParameter(key, value);
} }
return executeUpdate(query); return executeUpdate(query);
} }
} }

View file

@ -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" 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" providerName="vasc.forwardfire.net"
name="Xpql query loading" name="Xpql query loading"
id="mod-vasc-xpql" id="vasc-xpql"
> >
<namespace uri="http://vasc.forwardfire.net/xml/ns/vasc-xpql" <namespace uri="http://vasc.forwardfire.net/xml/ns/vasc-xpql"
schemaUri="http://vasc.forwardfire.net/xml/ns/vasc-xpql-1.0.xsd" schemaUri="http://vasc.forwardfire.net/xml/ns/vasc-xpql-1.0.xsd"