152 lines
No EOL
5.7 KiB
Java
152 lines
No EOL
5.7 KiB
Java
/*
|
|
* Copyright 2004-2006 IDCA. All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
|
* following conditions are met:
|
|
*
|
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
|
* the following disclaimer.
|
|
* 2. 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 IDCA 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 IDCA 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.
|
|
*
|
|
* The views and conclusions contained in the software and documentation are those of the authors and
|
|
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
|
*/
|
|
|
|
package com.idcanet.vasc;
|
|
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.lang.reflect.Method;
|
|
import java.util.Locale;
|
|
|
|
import com.idcanet.vasc.core.VascBackend;
|
|
import com.idcanet.vasc.core.VascBackendControllerLocal;
|
|
import com.idcanet.vasc.core.VascController;
|
|
import com.idcanet.vasc.core.VascEntry;
|
|
import com.idcanet.vasc.core.VascEntryField;
|
|
import com.idcanet.vasc.core.VascException;
|
|
import com.idcanet.vasc.core.VascFrontendData;
|
|
import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer;
|
|
import com.idcanet.vasc.impl.DefaultVascFactory;
|
|
import com.idcanet.vasc.impl.DefaultVascFrontendData;
|
|
import com.idcanet.vasc.impl.DefaultVascFrontendHelper;
|
|
import com.idcanet.vasc.impl.VascBackendProxyPaged;
|
|
import com.idcanet.vasc.impl.VascBackendProxySearch;
|
|
import com.idcanet.vasc.impl.VascBackendProxySort;
|
|
import com.idcanet.vasc.impl.actions.AddRowAction;
|
|
import com.idcanet.vasc.impl.actions.CSVExportGlobalAction;
|
|
import com.idcanet.vasc.impl.actions.DeleteRowAction;
|
|
import com.idcanet.vasc.impl.actions.EditRowAction;
|
|
import com.idcanet.vasc.impl.actions.RefreshDataGlobalAction;
|
|
import com.idcanet.vasc.impl.actions.XMLExportGlobalAction;
|
|
import com.idcanet.vasc.impl.x4o.VascParser;
|
|
|
|
|
|
/**
|
|
*
|
|
* @author Willem Cazander
|
|
* @version 1.0 Aug 2, 2007
|
|
*/
|
|
public class TestTable {
|
|
|
|
static VascController getDefaultVascController() throws Exception {
|
|
VascController c = DefaultVascFactory.getDefaultVascController(2288L,"idca.nl","user","admin");
|
|
|
|
// for test
|
|
TestModelVascDataSource backend = new TestModelVascDataSource();
|
|
backend.setId("testBackend1");
|
|
((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(backend);
|
|
|
|
return c;
|
|
}
|
|
|
|
static public void fill(VascEntry entry,VascController vascController) {
|
|
|
|
|
|
VascFrontendData frontendData = DefaultVascFactory.getDefaultVascFrontendData("i18n.vasc", Locale.getDefault());
|
|
frontendData.setVascController(vascController);
|
|
entry.setVascFrontendData(frontendData);
|
|
VascBackend backend = DefaultVascFactory.getProxyVascBackend(entry);
|
|
frontendData.getVascEntryState().setVascBackend(backend);
|
|
frontendData.getVascEntryState().setVascEntry(entry);
|
|
|
|
|
|
entry.addRowAction(new AddRowAction());
|
|
entry.addRowAction(new EditRowAction());
|
|
entry.addRowAction(new DeleteRowAction());
|
|
|
|
entry.addGlobalAction(new XMLExportGlobalAction());
|
|
entry.addGlobalAction(new CSVExportGlobalAction());
|
|
entry.addGlobalAction(new RefreshDataGlobalAction());
|
|
|
|
// hackje om deze manuale actions van i18n keys te voorzien;
|
|
// this is temp untill x4o templaing
|
|
DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer();
|
|
try {
|
|
f.finalizeVascEntry(entry, vascController);
|
|
} catch (VascException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
static public VascEntry getVascTable() throws Exception {
|
|
|
|
VascController c = getDefaultVascController();
|
|
|
|
VascParser parser = new VascParser(c);
|
|
File f = File.createTempFile("test-vasc", ".xml");
|
|
parser.setDebugOutputStream(new FileOutputStream(f));
|
|
parser.parseResource("vasc/tables.xml");
|
|
|
|
VascEntry entry = parser.getVascController().getVascEntryController().getVascEntryById("test1");
|
|
fill(entry,c);
|
|
|
|
return entry;
|
|
}
|
|
|
|
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));
|
|
}
|
|
}
|
|
}
|
|
} |