Refactored demo section to single app layout.
This commit is contained in:
parent
b3635cf64d
commit
4bd244f4e5
337 changed files with 1630 additions and 1883 deletions
23
vasc-test/vasc-test-frontend/.project
Normal file
23
vasc-test/vasc-test-frontend/.project
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>vasc-test-frontend-data</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>
|
||||
20
vasc-test/vasc-test-frontend/pom.xml
Normal file
20
vasc-test/vasc-test-frontend/pom.xml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<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>
|
||||
<artifactId>vasc-test</artifactId>
|
||||
<groupId>net.forwardfire.vasc.test</groupId>
|
||||
<version>0.4.2-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>vasc-test-frontend</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>vasc-test-frontend</name>
|
||||
<description>vasc-test-frontend</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<artifactId>vasc-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* 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.test.frontend.data;
|
||||
|
||||
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.VascEntryLocal;
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntry;
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntryField;
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntryListOption;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
|
||||
/**
|
||||
* TestModelData provided some vasc entries with object list datamodel to test frontends.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 2, 2007
|
||||
*/
|
||||
public class TestModelData {
|
||||
|
||||
public VascController getTestVascController() throws Exception {
|
||||
VascController c = DefaultVascFactory.getDefaultVascController();
|
||||
|
||||
// for test
|
||||
TestModelVascDataSource backends = new TestModelVascDataSource();
|
||||
backends.generatorData(10876);
|
||||
|
||||
backends.orderModel.setId("orderModelBackend");
|
||||
((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(backends.orderModel);
|
||||
|
||||
backends.orderLineModel.setId("orderLineModelBackend");
|
||||
((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(backends.orderLineModel);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public VascEntryLocal getTestEntry(VascController vc) {
|
||||
return (VascEntryLocal)vc.getVascEntryController().getVascEntryById("orderModel");
|
||||
}
|
||||
|
||||
public void createVascEntries(VascController vc,VascEntryControllerLocal vecl) throws Exception {
|
||||
DefaultVascEntry ve = new DefaultVascEntry();
|
||||
ve.setId("orderModel");
|
||||
ve.setBackendId("orderModelBackend");
|
||||
|
||||
DefaultVascEntryField field = new DefaultVascEntryField();
|
||||
field.setId("name");
|
||||
ve.addVascEntryField(field);
|
||||
|
||||
field = new DefaultVascEntryField();
|
||||
field.setId("description");
|
||||
field.setVascEntryFieldType(vc.getVascEntryFieldTypeController().getVascEntryFieldTypeById("TextAreaField"));
|
||||
ve.addVascEntryField(field);
|
||||
|
||||
field = new DefaultVascEntryField();
|
||||
field.setId("active");
|
||||
field.setVascEntryFieldType(vc.getVascEntryFieldTypeController().getVascEntryFieldTypeById("BooleanField"));
|
||||
ve.addVascEntryField(field);
|
||||
|
||||
field = new DefaultVascEntryField();
|
||||
field.setId("date");
|
||||
field.setVascEntryFieldType(vc.getVascEntryFieldTypeController().getVascEntryFieldTypeById("DateField"));
|
||||
ve.addVascEntryField(field);
|
||||
|
||||
field = new DefaultVascEntryField();
|
||||
field.setId("hexColor");
|
||||
ve.addVascEntryField(field);
|
||||
|
||||
field = new DefaultVascEntryField();
|
||||
field.setId("testModel");
|
||||
// LIST and vascEntryFieldType.dataObject="#{vascController.vascBackendControllerResolver.vascBackendController.vascBackendById('testBackend1')}"
|
||||
ve.addVascEntryField(field);
|
||||
|
||||
// table options
|
||||
DefaultVascEntryListOption option = new DefaultVascEntryListOption();
|
||||
option.setId("active");
|
||||
option.setVascEntryFieldType(vc.getVascEntryFieldTypeController().getVascEntryFieldTypeById("BooleanField"));
|
||||
option.setBackendName("active");
|
||||
option.setDefaultValue("true"); // obj does also work ! we are first need to fix string defaults.
|
||||
|
||||
ve.addVascEntryListOption(option);
|
||||
|
||||
vecl.addVascEntry(ve);
|
||||
|
||||
|
||||
ve = new DefaultVascEntry();
|
||||
ve.setId("orderLineModel");
|
||||
ve.setBackendId("orderLineModelBackend");
|
||||
|
||||
field = new DefaultVascEntryField();
|
||||
field.setId("name");
|
||||
ve.addVascEntryField(field);
|
||||
|
||||
field = new DefaultVascEntryField();
|
||||
field.setId("price");
|
||||
field.setVascEntryFieldType(vc.getVascEntryFieldTypeController().getVascEntryFieldTypeById("FloatField"));
|
||||
ve.addVascEntryField(field);
|
||||
|
||||
field = new DefaultVascEntryField();
|
||||
field.setId("date");
|
||||
field.setVascEntryFieldType(vc.getVascEntryFieldTypeController().getVascEntryFieldTypeById("DateField"));
|
||||
ve.addVascEntryField(field);
|
||||
|
||||
vecl.addVascEntry(ve);
|
||||
|
||||
DefaultVascFactory.fillVascControllerLocalEntries(vecl, vc);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,178 @@
|
|||
/*
|
||||
* 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.test.frontend.data;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import net.forwardfire.vasc.annotations.VascDefaultValue;
|
||||
import net.forwardfire.vasc.annotations.VascEntry;
|
||||
import net.forwardfire.vasc.annotations.VascI18n;
|
||||
import net.forwardfire.vasc.annotations.VascModelReference;
|
||||
import net.forwardfire.vasc.annotations.VascStyle;
|
||||
import net.forwardfire.vasc.validators.VascDateFuture;
|
||||
import net.forwardfire.vasc.validators.VascObjectNotNull;
|
||||
import net.forwardfire.vasc.validators.VascStringLength;
|
||||
|
||||
/**
|
||||
* TestModel
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 28, 2007
|
||||
*/
|
||||
@VascEntry(headerName="En een tooltip op het model")
|
||||
public class TestModelOrder {
|
||||
|
||||
private Integer id = null;
|
||||
private String name = null;
|
||||
private String description = null;
|
||||
private Float price = null;
|
||||
private Boolean active = null;
|
||||
private Date date = null;
|
||||
private TestModelOrder testModel = null;
|
||||
private String hexColor = null;
|
||||
//private Node nonEditorField = null;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the date
|
||||
*/
|
||||
@VascDateFuture
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date the date to set
|
||||
*/
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
@VascI18n( name="omscheiving",
|
||||
description="De omscrijving",
|
||||
image="/resources/images/gabelfresser.gif",
|
||||
helpId="help.id")
|
||||
@VascDefaultValue(value="xxxxx")
|
||||
@VascStyle(sizeList=200)
|
||||
// @NotNull
|
||||
// @Max(value=10)
|
||||
@VascObjectNotNull
|
||||
@VascStringLength(max=10)
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description the description to set
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the price
|
||||
*/
|
||||
public Float getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param price the price to set
|
||||
*/
|
||||
public void setPrice(Float price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
|
||||
// @NotNull
|
||||
@VascObjectNotNull
|
||||
@VascModelReference
|
||||
@VascI18n(image="/resources/images/gabelfresser.gif")
|
||||
public TestModelOrder getTestModel() {
|
||||
return testModel;
|
||||
}
|
||||
|
||||
public void setTestModel(TestModelOrder testModel) {
|
||||
this.testModel = testModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the active
|
||||
*/
|
||||
public Boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param active the active to set
|
||||
*/
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hexColor
|
||||
*/
|
||||
public String getHexColor() {
|
||||
return hexColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hexColor the hexColor to set
|
||||
*/
|
||||
public void setHexColor(String hexColor) {
|
||||
this.hexColor = hexColor;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* 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.test.frontend.data;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import net.forwardfire.vasc.annotations.VascDefaultValue;
|
||||
import net.forwardfire.vasc.annotations.VascEntry;
|
||||
import net.forwardfire.vasc.annotations.VascI18n;
|
||||
import net.forwardfire.vasc.annotations.VascModelReference;
|
||||
import net.forwardfire.vasc.annotations.VascStyle;
|
||||
import net.forwardfire.vasc.validators.VascDateFuture;
|
||||
import net.forwardfire.vasc.validators.VascObjectNotNull;
|
||||
import net.forwardfire.vasc.validators.VascStringLength;
|
||||
|
||||
/**
|
||||
* TestModelOrderLine
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 7, 2012
|
||||
*/
|
||||
@VascEntry(headerName="OrderLine")
|
||||
public class TestModelOrderLine {
|
||||
|
||||
private TestModelOrder order = null;
|
||||
private String name = null;
|
||||
private Float price = null;
|
||||
private Date date = null;
|
||||
|
||||
/**
|
||||
* @return the order
|
||||
*/
|
||||
public TestModelOrder getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param order the order to set
|
||||
*/
|
||||
public void setOrder(TestModelOrder order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the date
|
||||
*/
|
||||
@VascDateFuture
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date the date to set
|
||||
*/
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the price
|
||||
*/
|
||||
public Float getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param price the price to set
|
||||
*/
|
||||
public void setPrice(Float price) {
|
||||
this.price = price;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
/*
|
||||
* 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.test.frontend.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.x4o.xml.element.DefaultElementObjectPropertyValue;
|
||||
import org.x4o.xml.element.ElementObjectPropertyValueException;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.impl.entry.BeanPropertyVascEntryFieldValue;
|
||||
import net.forwardfire.vasc.impl.entry.BeanVascEntryRecordCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public class TestModelVascDataSource {
|
||||
|
||||
//private List<TestModelOrder> testModels = null;
|
||||
public ListObjectVascDataSource orderModel = null;
|
||||
public ListObjectVascDataSource orderLineModel = null;
|
||||
|
||||
public TestModelVascDataSource() {
|
||||
this(new ArrayList<TestModelOrder>(200),new ArrayList<TestModelOrderLine>(200));
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
public void generatorData(int size) {
|
||||
for (int i=0;i<size/3;i++) {
|
||||
TestModelOrder t = new TestModelOrder();
|
||||
t.setDate(new Date());
|
||||
t.setDescription("Some long text in this....");
|
||||
t.setName("BeanName_"+i);
|
||||
t.setPrice(19.2f+i*4);
|
||||
if (i%4==0) {
|
||||
t.setActive(false);
|
||||
} else {
|
||||
t.setActive(true);
|
||||
}
|
||||
if (orderModel.getObjectList().isEmpty()==false) {
|
||||
t.setTestModel((TestModelOrder)orderModel.getObjectList().get(0));
|
||||
}
|
||||
orderModel.getObjectList().add(t);
|
||||
|
||||
for (int ii=0;ii<size/1000;ii++) {
|
||||
TestModelOrderLine line = new TestModelOrderLine();
|
||||
line.setDate(new Date());
|
||||
line.setName("OrderLine"+ii);
|
||||
line.setPrice(new Float(123+ii));
|
||||
line.setOrder(t);
|
||||
orderLineModel.getObjectList().add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ListObjectVascDataSource extends AbstractVascBackend {
|
||||
private Class<?> modelClass = null;
|
||||
private List<Object> modelList = null;
|
||||
private String nullLabel = null;
|
||||
private String nullKeyValue = null;
|
||||
|
||||
public ListObjectVascDataSource(Class<?> modelClass,List<Object> modelList) {
|
||||
this.modelClass=modelClass;
|
||||
this.modelList=modelList;
|
||||
}
|
||||
|
||||
public List<Object> getObjectList() {
|
||||
return modelList;
|
||||
}
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
if (state.getDataParameterKeys().isEmpty()==false) {
|
||||
List<Object> result = new ArrayList<Object>(modelList.size()/2);
|
||||
DefaultElementObjectPropertyValue helper = new DefaultElementObjectPropertyValue();
|
||||
for (Object row:modelList) {
|
||||
boolean addRow = true;
|
||||
for (String key:state.getDataParameterKeys()) {
|
||||
Object keyValue = state.getDataParameter(key);
|
||||
Object propValue = null;
|
||||
try {
|
||||
propValue = helper.getProperty(row, key);
|
||||
} catch (ElementObjectPropertyValueException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (keyValue==null && propValue==null) {
|
||||
continue;
|
||||
}
|
||||
if (keyValue.equals(propValue)) {
|
||||
continue;
|
||||
}
|
||||
addRow = false;
|
||||
}
|
||||
if (addRow) {
|
||||
result.add(row);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
List<Object> result = new ArrayList<Object>(modelList.size());
|
||||
for (Object row:modelList) {
|
||||
result.add(row);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public void persist(Object object) throws VascException {
|
||||
modelList.add(object);
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascException {
|
||||
if(modelList.contains(object)==false) {
|
||||
modelList.add(object);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascException {
|
||||
modelList.remove(object);
|
||||
}
|
||||
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
return new BeanPropertyVascEntryFieldValue(field.getBackendName());
|
||||
}
|
||||
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
return new BeanVascEntryRecordCreator(modelClass);
|
||||
}
|
||||
|
||||
// --- 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;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @return the nullLabel
|
||||
*/
|
||||
public String getNullLabel() {
|
||||
return nullLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nullLabel the nullLabel to set
|
||||
*/
|
||||
public void setNullLabel(String nullLabel) {
|
||||
this.nullLabel = nullLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the nullKeyValue
|
||||
*/
|
||||
public String getNullKeyValue() {
|
||||
return nullKeyValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nullKeyValue the nullKeyValue to set
|
||||
*/
|
||||
public void setNullKeyValue(String nullKeyValue) {
|
||||
this.nullKeyValue = nullKeyValue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue