Small refactor for comming converters
This commit is contained in:
parent
75b3d5e0a0
commit
1c308a684a
178 changed files with 5865 additions and 1531 deletions
|
|
@ -21,12 +21,12 @@
|
|||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
|
|
|
|||
|
|
@ -22,10 +22,13 @@
|
|||
|
||||
package net.forwardfire.vasc.ejb3;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -39,45 +42,26 @@ import java.util.logging.Logger;
|
|||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.el.ValueExpression;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
|
||||
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.backends.jpa.EntityManagerProvider;
|
||||
import net.forwardfire.vasc.core.VascBackend;
|
||||
import net.forwardfire.vasc.core.VascBackendControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.impl.DefaultVascBackedEntryFinalizer;
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntryController;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.impl.VascBackendProxyEventExecutor;
|
||||
import net.forwardfire.vasc.impl.actions.AddRowAction;
|
||||
import net.forwardfire.vasc.impl.actions.CSVExportGlobalAction;
|
||||
import net.forwardfire.vasc.impl.actions.DeleteRowAction;
|
||||
import net.forwardfire.vasc.impl.actions.EditRowAction;
|
||||
import net.forwardfire.vasc.impl.actions.XMLExportGlobalAction;
|
||||
import net.forwardfire.vasc.impl.entry.DefaultVascEntryResourceResolver;
|
||||
import net.forwardfire.vasc.impl.x4o.VascParser;
|
||||
import net.forwardfire.vasc.xpql.ejb3.XpqlQueryManager;
|
||||
import net.forwardfire.vasc.xpql.query.Query;
|
||||
|
||||
import org.x4o.xml.core.AbstractX4OPhaseHandler;
|
||||
import org.x4o.xml.core.X4OPhase;
|
||||
import org.x4o.xml.core.X4OPhaseException;
|
||||
import org.x4o.xml.core.X4OPhaseHandler;
|
||||
import org.x4o.xml.element.Element;
|
||||
import org.x4o.xml.element.ElementContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 13 Aug 2007
|
||||
*/
|
||||
@Stateless(name="ejb/vascSericeManager")
|
||||
@Stateless(name="ejb/vascServiceManager")
|
||||
public class VascServiceManagerImpl implements VascServiceManager.IRemote,VascServiceManager.ILocal {
|
||||
|
||||
private Logger logger = Logger.getLogger(VascServiceManagerImpl.class.getName());
|
||||
|
|
@ -128,10 +112,13 @@ public class VascServiceManagerImpl implements VascServiceManager.IRemote,VascSe
|
|||
String value = keys.get(key);
|
||||
if (key.startsWith("load")) {
|
||||
// TODO made reuse working.
|
||||
new HackVascParser(c).parseResource(value);
|
||||
VascParser vp = new VascParser(c);
|
||||
vp.addGlobalELBean("xpqlController", new XpqlController());
|
||||
vp.addGlobalELBean("entityManagerProvider", new LocalEntityManagerProvider());
|
||||
vp.parseResource(value);
|
||||
}
|
||||
}
|
||||
finalVascController(c);
|
||||
DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) c.getVascEntryController(), c);
|
||||
|
||||
sharedVascController = c;
|
||||
|
||||
|
|
@ -203,6 +190,9 @@ public class VascServiceManagerImpl implements VascServiceManager.IRemote,VascSe
|
|||
|
||||
public List<String> getVascEntryIds() {
|
||||
VascController v = getVascController();
|
||||
if (v==null) {
|
||||
return new ArrayList<String>(0);
|
||||
}
|
||||
return v.getVascEntryController().getVascEntryIds();
|
||||
}
|
||||
|
||||
|
|
@ -212,16 +202,16 @@ public class VascServiceManagerImpl implements VascServiceManager.IRemote,VascSe
|
|||
|
||||
try {
|
||||
VascEntry result = ve.clone();
|
||||
//logger.info("Returning cloned ve.");
|
||||
/*
|
||||
logger.info("Returning cloned ve.");
|
||||
|
||||
ByteArrayOutputStream dataArray = new ByteArrayOutputStream(256); // it grows when needed
|
||||
ObjectOutputStream objOutstream = new ObjectOutputStream(dataArray);
|
||||
objOutstream.writeObject(ve);
|
||||
objOutstream.close();
|
||||
|
||||
int objectSize = dataArray.size();
|
||||
*/
|
||||
//logger.info("Writing obj to data: "+objectSize);
|
||||
|
||||
logger.info("Writing obj to data: "+objectSize);
|
||||
|
||||
return result;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
|
|
@ -308,7 +298,7 @@ public class VascServiceManagerImpl implements VascServiceManager.IRemote,VascSe
|
|||
|
||||
}
|
||||
|
||||
class DatafeedsEntityManagerProvider implements EntityManagerProvider {
|
||||
class LocalEntityManagerProvider implements EntityManagerProvider {
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backends.jpa.EntityManagerProvider#getEntityManager()
|
||||
*/
|
||||
|
|
@ -320,89 +310,4 @@ public class VascServiceManagerImpl implements VascServiceManager.IRemote,VascSe
|
|||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class HackVascParser extends VascParser {
|
||||
|
||||
public HackVascParser(VascController c) throws Exception {
|
||||
super(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected X4OPhaseHandler getConfigOptionalPhase() {
|
||||
final X4OPhaseHandler resultSuper = super.getConfigOptionalPhase();
|
||||
X4OPhaseHandler result = new AbstractX4OPhaseHandler() {
|
||||
protected void setX4OPhase() {
|
||||
phase = X4OPhase.configOptionalPhase;
|
||||
}
|
||||
@Override
|
||||
public boolean isElementPhase() {
|
||||
return false;
|
||||
}
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
}
|
||||
public void runPhase(ElementContext elementContext) throws X4OPhaseException {
|
||||
resultSuper.runPhase(elementContext); // this is needed !!
|
||||
ValueExpression e1 = getElementContext().getExpressionFactory().createValueExpression(getElementContext().getELContext(),"${entityManagerProvider}", EntityManagerProvider.class);
|
||||
e1.setValue(getElementContext().getELContext(), new DatafeedsEntityManagerProvider());
|
||||
|
||||
ValueExpression e2 = getElementContext().getExpressionFactory().createValueExpression(getElementContext().getELContext(),"${xpqlController}", XpqlController.class);
|
||||
e2.setValue(getElementContext().getELContext(), new XpqlController());
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private void finalVascController(VascController c) {
|
||||
try {
|
||||
// fill stuff in all global entry'ies
|
||||
for (String id:c.getVascEntryController().getVascEntryIds()) {
|
||||
VascEntry entry = ((DefaultVascEntryController)c.getVascEntryController()).getRealVascEntryById(id);
|
||||
if (entry.isVascDisplayOnly()==false) {
|
||||
if (entry.isVascAdminCreate()) {
|
||||
entry.addRowAction(new AddRowAction());
|
||||
}
|
||||
if (entry.isVascAdminEdit()) {
|
||||
entry.addRowAction(new EditRowAction());
|
||||
}
|
||||
if (entry.isVascAdminDelete()) {
|
||||
entry.addRowAction(new DeleteRowAction());
|
||||
}
|
||||
}
|
||||
entry.addGlobalAction(new XMLExportGlobalAction());
|
||||
entry.addGlobalAction(new CSVExportGlobalAction());
|
||||
//entry.addGlobalAction(new RefreshDataGlobalAction());
|
||||
|
||||
DefaultVascEntryResourceResolver t = new DefaultVascEntryResourceResolver(resourceBundle);
|
||||
if (t.getTextValue(entry.getEditDescription()).equals(entry.getEditDescription())) {
|
||||
entry.setEditDescription("generic.editDescription");
|
||||
}
|
||||
if (t.getTextValue(entry.getDeleteDescription()).equals(entry.getDeleteDescription())) {
|
||||
entry.setDeleteDescription("generic.deleteDescription");
|
||||
}
|
||||
if (t.getTextValue(entry.getCreateDescription()).equals(entry.getCreateDescription())) {
|
||||
entry.setCreateDescription("generic.createDescription");
|
||||
}
|
||||
|
||||
// add global listener to make sure we have all LAZY properties of a bean before we goto edit mode.
|
||||
//entry.addVascEntryEventListener(VascEventType.DATA_SELECT, new RefreshObjectForLazyPropertiesListener());
|
||||
|
||||
// hackje om deze manuale actions van i18n keys te voorzien;
|
||||
// this is temp untill x4o templaing
|
||||
DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer();
|
||||
f.finalizeVascEntry(entry, c);
|
||||
|
||||
// execute backend event listeners
|
||||
VascBackend vb = c.getVascBackendController().getVascBackendById(entry.getBackendId());
|
||||
vb = new VascBackendProxyEventExecutor(vb,entry);
|
||||
((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(vb);
|
||||
}
|
||||
|
||||
logger.finer("Done final config vascController: "+c);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue