2
0
Fork 0

Clean demo directory layout

This commit is contained in:
Willem Cazander 2012-05-13 17:25:50 +02:00
parent b3923bd2fb
commit 7c044adb1f
61 changed files with 2334 additions and 252 deletions

View file

@ -1,3 +1,25 @@
/*
* Copyright 2007-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.backend.metamodel;
import java.io.File;
@ -7,6 +29,12 @@ import org.eobjects.metamodel.DataContext;
import org.eobjects.metamodel.csv.CsvConfiguration;
import org.eobjects.metamodel.csv.CsvDataContext;
/**
* MetaModelDataContextCsv provides csv file/url backend.
*
* @author Willem Cazander
* @version 1.0 May 3, 2012
*/
public class MetaModelDataContextCsv implements MetaModelDataContextProvider {
private String file = null;

View file

@ -1,3 +1,25 @@
/*
* Copyright 2007-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.backend.metamodel;
import java.sql.Connection;
@ -6,7 +28,12 @@ import java.sql.DriverManager;
import org.eobjects.metamodel.DataContext;
import org.eobjects.metamodel.jdbc.JdbcDataContext;
/**
* MetaModelDataContextJdbc provides basic jdbc connection for meta model data context.
*
* @author Willem Cazander
* @version 1.0 May 3, 2012
*/
public class MetaModelDataContextJdbc implements MetaModelDataContextProvider {
private String driverClass = null;
@ -22,7 +49,13 @@ public class MetaModelDataContextJdbc implements MetaModelDataContextProvider {
public Connection getConnection() {
synchronized (this) {
try {
Class.forName(getDriverClass());
if (getDriverClass()!=null) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl==null) {
cl = this.getClass().getClassLoader();
}
cl.loadClass(getDriverClass());
}
Connection connection = DriverManager.getConnection(getConnectUrl(),getUsername(),getPassword());
return connection;
} catch (Exception e) {

View file

@ -1,3 +1,25 @@
/*
* Copyright 2007-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.backend.metamodel;
import java.net.UnknownHostException;
@ -10,6 +32,12 @@ import com.mongodb.Mongo;
import com.mongodb.MongoOptions;
import com.mongodb.ServerAddress;
/**
* MetaModelDataContextMongodb provides basic mongo connection support for data context.
*
* @author Willem Cazander
* @version 1.0 May 2, 2012
*/
public class MetaModelDataContextMongodb implements MetaModelDataContextProvider {
private String hostname = "localhost";

View file

@ -25,7 +25,7 @@ package net.forwardfire.vasc.backend.metamodel;
import org.eobjects.metamodel.DataContext;
/**
* Provides an metamodel datacontext object to the metamodel backend.
* MetaModelDataContextProvider provides an meta model data context object to the meta model back-end.
*
* @author Willem Cazander
* @version 1.0 Apr 25, 2012

View file

@ -0,0 +1,323 @@
/*
* Copyright 2007-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.backend.metamodel;
import java.util.logging.Logger;
import org.eobjects.metamodel.DataContext;
import org.eobjects.metamodel.schema.Column;
import org.eobjects.metamodel.schema.Relationship;
import org.eobjects.metamodel.schema.Table;
import net.forwardfire.vasc.backend.VascBackendControllerLocal;
import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryControllerLocal;
import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.VascLinkEntry;
import net.forwardfire.vasc.core.VascLinkEntryType;
import net.forwardfire.vasc.impl.DefaultVascEntry;
import net.forwardfire.vasc.impl.DefaultVascEntryField;
import net.forwardfire.vasc.impl.DefaultVascFactory;
import net.forwardfire.vasc.impl.DefaultVascLinkEntry;
import net.forwardfire.vasc.impl.ui.VascSelectItemModelEntry;
/**
* MetaModelSchemaAutoEntry
*
* @author Willem Cazander
* @version 1.0 May 2, 2012
*/
public class MetaModelSchemaAutoEntry {
private Logger logger = null;
private VascController vascController = null;
private MetaModelDataContextProvider dataContextProvider = null;
private String tableInclude = null;
private String tableExclude = null;
private String entryPrefix = null;
public MetaModelSchemaAutoEntry() {
logger = Logger.getLogger(MetaModelSchemaAutoEntry.class.getName());
}
public void autoCreateEntries(VascController vascController) {
if (getDataContextProvider()==null) {
throw new NullPointerException("Can't auto create entries with null dataContextProvider.");
}
if (getEntryPrefix()==null) {
throw new NullPointerException("Can't auto create with null entryPrefix.");
}
this.vascController=vascController;
DataContext ds = getDataContextProvider().getDataContext();
for (String table:ds.getDefaultSchema().getTableNames()) {
if (getTableInclude()!=null && table.matches(getTableInclude())==false) {
logger.fine("Excluding table: "+table+" from include rule.");
continue;
}
if (getTableExclude()!=null && table.matches(getTableExclude())) {
logger.fine("Excluding table: "+table+" from exclude rule.");
continue;
}
createMetaEntry(ds,getEntryPrefix()+"_"+table,table);
}
}
private VascController getVascController() {
return vascController;
}
private void createMetaEntry(DataContext ds,String id,String tableName) {
logger.info("Creating entry id: "+id+" of table: "+tableName);
Table metaTable = null;
if (tableName==null) {
metaTable = ds.getDefaultSchema().getTable(0);
} else {
metaTable = ds.getDefaultSchema().getTableByName(tableName);
}
Column[] keys = metaTable.getPrimaryKeys();
Column[] cols = metaTable.getColumns();
if (cols.length==0) {
return; // vasc needs at least one column
}
MetaModelVascBackend backend = new MetaModelVascBackend();
backend.setId(id+"_backend");
backend.setDataContextProvider(getDataContextProvider());
backend.setTable(metaTable.getName());
if (keys.length>0) {
backend.setTableId(keys[0].getName());
} else {
backend.setTableId(cols[0].getName());
//TODO backend.setRequestReadOnly(true);
}
VascEntry ve = new DefaultVascEntry();
ve.setId(id);
ve.setBackendId(id+"_backend");
ve.setPrimaryKeyFieldId(backend.getTableId());
createFields(ve,cols);
for (Relationship rs:metaTable.getRelationships()) {
logger.finer("Found relation FT: "+rs.getForeignTable().getName()+" PT: "+rs.getPrimaryTable().getName());
if (tableName.equals(rs.getForeignTable().getName())==false) {
logger.info("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName());
createLinkEntry(rs,ve,metaTable,id+"_"+rs.getForeignTable().getName()+"_"+rs.getForeignColumns()[0].getName()+"_link");
} else {
logger.info("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName());
createListEntry(rs,ve,metaTable,id+"_"+rs.getPrimaryTable().getName()+"_"+rs.getPrimaryColumns()[0].getName()+"_list");
}
}
try {
((VascBackendControllerLocal)getVascController().getVascBackendController()).addVascBackend(backend);
((VascEntryControllerLocal)getVascController().getVascEntryController()).addVascEntry(ve);
// mm TODO rm this fill which adds the global actions ... and show updated tree in editor
DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) getVascController().getVascEntryController(), getVascController());
} catch (Exception ee) {
ee.printStackTrace();
}
}
private void createLinkEntry(Relationship rs2,VascEntry ve,Table metaTable,String id) {
MetaModelVascBackend backendLink = new MetaModelVascBackend();
backendLink.setId(id+"_backend");
backendLink.setDataContextProvider(getDataContextProvider());
backendLink.setTable(rs2.getForeignTable().getName());
Column[] keys = rs2.getForeignTable().getPrimaryKeys();
Column[] cols = rs2.getForeignTable().getColumns();
if (cols.length==0) {
return;
}
if (keys.length>0) {
backendLink.setTableId(keys[0].getName());
} else {
backendLink.setTableId(cols[0].getName());
}
VascEntry veLink = new DefaultVascEntry();
veLink.setId(id);
veLink.setBackendId(id+"_backend");
veLink.setPrimaryKeyFieldId(backendLink.getTableId());
createFields(veLink,cols);
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");
} else {
logger.info("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName());
createListEntry(rs,veLink,rs2.getForeignTable(),id+"_"+rs.getPrimaryTable().getName()+"_"+rs.getPrimaryColumns()[0].getName()+"_list");
}
}
try {
((VascBackendControllerLocal)getVascController().getVascBackendController()).addVascBackend(backendLink);
((VascEntryControllerLocal)getVascController().getVascEntryController()).addVascEntry(veLink);
VascLinkEntry vle = new DefaultVascLinkEntry();
vle.setId(id+"Link");
vle.setVascLinkEntryType(VascLinkEntryType.DEFAULT_TYPE);
vle.setVascEntryId(id);
vle.addEntryParameterFieldId(rs2.getForeignColumns()[0].getName(), rs2.getPrimaryColumns()[0].getName());
ve.addVascLinkEntry(vle);
} catch (Exception e) {
e.printStackTrace();
}
}
private void createListEntry(Relationship rs,VascEntry ve,Table metaTable,String id) {
MetaModelVascBackend backendLink = new MetaModelVascBackend();
backendLink.setId(id+"_backend");
backendLink.setDataContextProvider(getDataContextProvider());
backendLink.setTable(rs.getPrimaryTable().getName());
Column[] keys = rs.getPrimaryTable().getPrimaryKeys();
Column[] cols = rs.getPrimaryTable().getColumns();
if (cols.length==0) {
return;
}
if (keys.length>0) {
backendLink.setTableId(keys[0].getName());
} else {
backendLink.setTableId(cols[0].getName());
}
VascEntry veLink = new DefaultVascEntry();
veLink.setId(id);
veLink.setBackendId(id+"_backend");
veLink.setPrimaryKeyFieldId(backendLink.getTableId());
createFields(veLink,cols);
try {
VascEntryField vef = ve.getVascEntryFieldById(rs.getForeignColumns()[0].getName());
if (vef==null) {
logger.warning("Could not find: "+rs.getForeignColumns()[0].getName()+" in ve: "+ve.getId());
return;
}
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("ListField"));
VascSelectItemModelEntry itemModel = new VascSelectItemModelEntry();
itemModel.setEntryId(veLink.getId());
itemModel.setDisplayFieldId(veLink.getDisplayNameFieldId());
vef.getVascEntryFieldType().setDataObject(itemModel);
((VascBackendControllerLocal)getVascController().getVascBackendController()).addVascBackend(backendLink);
((VascEntryControllerLocal)getVascController().getVascEntryController()).addVascEntry(veLink);
} catch (Exception e) {
e.printStackTrace();
}
}
private void createFields(VascEntry ve,Column[] cols) {
for (Column c:cols) {
VascEntryField vef = new DefaultVascEntryField(c.getName());
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeByClass(c.getType().getJavaEquivalentClass()));
if (vef.getId().equals(ve.getPrimaryKeyFieldId())) {
vef.setEditReadOnly(true);
// vef.setCreate(false); mmm
}
if (vef.getVascEntryFieldType()==null || "TextField".equals(vef.getVascEntryFieldType().getId())) {
if (c.getName().toLowerCase().contains("desc") || c.getName().toLowerCase().contains("text")) {
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("TextAreaField"));
}
if (c.getName().toLowerCase().contains("active")) {
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("BooleanField"));
} /* todo
if (c.getName().toLowerCase().contains("email")) {
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("EmailField"));
}
if (c.getName().toLowerCase().contains("url")) {
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("URLField"));
} */
}
ve.addVascEntryField(vef);
if (ve.getDisplayNameFieldId()==null && c.getName().equals(ve.getPrimaryKeyFieldId())==false && c.getType().getJavaEquivalentClass()==String.class) {
ve.setDisplayNameFieldId(c.getName());
}
}
}
/**
* @return the dataContextProvider
*/
public MetaModelDataContextProvider getDataContextProvider() {
return dataContextProvider;
}
/**
* @param dataContextProvider the dataContextProvider to set
*/
public void setDataContextProvider(MetaModelDataContextProvider dataContextProvider) {
this.dataContextProvider = dataContextProvider;
}
/**
* @return the tableInclude
*/
public String getTableInclude() {
return tableInclude;
}
/**
* @param tableInclude the tableInclude to set
*/
public void setTableInclude(String tableInclude) {
this.tableInclude = tableInclude;
}
/**
* @return the tableExclude
*/
public String getTableExclude() {
return tableExclude;
}
/**
* @param tableExclude the tableExclude to set
*/
public void setTableExclude(String tableExclude) {
this.tableExclude = tableExclude;
}
/**
* @return the entryPrefix
*/
public String getEntryPrefix() {
return entryPrefix;
}
/**
* @param entryPrefix the entryPrefix to set
*/
public void setEntryPrefix(String entryPrefix) {
this.entryPrefix = entryPrefix;
}
}

View file

@ -54,7 +54,7 @@ import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
/**
* Provides backend for metamodel.
* MetaModelVascBackend provides vasc backend for metamodel.
*
* @author Willem Cazander
* @version 1.0 Dec 31, 2011
@ -65,15 +65,23 @@ public class MetaModelVascBackend extends AbstractVascBackend {
private UpdateableDataContext dataContext = null;
private String table = null;
private String tableId = null;
private UpdateableDataContext getUpdateableDataContext() {
if (dataContext!=null) {
return dataContext;
}
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackend#startBackend()
*/
@Override
public void startBackend() {
dataContext = (UpdateableDataContext)dataContextProvider.getDataContext();
return dataContext;
}
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackend#stopBackend()
*/
@Override
public void stopBackend() {
dataContext = null;
}
/**
* @see net.forwardfire.vasc.backend.AbstractVascBackend#isPageable()
*/
@ -87,7 +95,6 @@ public class MetaModelVascBackend extends AbstractVascBackend {
*/
@Override
public long fetchTotalExecuteSize(VascBackendState state) {
UpdateableDataContext dataContext = getUpdateableDataContext();
Schema schema = dataContext.getDefaultSchema();
Table t = schema.getTableByName(table);
Query q = createFilterQuery(state,t,true);
@ -105,9 +112,9 @@ public class MetaModelVascBackend extends AbstractVascBackend {
private Query createFilterQuery(VascBackendState state,Table t,boolean count) {
Object qWhere = null;
if (count==false) {
qWhere = getUpdateableDataContext().query().from(t).select(t.getColumns());
qWhere = dataContext.query().from(t).select(t.getColumns());
} else {
qWhere = getUpdateableDataContext().query().from(t).selectCount();
qWhere = dataContext.query().from(t).selectCount();
}
Iterator<String> keys = state.getDataParameterKeys().iterator();
boolean first = true;
@ -154,7 +161,6 @@ public class MetaModelVascBackend extends AbstractVascBackend {
}
public List<Object> execute(VascBackendState state) throws VascException {
UpdateableDataContext dataContext = getUpdateableDataContext();
Schema schema = dataContext.getDefaultSchema();
Table t = schema.getTableByName(table);
Query q = createFilterQuery(state,t,false);
@ -182,7 +188,6 @@ public class MetaModelVascBackend extends AbstractVascBackend {
@SuppressWarnings("unchecked")
public void persist(Object object) throws VascException {
final Map<String,Object> map = (Map<String,Object>)object;
UpdateableDataContext dataContext = getUpdateableDataContext();
dataContext.executeUpdate(new UpdateScript() {
public void run(UpdateCallback backendImpl) {
RowInsertionBuilder query = backendImpl.insertInto(table);
@ -193,12 +198,12 @@ public class MetaModelVascBackend extends AbstractVascBackend {
query.execute();
}
});
}
@SuppressWarnings("unchecked")
public Object merge(Object object) throws VascException {
final Map<String,Object> map = (Map<String,Object>)object;
UpdateableDataContext dataContext = getUpdateableDataContext();
dataContext.executeUpdate(new UpdateScript() {
public void run(UpdateCallback backendImpl) {
@ -224,7 +229,6 @@ public class MetaModelVascBackend extends AbstractVascBackend {
@SuppressWarnings("unchecked")
public void delete(Object object) throws VascException {
final Map<String,Object> map = (Map<String,Object>)object;
UpdateableDataContext dataContext = getUpdateableDataContext();
dataContext.executeUpdate(new UpdateScript() {
public void run(UpdateCallback backendImpl) {
if (map.get(tableId) instanceof Number) {

View file

@ -0,0 +1,56 @@
/*
* Copyright 2007-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.backend.metamodel.x4o;
import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry;
import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.impl.x4o.VascParser;
import org.x4o.xml.element.AbstractElementConfigurator;
import org.x4o.xml.element.Element;
import org.x4o.xml.element.ElementConfiguratorException;
/**
* SchemaAutoEntryElementConfigurator runs the autoCreateEntries method the MetaModelSchemaAutoEntry bean.
*
* @author Willem Cazander
* @version 1.0 May 12, 2012
*/
public class SchemaAutoEntryElementConfigurator extends AbstractElementConfigurator {
/**
* @see org.x4o.xml.element.AbstractElementConfigurator#doConfigEndTag(org.x4o.xml.element.Element)
*/
public void doConfigElement(Element element) throws ElementConfiguratorException {
if (element.getElementObject()==null) {
throw new ElementConfiguratorException(this,"ElementObject is null");
}
if ((element.getElementObject() instanceof MetaModelSchemaAutoEntry)==false) {
throw new ElementConfiguratorException(this,"ElementObject is not MetaModelSchemaAutoEntry object.");
}
MetaModelSchemaAutoEntry autoEntry = (MetaModelSchemaAutoEntry)element.getElementObject();
VascController vascController = VascParser.getVascController(element.getElementContext());
autoEntry.autoCreateEntries(vascController);
}
}

View file

@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<eld:root xmlns:eld="http://eld.x4o.org/eld/eld-lang.eld">
<eld:elementClass tag="metaModelBackend" objectClassName="net.forwardfire.vasc.backend.metamodel.MetaModelVascBackend">
<eld:elementConfigurator bean.class="net.forwardfire.vasc.impl.x4o.VascBackendElementConfigurator" configAction="true"/>
</eld:elementClass>
<eld:root xmlns:eld="http://eld.x4o.org/eld/eld-lang.eld">
<eld:elementClass tag="metaModelBackend" objectClassName="net.forwardfire.vasc.backend.metamodel.MetaModelVascBackend"/>
<eld:elementClass tag="mongodbDataContext" objectClassName="net.forwardfire.vasc.backend.metamodel.MetaModelDataContextMongodb"/>
<eld:elementClass tag="csvDataContext" objectClassName="net.forwardfire.vasc.backend.metamodel.MetaModelDataContextCsv"/>
<eld:elementClass tag="jdbcDataContext" objectClassName="net.forwardfire.vasc.backend.metamodel.MetaModelDataContextJdbc"/>
<eld:elementClass tag="csvDataContext" objectClassName="net.forwardfire.vasc.backend.metamodel.MetaModelDataContextCsv"/>
<eld:elementClass tag="schemaAutoEntry" objectClassName="net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry">
<eld:elementConfigurator bean.class="net.forwardfire.vasc.backend.metamodel.x4o.SchemaAutoEntryElementConfigurator" configAction="true"/>
</eld:elementClass>
</eld:root>