Switch to new meta model,fixed small bugs and made demo work pretty oke.
This commit is contained in:
parent
afd821c360
commit
b3635cf64d
18
pom.xml
18
pom.xml
|
@ -86,7 +86,7 @@
|
|||
<jldap.version>4.3</jldap.version>
|
||||
|
||||
<!-- vasc-backend-metamodel -->
|
||||
<metamodel.version>3.1.3-SNAPSHOT</metamodel.version>
|
||||
<metamodel.version>3.2.5</metamodel.version>
|
||||
|
||||
<!-- vasc-backend-mongo -->
|
||||
<mongo-java-driver.version>2.7.3</mongo-java-driver.version>
|
||||
|
@ -107,18 +107,18 @@
|
|||
<jasperreports.version>4.5.1</jasperreports.version>
|
||||
|
||||
<!-- vasc-demo-tech-core -->
|
||||
<logback-access.version>1.0.3</logback-access.version>
|
||||
<logback-classic.version>1.0.3</logback-classic.version>
|
||||
<logback-access.version>1.0.9</logback-access.version>
|
||||
<logback-classic.version>1.0.9</logback-classic.version>
|
||||
<jul-to-slf4j.version>1.6.4</jul-to-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>
|
||||
|
||||
<!-- vasc-demo-tech-core jdbc drivers -->
|
||||
<postgresql.version>9.1-901.jdbc4</postgresql.version>
|
||||
<mysql-connector-java.version>5.1.20</mysql-connector-java.version>
|
||||
<h2.version>1.3.167</h2.version>
|
||||
<derby.version>10.8.2.2</derby.version>
|
||||
<postgresql.version>9.1-901-1.jdbc4</postgresql.version>
|
||||
<mysql-connector-java.version>5.1.22</mysql-connector-java.version>
|
||||
<h2.version>1.3.170</h2.version>
|
||||
<derby.version>10.9.1.0</derby.version>
|
||||
|
||||
<!-- Vasc Hibernate integration -->
|
||||
<hibernate-validator.version>3.1.0.CR1</hibernate-validator.version>
|
||||
|
@ -148,7 +148,7 @@
|
|||
<el-api.version>2.2.1-b04</el-api.version>
|
||||
<quartz.version>1.6.3</quartz.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 -->
|
||||
<saxon.version>9.1.0.8</saxon.version>
|
||||
|
|
13
todo.txt
13
todo.txt
|
@ -8,21 +8,8 @@
|
|||
- demo menu
|
||||
- demo wiki
|
||||
|
||||
- hotdeploy
|
||||
- null list option mongo query
|
||||
- sql conn limit
|
||||
- mongo backend limit
|
||||
|
||||
Build layout:
|
||||
lib/
|
||||
demo/
|
||||
deploy/
|
||||
config/
|
||||
workdir/
|
||||
logs/
|
||||
|
||||
- remote ejb3
|
||||
|
||||
- encodeing select model
|
||||
- lcoale select model
|
||||
- x4o template
|
||||
|
|
|
@ -102,7 +102,7 @@ public class XpqlHibernateVascBackend extends AbstractHibernateVascBackend {
|
|||
i++;
|
||||
}
|
||||
if (isPageable() && state.getPageSize()>0) {
|
||||
q.setFirstResult(state.getPageIndex());
|
||||
q.setFirstResult(state.getPageIndex()*state.getPageSize());
|
||||
q.setMaxResults(state.getPageSize());
|
||||
}
|
||||
List<Object> data = q.list();
|
||||
|
|
|
@ -102,7 +102,7 @@ public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend
|
|||
i++;
|
||||
}
|
||||
if (isPageable() && state.getPageSize()>0) {
|
||||
q.setFirstResult(state.getPageIndex());
|
||||
q.setFirstResult(state.getPageIndex()*state.getPageSize());
|
||||
q.setMaxResults(state.getPageSize());
|
||||
}
|
||||
if (emTransaction) {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd"
|
||||
providerName="vasc.forwardfire.net"
|
||||
name="Vasc Backend JPA"
|
||||
id="mod-vasc-backend-jpa"
|
||||
id="vasc-backend-jpa"
|
||||
>
|
||||
<description>Provides VASC JPA backend support.</description>
|
||||
<namespace uri="http://vasc.forwardfire.net/xml/ns/vasc-backend-jpa"
|
||||
|
|
|
@ -61,6 +61,8 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
private String keyAttribute = null;
|
||||
private String ldapFilter = null;
|
||||
private String createObjectClass = null;
|
||||
private int timeLimit = 10000;
|
||||
private boolean referralFollowing = true;
|
||||
|
||||
/**
|
||||
* @return the ldapConnectionProvider
|
||||
|
@ -75,9 +77,6 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
public void setLdapConnectionProvider(LdapConnectionProvider ldapConnectionProvider) {
|
||||
this.ldapConnectionProvider = ldapConnectionProvider;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#execute()
|
||||
|
@ -88,23 +87,21 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
List<Object> result = new ArrayList<Object>(50);
|
||||
try {
|
||||
|
||||
|
||||
LDAPSearchConstraints cons = new LDAPSearchConstraints();
|
||||
cons.setBatchSize( 0 );
|
||||
cons.setTimeLimit( 10000 ) ;
|
||||
cons.setReferralFollowing(true);
|
||||
cons.setTimeLimit(getTimeLimit() ) ;
|
||||
cons.setReferralFollowing(isReferralFollowing());
|
||||
connection.setConstraints(cons);
|
||||
|
||||
int searchScope = LDAPConnection.SCOPE_ONE;
|
||||
String searchBase = baseDN;
|
||||
|
||||
//System.out.println("Reading object :" + searchBase + " with filter: " + ldapFilter);
|
||||
LDAPSearchResults searchResults = connection.search(
|
||||
searchBase, // object to read
|
||||
searchScope, // scope - read single object
|
||||
ldapFilter, // search filter
|
||||
null, // return all attributes
|
||||
false); // return attrs and values
|
||||
searchBase, // object to read
|
||||
searchScope, // scope - read single object
|
||||
getLdapFilter(), // search filter
|
||||
null, // return all attributes
|
||||
false); // return attrs and values
|
||||
|
||||
while (searchResults.hasMore()) {
|
||||
LDAPEntry entry = searchResults.next();
|
||||
|
@ -114,7 +111,6 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
Iterator<LDAPAttribute> i = attributeSet.iterator();
|
||||
while (i.hasNext()) {
|
||||
LDAPAttribute attr = i.next();
|
||||
//System.out.println("ATTR: "+attr.getName()+" value: "+attr.getStringValue());
|
||||
String[] s = attr.getStringValueArray();
|
||||
if (s.length==1) {
|
||||
map.put(attr.getName(), attr.getStringValue());
|
||||
|
@ -149,14 +145,12 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
String keyValue = (String)map.get(keyAttribute);
|
||||
LDAPSearchConstraints cons = new LDAPSearchConstraints();
|
||||
cons.setBatchSize( 0 );
|
||||
cons.setTimeLimit( 10000 ) ;
|
||||
cons.setReferralFollowing(true);
|
||||
cons.setTimeLimit(getTimeLimit() ) ;
|
||||
cons.setReferralFollowing(isReferralFollowing());
|
||||
connection.setConstraints(cons);
|
||||
|
||||
int searchScope = LDAPConnection.SCOPE_ONE;
|
||||
String searchBase = baseDN;
|
||||
String filter = "(&("+keyAttribute+"="+keyValue+"))";
|
||||
System.out.println("ldap filter: "+filter);
|
||||
String filter = "(&"+ldapFilter+"("+keyAttribute+"="+keyValue+"))";
|
||||
LDAPSearchResults searchResults = connection.search(
|
||||
searchBase, // object to read
|
||||
searchScope, // scope - read single object
|
||||
|
@ -210,8 +204,9 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
}
|
||||
|
||||
LDAPModification[] m = new LDAPModification[mods.size()];
|
||||
mods.toArray(m);
|
||||
m = mods.toArray(m);
|
||||
connection.modify(entry.getDN(), m);
|
||||
|
||||
return object;
|
||||
} catch (Exception e) {
|
||||
throw new VascException(e);
|
||||
|
@ -270,7 +265,7 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
String keyValue = (String)map.get(keyAttribute);
|
||||
int searchScope = LDAPConnection.SCOPE_ONE;
|
||||
String searchBase = baseDN;
|
||||
String filter = "(&("+ldapFilter+")("+keyAttribute+"="+keyValue+"))";
|
||||
String filter = "(&"+ldapFilter+"("+keyAttribute+"="+keyValue+"))";
|
||||
LDAPSearchResults searchResults = connection.search(
|
||||
searchBase, // object to read
|
||||
searchScope, // scope - read single object
|
||||
|
@ -362,4 +357,32 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
public void setCreateObjectClass(String createObjectClass) {
|
||||
this.createObjectClass = createObjectClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the timeLimit
|
||||
*/
|
||||
public int getTimeLimit() {
|
||||
return timeLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param timeLimit the timeLimit to set
|
||||
*/
|
||||
public void setTimeLimit(int timeLimit) {
|
||||
this.timeLimit = timeLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the referralFollowing
|
||||
*/
|
||||
public boolean isReferralFollowing() {
|
||||
return referralFollowing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param referralFollowing the referralFollowing to set
|
||||
*/
|
||||
public void setReferralFollowing(boolean referralFollowing) {
|
||||
this.referralFollowing = referralFollowing;
|
||||
}
|
||||
}
|
|
@ -26,7 +26,6 @@ import java.net.UnknownHostException;
|
|||
|
||||
import org.eobjects.metamodel.DataContext;
|
||||
import org.eobjects.metamodel.mongodb.MongoDbDataContext;
|
||||
import org.eobjects.metamodel.mongodb.MongoDbDataContextBean;
|
||||
|
||||
import com.mongodb.DB;
|
||||
import com.mongodb.Mongo;
|
||||
|
@ -51,13 +50,16 @@ public class MetaModelDataContextMongodb implements MetaModelDataContextProvider
|
|||
protected Mongo mongo = null;
|
||||
|
||||
public DataContext getDataContext() {
|
||||
MongoDbDataContextBean dataContext = new MongoDbDataContextBean(getMongodbConnection());
|
||||
dataContext.setRegisterMBean(true);
|
||||
dataContext.start();
|
||||
//MongoDbDataContextBean dataContext = new MongoDbDataContextBean(getMongodbConnection());
|
||||
///dataContext.setRegisterMBean(true);
|
||||
//dataContext.start();
|
||||
|
||||
//MongoDbDataContextSchemaDetector detector = new MongoDbDataContextSchemaDetector();
|
||||
//detector.setDataCheckSize(10);
|
||||
//detector.setSearchReference(true);
|
||||
//DataContext dataContext = detector.new MongoDbDataContextExtended(getMongodbConnection(),detector);
|
||||
|
||||
DataContext dataContext = new MongoDbDataContext(getMongodbConnection());
|
||||
return dataContext;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
package net.forwardfire.vasc.backend.metamodel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -67,6 +69,8 @@ public class MetaModelSchemaAutoEntry {
|
|||
private String tableExclude = null;
|
||||
private String entryPrefix = null;
|
||||
private String vascGroupId = null;
|
||||
private String veLinkPostfix = "_velink";
|
||||
private String veListPostfix = "_velist";
|
||||
|
||||
private Map<String,VascEntryLocal> resultEntries = null;
|
||||
private Map<String,VascEntryGroupLocal> resultEntryGroups = null;
|
||||
|
@ -160,11 +164,9 @@ public class MetaModelSchemaAutoEntry {
|
|||
if (tableName.equals(rs.getForeignTable().getName())==false) {
|
||||
logger.finer("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName());
|
||||
createLinkEntry(rs,ve,metaTable);
|
||||
//createLinkEntry(rs,ve,metaTable,id+"_"+rs.getForeignTable().getName()+"_"+rs.getForeignColumns()[0].getName()+"_link");
|
||||
} else {
|
||||
logger.finer("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName());
|
||||
createListEntry(rs,ve,metaTable);
|
||||
//createListEntry(rs,ve,metaTable,id+"_"+rs.getPrimaryTable().getName()+"_"+rs.getPrimaryColumns()[0].getName()+"_list");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,7 +175,7 @@ public class MetaModelSchemaAutoEntry {
|
|||
}
|
||||
|
||||
private void createLinkEntry(Relationship rs2,VascEntryLocal ve,Table metaTable) {
|
||||
String id = getEntryPrefix()+"_"+metaTable.getName()+"_link";
|
||||
String id = getEntryPrefix()+"_"+rs2.getForeignTable().getName()+getVeLinkPostfix();
|
||||
MetaModelVascBackend backendLink = new MetaModelVascBackend();
|
||||
backendLink.setId(id+"_backend");
|
||||
backendLink.setDataContextProvider(getDataContextProvider());
|
||||
|
@ -195,26 +197,25 @@ public class MetaModelSchemaAutoEntry {
|
|||
veLink.setBackendId(id+"_backend");
|
||||
veLink.setPrimaryKeyFieldId(backendLink.getTableId());
|
||||
veLink.setVascGroupId(getVascGroupId());
|
||||
veLink.setAccessType(VascEntryAccessType.ENTRY_LIST);
|
||||
veLink.setAccessType(VascEntryAccessType.ENTRY_LINK);
|
||||
createFields(veLink,cols);
|
||||
|
||||
if (resultBackends.containsKey(backendLink.getId())==false) {
|
||||
resultBackends.put(backendLink.getId(),backendLink);
|
||||
resultEntries.put(veLink.getId(),veLink);
|
||||
}
|
||||
|
||||
for (Relationship rs:rs2.getForeignTable().getRelationships()) {
|
||||
logger.finer("Found relation FT: "+rs.getForeignTable().getName()+" PT: "+rs.getPrimaryTable().getName());
|
||||
if (rs2.getForeignTable().getName().equals(rs.getForeignTable().getName())==false) {
|
||||
//logger.info("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName());
|
||||
//createLinkEntry(rs,ve,rs2.getForeignTable(),id+"_"+rs.getForeignTable().getName()+"_"+rs.getForeignColumns()[0].getName()+"_link");
|
||||
//createLinkEntry(rs,veLink,rs2.getForeignTable());
|
||||
} else {
|
||||
logger.fine("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName());
|
||||
createListEntry(rs,veLink,rs2.getForeignTable());
|
||||
//createListEntry(rs,veLink,rs2.getForeignTable(),id+"_"+rs.getPrimaryTable().getName()+"_"+rs.getPrimaryColumns()[0].getName()+"_list");
|
||||
}
|
||||
}
|
||||
|
||||
if (resultBackends.containsKey(backendLink.getId())==false) {
|
||||
resultBackends.put(backendLink.getId(),backendLink);
|
||||
resultEntries.put(veLink.getId(),veLink);
|
||||
}
|
||||
|
||||
DefaultVascEntryLink vle = new DefaultVascEntryLink();
|
||||
vle.setId(id+"Link");
|
||||
vle.setVascEntryLinkType(VascEntryLinkType.DEFAULT_TYPE);
|
||||
|
@ -225,7 +226,7 @@ public class MetaModelSchemaAutoEntry {
|
|||
}
|
||||
|
||||
private void createListEntry(Relationship rs,VascEntry ve,Table metaTable) {
|
||||
String id = getEntryPrefix()+"_"+metaTable.getName()+"_list";
|
||||
String id = getEntryPrefix()+"_"+rs.getPrimaryTable().getName()+getVeListPostfix();
|
||||
MetaModelVascBackend backendList = new MetaModelVascBackend();
|
||||
backendList.setId(id+"_backend");
|
||||
backendList.setDataContextProvider(getDataContextProvider());
|
||||
|
@ -263,27 +264,34 @@ public class MetaModelSchemaAutoEntry {
|
|||
|
||||
VascSelectItemModelEntry itemModel = new VascSelectItemModelEntry();
|
||||
itemModel.setEntryId(veList.getId());
|
||||
itemModel.setDisplayFieldId(veList.getDisplayNameFieldId());
|
||||
if (veList.getDisplayNameFieldId()==null) {
|
||||
itemModel.setDisplayFieldId(veList.getPrimaryKeyFieldId()); // display can be null see createFields(), in vasc display is not null but defaulted on primary id.
|
||||
} else {
|
||||
itemModel.setDisplayFieldId(veList.getDisplayNameFieldId());
|
||||
}
|
||||
|
||||
vef.getVascEntryFieldType().setDataObject(itemModel);
|
||||
|
||||
}
|
||||
|
||||
private void createFields(VascEntryLocal ve,Column[] cols) {
|
||||
for (Column c:cols) {
|
||||
String name = c.getName().toLowerCase();
|
||||
DefaultVascEntryField vef = new DefaultVascEntryField();
|
||||
vef.setId(c.getName());
|
||||
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeByClass(c.getType().getJavaEquivalentClass()));
|
||||
|
||||
if (vef.getId().equals(ve.getPrimaryKeyFieldId())) {
|
||||
vef.setEditReadOnly(true);
|
||||
// vef.setCreate(false); mmm
|
||||
vef.setCreate(false);
|
||||
}
|
||||
|
||||
if (vef.getVascEntryFieldType()==null || "TextField".equals(vef.getVascEntryFieldType().getId())) {
|
||||
if (c.getName().toLowerCase().contains("desc") || c.getName().toLowerCase().contains("text")) {
|
||||
if (name.contains("desc") || name.contains("text") || name.contains("comment") || name.contains("memo") ) {
|
||||
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("TextAreaField"));
|
||||
}
|
||||
if (c.getName().toLowerCase().contains("active")) {
|
||||
if (name.contains("active")) {
|
||||
vef.setDefaultValue("true");
|
||||
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("BooleanField"));
|
||||
} /* todo
|
||||
if (c.getName().toLowerCase().contains("email")) {
|
||||
|
@ -293,25 +301,55 @@ public class MetaModelSchemaAutoEntry {
|
|||
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("URLField"));
|
||||
} */
|
||||
}
|
||||
|
||||
if (vef.getVascEntryFieldType()!=null && vef.getVascEntryFieldType().getAutoDetectClass()==Date.class) {
|
||||
vef.setDefaultValue("now()");
|
||||
if (name.contains("create") || name.contains("modified")) {
|
||||
vef.setEdit(false);
|
||||
vef.setCreate(false);
|
||||
}
|
||||
if (name.contains("update")) {
|
||||
vef.setCreate(false);
|
||||
}
|
||||
}
|
||||
|
||||
ve.addVascEntryField(vef);
|
||||
if (ve.getDisplayNameFieldId()==null && c.getName().equals(ve.getPrimaryKeyFieldId())==false && c.getType().getJavaEquivalentClass()==String.class) {
|
||||
ve.setDisplayNameFieldId(c.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// Disable lists when id contains;
|
||||
for (VascEntryField vef:ve.getVascEntryFields()) {
|
||||
String id = vef.getId().toLowerCase();
|
||||
if (ve.getDisplayNameFieldId()!=null && ve.getDisplayNameFieldId().equals(vef.getId())) {
|
||||
continue;
|
||||
}
|
||||
if (ve.getPrimaryKeyFieldId()!=null && ve.getPrimaryKeyFieldId().equals(vef.getId())) {
|
||||
continue;
|
||||
}
|
||||
if (vef.getList()!=null && vef.getList()==false) {
|
||||
continue;
|
||||
}
|
||||
if ( id.contains("email") |
|
||||
id.contains("phone") |
|
||||
id.contains("data") |
|
||||
id.contains("value") |
|
||||
id.contains("create") |
|
||||
id.contains("update") |
|
||||
id.contains("delete") |
|
||||
id.contains("classname") |
|
||||
id.contains("description")
|
||||
) {
|
||||
vef.setList(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Some auto detection on fields so default imported list view looks oke on 8++ columns.
|
||||
if (ve.getVascEntryFields().size()>8) {
|
||||
if (ve.getVascEntryFields().size()>10) {
|
||||
List<String> vefListIds = new ArrayList<String>(20);
|
||||
int max = 0;
|
||||
for (VascEntryField vef:ve.getVascEntryFields()) {
|
||||
String id = vef.getId().toLowerCase();
|
||||
if ( id.contains("create") |
|
||||
id.contains("update") |
|
||||
id.contains("delete") |
|
||||
id.contains("classname") |
|
||||
id.contains("description")
|
||||
) {
|
||||
vef.setList(false);
|
||||
}
|
||||
if (ve.getDisplayNameFieldId()!=null && ve.getDisplayNameFieldId().equals(vef.getId())) {
|
||||
continue;
|
||||
}
|
||||
|
@ -322,14 +360,15 @@ public class MetaModelSchemaAutoEntry {
|
|||
continue;
|
||||
}
|
||||
vefListIds.add(vef.getId());
|
||||
}
|
||||
if (vefListIds.size()<8) {
|
||||
List<String> vefListFalseIds = vefListIds.subList(8-1, vefListIds.size());
|
||||
for (String key:vefListFalseIds) {
|
||||
VascEntryField vef = ve.getVascEntryFieldById(key);
|
||||
vef.setList(false);
|
||||
max++;
|
||||
if (max>8) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (String key:vefListIds) {
|
||||
VascEntryField vef = ve.getVascEntryFieldById(key);
|
||||
vef.setList(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -406,22 +445,43 @@ public class MetaModelSchemaAutoEntry {
|
|||
/**
|
||||
* @return the resultEntries
|
||||
*/
|
||||
public Collection<VascEntryLocal> getResultEntries() {
|
||||
return resultEntries.values();
|
||||
public List<VascEntryLocal> getResultEntries() {
|
||||
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
|
||||
*/
|
||||
public Collection<VascEntryGroupLocal> getResultEntryGroups() {
|
||||
return resultEntryGroups.values();
|
||||
public List<VascEntryGroupLocal> getResultEntryGroups() {
|
||||
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
|
||||
*/
|
||||
public Collection<MetaModelVascBackend> getResultBackends() {
|
||||
return resultBackends.values();
|
||||
public List<MetaModelVascBackend> getResultBackends() {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,10 +32,13 @@ import org.eobjects.metamodel.DataContext;
|
|||
import org.eobjects.metamodel.UpdateableDataContext;
|
||||
import org.eobjects.metamodel.data.DataSet;
|
||||
import org.eobjects.metamodel.data.Row;
|
||||
import org.eobjects.metamodel.jdbc.JdbcDataContext;
|
||||
import org.eobjects.metamodel.query.OrderByItem.Direction;
|
||||
import org.eobjects.metamodel.query.Query;
|
||||
import org.eobjects.metamodel.query.SelectItem;
|
||||
import org.eobjects.metamodel.query.builder.SatisfiedQueryBuilder;
|
||||
import org.eobjects.metamodel.query.builder.SatisfiedWhereBuilder;
|
||||
import org.eobjects.metamodel.schema.Column;
|
||||
import org.eobjects.metamodel.schema.Schema;
|
||||
import org.eobjects.metamodel.schema.Table;
|
||||
|
||||
|
@ -131,6 +134,14 @@ public class MetaModelVascBackend extends AbstractVascBackend {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.AbstractVascBackend#isSortable()
|
||||
*/
|
||||
@Override
|
||||
public boolean isSortable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.AbstractVascBackend#fetchTotalExecuteSize(net.forwardfire.vasc.backend.VascBackendState)
|
||||
*/
|
||||
|
@ -208,8 +219,23 @@ public class MetaModelVascBackend extends AbstractVascBackend {
|
|||
throw new VascException("Could not get meta table for: '"+table+"'.");
|
||||
}
|
||||
Query q = createFilterQuery(state,t,false);
|
||||
if (isSortable() && state.getSortField() != null) {
|
||||
Column orderColumn = t.getColumnByName(state.getSortField());
|
||||
if (state.isSortAscending()) {
|
||||
q.orderBy(orderColumn,Direction.ASC);
|
||||
} else {
|
||||
q.orderBy(orderColumn,Direction.DESC);
|
||||
}
|
||||
}
|
||||
if (isPageable() && state.getPageSize()>0) {
|
||||
q.setFirstRow(state.getPageIndex()+1); // +1 for mm ?
|
||||
if (state.getPageIndex()>0) {
|
||||
q.setFirstRow((state.getPageIndex()*state.getPageSize())+1); // MM is 1 based ??
|
||||
|
||||
// workaround for bug in MM in jdbc/pg mode which is zero based.
|
||||
if (dataContext instanceof JdbcDataContext) {
|
||||
q.setFirstRow((state.getPageIndex()*state.getPageSize())+0); // MM is 1 based but sql is 0 based
|
||||
}
|
||||
}
|
||||
q.setMaxRows(state.getPageSize());
|
||||
}
|
||||
if (crudDataContext!=null) {
|
||||
|
@ -227,7 +253,7 @@ public class MetaModelVascBackend extends AbstractVascBackend {
|
|||
SelectItem[] cols = row.getSelectItems();
|
||||
List<String> keys = new ArrayList<String>(1);
|
||||
keys.add(cols[0].getColumn().getName());
|
||||
UpdateableRowMapImpl rowMM = new UpdateableRowMapImpl(dataContext.getDefaultSchema().getTableByName(table),keys);
|
||||
UpdateableRowMapImpl rowMM = new UpdateableRowMapImpl(dataContext.getDefaultSchema().getTableByName(table),keys,cols);
|
||||
for (SelectItem col:cols) {
|
||||
Object value = row.getValue(col);
|
||||
rowMM.setValue(col, value);
|
||||
|
|
|
@ -46,7 +46,7 @@ public class MongoDbDataContextSchemaDetector /* implements MetaModelSchemaDetec
|
|||
private int dataCheckSize = 100;
|
||||
private boolean searchReference = true;
|
||||
|
||||
public MongoDbDataContextSchemaDetector() {
|
||||
private MongoDbDataContextSchemaDetector() {
|
||||
}
|
||||
|
||||
public class MongoDbDataContextExtended extends QueryPostprocessDataContext /* MongoDbDataContext */ {
|
||||
|
@ -153,8 +153,10 @@ public class MongoDbDataContextSchemaDetector /* implements MetaModelSchemaDetec
|
|||
private boolean _closed;
|
||||
private volatile DBObject _dbObject;
|
||||
|
||||
public MongoDbDataSet(DBCursor cursor, Column[] columns,
|
||||
boolean queryPostProcessed) {
|
||||
public MongoDbDataSet(DBCursor cursor, Column[] columns,boolean queryPostProcessed) {
|
||||
|
||||
super(columns); // create header
|
||||
|
||||
_cursor = cursor;
|
||||
_selectItems = new SelectItem[columns.length];
|
||||
for (int i = 0; i < columns.length; i++) {
|
||||
|
@ -211,7 +213,7 @@ public class MongoDbDataContextSchemaDetector /* implements MetaModelSchemaDetec
|
|||
Object value = _dbObject.get(key);
|
||||
values[i] = toValue(_selectItems[i].getColumn(), value);
|
||||
}
|
||||
return new DefaultRow(_selectItems, values);
|
||||
return new DefaultRow(getHeader(), values);
|
||||
}
|
||||
|
||||
private Object toValue(Column column, Object value) {
|
||||
|
@ -440,6 +442,7 @@ public class MongoDbDataContextSchemaDetector /* implements MetaModelSchemaDetec
|
|||
|
||||
// Override to make public
|
||||
class PublicTable extends MutableTable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public PublicTable(String name,TableType type) {
|
||||
super(name,type);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.forwardfire.vasc.backend.metamodel.crud;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.eobjects.metamodel.DataContext;
|
||||
|
@ -45,15 +44,15 @@ abstract public class AbstractCrudDataContext implements CrudDataContext {
|
|||
public void persist(final UpdateableRow row) {
|
||||
UpdateableDataContext dataContext = abstractProviderUpdateableDataContext();
|
||||
dataContext.executeUpdate(new UpdateScript() {
|
||||
public void run(UpdateCallback backendImpl) {
|
||||
RowInsertionBuilder query = backendImpl.insertInto(row.getTable());
|
||||
for (int i=0;i<row.size();i++) {
|
||||
SelectItem si = row.getSelectItem(i);
|
||||
Object value = row.getValue(i);
|
||||
query.value(si.getColumn(), value);
|
||||
}
|
||||
query.execute();
|
||||
}
|
||||
public void run(UpdateCallback backendImpl) {
|
||||
RowInsertionBuilder query = backendImpl.insertInto(row.getTable());
|
||||
for (int i=0;i<row.size();i++) {
|
||||
SelectItem si = row.getSelectItem(i);
|
||||
Object value = row.getValue(i);
|
||||
query.value(si.getColumn(), value);
|
||||
}
|
||||
query.execute();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -70,18 +69,18 @@ abstract public class AbstractCrudDataContext implements CrudDataContext {
|
|||
boolean first = true;
|
||||
List<String> primaryKeyColumns = new ArrayList<String>(30);
|
||||
Collections.addAll(primaryKeyColumns, row.getPrimaryKeys());
|
||||
for (String column:primaryKeyColumns) {
|
||||
Object value = row.getValue(column);
|
||||
queryWhereBuilderUpdate(qWhere,column,value,first);
|
||||
first = false;
|
||||
}
|
||||
List<String> columns = new ArrayList<String>(30);
|
||||
for (String column:primaryKeyColumns) {
|
||||
Object value = row.getValue(column);
|
||||
queryWhereBuilderUpdate(qWhere,column,value,first);
|
||||
first = false;
|
||||
}
|
||||
List<String> columns = new ArrayList<String>(30);
|
||||
Collections.addAll(columns, row.getTable().getColumnNames());
|
||||
columns.removeAll(primaryKeyColumns);
|
||||
for (String column:columns) {
|
||||
Object value = row.getValue(column);
|
||||
((RowUpdationBuilder)qWhere).value(column, value);
|
||||
}
|
||||
Object value = row.getValue(column);
|
||||
((RowUpdationBuilder)qWhere).value(column, value);
|
||||
}
|
||||
if (first==false) {
|
||||
((RowUpdationBuilder)qWhere).execute();
|
||||
} else {
|
||||
|
@ -92,18 +91,18 @@ abstract public class AbstractCrudDataContext implements CrudDataContext {
|
|||
|
||||
Object qWhere = dataContext.query().from(row.getTable()).select(row.getTable().getColumns());
|
||||
boolean first = true;
|
||||
for (String column:row.getPrimaryKeys()) {
|
||||
Object value = row.getValue(column);
|
||||
queryWhereBuilder(qWhere,column,value,first);
|
||||
first = false;
|
||||
}
|
||||
Query mergeSelectQuery = ((SatisfiedQueryBuilder<?>)qWhere).toQuery();
|
||||
DataSet ds = dataContext.executeQuery(mergeSelectQuery);
|
||||
if (ds.next()==false) {
|
||||
ds.close();
|
||||
throw new IllegalStateException("Could not fetch row after merging.");
|
||||
}
|
||||
UpdateableRow rowResult = wrapOrCreateToUpdateableRow(ds.getRow(),row.getTable());
|
||||
for (String column:row.getPrimaryKeys()) {
|
||||
Object value = row.getValue(column);
|
||||
queryWhereBuilder(qWhere,column,value,first);
|
||||
first = false;
|
||||
}
|
||||
Query mergeSelectQuery = ((SatisfiedQueryBuilder<?>)qWhere).toQuery();
|
||||
DataSet ds = dataContext.executeQuery(mergeSelectQuery);
|
||||
if (ds.next()==false) {
|
||||
ds.close();
|
||||
throw new IllegalStateException("Could not fetch row after merging.");
|
||||
}
|
||||
UpdateableRow rowResult = wrapOrCreateToUpdateableRow(ds.getRow(),row.getTable());
|
||||
ds.close();
|
||||
return rowResult;
|
||||
}
|
||||
|
@ -111,131 +110,71 @@ abstract public class AbstractCrudDataContext implements CrudDataContext {
|
|||
public void delete(final UpdateableRow row) {
|
||||
UpdateableDataContext dataContext = abstractProviderUpdateableDataContext();
|
||||
dataContext.executeUpdate(new UpdateScript() {
|
||||
public void run(UpdateCallback backendImpl) {
|
||||
Object qWhere = backendImpl.deleteFrom(row.getTable());
|
||||
boolean first = true;
|
||||
for (String column:row.getPrimaryKeys()) {
|
||||
Object value = row.getValue(column);
|
||||
queryWhereBuilderDelete(qWhere,column,value,first);
|
||||
first = false;
|
||||
}
|
||||
if (first==false) {
|
||||
((RowDeletionBuilder)qWhere).execute();
|
||||
} else {
|
||||
///logger.warning no where clause
|
||||
}
|
||||
}
|
||||
public void run(UpdateCallback backendImpl) {
|
||||
Object qWhere = backendImpl.deleteFrom(row.getTable());
|
||||
boolean first = true;
|
||||
for (String column:row.getPrimaryKeys()) {
|
||||
Object value = row.getValue(column);
|
||||
queryWhereBuilderDelete(qWhere,column,value,first);
|
||||
first = false;
|
||||
}
|
||||
if (first==false) {
|
||||
((RowDeletionBuilder)qWhere).execute();
|
||||
} else {
|
||||
///logger.warning no where clause
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: redo these queryWhereBuilder methods to cleaner code
|
||||
|
||||
protected Object queryWhereBuilder(Object qWhere,String key,Object value,boolean first) {
|
||||
if (value instanceof Number) {
|
||||
if (first) {
|
||||
qWhere = ((SatisfiedQueryBuilder<?>)qWhere).where(key).equals((Number)value);
|
||||
} else {
|
||||
qWhere = ((SatisfiedWhereBuilder<?>)qWhere).and(key).equals((Number)value);
|
||||
}
|
||||
} else if (value instanceof Date) {
|
||||
if (value==null) {
|
||||
if (first) {
|
||||
qWhere = ((SatisfiedQueryBuilder<?>)qWhere).where(key).equals((Date)value);
|
||||
qWhere = ((SatisfiedQueryBuilder<?>)qWhere).where(key).isNull();
|
||||
} else {
|
||||
qWhere = ((SatisfiedWhereBuilder<?>)qWhere).and(key).equals((Date)value);
|
||||
}
|
||||
} else if (value instanceof Boolean) {
|
||||
if (first) {
|
||||
qWhere = ((SatisfiedQueryBuilder<?>)qWhere).where(key).equals((Boolean)value);
|
||||
} else {
|
||||
qWhere = ((SatisfiedWhereBuilder<?>)qWhere).and(key).equals((Boolean)value);
|
||||
qWhere = ((SatisfiedWhereBuilder<?>)qWhere).and(key).isNull();
|
||||
}
|
||||
} else {
|
||||
if (value==null) {
|
||||
if (first) {
|
||||
qWhere = ((SatisfiedQueryBuilder<?>)qWhere).where(key).isNull();
|
||||
} else {
|
||||
qWhere = ((SatisfiedWhereBuilder<?>)qWhere).and(key).isNull();
|
||||
}
|
||||
if (first) {
|
||||
qWhere = ((SatisfiedQueryBuilder<?>)qWhere).where(key).isEquals(value);
|
||||
} else {
|
||||
if (first) {
|
||||
qWhere = ((SatisfiedQueryBuilder<?>)qWhere).where(key).equals(value.toString());
|
||||
} else {
|
||||
qWhere = ((SatisfiedWhereBuilder<?>)qWhere).and(key).equals(value.toString());
|
||||
}
|
||||
qWhere = ((SatisfiedWhereBuilder<?>)qWhere).and(key).isEquals(value);
|
||||
}
|
||||
}
|
||||
return qWhere;
|
||||
}
|
||||
|
||||
protected Object queryWhereBuilderUpdate(Object qWhere,String key,Object value,boolean first) {
|
||||
if (value instanceof Number) {
|
||||
if (first) {
|
||||
qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Number)value);
|
||||
} else {
|
||||
qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Number)value);
|
||||
}
|
||||
} else if (value instanceof Date) {
|
||||
if (value==null) {
|
||||
if (first) {
|
||||
qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Date)value);
|
||||
qWhere = ((RowUpdationBuilder)qWhere).where(key).isNull();
|
||||
} else {
|
||||
qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Date)value);
|
||||
}
|
||||
} else if (value instanceof Boolean) {
|
||||
if (first) {
|
||||
qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Boolean)value);
|
||||
} else {
|
||||
qWhere = ((RowUpdationBuilder)qWhere).where(key).equals((Boolean)value);
|
||||
qWhere = ((RowUpdationBuilder)qWhere).where(key).isNull();
|
||||
}
|
||||
} else {
|
||||
if (value==null) {
|
||||
if (first) {
|
||||
qWhere = ((RowUpdationBuilder)qWhere).where(key).isNull();
|
||||
} else {
|
||||
qWhere = ((RowUpdationBuilder)qWhere).where(key).isNull();
|
||||
}
|
||||
if (first) {
|
||||
qWhere = ((RowUpdationBuilder)qWhere).where(key).isEquals(value);
|
||||
} else {
|
||||
if (first) {
|
||||
qWhere = ((RowUpdationBuilder)qWhere).where(key).equals(value.toString());
|
||||
} else {
|
||||
qWhere = ((RowUpdationBuilder)qWhere).where(key).equals(value.toString());
|
||||
}
|
||||
qWhere = ((RowUpdationBuilder)qWhere).where(key).isEquals(value);
|
||||
}
|
||||
}
|
||||
return qWhere;
|
||||
}
|
||||
|
||||
protected Object queryWhereBuilderDelete(Object qWhere,String key,Object value,boolean first) {
|
||||
if (value instanceof Number) {
|
||||
if (first) {
|
||||
qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Number)value);
|
||||
} else {
|
||||
qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Number)value);
|
||||
}
|
||||
} else if (value instanceof Date) {
|
||||
if (value==null) {
|
||||
if (first) {
|
||||
qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Date)value);
|
||||
qWhere = ((RowDeletionBuilder)qWhere).where(key).isNull();
|
||||
} else {
|
||||
qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Date)value);
|
||||
}
|
||||
} else if (value instanceof Boolean) {
|
||||
if (first) {
|
||||
qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Boolean)value);
|
||||
} else {
|
||||
qWhere = ((RowDeletionBuilder)qWhere).where(key).equals((Boolean)value);
|
||||
qWhere = ((RowDeletionBuilder)qWhere).where(key).isNull();
|
||||
}
|
||||
} else {
|
||||
if (value==null) {
|
||||
if (first) {
|
||||
qWhere = ((RowDeletionBuilder)qWhere).where(key).isNull();
|
||||
} else {
|
||||
qWhere = ((RowDeletionBuilder)qWhere).where(key).isNull();
|
||||
}
|
||||
if (first) {
|
||||
qWhere = ((RowDeletionBuilder)qWhere).where(key).isEquals(value);
|
||||
} else {
|
||||
if (first) {
|
||||
qWhere = ((RowDeletionBuilder)qWhere).where(key).equals(value.toString());
|
||||
} else {
|
||||
qWhere = ((RowDeletionBuilder)qWhere).where(key).equals(value.toString());
|
||||
}
|
||||
qWhere = ((RowDeletionBuilder)qWhere).where(key).isEquals(value);
|
||||
}
|
||||
}
|
||||
return qWhere;
|
||||
|
|
|
@ -22,7 +22,8 @@ abstract public class AbstractUpdateableRow extends AbstractRow implements Updat
|
|||
}
|
||||
public int indexOf(String columnName) {
|
||||
if (columnName==null) {
|
||||
return UpdateableRow.INDEX_NOT_FOUND;
|
||||
throw new NullPointerException("Can't search for null column name.");
|
||||
//return UpdateableRow.INDEX_NOT_FOUND;
|
||||
}
|
||||
int index = 0;
|
||||
for (SelectItem si:getIndexedSelectItemList()) {
|
||||
|
@ -31,7 +32,8 @@ abstract public class AbstractUpdateableRow extends AbstractRow implements Updat
|
|||
}
|
||||
index++;
|
||||
}
|
||||
return UpdateableRow.INDEX_NOT_FOUND;
|
||||
throw new IndexOutOfBoundsException("Can't find key of column: "+columnName);
|
||||
////return UpdateableRow.INDEX_NOT_FOUND;
|
||||
}
|
||||
|
||||
public void setValue(Row row) {
|
||||
|
@ -66,7 +68,7 @@ abstract public class AbstractUpdateableRow extends AbstractRow implements Updat
|
|||
|
||||
if (selectItem.getSubQuerySelectItem() != null) {
|
||||
value = getValue(selectItem.getSubQuerySelectItem());
|
||||
style = getStyle(selectItem.getSubQuerySelectItem());
|
||||
style = getStyle(selectItem.getSubQuerySelectItem());
|
||||
}
|
||||
if (value == null) {
|
||||
value = getValue(selectItem);
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.eobjects.metamodel.UpdateScript;
|
|||
import org.eobjects.metamodel.UpdateableDataContext;
|
||||
import org.eobjects.metamodel.data.DataSet;
|
||||
import org.eobjects.metamodel.data.Row;
|
||||
import org.eobjects.metamodel.query.CompiledQuery;
|
||||
import org.eobjects.metamodel.query.Query;
|
||||
import org.eobjects.metamodel.query.builder.InitFromBuilder;
|
||||
import org.eobjects.metamodel.query.builder.InitFromBuilderImpl;
|
||||
|
@ -81,7 +82,7 @@ public class CrudDataContextImpl extends AbstractCrudDataContext implements Abst
|
|||
if (row==null) {
|
||||
result.addSelectItems(table.getColumns()); // create new when row is null
|
||||
} else {
|
||||
result.addSelectItems(row.getSelectItems());
|
||||
result.addSelectItems(row.getSelectItems());
|
||||
result.setValue(row); // copy all values to impl
|
||||
}
|
||||
return result;
|
||||
|
@ -205,4 +206,12 @@ public class CrudDataContextImpl extends AbstractCrudDataContext implements Abst
|
|||
public DataSet executeQuery(String queryString) throws MetaModelException {
|
||||
return dataContextDelegate.executeQuery(queryString);
|
||||
}
|
||||
|
||||
public CompiledQuery compileQuery(Query q) throws MetaModelException {
|
||||
return dataContextDelegate.compileQuery(q);
|
||||
}
|
||||
|
||||
public DataSet executeQuery(CompiledQuery cq, Object... args) {
|
||||
return dataContextDelegate.executeQuery(cq, args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eobjects.metamodel.data.DataSetHeader;
|
||||
import org.eobjects.metamodel.data.Row;
|
||||
import org.eobjects.metamodel.query.SelectItem;
|
||||
import org.eobjects.metamodel.schema.Table;
|
||||
|
@ -47,6 +48,9 @@ public class UpdateableRowMapImpl extends AbstractUpdateableRow {
|
|||
}
|
||||
|
||||
public void setValue(int index, Object value) throws IndexOutOfBoundsException {
|
||||
if (index == UpdateableRow.INDEX_NOT_FOUND) {
|
||||
throw new IndexOutOfBoundsException("Can't save value without key index: "+UpdateableRow.INDEX_NOT_FOUND+" value:"+value);
|
||||
}
|
||||
dataMap.put(index, value);
|
||||
}
|
||||
|
||||
|
@ -57,4 +61,8 @@ public class UpdateableRowMapImpl extends AbstractUpdateableRow {
|
|||
public Row getSubSelection(SelectItem[] selectItems) {
|
||||
return getSubSelectionFromImpl(new UpdateableRowMapImpl(table,primaryKeys,selectItems),selectItems);
|
||||
}
|
||||
|
||||
public Row getSubSelection(DataSetHeader header) {
|
||||
return getSubSelection(header.getSelectItems());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.forwardfire.vasc.backend.metamodel.jndi;
|
|||
import org.eobjects.metamodel.DataContext;
|
||||
import org.eobjects.metamodel.MetaModelException;
|
||||
import org.eobjects.metamodel.data.DataSet;
|
||||
import org.eobjects.metamodel.query.CompiledQuery;
|
||||
import org.eobjects.metamodel.query.Query;
|
||||
import org.eobjects.metamodel.query.builder.InitFromBuilder;
|
||||
import org.eobjects.metamodel.schema.Column;
|
||||
|
@ -53,4 +54,12 @@ public class JndiReadOnlyDataContext /* extends DataContextProxy */ implements D
|
|||
public DataSet executeQuery(String queryString) throws MetaModelException {
|
||||
return proxyDataContext.executeQuery(queryString);
|
||||
}
|
||||
@Override
|
||||
public CompiledQuery compileQuery(Query q) throws MetaModelException {
|
||||
return proxyDataContext.compileQuery(q);
|
||||
}
|
||||
@Override
|
||||
public DataSet executeQuery(CompiledQuery cq, Object... args) {
|
||||
return proxyDataContext.executeQuery(cq, args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import javax.naming.NamingException;
|
|||
|
||||
import org.eobjects.metamodel.DataContext;
|
||||
import org.eobjects.metamodel.mongodb.MongoDbDataContext;
|
||||
import org.eobjects.metamodel.mongodb.MongoDbDataContextBean;
|
||||
|
||||
import com.mongodb.DB;
|
||||
import com.mongodb.Mongo;
|
||||
|
@ -31,27 +30,38 @@ public class JndiMongodbDataContextLoader implements JndiDataContextLoader {
|
|||
}
|
||||
|
||||
public DataContext loadDataContext(JndiDataContextLoaderConfig config) {
|
||||
MongoDbDataContextBean result = null;
|
||||
//MongoDbDataContextBean result = null;
|
||||
DB mongoDb = null;
|
||||
if (useJndiResource) {
|
||||
config.checkBackendUrl();
|
||||
result = new MongoDbDataContextBean(getMongodbJdni(config.getJndiObjectName(),config.getBackendUrl()));
|
||||
//result = new MongoDbDataContextBean(,));
|
||||
mongoDb = getMongodbJdni(config.getJndiObjectName(),config.getBackendUrl());
|
||||
|
||||
} else {
|
||||
int mongoPort = 27017;
|
||||
if (config.getBackendPort()!=null && config.getBackendPort().isEmpty()==false) {
|
||||
mongoPort = new Integer(config.getBackendPort());
|
||||
}
|
||||
result = new MongoDbDataContextBean(getMongodbConnection(
|
||||
mongoDb = getMongodbConnection(
|
||||
config.getJndiObjectName(),
|
||||
config.getBackendHost(),
|
||||
mongoPort,
|
||||
config.getBackendDatabase(),
|
||||
config.getBackendUsername(),
|
||||
config.getBackendPassword()
|
||||
));
|
||||
);
|
||||
}
|
||||
result.setRegisterMBean(true); // TODO: make flag
|
||||
result.start();
|
||||
return result;
|
||||
//MongoDbDataContextSchemaDetector detector = new MongoDbDataContextSchemaDetector();
|
||||
//detector.setDataCheckSize(10);
|
||||
//detector.setSearchReference(true);
|
||||
//DataContext dataContext = detector.new MongoDbDataContextExtended(mongoDb,detector);
|
||||
|
||||
DataContext dataContext = new MongoDbDataContext(mongoDb);
|
||||
return dataContext;
|
||||
|
||||
//result.setRegisterMBean(true); // TODO: make flag
|
||||
//result.start();
|
||||
//return result;
|
||||
}
|
||||
|
||||
protected DB getMongodbJdni(String objectName,String jndiName) {
|
||||
|
|
|
@ -45,9 +45,23 @@ public interface VascFrontendDataSelector extends VascFrontendEntry {
|
|||
public boolean isFieldEditReadOnly(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);
|
||||
}
|
|
@ -155,6 +155,8 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
|
|||
// save object on backend
|
||||
if (persist) {
|
||||
entry.getVascFrontendController().getVascEntryState().getVascBackend().persist(object);
|
||||
result = object; // TODO: fix persist
|
||||
entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(1+entry.getVascFrontendController().getVascEntryState().getTotalBackendRecords());
|
||||
} else {
|
||||
result = entry.getVascFrontendController().getVascEntryState().getVascBackend().merge(object);
|
||||
}
|
||||
|
@ -185,6 +187,7 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
|
|||
|
||||
removeObjectFromDataList(object);
|
||||
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(null);
|
||||
entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(entry.getVascFrontendController().getVascEntryState().getTotalBackendRecords()-1);
|
||||
entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_DELETE, object);
|
||||
} catch (VascException ve) {
|
||||
throw new VascFrontendException(ve);
|
||||
|
@ -195,6 +198,8 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
|
|||
* @see net.forwardfire.vasc.frontend.VascFrontendHelper#refreshData(net.forwardfire.vasc.core.VascEntry)
|
||||
*/
|
||||
public void refreshData() throws VascFrontendException {
|
||||
|
||||
// Fire pre read event
|
||||
entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_READ, null);
|
||||
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(null);
|
||||
VascBackendState backendState = entry.getVascFrontendController().getVascEntryState().getVascBackendState();
|
||||
|
@ -213,21 +218,21 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
|
|||
}
|
||||
}
|
||||
|
||||
// Update total every time first
|
||||
// Always update total records
|
||||
Long total = entry.getVascFrontendController().getVascEntryState().getVascBackend().fetchTotalExecuteSize(backendState);
|
||||
entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(total);
|
||||
|
||||
// check if we need to change the current page if table size if changed in between
|
||||
int pages = new Long(total/backendState.getPageSize()).intValue();
|
||||
if (backendState.getPageIndex() > pages) {
|
||||
backendState.setPageIndex(pages);
|
||||
}
|
||||
|
||||
try {
|
||||
// Execute to get data.
|
||||
entry.getVascFrontendController().getVascEntryState().setEntryDataList(entry.getVascFrontendController().getVascEntryState().getVascBackend().execute(backendState));
|
||||
|
||||
// check if we need to change the current page
|
||||
int pages = new Long(total/backendState.getPageSize()).intValue();
|
||||
if (backendState.getPageIndex() > pages) {
|
||||
backendState.setPageIndex(pages);
|
||||
entry.getVascFrontendController().getVascEntryState().setEntryDataList(entry.getVascFrontendController().getVascEntryState().getVascBackend().execute(backendState));
|
||||
}
|
||||
|
||||
// Fire event post read
|
||||
entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.POST_READ, null);
|
||||
} catch (VascException ve) {
|
||||
throw new VascFrontendException(ve);
|
||||
|
@ -251,12 +256,10 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
|
|||
|
||||
public void searchAction(String searchString) throws VascFrontendException {
|
||||
entry.getVascFrontendController().getVascEntryState().getVascBackendState().setSearchString(searchString);
|
||||
entry.getVascFrontendController().getVascEntryState().getVascBackendState().setSortField(null);
|
||||
entry.getVascFrontendController().getVascEntryState().getVascBackendState().setPageIndex(0);
|
||||
entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.SEARCH, searchString);
|
||||
|
||||
refreshData();
|
||||
|
||||
refreshData();
|
||||
entry.getVascFrontendController().getVascFrontend().renderView();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,13 +23,15 @@
|
|||
package net.forwardfire.vasc.impl.frontend;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.actions.VascAction;
|
||||
import net.forwardfire.vasc.frontend.VascFrontendDataSelector;
|
||||
import net.forwardfire.vasc.frontend.VascFrontendDataSelector.EntryFieldSelectType;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -38,7 +40,7 @@ import net.forwardfire.vasc.frontend.VascFrontendDataSelector;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Jun 1, 2012
|
||||
*/
|
||||
public class DefaultVascFrontendDataSelector implements VascFrontendDataSelector {
|
||||
public class DefaultVascFrontendDataSelector implements VascFrontendDataSelector {
|
||||
|
||||
private VascEntry entry = null;
|
||||
|
||||
|
@ -126,30 +128,48 @@ public class DefaultVascFrontendDataSelector implements VascFrontendDataSelector
|
|||
|
||||
*/
|
||||
|
||||
private List<VascEntryField> filter() {
|
||||
|
||||
public List<VascEntryField> getFields(final EntryFieldSelectType type) {
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd"
|
||||
providerName="vasc.forwardfire.net"
|
||||
name="Vasc Config Language"
|
||||
id="mod-vasc-lang"
|
||||
id="vasc-lang"
|
||||
>
|
||||
|
||||
<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: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:namespace
|
||||
|
@ -49,12 +50,14 @@
|
|||
<!-- Object for building an entry -->
|
||||
<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:elementParent tag="root" uri="http://vasc.forwardfire.net/xml/ns/vasc-root"/>
|
||||
</eld:element>
|
||||
<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:attribute name="accessType">
|
||||
<conv:enumConverter enumClass="net.forwardfire.vasc.core.VascEntryAccessType"/>
|
||||
</eld:attribute>
|
||||
<eld:elementParent tag="root" uri="http://vasc.forwardfire.net/xml/ns/vasc-root"/>
|
||||
</eld:element>
|
||||
<eld:element tag="field" objectClass="net.forwardfire.vasc.impl.DefaultVascEntryField" elementClass="net.forwardfire.vasc.impl.x4o.VascEntryFieldElement">
|
||||
<eld:attribute name="vascEntryFieldType" runBeanFill="false"/>
|
||||
|
@ -115,6 +118,7 @@
|
|||
|
||||
<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:elementParent tag="root" uri="http://vasc.forwardfire.net/xml/ns/vasc-root"/>
|
||||
</eld:element>
|
||||
|
||||
</eld:namespace>
|
||||
|
|
|
@ -57,27 +57,36 @@
|
|||
<v:field id="id" backendName="ID" list="false" editReadOnly="true" create="false"/>
|
||||
<v:field id="slug" backendName="SLUG"/>
|
||||
<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="roles" backendName="ROLES" list="false"/>
|
||||
<v:link id="AdminVascPagePartLink" vascEntryId="AdminVascPagePart">
|
||||
<v:linkParameter name="page_id" valueFieldId="id"/>
|
||||
</v:link>
|
||||
</v:entry>
|
||||
|
||||
|
||||
<mm:metaModelBackend id="AdminVascPagePartBackend" dataContextProvider="${DemoManagerDataDC}" table="VASC_PAGE_PART" tableId="ID" />
|
||||
<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="page_id" backendName="PAGE_ID" vascEntryFieldType="ListField">
|
||||
<v:vascSelectItemModel entryId="AdminVascPage" keyFieldId="id" displayFieldId="slug"/>
|
||||
</v:field>
|
||||
<v:field id="title" backendName="TITLE"/>
|
||||
<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="sitemap" backendName="SITEMAP" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="part_order" backendName="PART_ORDER" vascEntryFieldType="IntegerField"/>
|
||||
<v:field id="part_type" backendName="PART_TYPE" vascEntryFieldType="ListField">
|
||||
<v:vascSelectItemModelEnum enumClass="net.forwardfire.vasc.demo.tech.web.pages.model.VascPagePartType"/>
|
||||
</v:field>
|
||||
<v:field id="roles" backendName="ROLES" list="false"/>
|
||||
</v:entry>
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ package net.forwardfire.vasc.demo.server.ui;
|
|||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.MenuItem;
|
||||
|
@ -35,7 +36,9 @@ import java.awt.event.ActionListener;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventObject;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -74,7 +77,8 @@ public class ServerGuiApplication extends SingleFrameApplication {
|
|||
mainView.setComponent(statusPanel);
|
||||
mainView.getFrame().setMinimumSize(new Dimension(640,480));
|
||||
mainView.getFrame().setMaximumSize(new Dimension(800,600));
|
||||
|
||||
mainView.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
|
||||
show(mainView);
|
||||
startSystemTray();
|
||||
|
||||
|
@ -124,7 +128,11 @@ public class ServerGuiApplication extends SingleFrameApplication {
|
|||
}
|
||||
|
||||
public void startupDone() {
|
||||
statusPanel.startupDone();
|
||||
try {
|
||||
statusPanel.startupDone();
|
||||
} finally {
|
||||
getMainFrame().setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -231,6 +239,39 @@ public class ServerGuiApplication extends SingleFrameApplication {
|
|||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
// Invert focus painters
|
||||
List<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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
package net.forwardfire.vasc.demo.server.ui.load;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Frame;
|
||||
|
@ -194,17 +195,22 @@ public class JLoadDialog extends JDialog implements ActionListener {
|
|||
if (currentStep <= 0) {
|
||||
return;
|
||||
}
|
||||
currentStep--;
|
||||
centerPanel.removeAll();
|
||||
LoadStep step = steps.get(currentStep);
|
||||
centerPanel.add(step.getPanel());
|
||||
topLabel.setText(step.getStepTitle());
|
||||
step.setupStep(model);
|
||||
SwingUtilities.updateComponentTreeUI(centerPanel);
|
||||
if (currentStep==0) {
|
||||
prev.setEnabled(false);
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
try {
|
||||
currentStep--;
|
||||
centerPanel.removeAll();
|
||||
LoadStep step = steps.get(currentStep);
|
||||
centerPanel.add(step.getPanel());
|
||||
topLabel.setText(step.getStepTitle());
|
||||
step.setupStep(model);
|
||||
SwingUtilities.updateComponentTreeUI(centerPanel);
|
||||
if (currentStep==0) {
|
||||
prev.setEnabled(false);
|
||||
}
|
||||
next.setText("Next");
|
||||
} finally {
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
next.setText("Next");
|
||||
}
|
||||
|
||||
public void gotoStepNext() {
|
||||
|
@ -221,21 +227,26 @@ public class JLoadDialog extends JDialog implements ActionListener {
|
|||
if (currentStep > steps.size()-1) {
|
||||
return;
|
||||
}
|
||||
LoadStep step = steps.get(currentStep);
|
||||
boolean result = step.performStep(model);
|
||||
if (result==false) {
|
||||
return;
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
try {
|
||||
LoadStep step = steps.get(currentStep);
|
||||
boolean result = step.performStep(model);
|
||||
if (result==false) {
|
||||
return;
|
||||
}
|
||||
currentStep++;
|
||||
centerPanel.removeAll();
|
||||
step = steps.get(currentStep);
|
||||
centerPanel.add(step.getPanel());
|
||||
topLabel.setText(step.getStepTitle());
|
||||
step.setupStep(model);
|
||||
SwingUtilities.updateComponentTreeUI(centerPanel);
|
||||
if (currentStep==steps.size()-1) {
|
||||
next.setText("Finish");
|
||||
}
|
||||
prev.setEnabled(true);
|
||||
} finally {
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
currentStep++;
|
||||
centerPanel.removeAll();
|
||||
step = steps.get(currentStep);
|
||||
centerPanel.add(step.getPanel());
|
||||
topLabel.setText(step.getStepTitle());
|
||||
step.setupStep(model);
|
||||
SwingUtilities.updateComponentTreeUI(centerPanel);
|
||||
if (currentStep==steps.size()-1) {
|
||||
next.setText("Finish");
|
||||
}
|
||||
prev.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class JLoadStepWriteFile extends JPanel implements LoadStep,ActionListene
|
|||
}
|
||||
|
||||
public String getStepTitle() {
|
||||
return "Select Tables";
|
||||
return "Write xml to file.";
|
||||
}
|
||||
|
||||
public JPanel getPanel() {
|
||||
|
|
|
@ -223,6 +223,19 @@ public class LoadVascXmlWriter {
|
|||
if (f.getEditReadOnly()!=null) {
|
||||
atts.addAttribute ("", "editReadOnly", "", "", ""+f.getEditReadOnly());
|
||||
}
|
||||
if (f.getDefaultValue()!=null) {
|
||||
atts.addAttribute ("", "defaultValue", "", "", ""+f.getDefaultValue());
|
||||
}
|
||||
if (f.getList()!=null) {
|
||||
atts.addAttribute ("", "list", "", "", ""+f.getList());
|
||||
}
|
||||
if (f.getEdit()!=null) {
|
||||
atts.addAttribute ("", "edit", "", "", ""+f.getEdit());
|
||||
}
|
||||
if (f.getCreate()!=null) {
|
||||
atts.addAttribute ("", "create", "", "", ""+f.getCreate());
|
||||
}
|
||||
|
||||
//atts.addAttribute ("", "vascGroupId", "", "", model.groupId);
|
||||
xmlWriter.startElement (URI_VASC_LANG, "field", "", atts);
|
||||
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
|
||||
#
|
||||
# Default dark red color thema for pulsefire
|
||||
# yellow-purple color schema from pulsefire.
|
||||
#
|
||||
text=#DF0A0A
|
||||
info=#370A00
|
||||
control=#0A1428
|
||||
nimbusBase=#00050A
|
||||
nimbusFocus=#0A6428
|
||||
nimbusOrange=#00960A
|
||||
nimbusBorder=#34415E
|
||||
nimbusDisabledText=#850F0F
|
||||
nimbusLightBackground=#050A28
|
||||
text=#FF9900
|
||||
info=#9F3B00
|
||||
control=#5B084C
|
||||
nimbusBase=#3A0053
|
||||
nimbusDisabledText=#3A0053
|
||||
nimbusFocus=#FF6600
|
||||
nimbusLightBackground=#47184D
|
||||
nimbusSelectedText=#47184D
|
||||
nimbusBlueGrey=#661C7D
|
||||
nimbusGreen=#D2C122
|
||||
nimbusBorder=#A018D8
|
||||
nimbusSelectionBackground=#BF6204
|
||||
ComboBox.background=#380030
|
||||
TabbedPane.background=#380030
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
|
||||
package net.forwardfire.vasc.demo.client.swing;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -36,6 +40,7 @@ import javax.naming.InitialContext;
|
|||
import javax.security.auth.login.LoginContext;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuController;
|
||||
import net.forwardfire.vasc.demo.tech.ejb3.user.ClientUserController;
|
||||
|
@ -70,6 +75,7 @@ public class VascDemoSwingClient extends SingleFrameApplication {
|
|||
protected void startup() {
|
||||
|
||||
logger = Logger.getLogger(VascDemoSwingClient.class.getName());
|
||||
installColorsLaF();
|
||||
doLogin();
|
||||
|
||||
VascServiceManager vc = null;
|
||||
|
@ -187,14 +193,81 @@ public class VascDemoSwingClient extends SingleFrameApplication {
|
|||
return false;
|
||||
} catch (Exception e) {
|
||||
JOptionPane.showMessageDialog(null, "Server error: "+e.getMessage());
|
||||
e.printStackTrace();
|
||||
//e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private String installColorsLaF() {
|
||||
UIManager.put("TabbedPane.font", Font.decode("SansSerif-BOLD-12"));
|
||||
UIManager.put("TitledBorder.font", Font.decode("SansSerif-BOLD-16"));
|
||||
UIManager.put("FireDial.font", Font.decode("SansSerif-9"));
|
||||
|
||||
String colorName = "laf-colors";
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
if (cl==null) {
|
||||
cl = this.getClass().getClassLoader();
|
||||
}
|
||||
InputStream in = cl.getResourceAsStream("net/forwardfire/vasc/demo/client/swing/resources/"+colorName+".properties");
|
||||
if (in==null) {
|
||||
logger.warning("Color schema not found: "+colorName);
|
||||
return "unknown";
|
||||
}
|
||||
try {
|
||||
Properties p = new Properties();
|
||||
p.load(in);
|
||||
for (Object key:p.keySet()) {
|
||||
String value = p.getProperty(key.toString());
|
||||
Color colorValue = Color.decode(value);
|
||||
UIManager.put(key,colorValue);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.warning("Could not load color schema: "+colorName+" error: "+e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
// Invert focus painters
|
||||
List<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) {
|
||||
if(obj==null) { throw new NullPointerException("Can't get key of null obj"); }
|
||||
if (key==null) { throw new NullPointerException("key may not be null"); }
|
||||
if(obj==null) { throw new NullPointerException("Can't get key of null obj"); }
|
||||
if (key==null) { throw new NullPointerException("key may not be null"); }
|
||||
if(obj instanceof Class) {
|
||||
key=((Class<?>)obj).getName()+"."+key;
|
||||
} else {
|
||||
|
@ -203,23 +276,16 @@ public class VascDemoSwingClient extends SingleFrameApplication {
|
|||
return i18n(key,params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Some simple hardcoded i18n function here
|
||||
*
|
||||
* @param key
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public String i18n(String key,Object...params) {
|
||||
try {
|
||||
String text = ResourceBundle.getBundle(RootApplicationBundle.class.getName()).getString(key);
|
||||
if (params != null) {
|
||||
MessageFormat mf = new MessageFormat(text);
|
||||
text = mf.format(params, new StringBuffer(), null).toString();
|
||||
}
|
||||
return text;
|
||||
} catch(MissingResourceException e){
|
||||
return key;
|
||||
}
|
||||
}
|
||||
public String i18n(String key,Object...params) {
|
||||
try {
|
||||
String text = ResourceBundle.getBundle(RootApplicationBundle.class.getName()).getString(key);
|
||||
if (params != null) {
|
||||
MessageFormat mf = new MessageFormat(text);
|
||||
text = mf.format(params, new StringBuffer(), null).toString();
|
||||
}
|
||||
return text;
|
||||
} catch(MissingResourceException e){
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
package net.forwardfire.vasc.demo.client.swing;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
|
@ -43,6 +42,7 @@ import java.util.TimerTask;
|
|||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
|
@ -51,47 +51,19 @@ import javax.swing.JPasswordField;
|
|||
import javax.swing.JTextField;
|
||||
|
||||
/**
|
||||
* Zwaar gehacke jaas login dialog
|
||||
* added features:
|
||||
* - name remebering
|
||||
* - focus on name field
|
||||
* - alway on top
|
||||
* - logo stuff
|
||||
* - message field
|
||||
*
|
||||
* <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
|
||||
* VascDemoUserLoginDialog used be be true jaas auth module but now only dialog.
|
||||
*
|
||||
* @see javax.security.auth.callback
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 10, 2012
|
||||
*/
|
||||
public class VascDemoUserLoginDialog {
|
||||
|
||||
private Component parentComponent;
|
||||
private static final int JPasswordFieldLen = 8;
|
||||
private int loginTry = 0;
|
||||
private String connectUrl = null;
|
||||
private String username = null;
|
||||
private String password = null;
|
||||
|
||||
/**
|
||||
* Creates a callback dialog with the default parent window.
|
||||
*/
|
||||
public VascDemoUserLoginDialog() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a callback dialog and specify the parent window.
|
||||
*
|
||||
* @param parentComponent
|
||||
* the parent window -- specify <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
|
||||
* the dialog.
|
||||
|
@ -105,10 +77,9 @@ public class VascDemoUserLoginDialog {
|
|||
*/
|
||||
public void handle() {
|
||||
this.loginTry++;
|
||||
/* Collect messages to display in the dialog */
|
||||
final JPanel loginDesign = new JPanel();
|
||||
loginDesign.setLayout(new BoxLayout(loginDesign, BoxLayout.PAGE_AXIS));
|
||||
//final Image logoImage = Toolkit.getDefaultToolkit().createImage(getClass().getResource("/resources/images/logos/logo.png"));
|
||||
final Image logoImage = Toolkit.getDefaultToolkit().createImage(getClass().getResource("/net/forwardfire/vasc/demo/client/swing/resources/logo.png"));
|
||||
final JPanel logoPanel = new JPanel() {
|
||||
private static final long serialVersionUID = 10l;
|
||||
protected void paintComponent(Graphics g) {
|
||||
|
@ -119,20 +90,14 @@ public class VascDemoUserLoginDialog {
|
|||
|
||||
// Paint the default look of the panel.
|
||||
super.paintComponent(g2d);
|
||||
|
||||
int offsetX = 0; // for windows systems
|
||||
boolean isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows") != -1;
|
||||
if (isWindows) {
|
||||
offsetX += 25;
|
||||
}
|
||||
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.fillRect(0,0,getWidth(),getHeight());
|
||||
g2d.setColor(new Color(238,212,1));
|
||||
|
||||
//int w = (getWidth()/2)-(logoImage.getWidth(null)/2);
|
||||
//int h = (getHeight()/2)-(logoImage.getHeight(null)/2);
|
||||
//g2d.drawImage(logoImage, w, h, this);
|
||||
|
||||
int w = (getWidth()/2)-(logoImage.getWidth(null)/2);
|
||||
int h = (getHeight()/2)-(logoImage.getHeight(null)/2);
|
||||
g2d.drawImage(logoImage, w, h, this);
|
||||
}
|
||||
};
|
||||
logoPanel.setPreferredSize(new Dimension(200, 170));
|
||||
|
@ -146,13 +111,11 @@ public class VascDemoUserLoginDialog {
|
|||
loginDesign.add(namePanel);
|
||||
loginDesign.add(Box.createVerticalStrut(5));
|
||||
|
||||
final List<Action> okActions = new ArrayList<Action>(2);
|
||||
final GridLayout messagesLayout = new GridLayout(3,2);
|
||||
final JPanel messages = new JPanel();
|
||||
messages.setLayout(messagesLayout);
|
||||
|
||||
/* Collection actions to perform if the user clicks OK */
|
||||
final List<Action> okActions = new ArrayList<Action>(2);
|
||||
|
||||
// Add server field
|
||||
JLabel serverName = new JLabel("Server:");
|
||||
final JTextField serverField = new JTextField(getConnectUrl());
|
||||
|
@ -225,6 +188,7 @@ public class VascDemoUserLoginDialog {
|
|||
/// JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options, Object initialValue)
|
||||
JOptionPane jop = new JOptionPane(loginDesign, JOptionPane.PLAIN_MESSAGE,JOptionPane.OK_CANCEL_OPTION,null,options,name);
|
||||
|
||||
JComponent parentComponent = null;
|
||||
JDialog dialog = jop.createDialog(parentComponent,"Vasc Demo Login");
|
||||
|
||||
// We alway request focus after the windows gets focus
|
||||
|
|
|
@ -29,4 +29,5 @@ Application.homepage = http://vasc.forwardfire.org/
|
|||
Application.vendorId = vasc
|
||||
Application.id = vascdemotech
|
||||
Application.lookAndFeel = com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel
|
||||
#Application.icon = images/icon.png
|
||||
Application.icon = icon.png
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 264 B |
|
@ -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
|
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -7,10 +7,12 @@
|
|||
>
|
||||
|
||||
<application>
|
||||
<!-- moved to I18nController because of hard caching resources in jsf impl.
|
||||
<resource-bundle>
|
||||
<base-name>net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle</base-name>
|
||||
<var>i18n</var>
|
||||
</resource-bundle>
|
||||
-->
|
||||
<locale-config>
|
||||
<default-locale>en</default-locale>
|
||||
</locale-config>
|
||||
|
@ -20,6 +22,13 @@
|
|||
</system-event-listener>
|
||||
</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>
|
||||
<description>Fixes the context path for root vs non-root deployments.</description>
|
||||
<managed-bean-name>contextPathController</managed-bean-name>
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.Map;
|
|||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.frontend.VascFrontendDataSelector.EntryFieldSelectType;
|
||||
import net.forwardfire.vasc.lib.jr4o.data.AbstractJRDynamicDataSource;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
import net.sf.jasperreports.engine.JRField;
|
||||
|
@ -46,6 +47,7 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource {
|
|||
|
||||
|
||||
private VascEntry vascEntry = null;
|
||||
private List<VascEntryField> fields = null;
|
||||
private long total = -1;
|
||||
private int index = -1;
|
||||
private static final String PREFIX_COLUMN = "COLUMN_";
|
||||
|
@ -61,6 +63,8 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource {
|
|||
this.vascEntry = vascEntry;
|
||||
total = vascEntry.getVascFrontendController().getVascEntryState().getTotalBackendRecords();
|
||||
|
||||
fields = vascEntry.getVascFrontendController().getVascFrontendDataSelector().getFields(EntryFieldSelectType.EXPORT);
|
||||
|
||||
// hackje until calc index to page and row.
|
||||
try {
|
||||
data = new ArrayList<List<String>>(1000);
|
||||
|
@ -70,7 +74,7 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource {
|
|||
vascEntry.getVascFrontendController().getVascFrontendActions().refreshData();
|
||||
for (Object o:vascEntry.getVascFrontendController().getVascEntryState().getEntryDataList()) {
|
||||
List<String> row = new ArrayList<String>(30);
|
||||
for (VascEntryField c:vascEntry.getVascEntryFields()) {
|
||||
for (VascEntryField c:fields) {
|
||||
row.add(c.getVascEntryFieldValue().getDisplayValue(c, o));
|
||||
}
|
||||
data.add(row);
|
||||
|
@ -90,10 +94,8 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource {
|
|||
return data.get(index).get(Integer.parseInt(fieldName.substring(7)));
|
||||
}
|
||||
if (fieldName.startsWith(PREFIX_HEADER)) {
|
||||
return "todo"; // TODO: fixme
|
||||
//List<VascEntryField> fields = vascEntry.getVascEntryFields();
|
||||
//VascEntryField field = fields.get(Integer.parseInt(fieldName.substring(7)));
|
||||
//return vascEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(field.getName());
|
||||
VascEntryField field = fields.get(Integer.parseInt(fieldName.substring(7)));
|
||||
return vascEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(field.getName());
|
||||
}
|
||||
throw new JRException("Unknown column name : " + fieldName);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,11 @@ public class JSFVascEntryEventListener implements VascEntryFrontendEventListener
|
|||
* @see net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener#getEventTypes()
|
||||
*/
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.POST_READ};
|
||||
VascFrontendEventType[] result = {
|
||||
VascEntryFrontendEventListener.VascFrontendEventType.POST_READ,
|
||||
VascEntryFrontendEventListener.VascFrontendEventType.POST_DELETE,
|
||||
VascEntryFrontendEventListener.VascFrontendEventType.POST_UPDATE
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,8 +87,6 @@ public class JSFVascEntrySupportBean implements Serializable {
|
|||
private Boolean backendMoveable = null;
|
||||
private Boolean backendSearchable = null;
|
||||
private Boolean backendPageable = null;
|
||||
private Boolean sortOrder = null;
|
||||
private String sortField = null;
|
||||
private VascEntryExport selectedExporter = null;
|
||||
private String selectedExporterAction = "null";
|
||||
private String selectedDirectPage = "null";
|
||||
|
@ -441,8 +439,6 @@ public class JSFVascEntrySupportBean implements Serializable {
|
|||
VascEntry entry = comp.getVascEntry();
|
||||
VascEntryField field = entry.getVascEntryFieldById(fieldIdString);
|
||||
entry.getVascFrontendController().getVascFrontendActions().sortAction(field);
|
||||
sortOrder = entry.getVascFrontendController().getVascEntryState().getVascBackendState().isSortAscending();
|
||||
sortField = field.getId();
|
||||
}
|
||||
|
||||
public boolean getRenderBackAction() {
|
||||
|
@ -855,20 +851,6 @@ public class JSFVascEntrySupportBean implements Serializable {
|
|||
return tablePagesDataModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sortOrder
|
||||
*/
|
||||
public Boolean getSortOrder() {
|
||||
return sortOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sortField
|
||||
*/
|
||||
public String getSortField() {
|
||||
return sortField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the selectedExporter
|
||||
*/
|
||||
|
|
|
@ -38,8 +38,6 @@ import net.forwardfire.vasc.frontend.web.jsf.ui.JSFList;
|
|||
import net.forwardfire.vasc.frontend.web.jsf.ui.JSFText;
|
||||
import net.forwardfire.vasc.frontend.web.jsf.ui.JSFTextArea;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Given the jsf vasc renderer its own class
|
||||
*
|
||||
|
@ -56,8 +54,6 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser
|
|||
logger = Logger.getLogger(JSFVascFrontendRenderer.class.getName());
|
||||
}
|
||||
|
||||
// Frontend Stuff
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.frontend.VascFrontend#getFrontendType()
|
||||
*/
|
||||
|
@ -65,10 +61,9 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser
|
|||
return "jsf";
|
||||
}
|
||||
|
||||
|
||||
protected void addUiComponents() {
|
||||
VascFrontendController vfd = getVascEntry().getVascFrontendController();
|
||||
|
||||
|
||||
// required UI components
|
||||
vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_LABEL,JSFLabel.class.getName());
|
||||
vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_TEXT, JSFText.class.getName());
|
||||
|
@ -82,7 +77,7 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser
|
|||
//vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_COLOR , JSFColorChooser.class.getName());
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.frontend.VascFrontend#renderDelete(java.lang.Object)
|
||||
*/
|
||||
|
@ -92,7 +87,7 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser
|
|||
JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId());
|
||||
comp.setRenderFacetState("deleteView");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.frontend.VascFrontend#renderEdit(java.lang.Object)
|
||||
*/
|
||||
|
@ -114,7 +109,7 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser
|
|||
|
||||
comp.getSupportBean().setSelected(selBean);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.frontend.VascFrontend#renderExport(net.forwardfire.vasc.core.entry.VascEntryExport)
|
||||
*/
|
||||
|
@ -125,7 +120,7 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser
|
|||
comp.setRenderFacetState("exportView");
|
||||
comp.getSupportBean().setSelectedExporter(exporter);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.frontend.VascFrontend#renderView()
|
||||
*/
|
||||
|
@ -134,10 +129,5 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser
|
|||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId());
|
||||
comp.setRenderFacetState("listView");
|
||||
|
||||
//if (comp.getSupportBean().getSelected()!=null) {
|
||||
// comp.getSupportBean().getSelected().setRealValue(false);
|
||||
// comp.getSupportBean().setSelected(null);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.el.ValueExpression;
|
||||
|
@ -57,63 +56,62 @@ import net.forwardfire.vasc.frontend.web.jsf.ui.JSFListModel;
|
|||
*/
|
||||
public class JSFVascUIComponent extends UIComponentBase {
|
||||
|
||||
public static final String FAMILY = "vasc.jsf.component.family";
|
||||
public static final String ENTRY_SUPPORT_VAR_KEY = "entrySupportVar";
|
||||
public static final String TABLE_RECORD_VAR_KEY = "tableRecordVar";
|
||||
public static final String INJECT_EDIT_FIELDS_ID = "injectEditFieldsId";
|
||||
public static final String INJECT_TABLE_OPTIONS_ID = "injectTableOptionsId";
|
||||
public static final String INJECT_TABLE_COLUMNS_ID = "injectTableColumnsId";
|
||||
public static final String DISABLE_LINK_COLUMNS = "disableLinkColumns";
|
||||
public static final String INJECT_TABLE_OPTIONS_ON_CHANGE = "injectTableOptionOnChange";
|
||||
|
||||
private JSFVascFrontendRenderer renderer = null;
|
||||
private JSFVascEntrySupportBean supportBean = null;
|
||||
private String renderFacetState = null;
|
||||
private VascEntryLink link = null;
|
||||
private VascEntryState linkState = null;
|
||||
private VascEntryState state = null;
|
||||
private Object stateEditId = null;
|
||||
private Logger logger = null;
|
||||
private Boolean initClear = null;
|
||||
private String injectTableOptionOnChange = null;
|
||||
|
||||
public JSFVascUIComponent() {
|
||||
logger = Logger.getLogger(JSFVascUIComponent.class.getName());
|
||||
}
|
||||
|
||||
public String getFamily() {
|
||||
return FAMILY;
|
||||
}
|
||||
public static final String FAMILY = "vasc.jsf.component.family";
|
||||
public static final String ENTRY_SUPPORT_VAR_KEY = "entrySupportVar";
|
||||
public static final String TABLE_RECORD_VAR_KEY = "tableRecordVar";
|
||||
public static final String INJECT_EDIT_FIELDS_ID = "injectEditFieldsId";
|
||||
public static final String INJECT_TABLE_OPTIONS_ID = "injectTableOptionsId";
|
||||
public static final String INJECT_TABLE_COLUMNS_ID = "injectTableColumnsId";
|
||||
public static final String DISABLE_LINK_COLUMNS = "disableLinkColumns";
|
||||
public static final String INJECT_TABLE_OPTIONS_ON_CHANGE = "injectTableOptionOnChange";
|
||||
|
||||
private JSFVascFrontendRenderer renderer = null;
|
||||
private JSFVascEntrySupportBean supportBean = null;
|
||||
private String renderFacetState = null;
|
||||
private VascEntryLink link = null;
|
||||
private VascEntryState linkState = null;
|
||||
private VascEntryState state = null;
|
||||
private Object stateEditId = null;
|
||||
private Logger logger = null;
|
||||
private Boolean initClear = null;
|
||||
private String injectTableOptionOnChange = null;
|
||||
|
||||
public JSFVascUIComponent() {
|
||||
logger = Logger.getLogger(JSFVascUIComponent.class.getName());
|
||||
}
|
||||
|
||||
public String getFamily() {
|
||||
return FAMILY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object saveState(FacesContext facesContext) {
|
||||
logger.fine("Save State");
|
||||
Object values[] = new Object[5];
|
||||
values[0] = super.saveState(facesContext);
|
||||
values[1] = renderer;
|
||||
values[2] = supportBean;
|
||||
values[3] = renderFacetState;
|
||||
values[4] = this.getAttributes().get(INJECT_TABLE_OPTIONS_ON_CHANGE);
|
||||
return values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object saveState(FacesContext facesContext) {
|
||||
logger.fine("Save State");
|
||||
Object values[] = new Object[5];
|
||||
values[0] = super.saveState(facesContext);
|
||||
values[1] = renderer;
|
||||
values[2] = supportBean;
|
||||
values[3] = renderFacetState;
|
||||
values[4] = this.getAttributes().get(INJECT_TABLE_OPTIONS_ON_CHANGE);
|
||||
return values;
|
||||
@Override
|
||||
public void restoreState(FacesContext facesContext, Object state) {
|
||||
logger.fine("Resotre State");
|
||||
Object values[] = (Object[])state;
|
||||
super.restoreState(facesContext, values[0]);
|
||||
renderer = (JSFVascFrontendRenderer) values[1];
|
||||
supportBean = (JSFVascEntrySupportBean) values[2];
|
||||
renderFacetState = (String) values[3];
|
||||
injectTableOptionOnChange = (String) values[4];
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreState(FacesContext facesContext, Object state) {
|
||||
logger.fine("Resotre State");
|
||||
Object values[] = (Object[])state;
|
||||
super.restoreState(facesContext, values[0]);
|
||||
renderer = (JSFVascFrontendRenderer) values[1];
|
||||
supportBean = (JSFVascEntrySupportBean) values[2];
|
||||
renderFacetState = (String) values[3];
|
||||
injectTableOptionOnChange = (String) values[4];
|
||||
|
||||
// TODO: check if we can move this some day...
|
||||
// TODO: check if we can move this some day...
|
||||
String entrySupportVar = (String)getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
|
||||
ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+"}", Object.class);
|
||||
ve2.setValue(FacesContext.getCurrentInstance().getELContext(), getSupportBean());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static public JSFVascUIComponent findVascParent(UIComponent comp) {
|
||||
if (comp==null) {
|
||||
return null;
|
||||
|
@ -146,7 +144,7 @@ public class JSFVascUIComponent extends UIComponentBase {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds component with the given id
|
||||
*/
|
||||
|
@ -229,7 +227,7 @@ public class JSFVascUIComponent extends UIComponentBase {
|
|||
|
||||
// edit action copyed
|
||||
try {
|
||||
VascEntry entry = supportBean.getVascEntry();
|
||||
VascEntry entry = supportBean.getVascEntry();
|
||||
entry.getVascFrontendController().getVascEntryState().setEditCreate(false);
|
||||
entry.getVascFrontendController().fireVascFrontendEvent(entry, VascFrontendEventType.SELECT, rowObject);
|
||||
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(rowObject);
|
||||
|
@ -263,46 +261,44 @@ public class JSFVascUIComponent extends UIComponentBase {
|
|||
super.encodeBegin(context);
|
||||
}
|
||||
|
||||
public UIComponent getCurrentView() {
|
||||
UIComponent result = getFacet(renderFacetState);
|
||||
if (result==null) {
|
||||
throw new IllegalArgumentException("Could not get facet: "+renderFacetState);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public JSFVascEntrySupportBean getSupportBean() {
|
||||
return supportBean;
|
||||
}
|
||||
|
||||
public void setRenderFacetState(String renderFacetState) {
|
||||
this.renderFacetState=renderFacetState;
|
||||
}
|
||||
|
||||
public String getRenderFacetState() {
|
||||
return renderFacetState;
|
||||
}
|
||||
|
||||
public UIComponent getCurrentView() {
|
||||
UIComponent result = getFacet(renderFacetState);
|
||||
if (result==null) {
|
||||
throw new IllegalArgumentException("Could not get facet: "+renderFacetState);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public JSFVascEntrySupportBean getSupportBean() {
|
||||
return supportBean;
|
||||
}
|
||||
|
||||
public void setRenderFacetState(String renderFacetState) {
|
||||
this.renderFacetState=renderFacetState;
|
||||
}
|
||||
|
||||
public String getRenderFacetState() {
|
||||
return renderFacetState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the injectTableOptionOnChange
|
||||
*/
|
||||
public String getInjectTableOptionOnChange() {
|
||||
return injectTableOptionOnChange;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param injectTableOptionOnChange the injectTableOptionOnChange to set
|
||||
*/
|
||||
public void setInjectTableOptionOnChange(String injectTableOptionOnChange) {
|
||||
this.injectTableOptionOnChange = injectTableOptionOnChange;
|
||||
}
|
||||
|
||||
|
||||
public VascEntry createClonedVascEntry() {
|
||||
|
||||
|
||||
VascController vascController = (VascController)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(VascRequestFacesFilter.REQ_VASC_CONTOLLER);
|
||||
String entryId = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(VascRequestFacesFilter.REQ_VASC_ENTRY_ID);
|
||||
|
||||
|
||||
if (link!=null) {
|
||||
entryId = link.getVascEntryId();
|
||||
}
|
||||
|
@ -314,8 +310,6 @@ public class JSFVascUIComponent extends UIComponentBase {
|
|||
if (entry==null) {
|
||||
throw new NullPointerException("Could not get '"+entryId+"' from : "+vascController);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
vascController.getVascEntryConfigController().configVascFrontendController(vascController, entry);
|
||||
} catch (Exception e1) {
|
||||
|
@ -410,4 +404,4 @@ public class JSFVascUIComponent extends UIComponentBase {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -419,14 +419,14 @@ public class JSFVascUIComponentRenderer extends Renderer {
|
|||
orderUp.setId(viewRoot.createUniqueId());
|
||||
orderUp.setEscape(false);
|
||||
orderUp.setValue("↑"); // ↑
|
||||
ValueExpression ren2 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".sortOrder==true and "+entrySupportVar+".sortField=='"+c.getId()+"'}", Boolean.class);
|
||||
ValueExpression ren2 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".vascEntry.vascFrontendController.vascEntryState.vascBackendState.sortAscending==true and "+entrySupportVar+".vascEntry.vascFrontendController.vascEntryState.vascBackendState.sortField=='"+c.getId()+"'}", Boolean.class);
|
||||
orderUp.setValueExpression("rendered", ren2);
|
||||
|
||||
HtmlOutputText orderDown = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
|
||||
orderDown.setId(viewRoot.createUniqueId());
|
||||
orderDown.setEscape(false);
|
||||
orderDown.setValue("↓"); // ↓
|
||||
ValueExpression ren3 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".sortOrder==false and "+entrySupportVar+".sortField=='"+c.getId()+"'}", Boolean.class);
|
||||
ValueExpression ren3 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".vascEntry.vascFrontendController.vascEntryState.vascBackendState.sortAscending==false and "+entrySupportVar+".vascEntry.vascFrontendController.vascEntryState.vascBackendState.sortField=='"+c.getId()+"'}", Boolean.class);
|
||||
orderDown.setValueExpression("rendered", ren3);
|
||||
|
||||
link.getChildren().add(out2);
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.forwardfire.vasc.core.VascEntry;
|
|||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.frontend.VascFrontendDataSelector.EntryFieldSelectType;
|
||||
|
||||
|
||||
|
||||
|
@ -63,7 +64,7 @@ public class VascDataBackendBean implements Serializable {
|
|||
if (index>entry.getVascEntryFields().size()) {
|
||||
throw new IllegalArgumentException("Index is bigger then total field size: "+index);
|
||||
}
|
||||
return entry.getVascFrontendController().getVascFrontendDataSelector().getFieldsList().get(index);
|
||||
return entry.getVascFrontendController().getVascFrontendDataSelector().getFields(EntryFieldSelectType.ALL).get(index);
|
||||
}
|
||||
|
||||
static public int getIndexId(VascEntryField field) {
|
||||
|
|
|
@ -94,20 +94,19 @@ public class VascRequestFacesFilter implements Filter {
|
|||
className = className.substring(atIndex+1);
|
||||
}
|
||||
try {
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
if (cl == null) {
|
||||
cl = className.getClass().getClassLoader();
|
||||
}
|
||||
Class<?> clazz = cl.loadClass(className);
|
||||
if (classArgument==null) {
|
||||
vascControllerProvider = (VascControllerProvider)clazz.newInstance();
|
||||
} else {
|
||||
vascControllerProvider = (VascControllerProvider)clazz.getConstructor(String.class).newInstance(classArgument);
|
||||
}
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
if (cl == null) {
|
||||
cl = className.getClass().getClassLoader();
|
||||
}
|
||||
Class<?> clazz = cl.loadClass(className);
|
||||
if (classArgument==null) {
|
||||
vascControllerProvider = (VascControllerProvider)clazz.newInstance();
|
||||
} else {
|
||||
vascControllerProvider = (VascControllerProvider)clazz.getConstructor(String.class).newInstance(classArgument);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServletException("Could not create VascControllerProvider: "+e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,16 +56,25 @@ public class VascBundleCheckEntryKeys {
|
|||
}
|
||||
|
||||
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);
|
||||
keys.put(ve.getName(), ve.getId());
|
||||
keys.put(ve.getName(), value);
|
||||
keys.put(ve.getImage(), ve.getId());
|
||||
keys.put(ve.getListDescription(), ve.getId());
|
||||
keys.put(ve.getListDescription(), "View list of "+value);
|
||||
keys.put(ve.getListImage(), imagePrefix+ve.getId()+imagePostfix);
|
||||
keys.put(ve.getEditDescription(), ve.getId());
|
||||
keys.put(ve.getEditDescription(), "Edit your "+value);
|
||||
keys.put(ve.getEditImage(), imagePrefix+ve.getId()+imagePostfix);
|
||||
keys.put(ve.getDeleteDescription(), ve.getId());
|
||||
keys.put(ve.getDeleteDescription(), "Delete this "+value);
|
||||
keys.put(ve.getDeleteImage(), imagePrefix+ve.getId()+imagePostfix);
|
||||
keys.put(ve.getCreateDescription(), ve.getId());
|
||||
keys.put(ve.getCreateDescription(), "Create new "+value);
|
||||
keys.put(ve.getCreateImage(), imagePrefix+ve.getId()+imagePostfix);
|
||||
for (VascEntryField vef:ve.getVascEntryFields()) {
|
||||
keys.put(vef.getName(), vef.getId());
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd"
|
||||
providerName="vasc.forwardfire.net"
|
||||
name="Vasc EJB3 Xpql query loading"
|
||||
id="mod-vasc-xpql-ejb3"
|
||||
id="vasc-xpql-ejb3"
|
||||
>
|
||||
<namespace uri="http://vasc.forwardfire.net/xml/ns/xpql-ejb3"
|
||||
schemaUri="http://vasc.forwardfire.net/xml/ns/xpql-ejb3-1.0.xsd"
|
||||
|
|
|
@ -49,6 +49,7 @@ import net.forwardfire.vasc.xpql.query.QueryParameterValue;
|
|||
|
||||
|
||||
/**
|
||||
* XpqlQueryManagerImpl
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @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 {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(XpqlQueryManagerImpl.class.getName());
|
||||
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Resource
|
||||
private UserTransaction utx;
|
||||
|
||||
@Resource
|
||||
private UserTransaction utx;
|
||||
|
||||
private Map<String,Query> queries = new HashMap<String,Query>(100);
|
||||
|
||||
@PostConstruct
|
||||
|
@ -73,117 +73,114 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa
|
|||
long s = System.currentTimeMillis();
|
||||
|
||||
Map<String,String> keys = loadKeys();
|
||||
for (String key:keys.keySet()) {
|
||||
String value = keys.get(key);
|
||||
if (key.startsWith("load")) {
|
||||
loadResource(value);
|
||||
}
|
||||
if ("persistenceUnit".equals(key)) {
|
||||
logger.fine("getting EntityManager: "+value);
|
||||
entityManager = (EntityManager)new InitialContext().lookup(value);
|
||||
}
|
||||
}
|
||||
for (String key:keys.keySet()) {
|
||||
String value = keys.get(key);
|
||||
if (key.startsWith("load")) {
|
||||
loadResource(value);
|
||||
}
|
||||
if ("persistenceUnit".equals(key)) {
|
||||
logger.fine("getting EntityManager: "+value);
|
||||
entityManager = (EntityManager)new InitialContext().lookup(value);
|
||||
}
|
||||
}
|
||||
long t = System.currentTimeMillis()-s;
|
||||
logger.info("Total loaded xpql queries: "+queries.size()+" in "+t+" ms.");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error while load xpql resources error: "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads xtes-xpql-ejb3.xml from meta-inf and gives the keys
|
||||
*/
|
||||
protected Map<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) {
|
||||
XPQLParser parser = new XPQLParser();
|
||||
logger.fine("Try loading: "+resource);
|
||||
try {
|
||||
private void loadResource(String resource) {
|
||||
XPQLParser parser = new XPQLParser();
|
||||
logger.fine("Try loading: "+resource);
|
||||
try {
|
||||
parser.parseResource(resource);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not load xpql resource: "+resource+" error: "+e.getMessage(),e);
|
||||
}
|
||||
QueryStore store = parser.getQueryStore();
|
||||
|
||||
for (String key:store.getQueryNames()) {
|
||||
Query q = store.getQuery(key);
|
||||
|
||||
QueryStore store = parser.getQueryStore();
|
||||
|
||||
for (String key:store.getQueryNames()) {
|
||||
Query q = store.getQuery(key);
|
||||
|
||||
queries.put(q.getName(),q);
|
||||
|
||||
String out = "\n\n=========== SQL: "+q.getName()+"\n";
|
||||
//out +=q.toSQL(q);
|
||||
out +="=========== XML: "+q.getName()+"\n";
|
||||
out +=q.toXML(q);
|
||||
//out +="=========== Edit: "+q.getName()+"\n";
|
||||
//out +=q.toEdit(q);
|
||||
out +="=========== Prepard: "+q.getName()+"\n";
|
||||
out +=q.toPreparedSQL(q)+"\n";
|
||||
logger.finer("FOUND Query: "+out);
|
||||
}
|
||||
}
|
||||
String out = "\n\n=========== SQL: "+q.getName()+"\n";
|
||||
//out +=q.toSQL(q);
|
||||
out +="=========== XML: "+q.getName()+"\n";
|
||||
out +=q.toXML(q);
|
||||
//out +="=========== Edit: "+q.getName()+"\n";
|
||||
//out +=q.toEdit(q);
|
||||
out +="=========== Prepard: "+q.getName()+"\n";
|
||||
out +=q.toPreparedSQL(q)+"\n";
|
||||
logger.finer("FOUND Query: "+out);
|
||||
}
|
||||
}
|
||||
|
||||
public Query getQuery(String name) {
|
||||
Query q = queries.get(name);
|
||||
return q;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Query getQuery(String name) {
|
||||
Query q = queries.get(name);
|
||||
return q;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> execute(Query query) {
|
||||
String sql = query.toPreparedSQL(query);
|
||||
logger.finer("Executing: "+query.getName()+" sql: "+sql);
|
||||
javax.persistence.Query q2 = null;
|
||||
if (Query.QueryType.hql==query.getType()) {
|
||||
q2 = entityManager.createQuery(sql);
|
||||
}
|
||||
if (Query.QueryType.sql==query.getType()) {
|
||||
q2 = entityManager.createNativeQuery(sql);
|
||||
}
|
||||
|
||||
String sql = query.toPreparedSQL(query);
|
||||
logger.finer("Executing: "+query.getName()+" sql: "+sql);
|
||||
javax.persistence.Query q2 = null;
|
||||
if (Query.QueryType.hql==query.getType()) {
|
||||
q2 = entityManager.createQuery(sql);
|
||||
}
|
||||
if (Query.QueryType.sql==query.getType()) {
|
||||
q2 = entityManager.createNativeQuery(sql);
|
||||
}
|
||||
|
||||
// TODO: move this hack to xtest xpql
|
||||
if (query.getProperty("limit")!=null) {
|
||||
int max = new Integer(query.getPropertyString("limit"));
|
||||
|
@ -193,9 +190,8 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa
|
|||
int offset = new Integer(query.getPropertyString("offset"));
|
||||
q2.setFirstResult(offset);
|
||||
}
|
||||
|
||||
|
||||
List<QueryParameterValue> options = query.getOrderQueryParameterValues();
|
||||
|
||||
List<QueryParameterValue> options = query.getOrderQueryParameterValues();
|
||||
int i=1;
|
||||
for ( QueryParameterValue value : options ) {
|
||||
Object para = value.getValue();
|
||||
|
@ -208,20 +204,19 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa
|
|||
}
|
||||
return q2.getResultList();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object executeObject(Query query) {
|
||||
String sql = query.toPreparedSQL(query);
|
||||
logger.finer("Executing: "+query.getName()+" sql: "+sql);
|
||||
javax.persistence.Query q2 = null;
|
||||
if (Query.QueryType.hql==query.getType()) {
|
||||
q2 = entityManager.createQuery(sql);
|
||||
}
|
||||
if (Query.QueryType.sql==query.getType()) {
|
||||
q2 = entityManager.createNativeQuery(sql);
|
||||
}
|
||||
|
||||
|
||||
String sql = query.toPreparedSQL(query);
|
||||
logger.finer("Executing: "+query.getName()+" sql: "+sql);
|
||||
javax.persistence.Query q2 = null;
|
||||
if (Query.QueryType.hql==query.getType()) {
|
||||
q2 = entityManager.createQuery(sql);
|
||||
}
|
||||
if (Query.QueryType.sql==query.getType()) {
|
||||
q2 = entityManager.createNativeQuery(sql);
|
||||
}
|
||||
|
||||
// TODO: move this hack to xtest xpql
|
||||
if (query.getProperty("limit")!=null) {
|
||||
int max = new Integer(query.getPropertyString("limit"));
|
||||
|
@ -231,8 +226,8 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa
|
|||
int offset = new Integer(query.getPropertyString("offset"));
|
||||
q2.setFirstResult(offset);
|
||||
}
|
||||
|
||||
List<QueryParameterValue> options = query.getOrderQueryParameterValues();
|
||||
|
||||
List<QueryParameterValue> options = query.getOrderQueryParameterValues();
|
||||
int i=1;
|
||||
for ( QueryParameterValue value : options ) {
|
||||
Object para = value.getValue();
|
||||
|
@ -255,9 +250,9 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa
|
|||
}
|
||||
}
|
||||
return result;
|
||||
} catch (Exception se) {
|
||||
throw new RuntimeException("Transaction error: "+se.getMessage(),se);
|
||||
}
|
||||
} catch (Exception se) {
|
||||
throw new RuntimeException("Transaction error: "+se.getMessage(),se);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Object> execute(String name,Map<String,Object> parameters) {
|
||||
|
@ -283,59 +278,59 @@ public class XpqlQueryManagerImpl implements XpqlQueryManager.ILocal,XpqlQueryMa
|
|||
}
|
||||
|
||||
public Integer executeUpdate(Query query) {
|
||||
String sql = query.toPreparedSQL(query);
|
||||
logger.fine("Executing: "+query.getName()+" sql: "+sql);
|
||||
try {
|
||||
javax.persistence.Query q2 = null;
|
||||
if (Query.QueryType.hql==query.getType()) {
|
||||
q2 = entityManager.createQuery(sql);
|
||||
List<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;
|
||||
}
|
||||
|
||||
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();
|
||||
String sql = query.toPreparedSQL(query);
|
||||
logger.fine("Executing: "+query.getName()+" sql: "+sql);
|
||||
try {
|
||||
javax.persistence.Query q2 = null;
|
||||
if (Query.QueryType.hql==query.getType()) {
|
||||
q2 = entityManager.createQuery(sql);
|
||||
List<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");
|
||||
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();
|
||||
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) {
|
||||
Query query = getQuery(name);
|
||||
for (String key:parameters.keySet()) {
|
||||
Object value = parameters.get(key);
|
||||
query.setQueryParameter(key, value);
|
||||
}
|
||||
Object value = parameters.get(key);
|
||||
query.setQueryParameter(key, value);
|
||||
}
|
||||
return executeUpdate(query);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd"
|
||||
providerName="vasc.forwardfire.net"
|
||||
name="Xpql query loading"
|
||||
id="mod-vasc-xpql"
|
||||
id="vasc-xpql"
|
||||
>
|
||||
<namespace uri="http://vasc.forwardfire.net/xml/ns/vasc-xpql"
|
||||
schemaUri="http://vasc.forwardfire.net/xml/ns/vasc-xpql-1.0.xsd"
|
||||
|
|
Loading…
Reference in a new issue