added files
This commit is contained in:
parent
90b81deb29
commit
fc4c568b18
11 changed files with 484 additions and 0 deletions
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* AbstractVascBackendResult.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 23, 2014
|
||||
*/
|
||||
abstract public class AbstractVascBackendResult<DATA_OBJECT extends Serializable> implements VascBackendResult<DATA_OBJECT> {
|
||||
|
||||
private final List<DATA_OBJECT> pageData;
|
||||
private final long totalSize;
|
||||
private final Map<String, Serializable> pageSummary;
|
||||
private final Map<String, Serializable> totalSummary;
|
||||
|
||||
public AbstractVascBackendResult(List<DATA_OBJECT> pageData,long totalSize,Map<String, Serializable> pageSummary,Map<String, Serializable> totalSummary) {
|
||||
this.pageData = pageData;
|
||||
this.totalSize = totalSize;
|
||||
this.pageSummary = pageSummary;
|
||||
this.totalSummary = totalSummary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackendResult#getPageData()
|
||||
*/
|
||||
@Override
|
||||
public List<DATA_OBJECT> getPageData() {
|
||||
return pageData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackendResult#getTotalSize()
|
||||
*/
|
||||
@Override
|
||||
public long getTotalSize() {
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackendResult#getPageSummary()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Serializable> getPageSummary() {
|
||||
return pageSummary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackendResult#getTotalSummary()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Serializable> getTotalSummary() {
|
||||
return totalSummary;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* DefaultVascBackendResult.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 23, 2014
|
||||
*/
|
||||
public final class DefaultVascBackendResult<DATA_OBJECT extends Serializable> extends AbstractVascBackendResult<DATA_OBJECT> {
|
||||
|
||||
public DefaultVascBackendResult(List<DATA_OBJECT> pageData) {
|
||||
this(pageData,-1,null,null);
|
||||
}
|
||||
|
||||
public DefaultVascBackendResult(List<DATA_OBJECT> pageData, long totalSize,
|
||||
Map<String, Serializable> pageSummary,
|
||||
Map<String, Serializable> totalSummary) {
|
||||
super(pageData, totalSize, pageSummary, totalSummary);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* VascBackendResult.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 23, 2014
|
||||
*/
|
||||
public interface VascBackendResult<DATA_OBJECT extends Serializable> {
|
||||
|
||||
List<DATA_OBJECT> getPageData();
|
||||
long getTotalSize();
|
||||
Map<String,Serializable> getPageSummary();
|
||||
Map<String,Serializable> getTotalSummary();
|
||||
}
|
||||
23
vasc-backend/vasc-backend-test/.project
Normal file
23
vasc-backend/vasc-backend-test/.project
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?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>
|
||||
44
vasc-backend/vasc-backend-test/pom.xml
Normal file
44
vasc-backend/vasc-backend-test/pom.xml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<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>
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
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.DefaultVascBackendState;
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendResult;
|
||||
import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextJdbc;
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelVascBackend;
|
||||
|
||||
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");
|
||||
|
||||
MetaModelVascBackend mm = new MetaModelVascBackend();
|
||||
mm.setId("mm");
|
||||
mm.setTable("country");
|
||||
mm.setTableId("country_id");
|
||||
mm.setDataContextProvider(mmDB);
|
||||
|
||||
|
||||
backends.addVascBackend(mm);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCrudBackends() throws Exception {
|
||||
|
||||
setup();
|
||||
|
||||
VascBackend<Serializable> backend = (VascBackend<Serializable>) backends.getVascBackendById("mm");
|
||||
assertNotNull(backend);
|
||||
|
||||
DefaultVascBackendState state = new DefaultVascBackendState();
|
||||
VascBackendResult<Serializable> result = backend.execute(state);
|
||||
assertNotNull(result);
|
||||
assertFalse(result.getPageData().isEmpty());
|
||||
|
||||
VascEntryFieldValue<Serializable> values = backend.provideVascEntryFieldValue();
|
||||
|
||||
for (Serializable record:result.getPageData()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @author willemc
|
||||
*
|
||||
*/
|
||||
package net.forwardfire.vasc.backend.test;
|
||||
Loading…
Add table
Add a link
Reference in a new issue