diff --git a/pom.xml b/pom.xml
index 078efb6..26bdfda 100644
--- a/pom.xml
+++ b/pom.xml
@@ -321,6 +321,13 @@
http://repository.ops4j.org/maven2/
false
+
+ eobjects-metamodel
+ eobjects.org
+ default
+ http://repo.eobjects.org
+ true
+
diff --git a/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapConnectionProviderImpl.java b/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapConnectionProviderImpl.java
index 2b5d926..9ad53ec 100644
--- a/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapConnectionProviderImpl.java
+++ b/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapConnectionProviderImpl.java
@@ -56,7 +56,11 @@ public class LdapConnectionProviderImpl implements LdapConnectionProvider {
}
return lc;
} catch (Exception e) {
- throw new RuntimeException(e);
+ if (bindUser!=null && bindPass!=null) {
+ throw new RuntimeException("Connect as: "+bindUser+" pass: "+bindPass+" message: "+e.getMessage(),e);
+ } else {
+ throw new RuntimeException(e);
+ }
}
}
diff --git a/vasc-backend/vasc-backend-metamodel/pom.xml b/vasc-backend/vasc-backend-metamodel/pom.xml
index 009c8fb..ed0e903 100644
--- a/vasc-backend/vasc-backend-metamodel/pom.xml
+++ b/vasc-backend/vasc-backend-metamodel/pom.xml
@@ -17,8 +17,8 @@
org.eobjects.metamodel
- MetaModel-core
- 2.1
+ MetaModel-full
+ 3.0-SNAPSHOT
\ No newline at end of file
diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextCsv.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextCsv.java
new file mode 100644
index 0000000..030abe9
--- /dev/null
+++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextCsv.java
@@ -0,0 +1,91 @@
+package net.forwardfire.vasc.backend.metamodel;
+
+import java.io.File;
+import java.net.URL;
+
+import org.eobjects.metamodel.DataContext;
+import org.eobjects.metamodel.csv.CsvConfiguration;
+import org.eobjects.metamodel.csv.CsvDataContext;
+
+public class MetaModelDataContextCsv implements MetaModelDataContextProvider {
+
+ private String file = null;
+ private String resource = null;
+ private String url = null;
+ private CsvConfiguration csvConfiguration = null;
+
+ public DataContext getDataContext() {
+ if (csvConfiguration==null) {
+ csvConfiguration = new CsvConfiguration();
+ }
+ CsvDataContext dataContext;
+ if (file != null) {
+ dataContext = new CsvDataContext(new File(file),csvConfiguration);
+ } else if (url != null) {
+ try {
+ dataContext = new CsvDataContext(new URL(url),csvConfiguration);
+ } catch (Exception e) {
+ throw new IllegalStateException("Could not parse url: "+e.getMessage(),e);
+ }
+ } else {
+ throw new IllegalStateException("No file or url defined.");
+ }
+ return dataContext;
+ }
+
+ /**
+ * @return the file
+ */
+ public String getFile() {
+ return file;
+ }
+
+ /**
+ * @param file the file to set
+ */
+ public void setFile(String file) {
+ this.file = file;
+ }
+
+ /**
+ * @return the resource
+ */
+ public String getResource() {
+ return resource;
+ }
+
+ /**
+ * @param resource the resource to set
+ */
+ public void setResource(String resource) {
+ this.resource = resource;
+ }
+
+ /**
+ * @return the url
+ */
+ public String getUrl() {
+ return url;
+ }
+
+ /**
+ * @param url the url to set
+ */
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ /**
+ * @return the csvConfiguration
+ */
+ public CsvConfiguration getCsvConfiguration() {
+ return csvConfiguration;
+ }
+
+ /**
+ * @param csvConfiguration the csvConfiguration to set
+ */
+ public void setCsvConfiguration(CsvConfiguration csvConfiguration) {
+ this.csvConfiguration = csvConfiguration;
+ }
+}
diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextMongodb.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextMongodb.java
new file mode 100644
index 0000000..b58e7f3
--- /dev/null
+++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextMongodb.java
@@ -0,0 +1,141 @@
+package net.forwardfire.vasc.backend.metamodel;
+
+import java.net.UnknownHostException;
+
+import org.eobjects.metamodel.DataContext;
+import org.eobjects.metamodel.mongodb.MongoDbDataContext;
+
+import com.mongodb.DB;
+import com.mongodb.Mongo;
+import com.mongodb.MongoOptions;
+import com.mongodb.ServerAddress;
+
+public class MetaModelDataContextMongodb implements MetaModelDataContextProvider {
+
+ private String hostname = "localhost";
+ private int port = 27017;
+ private String database = null;
+ private String username = null;
+ private String password = null;
+ private boolean readonly = false;
+
+ protected static Mongo mongo = null;
+ protected static DB db = null;
+
+ public DataContext getDataContext() {
+ MongoDbDataContext dataContext = new MongoDbDataContext(getMongodbConnection());
+ return dataContext;
+ }
+
+ public DB getMongodbConnection() {
+ if (db!=null) {
+ return db;
+ }
+ synchronized (this) {
+ ServerAddress server;
+ try {
+ server = new ServerAddress(hostname,port);
+ } catch (UnknownHostException e) {
+ throw new RuntimeException(e);
+ }
+ MongoOptions options = new MongoOptions();
+ mongo = new Mongo(server,options);
+ db = mongo.getDB(database);
+ if (username!=null && password!=null) {
+ boolean auth = db.authenticate(username, password.toCharArray());
+ if (auth==false) {
+ throw new RuntimeException("Could not auth to db: "+database+" with username: "+username);
+ }
+ }
+ if (readonly) {
+ db.setReadOnly(true);
+ }
+ //logger.info("Connection to: "+db.getName());
+ }
+ return db;
+ }
+
+ /**
+ * @return the hostname
+ */
+ public String getHostname() {
+ return hostname;
+ }
+
+ /**
+ * @param hostname the hostname to set
+ */
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ /**
+ * @return the port
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * @param port the port to set
+ */
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ /**
+ * @return the database
+ */
+ public String getDatabase() {
+ return database;
+ }
+
+ /**
+ * @param database the database to set
+ */
+ public void setDatabase(String database) {
+ this.database = database;
+ }
+
+ /**
+ * @return the username
+ */
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * @param username the username to set
+ */
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ /**
+ * @return the password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * @param password the password to set
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ /**
+ * @return the readonly
+ */
+ public boolean isReadonly() {
+ return readonly;
+ }
+
+ /**
+ * @param readonly the readonly to set
+ */
+ public void setReadonly(boolean readonly) {
+ this.readonly = readonly;
+ }
+}
diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextProvider.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextProvider.java
new file mode 100644
index 0000000..6b22836
--- /dev/null
+++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelDataContextProvider.java
@@ -0,0 +1,40 @@
+/*
+ * 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 org.eobjects.metamodel.DataContext;
+
+/**
+ * Provides an metamodel datacontext object to the metamodel backend.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Apr 25, 2012
+ */
+public interface MetaModelDataContextProvider {
+
+ /**
+ * Returns a DB connection.
+ * @return An DB connection to mongodb
+ */
+ public DataContext getDataContext();
+}
diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java
index ce73785..c683df7 100644
--- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java
+++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java
@@ -23,17 +23,21 @@
package net.forwardfire.vasc.backend.metamodel;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.eobjects.metamodel.DataContext;
+import org.eobjects.metamodel.UpdateCallback;
+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.Query;
import org.eobjects.metamodel.query.SelectItem;
import org.eobjects.metamodel.schema.Schema;
import org.eobjects.metamodel.schema.Table;
+import org.eobjects.metamodel.update.RowUpdationBuilder;
import net.forwardfire.vasc.backend.AbstractVascBackend;
import net.forwardfire.vasc.backend.VascBackendState;
@@ -53,13 +57,23 @@ import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
*/
public class MetaModelVascBackend extends AbstractVascBackend {
- private DataContext dataContext = null;
+ private MetaModelDataContextProvider dataContextProvider = null;
+ private UpdateableDataContext dataContext = null;
private String table = null;
+ private String tableId = null;
+
+ private UpdateableDataContext getUpdateableDataContext() {
+ if (dataContext!=null) {
+ return dataContext;
+ }
+ dataContext = (UpdateableDataContext)dataContextProvider.getDataContext();
+ return dataContext;
+ }
public List