2
0
Fork 0

Small refactor for comming converters

This commit is contained in:
Willem Cazander 2012-01-22 08:16:15 +01:00
parent 75b3d5e0a0
commit 1c308a684a
178 changed files with 5865 additions and 1531 deletions

17
vasc-test/.project Normal file
View file

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

View file

@ -0,0 +1,3 @@
#Tue Jan 17 02:16:16 CET 2012
eclipse.preferences.version=1
encoding/<project>=UTF-8

View file

@ -0,0 +1,5 @@
#Tue Jan 17 02:16:16 CET 2012
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

16
vasc-test/pom.xml Normal file
View file

@ -0,0 +1,16 @@
<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</artifactId>
<groupId>net.forwardfire.vasc</groupId>
<version>0.3.5-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>vasc-test</artifactId>
<packaging>pom</packaging>
<name>vasc-test</name>
<description>vasc-test</description>
<modules>
<module>vasc-test-frontend-data</module>
</modules>
</project>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View 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>

View file

@ -0,0 +1,7 @@
#Tue Jan 17 02:17:53 CET 2012
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8

View file

@ -0,0 +1,6 @@
#Tue Jan 17 02:17:53 CET 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5

View file

@ -0,0 +1,5 @@
#Tue Jan 17 02:17:52 CET 2012
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

View file

@ -0,0 +1,17 @@
<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</groupId>
<version>0.3.5-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>vasc-test-frontend-data</artifactId>
<dependencies>
<dependency>
<groupId>net.forwardfire.vasc</groupId>
<artifactId>vasc-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,163 @@
/*
* 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 TestModel {
private String name = null;
private String description = null;
private Float price = null;
private Boolean active = null;
private Date date = null;
private TestModel testModel = null;
private String hexColor = null;
//private Node nonEditorField = null;
/**
* @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 TestModel getTestModel() {
return testModel;
}
public void setTestModel(TestModel 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;
}
}

View file

@ -0,0 +1,130 @@
/*
* 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.lang.reflect.Method;
import net.forwardfire.vasc.backend.VascBackendControllerLocal;
import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.impl.DefaultVascEntry;
import net.forwardfire.vasc.impl.DefaultVascEntryField;
import net.forwardfire.vasc.impl.DefaultVascFactory;
/**
*
* @author Willem Cazander
* @version 1.0 Aug 2, 2007
*/
public class TestModelEntry {
public VascController getTestVascController() throws Exception {
VascController c = DefaultVascFactory.getDefaultVascController(1234L,"Nice UserName","user","role_admin");
// for test
TestModelVascDataSource backend = new TestModelVascDataSource();
backend.generatorData(10876);
backend.setId("testBackend");
((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(backend);
return c;
}
public VascEntry createVascEntry(VascController vc) throws Exception {
VascEntry ve = new DefaultVascEntry();
ve.setId("testEntry");
ve.setBackendId("testBackend");
VascEntryField field = new DefaultVascEntryField();
field.setId("name");
ve.addVascEntryField(field);
field = new DefaultVascEntryField();
field.setId("description");
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
field = new DefaultVascEntryField();
field.setId("active");
field.setVascEntryFieldType(vc.getVascEntryFieldTypeController().getVascEntryFieldTypeById("BooleanField"));
field.setBackendName("active");
field.setDefaultValue("true"); // obj does also work ! we are first need to fix string defaults.
ve.addListOption(field);
return ve;
}
static void printEntry(VascEntry e) throws Exception {
System.out.println("");
System.out.println("=== Printing entry ===");
System.out.println("");
for (Method m:e.getClass().getMethods()) {
if (m.getName().startsWith("get")==false) { //a bit dirty
continue;
}
if (m.getParameterTypes().length>0) {
continue;
}
System.out.println("prop: "+m.getName()+" -> "+m.invoke(e));
}
System.out.println("");
System.out.println("=== Fields ===");
for (VascEntryField vef:e.getVascEntryFields()) {
System.out.println("=== Field: "+vef.getId());
for (Method m:vef.getClass().getMethods()) {
if (m.getName().startsWith("get")==false) { //a bit dirty
continue;
}
if (m.getParameterTypes().length>0) {
continue;
}
System.out.println("prop: "+m.getName()+" -> "+m.invoke(vef));
}
}
}
}

View file

@ -0,0 +1,163 @@
/*
* 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 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.VascException;
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
import net.forwardfire.vasc.core.ui.VascSelectItem;
import net.forwardfire.vasc.core.ui.VascSelectItemModel;
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 extends AbstractVascBackend implements VascSelectItemModel {
private List<TestModel> testModels = null;
private String nullLabel = null;
private String nullKeyValue = null;
public TestModelVascDataSource() {
testModels = new ArrayList<TestModel>(200);
}
public void generatorData(int size) {
for (int i=0;i<size;i++) {
TestModel t = new TestModel();
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 (testModels.isEmpty()==false) {
t.setTestModel((TestModel)testModels.get(0));
}
testModels.add(t);
}
}
public TestModelVascDataSource(List<TestModel> testModels) {
this.testModels=testModels;
}
public List<Object> execute(VascBackendState state) throws VascException {
if (state.getDataParameterKeys().contains("active")) {
List<Object> result = new ArrayList<Object>(testModels.size()/2);
for (TestModel tm:testModels) {
if (tm.getActive()!=null && tm.getActive().equals(state.getDataParameter("active"))) {
result.add(tm);
}
}
return result;
} else {
List<Object> result = new ArrayList<Object>(testModels.size());
for (TestModel tm:testModels) {
result.add(tm);
}
return result;
}
}
public void persist(Object object) throws VascException {
testModels.add((TestModel)object);
}
public Object merge(Object object) throws VascException {
if(testModels.contains(object)==false) {
testModels.add((TestModel)object);
}
return object;
}
public void delete(Object object) throws VascException {
testModels.remove(object);
}
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
return new BeanPropertyVascEntryFieldValue(field.getBackendName());
}
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
return new BeanVascEntryRecordCreator(TestModel.class);
}
// --- VascSelectItemModel interface
public List<VascSelectItem> getVascSelectItems(VascEntry entry) {
List<VascSelectItem> res = new ArrayList<VascSelectItem>(4);
for (Object o:testModels) {
TestModel t = (TestModel)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;
}
}