2
0
Fork 0

Removed a few complile errors

This commit is contained in:
Willem Cazander 2022-04-27 18:34:46 +02:00
parent 76aa74990e
commit 0997b66c89
14 changed files with 135 additions and 403 deletions

View file

@ -17,7 +17,6 @@
<module>vasc-backend-jdbc</module>
<module>vasc-backend-metamodel</module>
<module>vasc-backend-api</module>
<module>vasc-backend-test</module>
<module>vasc-backend-object</module>
</modules>
</project>

View file

@ -1,151 +0,0 @@
/*
* 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.list;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* Holds the state for the backend
*
* @author Willem Cazander
* @version 1.0 May 26, 2009
*/
@SuppressWarnings("serial")
public class DefaultVascBackendListRequest implements VascBackendListRequest {
protected Map<String,Object> parameters = null;
private int pageIndex = 0;
private int pageSize = 0;
private int pageSizeMax = 0;
private String sortField = null;
private String searchString = null;
private boolean ascending = true;
public DefaultVascBackendListRequest() {
parameters = new HashMap<String,Object>(10);
}
public void setDataParameter(String key, Object data) {
parameters.put(key,data);
}
public void removeDataParameter(String key) {
parameters.remove(key);
}
public void removeDataParameterAll() {
parameters.clear();
}
/**
* @see net.forwardfire.vasc.backend.list.VascBackendListRequest#getDataParameter(java.lang.String)
*/
@Override
public Object getDataParameter(String key) {
return parameters.get(key);
}
/**
* @see net.forwardfire.vasc.backend.list.VascBackendListRequest#getDataParameterKeys()
*/
@Override
public Set<String> getDataParameterKeys() {
return parameters.keySet();
}
/**
* @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getPageIndex()
*/
@Override
public int getPageIndex() {
return pageIndex;
}
public void setPageIndex(int pageIndex) {
this.pageIndex=pageIndex;
}
/**
* @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getPageSize()
*/
@Override
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize=pageSize;
}
/**
* @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getSearchString()
*/
@Override
public String getSearchString() {
return searchString;
}
public void setSearchString(String searchString) {
this.searchString=searchString;
}
/**
* @see net.forwardfire.vasc.backend.crud.VascBackendCrud#isSortAscending()
*/
@Override
public boolean isSortAscending() {
return ascending;
}
public void setSortAscending(boolean ascending) {
this.ascending=ascending;
}
/**
* @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getSortField()
*/
@Override
public String getSortField() {
return sortField;
}
public void setSortField(String sortField) {
this.sortField=sortField;
}
/**
* @return the pageSizeMax
*/
@Override
public int getPageSizeMax() {
return pageSizeMax;
}
public void setPageSizeMax(int pageSizeMax) {
this.pageSizeMax = pageSizeMax;
}
}

View file

@ -23,6 +23,8 @@
package net.forwardfire.vasc.backend.list;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
@ -31,20 +33,86 @@ import java.util.Set;
* @author Willem Cazander
* @version 1.0 May 26, 2009
*/
public interface VascBackendListRequest extends Serializable {
public class VascBackendListRequest implements Serializable {
Object getDataParameter(String key);
Set<String> getDataParameterKeys();
private static final long serialVersionUID = -2076113513122609253L;
protected Map<String,Object> parameters = null;
private int pageIndex = 0;
private int pageSize = 0;
private int pageSizeMax = 0;
private String sortField = null;
private String searchString = null;
private boolean ascending = true;
String getSortField();
public VascBackendListRequest() {
parameters = new HashMap<String,Object>(10);
}
boolean isSortAscending();
public void setDataParameter(String key, Object data) {
parameters.put(key,data);
}
int getPageSize();
public void removeDataParameter(String key) {
parameters.remove(key);
}
int getPageSizeMax();
public void removeDataParameterAll() {
parameters.clear();
}
public Object getDataParameter(String key) {
return parameters.get(key);
}
public Set<String> getDataParameterKeys() {
return parameters.keySet();
}
public int getPageIndex() {
return pageIndex;
}
int getPageIndex();
public void setPageIndex(int pageIndex) {
this.pageIndex=pageIndex;
}
String getSearchString();
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize=pageSize;
}
public String getSearchString() {
return searchString;
}
public void setSearchString(String searchString) {
this.searchString=searchString;
}
public boolean isSortAscending() {
return ascending;
}
public void setSortAscending(boolean ascending) {
this.ascending=ascending;
}
public String getSortField() {
return sortField;
}
public void setSortField(String sortField) {
this.sortField=sortField;
}
public int getPageSizeMax() {
return pageSizeMax;
}
public void setPageSizeMax(int pageSizeMax) {
this.pageSizeMax = pageSizeMax;
}
}

View file

@ -30,7 +30,6 @@ import java.util.Map;
import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backend.list.DefaultVascBackendListRequest;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.backend.select.VascBackendSelectItem;

View file

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>vasc-backend-test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View file

@ -1,44 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.forwardfire.vasc.backend</groupId>
<artifactId>vasc-backend</artifactId>
<version>0.4.2-SNAPSHOT</version>
</parent>
<artifactId>vasc-backend-test</artifactId>
<name>vasc-backend-test</name>
<description>vasc-backend-test</description>
<dependencies>
<dependency>
<groupId>net.forwardfire.vasc.backend</groupId>
<artifactId>vasc-backend-jdbc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc.backend</groupId>
<artifactId>vasc-backend-metamodel</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc.backend</groupId>
<artifactId>vasc-backend-mongodb</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc.backend</groupId>
<artifactId>vasc-backend-ldap</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
</dependencies>
</project>

View file

@ -1,64 +0,0 @@
package net.forwardfire.vasc.backend.test;
import java.io.Serializable;
import junit.framework.TestCase;
import net.forwardfire.vasc.backend.DefaultVascBackendController;
import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backend.list.DefaultVascBackendListRequest;
import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextJdbc;
import net.forwardfire.vasc.backend.metamodel.MetaModelVascBackendCrud;
import org.testng.annotations.Test;
public class CrudTest extends TestCase {
private DefaultVascBackendController backends;
//@Before
public void setup() {
backends = new DefaultVascBackendController();
MetaModelDataContextJdbc mmDB = new MetaModelDataContextJdbc();
mmDB.setConnectUrl("jdbc:postgresql://localhost/moviedb");
mmDB.setDriverClass("org.postgresql.Driver");
mmDB.setUsername("postgres");
mmDB.setPassword("postgresql");
MetaModelVascBackendCrud mm = new MetaModelVascBackendCrud();
mm.setId("mm");
mm.setTable("country");
mm.setTableId("country_id");
mm.setDataContextProvider(mmDB);
backends.addVascBackend(mm);
}
@Test
public void testCrudBackends() throws Exception {
setup();
VascBackendCrud<Serializable,Serializable> backend = (VascBackendCrud<Serializable,Serializable>) backends.getVascBackendById(VascBackendCrud.class,"mm");
assertNotNull(backend);
//
// DefaultVascBackendListRequest state = new DefaultVascBackendListRequest();
// VascBackendListResult<Serializable> result = backend.execute(state);
// assertNotNull(result);
// assertFalse(result.getData().isEmpty());
//
// VascBackendAccessDataRecord<Serializable,Serializable> values = backend.provideVascEntryFieldValue();
//
// for (Serializable record:result.getData()) {
// Object id = values.getValue("country_id", record);
// Object name = values.getValue("name", record);
// Object code = values.getValue("code", record);
// System.out.println("line: "+id+" name: "+name+" code: "+code);
// }
}
}

View file

@ -1,8 +0,0 @@
/**
*
*/
/**
* @author willemc
*
*/
package net.forwardfire.vasc.backend.test;

View file

@ -32,7 +32,6 @@ import java.util.ResourceBundle;
import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backend.list.DefaultVascBackendListRequest;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
import net.forwardfire.vasc.backend.proxy.VascBackendProxy;
import net.forwardfire.vasc.core.VascController;
@ -80,7 +79,7 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll
vascInterfaceImpls = new HashMap<VascInterfaceKey,Class<?>>(VascInterfaceKey.values().length);
vascInterfaceImplFrontends = new HashMap<VascInterfaceKeyFrontend,Class<?>>(VascInterfaceKeyFrontend.values().length);
vascInterfaceLoader = new DefaultVascInterfaceLoader(this);
masterVascBackendState = new DefaultVascBackendListRequest();
masterVascBackendState = new VascBackendListRequest();
masterVascBackendState.setPageSize(100);
masterVascBackendState.setPageSizeMax(1500);
}

View file

@ -68,7 +68,7 @@ public class VascIdCheckFinalizer implements VascEntryConfigFinalizer {
}
// Check if backendId is valid
VascBackendCrud<Serializable> back = vascController.getVascBackendController().getVascBackendById( entry.getBackendId() );
VascBackendCrud<Serializable,Serializable> back = vascController.getVascBackendController().getVascBackendById(VascBackendCrud.class, entry.getBackendId() );
if (back==null) {
throw new IllegalArgumentException("The VascEntry backend is not found in backends: '"+entry.getBackendId()+"' in entryId: "+id);
}

View file

@ -61,7 +61,7 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_CREATE, null);
Serializable object;
try {
object = entry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryRecordCreator().newRecord();
object = entry.getVascFrontendController().getVascEntryState().getVascBackend().newRecord();
} catch (VascBackendException e) {
throw new VascFrontendException(e);
}

View file

@ -76,7 +76,12 @@ public class JRDynamicDataSourceVascEntry extends AbstractJRDynamicDataSource {
for (Serializable o:vascEntry.getVascFrontendController().getVascEntryState().getEntryDataList()) {
List<String> row = new ArrayList<String>(30);
for (VascEntryField c:fields) {
row.add(c.getVascEntryFieldValue().getDisplayValue(c.getBackendName(), o));
Object rowData = c.getVascEntryFieldValue().getValue(c.getBackendName(), o);
if (rowData == null) {
row.add(null);
} else {
row.add(rowData.toString());
}
}
data.add(row);
}

View file

@ -48,10 +48,10 @@ public class TestModelData {
TestModelVascDataSource backends = new TestModelVascDataSource();
backends.generatorData(10876);
backends.orderModel.setId("orderModelBackend");
//backends.orderModel.setId("orderModelBackend");
((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(backends.orderModel);
backends.orderLineModel.setId("orderLineModelBackend");
//backends.orderLineModel.setId("orderLineModelBackend");
((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(backends.orderLineModel);
return c;

View file

@ -25,16 +25,20 @@ package net.forwardfire.vasc.test.frontend.data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.EnumSet;
import java.util.List;
import org.x4o.xml.element.DefaultElementObjectPropertyValue;
import org.x4o.xml.element.ElementObjectPropertyValueException;
import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendAccessDataKey;
import net.forwardfire.vasc.backend.VascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.crud.AbstractVascBackendCrud;
import net.forwardfire.vasc.backend.crud.VascBackendCrud;
import net.forwardfire.vasc.backend.data.BeanVascBackendAccessDataRecord;
import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendList;
import net.forwardfire.vasc.backend.list.VascBackendListFeature;
import net.forwardfire.vasc.backend.list.VascBackendListResult;
import net.forwardfire.vasc.backend.list.VascBackendListRequest;
@ -46,8 +50,8 @@ import net.forwardfire.vasc.backend.list.VascBackendListRequest;
public class TestModelVascDataSource {
//private List<TestModelOrder> testModels = null;
public ListObjectVascDataSource<TestModelOrder,Integer> orderModel = null;
public ListObjectVascDataSource<TestModelOrderLine,Integer> orderLineModel = null;
public ListObjectVascDataSource<Integer,TestModelOrder> orderModel = null;
public ListObjectVascDataSource<Integer,TestModelOrderLine> orderLineModel = null;
public TestModelVascDataSource() {
this(new ArrayList<TestModelOrder>(200),new ArrayList<TestModelOrderLine>(200));
@ -55,8 +59,8 @@ public class TestModelVascDataSource {
@SuppressWarnings({ "unchecked", "rawtypes" })
public TestModelVascDataSource(List<TestModelOrder> testModels,List<TestModelOrderLine> testModelLine) {
orderModel = new ListObjectVascDataSource(TestModelOrder.class,(List)testModels);
orderLineModel = new ListObjectVascDataSource(TestModelOrderLine.class,(List)testModelLine);
orderModel = new ListObjectVascDataSource((List)testModels);
orderLineModel = new ListObjectVascDataSource((List)testModelLine);
}
public void generatorData(int size) {
@ -72,7 +76,7 @@ public class TestModelVascDataSource {
t.setActive(true);
}
if (orderModel.getObjectList().isEmpty()==false) {
t.setTestModel((TestModelOrder)orderModel.getObjectList().get(0));
t.setTestModel(orderModel.getObjectList().get(0));
}
orderModel.getObjectList().add(t);
@ -87,27 +91,23 @@ public class TestModelVascDataSource {
}
}
class ListObjectVascDataSource<DATA_OBJECT extends Serializable,DATA_PK extends Serializable> extends AbstractVascBackendCrud<DATA_OBJECT,DATA_PK> {
private Class<?> modelClass = null;
private List<DATA_OBJECT> modelList = null;
private String nullLabel = null;
private String nullKeyValue = null;
class ListObjectVascDataSource<DATA_PK extends Serializable,DATA_RECORD extends Serializable> implements VascBackendList<DATA_PK,DATA_RECORD> {
private List<DATA_RECORD> modelList = null;
public ListObjectVascDataSource(Class<?> modelClass,List<DATA_OBJECT> modelList) {
this.modelClass=modelClass;
public ListObjectVascDataSource(List<DATA_RECORD> modelList) {
this.modelList=modelList;
}
public List<DATA_OBJECT> getObjectList() {
public List<DATA_RECORD> getObjectList() {
return modelList;
}
@Override
public VascBackendListResult<DATA_OBJECT> execute(VascBackendListRequest state) throws VascBackendException {
public VascBackendListResult<DATA_RECORD> execute(VascBackendListRequest state) throws VascBackendException {
if (state.getDataParameterKeys().isEmpty()==false) {
List<DATA_OBJECT> result = new ArrayList<DATA_OBJECT>(modelList.size()/2);
List<DATA_RECORD> result = new ArrayList<DATA_RECORD>(modelList.size()/2);
DefaultElementObjectPropertyValue helper = new DefaultElementObjectPropertyValue();
for (DATA_OBJECT row:modelList) {
for (DATA_RECORD row:modelList) {
boolean addRow = true;
for (String key:state.getDataParameterKeys()) {
Object keyValue = state.getDataParameter(key);
@ -129,99 +129,51 @@ public class TestModelVascDataSource {
result.add(row);
}
}
return new DefaultVascBackendListResult<DATA_OBJECT>(result);
return new DefaultVascBackendListResult<DATA_RECORD>(result);
} else {
List<DATA_OBJECT> result = new ArrayList<DATA_OBJECT>(modelList.size());
for (DATA_OBJECT row:modelList) {
List<DATA_RECORD> result = new ArrayList<DATA_RECORD>(modelList.size());
for (DATA_RECORD row:modelList) {
result.add(row);
}
return new DefaultVascBackendListResult<DATA_OBJECT>(result);
return new DefaultVascBackendListResult<DATA_RECORD>(result);
}
}
@Override
public DATA_OBJECT persist(DATA_OBJECT object) throws VascBackendException {
modelList.add(object);
return object;
}
@Override
public DATA_OBJECT merge(DATA_OBJECT object) throws VascBackendException {
if(modelList.contains(object)==false) {
modelList.add(object);
}
return object;
}
@Override
public void delete(DATA_PK object) throws VascBackendException {
modelList.remove(object); // TODO FIXME BUG
}
@Override
public VascBackendAccessDataRecord<DATA_OBJECT,DATA_PK> provideVascEntryFieldValue() {
return new BeanVascBackendAccessDataRecord();
}
/**
* @see net.forwardfire.vasc.backend.crud.VascBackendCrud#fetch(java.io.Serializable)
*/
@Override
public DATA_OBJECT fetch(DATA_PK recordPK) throws VascBackendException {
public EnumSet<VascBackendListFeature> getSupportedFeatures() {
// TODO Auto-generated method stub
return null;
}
/**
* @see net.forwardfire.vasc.backend.crud.VascBackendCrud#newRecord()
*/
@Override
@SuppressWarnings("unchecked")
public DATA_OBJECT newRecord() throws VascBackendException {
return (DATA_OBJECT)modelClass.newInstance();
public List<String> getSupportedRowActions() {
// TODO Auto-generated method stub
return null;
}
// --- VascSelectItemModel interface
/*
public List<VascSelectItem> getVascSelectItems(VascEntry entry) {
List<VascSelectItem> res = new ArrayList<VascSelectItem>(4);
for (Object o:testModels) {
TestModelOrder t = (TestModelOrder)o;
VascSelectItem i = new VascSelectItem(t.getName(),t);
res.add(i);
}
return res;
}*/
@Override
public VascBackendAccessDataRecord<DATA_PK, DATA_RECORD> createVascBackendAccessDataRecord() {
// TODO Auto-generated method stub
return null;
}
/**
* @return the nullLabel
*/
public String getNullLabel() {
return nullLabel;
@Override
public String getId() {
// TODO Auto-generated method stub
return null;
}
/**
* @param nullLabel the nullLabel to set
*/
public void setNullLabel(String nullLabel) {
this.nullLabel = nullLabel;
@Override
public VascBackendAccessDataKey<DATA_PK> createVascBackendAccessDataKey() {
// TODO Auto-generated method stub
return null;
}
/**
* @return the nullKeyValue
*/
public String getNullKeyValue() {
return nullKeyValue;
}
/**
* @param nullKeyValue the nullKeyValue to set
*/
public void setNullKeyValue(String nullKeyValue) {
this.nullKeyValue = nullKeyValue;
@Override
public void executeRowAction(VascBackendListRequest request, List<DATA_PK> recordPKs, String actionName)
throws VascBackendException {
// TODO Auto-generated method stub
}
}