Small refactor for comming converters
This commit is contained in:
parent
75b3d5e0a0
commit
1c308a684a
178 changed files with 5865 additions and 1531 deletions
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* 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.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eobjects.metamodel.DataContext;
|
||||
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 net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.backend.data.MapVascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.data.MapVascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
|
||||
/**
|
||||
* Provides backend for metamodel.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 31, 2011
|
||||
*/
|
||||
public class MetaModelVascBackend extends AbstractVascBackend {
|
||||
|
||||
private DataContext dataContext = null;
|
||||
private String table = null;
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
Schema schema = dataContext.getDefaultSchema();
|
||||
Table t = schema.getTableByName(table);
|
||||
//dataContext.query().from("").select("").where("").
|
||||
Query q = dataContext.query().from(t).select(t.getColumns()).toQuery();
|
||||
DataSet ds = dataContext.executeQuery(q);
|
||||
List<Object> result = new ArrayList<Object>(50);
|
||||
while (ds.next()) {
|
||||
Row row = ds.getRow();
|
||||
SelectItem[] cols = row.getSelectItems();
|
||||
Map<String,Object> map = new HashMap<String,Object>(cols.length);
|
||||
for (SelectItem col:cols) {
|
||||
Object value = row.getValue(col);
|
||||
map.put(col.getColumn().getName(), value);
|
||||
}
|
||||
result.add(map);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void persist(Object object) throws VascException {
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascException {
|
||||
return object;
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascException {
|
||||
}
|
||||
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
return new MapVascEntryFieldValue();
|
||||
}
|
||||
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
return new MapVascEntryRecordCreator();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue