Implemented system event on top of osgi event admin framework and dynamic service framework. Added event.test project as example of usage. Modify ModelEventValidationEngine to invoke osgi event handler.

This commit is contained in:
Heng Sin Low 2010-12-06 13:04:44 +08:00
parent a3de4bc94f
commit 0af05090d1
31 changed files with 1009 additions and 42 deletions

7
event.test/.classpath Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

33
event.test/.project Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>event.test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,8 @@
#Sun Dec 05 18:12:35 MYT 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View File

@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Test
Bundle-SymbolicName: event.test
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: event.test.Activator
Require-Bundle: org.adempiere.base;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.eclipse.equinox.events;version="1.0.0",
org.osgi.framework,
org.osgi.service.event;version="1.2.0"
Service-Component: OSGI-INF/event.xml

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="event.test">
<implementation class="event.test.MyEventHandler"/>
<reference bind="bindEventManager" cardinality="1..1" interface="org.adempiere.base.event.IEventManager" name="IEventManager" policy="static" unbind="unbindEventManager"/>
</scr:component>

View File

@ -0,0 +1,5 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/event.xml
source.. = src/

View File

@ -0,0 +1,30 @@
package event.test;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
private static BundleContext context;
static BundleContext getContext() {
return context;
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
}
}

View File

@ -0,0 +1,39 @@
package event.test;
import org.adempiere.base.event.IEventManager;
import org.adempiere.base.event.IEventTopics;
import org.adempiere.base.event.LoginEventData;
import org.compiere.model.PO;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
/**
*
* @author hengsin
*
*/
public class MyEventHandler implements EventHandler {
@Override
public void handleEvent(Event event) {
if (event.getTopic().equals(IEventTopics.AFTER_LOGIN)) {
LoginEventData eventData = (LoginEventData) event.getProperty(IEventManager.EVENT_DATA);
System.out.println(" topic="+event.getTopic()+" AD_Client_ID="+eventData.getAD_Client_ID()
+" AD_Org_ID="+eventData.getAD_Org_ID()+" AD_Role_ID="+eventData.getAD_Role_ID()
+" AD_User_ID="+eventData.getAD_User_ID());
} else if (event.getTopic().equals(IEventTopics.PO_AFTER_NEW)) {
PO po = (PO) event.getProperty(IEventManager.EVENT_DATA);
System.out.println(" topic="+event.getTopic()+" po="+po);
}
}
public void bindEventManager(IEventManager eventManager) {
eventManager.register(IEventTopics.AFTER_LOGIN, this);
eventManager.register(IEventTopics.PO_AFTER_NEW, "(tableName=C_Order)", this);
}
public void unbindEventManager(IEventManager eventManager) {
eventManager.unregister(this);
}
}

View File

@ -300,4 +300,25 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="org.eclipse.equinox.event"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.equinox.ds"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.osgi.services"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature> </feature>

View File

@ -34,6 +34,11 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature> <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>

View File

@ -59,6 +59,7 @@ Export-Package: bsh,
net.sourceforge.barbecue.twod.pdf417, net.sourceforge.barbecue.twod.pdf417,
org.adempiere.apps.graph, org.adempiere.apps.graph,
org.adempiere.base, org.adempiere.base,
org.adempiere.base.event,
org.adempiere.exceptions, org.adempiere.exceptions,
org.adempiere.impexp, org.adempiere.impexp,
org.adempiere.model, org.adempiere.model,
@ -164,6 +165,7 @@ Import-Package: com.sun.mail.smtp;version="1.4.0",
org.eclipse.osgi.framework.console;version="1.1.0", org.eclipse.osgi.framework.console;version="1.1.0",
org.eclipse.osgi.service.datalocation, org.eclipse.osgi.service.datalocation,
org.osgi.framework, org.osgi.framework,
org.osgi.service.event;version="1.2.0",
org.restlet, org.restlet,
org.restlet.data, org.restlet.data,
org.restlet.representation, org.restlet.representation,
@ -171,3 +173,5 @@ Import-Package: com.sun.mail.smtp;version="1.4.0",
Eclipse-BuddyPolicy: registered Eclipse-BuddyPolicy: registered
Eclipse-ExtensibleAPI: true Eclipse-ExtensibleAPI: true
Bundle-Activator: org.adempiere.base.BaseActivator Bundle-Activator: org.adempiere.base.BaseActivator
Service-Component: OSGI-INF/eventmanager.xml
Bundle-ActivationPolicy: lazy

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.adempiere.base">
<implementation class="org.adempiere.base.event.EventManager"/>
<reference bind="bindEventAdmin" cardinality="1..1" interface="org.osgi.service.event.EventAdmin" name="EventAdmin" policy="static" unbind="unbindEventAdmin"/>
<service>
<provide interface="org.adempiere.base.event.IEventManager"/>
</service>
</scr:component>

View File

@ -1,5 +1,3 @@
source.base.jar = src/
output.base.jar = build/
bin.includes = META-INF/,\ bin.includes = META-INF/,\
base.jar,\ base.jar,\
plugin.xml,\ plugin.xml,\
@ -14,4 +12,7 @@ bin.includes = META-INF/,\
iText-2.1.7.jar,\ iText-2.1.7.jar,\
jcommon-1.0.16.jar,\ jcommon-1.0.16.jar,\
jfreechart-1.0.13.jar,\ jfreechart-1.0.13.jar,\
jnlp.jar jnlp.jar,\
OSGI-INF/eventmanager.xml
output.base.jar = build/
source.base.jar = src/

View File

@ -24,8 +24,10 @@ import org.osgi.framework.BundleContext;
*/ */
public class BaseActivator implements BundleActivator { public class BaseActivator implements BundleActivator {
private static BundleContext bundleContext = null;
/** /**
* * default constructor
*/ */
public BaseActivator() { public BaseActivator() {
} }
@ -35,6 +37,7 @@ public class BaseActivator implements BundleActivator {
*/ */
@Override @Override
public void start(BundleContext context) throws Exception { public void start(BundleContext context) throws Exception {
bundleContext = context;
context.registerService(CommandProvider.class.getName(), new StackTraceCommand(), null); context.registerService(CommandProvider.class.getName(), new StackTraceCommand(), null);
} }
@ -43,6 +46,10 @@ public class BaseActivator implements BundleActivator {
*/ */
@Override @Override
public void stop(BundleContext context) throws Exception { public void stop(BundleContext context) throws Exception {
bundleContext = null;
} }
public static BundleContext getBundleContext() {
return bundleContext;
}
} }

View File

@ -0,0 +1,211 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 2010 Heng Sin Low *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.base.event;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import org.adempiere.base.BaseActivator;
import org.compiere.util.CLogger;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventAdmin;
import org.osgi.service.event.EventConstants;
import org.osgi.service.event.EventHandler;
/**
* Simple wrapper for the osgi event admin service.
* Usage: EventManager.getInstance().sendEvent/postEvent
* @author hengsin
*
*/
public class EventManager implements IEventManager {
private EventAdmin eventAdmin;
private static IEventManager instance = null;
private final static CLogger log = CLogger.getCLogger(EventManager.class);
private Map<EventHandler, List<ServiceRegistration>> registrations = new HashMap<EventHandler, List<ServiceRegistration>>();
/**
* @param eventAdmin
*/
public void bindEventAdmin(EventAdmin eventAdmin) {
if (instance == null)
instance = this;
this.eventAdmin = eventAdmin;
}
/**
* @param eventAdmin
*/
public void unbindEventAdmin(EventAdmin eventAdmin) {
this.eventAdmin = null;
}
/**
* Get the singleton instance created by the osgi service framework
* @return EventManager
*/
public static IEventManager getInstance() {
return instance;
}
/* (non-Javadoc)
* @see org.adempiere.base.event.IEventManager#postEvent(org.osgi.service.event.Event)
*/
@Override
public boolean postEvent(Event event) {
if (eventAdmin != null) {
eventAdmin.postEvent(event);
return true;
}
return false;
}
/* (non-Javadoc)
* @see org.adempiere.base.event.IEventManager#sendEvent(org.osgi.service.event.Event)
*/
@Override
public boolean sendEvent(Event event) {
if (eventAdmin != null) {
eventAdmin.postEvent(event);
return true;
}
return false;
}
/* (non-Javadoc)
* @see org.adempiere.base.event.IEventManager#register(java.lang.String, org.osgi.service.event.EventHandler)
*/
@Override
public boolean register(String topic, EventHandler eventHandler) {
return register(topic, null, eventHandler);
}
/* (non-Javadoc)
* @see org.adempiere.base.event.IEventManager#register(java.lang.String[], org.osgi.service.event.EventHandler)
*/
@Override
public boolean register(String[] topics, EventHandler eventHandler) {
return register(topics, null, eventHandler);
}
/* (non-Javadoc)
* @see org.adempiere.base.event.IEventManager#register(java.lang.String, java.lang.String, org.osgi.service.event.EventHandler)
*/
@Override
public boolean register(String topic, String filter, EventHandler eventHandler) {
String[] topics = new String[] {topic};
return register(topics, filter, eventHandler);
}
/* (non-Javadoc)
* @see org.adempiere.base.event.IEventManager#register(java.lang.String[], java.lang.String, org.osgi.service.event.EventHandler)
*/
@Override
public boolean register(String[] topics, String filter, EventHandler eventHandler) {
BundleContext bundleContext = BaseActivator.getBundleContext();
if (bundleContext == null) {
log.severe("No bundle context. Topic="+Arrays.toString(topics));
return false;
}
Dictionary<String, Object> d = new Hashtable<String, Object>();
d.put(EventConstants.EVENT_TOPIC, topics);
if (filter != null)
d.put(EventConstants.EVENT_FILTER, filter);
ServiceRegistration registration = bundleContext.registerService(EventHandler.class.getName(), eventHandler, d);
synchronized(registrations) {
List<ServiceRegistration> list = registrations.get(eventHandler);
if (list == null) {
list = new ArrayList<ServiceRegistration>();
registrations.put(eventHandler, list);
}
list.add(registration);
}
return true;
}
/* (non-Javadoc)
* @see org.adempiere.base.event.IEventManager#unregister(org.osgi.service.event.EventHandler)
*/
@Override
public boolean unregister(EventHandler eventHandler) {
List<ServiceRegistration> serviceRegistrations = null;
synchronized(registrations) {
serviceRegistrations = registrations.remove(eventHandler);
}
if (serviceRegistrations == null)
return false;
for (ServiceRegistration registration : serviceRegistrations)
registration.unregister();
return true;
}
/**
* @param topic
* @param parameter
*/
@SuppressWarnings("unchecked")
public static Event newEvent(String topic, Object data) {
Event event = null;
if (data instanceof Dictionary<?,?>) {
Dictionary<String,Object>dict = (Dictionary<String,Object>)data;
if (dict.get(EVENT_ERROR_MESSAGES) == null)
dict.put(EVENT_ERROR_MESSAGES, new ArrayList<String>());
event = new Event(topic, dict);
} else if (data instanceof Map<?, ?>) {
Map<String, Object> map = (Map<String, Object>)data;
if (!map.containsKey(EVENT_ERROR_MESSAGES))
map.put(EVENT_ERROR_MESSAGES, new ArrayList<String>());
event = new Event(topic, map);
} else {
Map<String, Object> map = new HashMap<String, Object>(3);
map.put(EventConstants.EVENT_TOPIC, topic);
if (data != null)
map.put(EVENT_DATA, data);
map.put(EVENT_ERROR_MESSAGES, new ArrayList<String>());
event = new Event(topic, map);
}
return event;
}
/**
*
* @param topic
* @param properties
* @return event object
*/
public static Event newEvent(String topic, EventProperty ...properties) {
Event event = null;
Map<String, Object> map = new HashMap<String, Object>(3);
if (properties != null) {
for(int i = 0; i < properties.length; i++) {
map.put(properties[i].name, properties[i].value);
}
if (!map.containsKey(EventConstants.EVENT_TOPIC))
map.put(EventConstants.EVENT_TOPIC, topic);
if (!map.containsKey(EVENT_ERROR_MESSAGES))
map.put(EVENT_ERROR_MESSAGES, new ArrayList<String>());
}
event = new Event(topic, map);
return event;
}
}

View File

@ -0,0 +1,34 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 2010 Heng Sin Low *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.base.event;
/**
*
* @author hengsin
*
*/
public class EventProperty {
public String name;
public Object value;
/**
* @param name
* @param value
*/
public EventProperty(String name, Object value) {
super();
this.name = name;
this.value = value;
}
}

View File

@ -0,0 +1,64 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 2010 Heng Sin Low *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.base.event;
import java.util.List;
import org.compiere.acct.Fact;
import org.compiere.model.MAcctSchema;
import org.compiere.model.PO;
/**
*
* @author hengsin
*
*/
public class FactsEventData {
private MAcctSchema acctSchema;
private List<Fact> facts;
private PO po;
/**
* @param acctSchema
* @param facts
* @param po
*/
public FactsEventData(MAcctSchema acctSchema, List<Fact> facts, PO po) {
super();
this.acctSchema = acctSchema;
this.facts = facts;
this.po = po;
}
/**
* @return the acctSchema
*/
public MAcctSchema getAcctSchema() {
return acctSchema;
}
/**
* @return the facts
*/
public List<Fact> getFacts() {
return facts;
}
/**
* @return the po
*/
public PO getPo() {
return po;
}
}

View File

@ -0,0 +1,98 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 2010 Heng Sin Low *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.base.event;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
/**
*
* @author hengsin
*
*/
public interface IEventManager {
public static final String EVENT_DATA = "event.data";
public static final String EVENT_ERROR_MESSAGES = "event.errorMessages";
/**
* Initiate asynchronous delivery of an event. This method returns to the
* caller before delivery of the event is completed.
*
* @param event The event to send to all listeners which subscribe to the
* topic of the event.
*
* @throws SecurityException If the caller does not have
* <code>TopicPermission[topic,PUBLISH]</code> for the topic
* specified in the event.
*/
public abstract boolean postEvent(Event event);
/**
* Initiate synchronous delivery of an event. This method does not return to
* the caller until delivery of the event is completed.
*
* @param event The event to send to all listeners which subscribe to the
* topic of the event.
*
* @throws SecurityException If the caller does not have
* <code>TopicPermission[topic,PUBLISH]</code> for the topic
* specified in the event.
*/
public abstract boolean sendEvent(Event event);
/**
* register a new event handler
* @param topic
* @param eventHandler
* @return true if registration is successful, false otherwise
*/
public abstract boolean register(String topic, EventHandler eventHandler);
/**
* register a new event handler
* @param topics
* @param eventHandler
* @return true if registration is successful, false otherwise
*/
public abstract boolean register(String[] topics, EventHandler eventHandler);
/**
* register a new event handler
* @param topic
* @param filter
* @param eventHandler
* @return true if registration is successful, false otherwise
*/
public abstract boolean register(String topic, String filter,
EventHandler eventHandler);
/**
* register a new event handler
* @param topics
* @param filter
* @param eventHandler
* @return true if registration is successful, false otherwise
*/
public abstract boolean register(String[] topics, String filter,
EventHandler eventHandler);
/**
* un-register an event handler
* @param eventHandler
* @return true if unregistration is done, false otherwise
*/
public abstract boolean unregister(EventHandler eventHandler);
}

View File

@ -0,0 +1,94 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 2010 Heng Sin Low *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.base.event;
/**
*
* @author hengsin
*
*/
public interface IEventTopics {
public static final String MODEL_EVENT_PREFIX = "adempiere/po/";
/** Model Change Type New */
public static final String PO_BEFORE_NEW = MODEL_EVENT_PREFIX+"beforeNew";
public static final String PO_AFTER_NEW = MODEL_EVENT_PREFIX+"afterNew";
public static final String PO_AFTER_NEW_REPLICATION = MODEL_EVENT_PREFIX+"afterNewReplication"; // @Trifon
/** Model Change Type Change */
public static final String PO_BEFORE_CHANGE = MODEL_EVENT_PREFIX+"beforeChange";
public static final String PO_AFTER_CHANGE = MODEL_EVENT_PREFIX+"afterChange";
public static final String PO_AFTER_CHANGE_REPLICATION = MODEL_EVENT_PREFIX+"afterChangeReplication"; // @Trifon
/** Model Change Type Delete */
public static final String PO_BEFORE_DELETE = MODEL_EVENT_PREFIX+"beforeDelete";
public static final String PO_AFTER_DELETE = MODEL_EVENT_PREFIX+"afterDelete";
public static final String PO_BEFORE_DELETE_REPLICATION = MODEL_EVENT_PREFIX+"beforeDeleteReplication"; // @Trifon
//asynchrous model event
public static final String PO_POST_CREATE = MODEL_EVENT_PREFIX+"postCreate";
public static final String PO_POST_UPADTE = MODEL_EVENT_PREFIX+"postUpdate";
public static final String PO_POST_DELETE = MODEL_EVENT_PREFIX+"postDelete";
public static final String PO_ALL = MODEL_EVENT_PREFIX+"*";
public static final String DOC_EVENT_PREFIX = "adempiere/doc/";
/** Called before document is prepared */
public static final String DOC_BEFORE_PREPARE = DOC_EVENT_PREFIX+"beforePrepare";
/** Called before document is void */
public static final String DOC_BEFORE_VOID = DOC_EVENT_PREFIX+"beforeVoid";
/** Called before document is close */
public static final String DOC_BEFORE_CLOSE = DOC_EVENT_PREFIX+"beforeClose";
/** Called before document is reactivate */
public static final String DOC_BEFORE_REACTIVATE = DOC_EVENT_PREFIX+"beforeReactivate";
/** Called before document is reversecorrect */
public static final String DOC_BEFORE_REVERSECORRECT = DOC_EVENT_PREFIX+"beforeReverseCorrect";
/** Called before document is reverseaccrual */
public static final String DOC_BEFORE_REVERSEACCRUAL = DOC_EVENT_PREFIX+"beforeReverseAccrual";
/** Called before document is completed */
public static final String DOC_BEFORE_COMPLETE = DOC_EVENT_PREFIX+"beforeComplete";
/** Called after document is prepared */
public static final String DOC_AFTER_PREPARE = DOC_EVENT_PREFIX+"afterPrepare";
/** Called after document is completed */
public static final String DOC_AFTER_COMPLETE = DOC_EVENT_PREFIX+"afterComplete";
/** Called after document is void */
public static final String DOC_AFTER_VOID = DOC_EVENT_PREFIX+"afterVoid";
/** Called after document is closed */
public static final String DOC_AFTER_CLOSE = DOC_EVENT_PREFIX+"afterClose";
/** Called after document is reactivated */
public static final String DOC_AFTER_REACTIVATE = DOC_EVENT_PREFIX+"afterReactivate";
/** Called after document is reversecorrect */
public static final String DOC_AFTER_REVERSECORRECT = DOC_EVENT_PREFIX+"afterReverseCorrect";
/** Called after document is reverseaccrual */
public static final String DOC_AFTER_REVERSEACCRUAL = DOC_EVENT_PREFIX+"afterReverseAccrual";
/** Called before document is posted */
public static final String DOC_BEFORE_POST = DOC_EVENT_PREFIX+"beforePost";
/** Called after document is posted */
public static final String DOC_AFTER_POST = DOC_EVENT_PREFIX+"afterPost";
public static final String DOC_ALL = DOC_EVENT_PREFIX+"*";
public static final String AFTER_LOGIN = "adempiere/afterLogin";
public static final String ACCT_FACTS_VALIDATE = "adempiere/acct/factsValidate";
/** Import Events **/
public static final String IMPORT_PREFIX = "adempiere/import/";
/** Event triggered before all import records are validated */
public static final String IMPORT_BEFORE_VALIDATE = IMPORT_PREFIX+"beforeValidate";
/** Event triggered after all import records are validated */
public static final String IMPORT_AFTER_VALIDATE = IMPORT_PREFIX+"afterValidate";
/** Event triggered before an import record is processed */
public static final String IMPORT_BEFORE_IMPORT = IMPORT_PREFIX+"beforeImport";
/** Event triggered after an import record is processed */
public static final String IMPORT_AFTER_IMPORT = IMPORT_PREFIX+"afterImport";
public static final String PREF_AFTER_LOAD = "adempiere/pref/afterLoad";
}

View File

@ -0,0 +1,61 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 2010 Heng Sin Low *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.base.event;
import org.adempiere.process.ImportProcess;
import org.compiere.model.PO;
/**
*
* @author hengsin
*
*/
public class ImportEventData {
private ImportProcess importProcess;
private PO source;
private PO target;
/**
* @param importProcess
* @param source
* @param target
*/
public ImportEventData(ImportProcess importProcess, PO source, PO target) {
super();
this.importProcess = importProcess;
this.source = source;
this.target = target;
}
/**
* @return the importProcess
*/
public ImportProcess getImportProcess() {
return importProcess;
}
/**
* @return the source
*/
public PO getSource() {
return source;
}
/**
* @return the target
*/
public PO getTarget() {
return target;
}
}

View File

@ -0,0 +1,70 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 2010 Heng Sin Low *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.base.event;
/**
*
* @author hengsin
*
*/
public class LoginEventData {
private int AD_Client_ID;
private int AD_Org_ID;
private int AD_Role_ID;
private int AD_User_ID;
/**
* @param aD_Client_ID
* @param aD_Org_ID
* @param aD_Role_ID
* @param aD_User_ID
*/
public LoginEventData(int aD_Client_ID, int aD_Org_ID, int aD_Role_ID,
int aD_User_ID) {
super();
AD_Client_ID = aD_Client_ID;
AD_Org_ID = aD_Org_ID;
AD_Role_ID = aD_Role_ID;
AD_User_ID = aD_User_ID;
}
/**
* @return the aD_Client_ID
*/
public int getAD_Client_ID() {
return AD_Client_ID;
}
/**
* @return the aD_Org_ID
*/
public int getAD_Org_ID() {
return AD_Org_ID;
}
/**
* @return the aD_Role_ID
*/
public int getAD_Role_ID() {
return AD_Role_ID;
}
/**
* @return the aD_User_ID
*/
public int getAD_User_ID() {
return AD_User_ID;
}
}

View File

@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Level; import java.util.logging.Level;
@ -27,12 +28,20 @@ import java.util.logging.Level;
import javax.script.ScriptEngine; import javax.script.ScriptEngine;
import org.adempiere.base.Core; import org.adempiere.base.Core;
import org.adempiere.base.event.EventManager;
import org.adempiere.base.event.EventProperty;
import org.adempiere.base.event.FactsEventData;
import org.adempiere.base.event.IEventManager;
import org.adempiere.base.event.IEventTopics;
import org.adempiere.base.event.ImportEventData;
import org.adempiere.base.event.LoginEventData;
import org.adempiere.model.ImportValidator; import org.adempiere.model.ImportValidator;
import org.adempiere.process.ImportProcess; import org.adempiere.process.ImportProcess;
import org.compiere.acct.Fact; import org.compiere.acct.Fact;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.KeyNamePair; import org.compiere.util.KeyNamePair;
import org.osgi.service.event.Event;
/** /**
* Model Validation Engine * Model Validation Engine
@ -146,7 +155,7 @@ public class ModelValidationEngine
{ {
// //
ModelValidator validator = null; ModelValidator validator = null;
if (Core.isExtension(className)) if (Core.isExtension(className))
{ {
validator = Core.getModelValidator(className); validator = Core.getModelValidator(className);
} }
@ -250,7 +259,15 @@ public class ModelValidationEngine
} }
} }
} }
//
//now process osgi event handler
LoginEventData eventData = new LoginEventData(AD_Client_ID, AD_Org_ID, AD_Role_ID, AD_User_ID);
Event event = EventManager.newEvent(IEventTopics.AFTER_LOGIN, eventData);
EventManager.getInstance().sendEvent(event);
@SuppressWarnings("unchecked")
List<String> errors = (List<String>) event.getProperty(IEventManager.EVENT_ERROR_MESSAGES);
if (errors != null && !errors.isEmpty())
return errors.get(0);
if (AD_User_ID == 0 && AD_Role_ID == 0) if (AD_User_ID == 0 && AD_Role_ID == 0)
; // don't validate for user system on role system ; // don't validate for user system on role system
@ -378,7 +395,15 @@ public class ModelValidationEngine
} }
} }
} }
//
//now process osgi event handlers
Event event = EventManager.newEvent(ModelValidator.tableEventTopics[changeType],
new EventProperty(EventManager.EVENT_DATA, po), new EventProperty("tableName", po.get_TableName()));
EventManager.getInstance().sendEvent(event);
@SuppressWarnings("unchecked")
List<String> errors = (List<String>) event.getProperty(IEventManager.EVENT_ERROR_MESSAGES);
if (errors != null && !errors.isEmpty())
return errors.get(0);
return null; return null;
} // fireModelChange } // fireModelChange
@ -534,7 +559,15 @@ public class ModelValidationEngine
} }
} }
} }
//
//now process osgi event handlers
Event event = EventManager.newEvent(ModelValidator.documentEventTopics[docTiming],
new EventProperty(EventManager.EVENT_DATA, po), new EventProperty("tableName", po.get_TableName()));
EventManager.getInstance().sendEvent(event);
@SuppressWarnings("unchecked")
List<String> errors = (List<String>) event.getProperty(IEventManager.EVENT_ERROR_MESSAGES);
if (errors != null && !errors.isEmpty())
return errors.get(0);
return null; return null;
} // fireDocValidate } // fireDocValidate
@ -676,6 +709,15 @@ public class ModelValidationEngine
return error; return error;
} }
//process osgi event handlers
FactsEventData eventData = new FactsEventData(schema, facts, po);
Event event = EventManager.newEvent(IEventTopics.ACCT_FACTS_VALIDATE,
new EventProperty(EventManager.EVENT_DATA, eventData), new EventProperty("tableName", po.get_TableName()));
@SuppressWarnings("unchecked")
List<String> errors = (List<String>) event.getProperty(IEventManager.EVENT_ERROR_MESSAGES);
if (errors != null && !errors.isEmpty())
return errors.get(0);
return null; return null;
} // fireFactsValidate } // fireFactsValidate
@ -737,6 +779,20 @@ public class ModelValidationEngine
validator.validate(process, importModel, targetModel, timing); validator.validate(process, importModel, targetModel, timing);
} }
} }
//osgi event handler
ImportEventData eventData = new ImportEventData(process, importModel, targetModel);
String topic = null;
if (timing == ImportValidator.TIMING_AFTER_IMPORT)
topic = IEventTopics.IMPORT_AFTER_IMPORT;
else if (timing == ImportValidator.TIMING_AFTER_VALIDATE)
topic = IEventTopics.IMPORT_AFTER_VALIDATE;
else if (timing == ImportValidator.TIMING_BEFORE_IMPORT)
topic = IEventTopics.IMPORT_BEFORE_IMPORT;
else if (timing == ImportValidator.TIMING_BEFORE_VALIDATE)
topic = IEventTopics.IMPORT_BEFORE_VALIDATE;
Event event = EventManager.newEvent(topic, new EventProperty(EventManager.EVENT_DATA, eventData), new EventProperty("importTableName", process.getImportTableName()));
EventManager.getInstance().sendEvent(event);
} }
/** /**
@ -827,6 +883,11 @@ public class ModelValidationEngine
} }
} }
} }
//osgi event handlers
@SuppressWarnings("rawtypes")
Event event = new Event(IEventTopics.PREF_AFTER_LOAD, (Map)null);
EventManager.getInstance().sendEvent(event);
} }
/** /**

View File

@ -17,35 +17,37 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import org.adempiere.base.event.IEventTopics;
/** /**
* Model Validator * Model Validator
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: ModelValidator.java,v 1.2 2006/07/30 00:58:18 jjanke Exp $ * @version $Id: ModelValidator.java,v 1.2 2006/07/30 00:58:18 jjanke Exp $
* *
* 2007/02/26 laydasalasc - globalqss - Add new timings for all before/after events on documents * 2007/02/26 laydasalasc - globalqss - Add new timings for all before/after events on documents
*/ */
public interface ModelValidator public interface ModelValidator
{ {
/** Model Change Type New */ /** Model Change Type New */
public static final int TYPE_BEFORE_NEW = 1; // teo_sarca [ 1675490 ] public static final int TYPE_BEFORE_NEW = 1; // teo_sarca [ 1675490 ]
public static final int TYPE_NEW = 1; public static final int TYPE_NEW = 1;
public static final int CHANGETYPE_NEW = 1; // Compatibility with Compiere 260c public static final int CHANGETYPE_NEW = 1; // Compatibility with Compiere 260c
public static final int TYPE_AFTER_NEW = 4; // teo_sarca [ 1675490 ] public static final int TYPE_AFTER_NEW = 4; // teo_sarca [ 1675490 ]
public static final int TYPE_AFTER_NEW_REPLICATION = 7; // @Trifon public static final int TYPE_AFTER_NEW_REPLICATION = 7; // @Trifon
/** Model Change Type Change */ /** Model Change Type Change */
public static final int TYPE_BEFORE_CHANGE = 2; // teo_sarca [ 1675490 ] public static final int TYPE_BEFORE_CHANGE = 2; // teo_sarca [ 1675490 ]
public static final int TYPE_CHANGE = 2; public static final int TYPE_CHANGE = 2;
public static final int CHANGETYPE_CHANGE = 2; // Compatibility with Compiere 260c public static final int CHANGETYPE_CHANGE = 2; // Compatibility with Compiere 260c
public static final int TYPE_AFTER_CHANGE = 5; // teo_sarca [ 1675490 ] public static final int TYPE_AFTER_CHANGE = 5; // teo_sarca [ 1675490 ]
public static final int TYPE_AFTER_CHANGE_REPLICATION = 8; // @Trifon public static final int TYPE_AFTER_CHANGE_REPLICATION = 8; // @Trifon
/** Model Change Type Delete */ /** Model Change Type Delete */
public static final int TYPE_BEFORE_DELETE = 3; // teo_sarca [ 1675490 ] public static final int TYPE_BEFORE_DELETE = 3; // teo_sarca [ 1675490 ]
public static final int TYPE_DELETE = 3; public static final int TYPE_DELETE = 3;
public static final int CHANGETYPE_DELETE = 3; // Compatibility with Compiere 260c public static final int CHANGETYPE_DELETE = 3; // Compatibility with Compiere 260c
public static final int TYPE_AFTER_DELETE = 6; // teo_sarca [ 1675490 ] public static final int TYPE_AFTER_DELETE = 6; // teo_sarca [ 1675490 ]
public static final int TYPE_BEFORE_DELETE_REPLICATION = 9; // @Trifon public static final int TYPE_BEFORE_DELETE_REPLICATION = 9; // @Trifon
// Correlation between constant events and list of event script model validators // Correlation between constant events and list of event script model validators
public static String[] tableEventValidators = new String[] { public static String[] tableEventValidators = new String[] {
"", // 0 "", // 0
@ -54,12 +56,26 @@ public interface ModelValidator
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableBeforeDelete, // TYPE_BEFORE_DELETE = 3 X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableBeforeDelete, // TYPE_BEFORE_DELETE = 3
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterNew, // TYPE_AFTER_NEW = 4 X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterNew, // TYPE_AFTER_NEW = 4
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterChange, // TYPE_AFTER_CHANGE = 5 X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterChange, // TYPE_AFTER_CHANGE = 5
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterDelete, // TYPE_AFTER_DELETE = 6 X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterDelete, // TYPE_AFTER_DELETE = 6
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterNewReplication, // TYPE_AFTER_NEW_REPLICATION = 7 X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterNewReplication, // TYPE_AFTER_NEW_REPLICATION = 7
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterChangeReplication, // TYPE_AFTER_CHANGE_REPLICATION = 8 X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterChangeReplication, // TYPE_AFTER_CHANGE_REPLICATION = 8
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableBeforeDeleteReplication // TYPE_BEFORE_DELETE_REPLICATION = 9 X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableBeforeDeleteReplication // TYPE_BEFORE_DELETE_REPLICATION = 9
}; };
// Correlation between constant events and list of osgi event topic
public static String[] tableEventTopics = new String[] {
"", // 0
IEventTopics.PO_BEFORE_NEW, // TYPE_BEFORE_NEW = 1
IEventTopics.PO_BEFORE_CHANGE, // TYPE_BEFORE_CHANGE = 2
IEventTopics.PO_BEFORE_DELETE, // TYPE_BEFORE_DELETE = 3
IEventTopics.PO_AFTER_NEW, // TYPE_AFTER_NEW = 4
IEventTopics.PO_AFTER_CHANGE, // TYPE_AFTER_CHANGE = 5
IEventTopics.PO_AFTER_DELETE, // TYPE_AFTER_DELETE = 6
IEventTopics.PO_AFTER_NEW_REPLICATION, // TYPE_AFTER_NEW_REPLICATION = 7
IEventTopics.PO_AFTER_CHANGE_REPLICATION, // TYPE_AFTER_CHANGE_REPLICATION = 8
IEventTopics.PO_BEFORE_DELETE_REPLICATION// TYPE_BEFORE_DELETE_REPLICATION = 9
};
/** Called before document is prepared */ /** Called before document is prepared */
public static final int TIMING_BEFORE_PREPARE = 1; public static final int TIMING_BEFORE_PREPARE = 1;
public static final int DOCTIMING_BEFORE_PREPARE = 1; // Compatibility with Compiere 260c public static final int DOCTIMING_BEFORE_PREPARE = 1; // Compatibility with Compiere 260c
@ -94,7 +110,7 @@ public interface ModelValidator
public static final int TIMING_BEFORE_POST = 15; public static final int TIMING_BEFORE_POST = 15;
/** Called after document is posted */ /** Called after document is posted */
public static final int TIMING_AFTER_POST = 16; public static final int TIMING_AFTER_POST = 16;
// Correlation between constant events and list of event script model validators // Correlation between constant events and list of event script model validators
public static String[] documentEventValidators = new String[] { public static String[] documentEventValidators = new String[] {
"", // 0 "", // 0
@ -115,10 +131,31 @@ public interface ModelValidator
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_DocumentBeforePost, // TIMING_BEFORE_POST = 15 X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_DocumentBeforePost, // TIMING_BEFORE_POST = 15
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_DocumentAfterPost // TIMING_AFTER_POST = 16 X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_DocumentAfterPost // TIMING_AFTER_POST = 16
}; };
// Correlation between constant events and list of osgi event topics
public static String[] documentEventTopics = new String[] {
"", // 0
IEventTopics.DOC_BEFORE_PREPARE, // TIMING_BEFORE_PREPARE = 1
IEventTopics.DOC_BEFORE_VOID, // TIMING_BEFORE_VOID = 2
IEventTopics.DOC_BEFORE_CLOSE, // TIMING_BEFORE_CLOSE = 3
IEventTopics.DOC_BEFORE_REACTIVATE, // TIMING_BEFORE_REACTIVATE = 4
IEventTopics.DOC_BEFORE_REVERSECORRECT, // TIMING_BEFORE_REVERSECORRECT = 5
IEventTopics.DOC_BEFORE_REVERSEACCRUAL, // TIMING_BEFORE_REVERSEACCRUAL = 6
IEventTopics.DOC_BEFORE_COMPLETE, // TIMING_BEFORE_COMPLETE = 7
IEventTopics.DOC_AFTER_PREPARE, // TIMING_AFTER_PREPARE = 8
IEventTopics.DOC_AFTER_COMPLETE, // TIMING_AFTER_COMPLETE = 9
IEventTopics.DOC_AFTER_VOID, // TIMING_AFTER_VOID = 10
IEventTopics.DOC_AFTER_CLOSE, // TIMING_AFTER_CLOSE = 11
IEventTopics.DOC_AFTER_REACTIVATE, // TIMING_AFTER_REACTIVATE = 12
IEventTopics.DOC_AFTER_REVERSECORRECT, // TIMING_AFTER_REVERSECORRECT = 13
IEventTopics.DOC_AFTER_REVERSEACCRUAL, // TIMING_AFTER_REVERSEACCRUAL = 14
IEventTopics.DOC_BEFORE_POST, // TIMING_BEFORE_POST = 15
IEventTopics.DOC_AFTER_POST // TIMING_AFTER_POST = 16
};
/** /**
* Initialize Validation * Initialize Validation
* @param engine validation engine * @param engine validation engine
* @param client client * @param client client
*/ */
public void initialize (ModelValidationEngine engine, MClient client); public void initialize (ModelValidationEngine engine, MClient client);
@ -128,9 +165,9 @@ public interface ModelValidator
* @return AD_Client_ID * @return AD_Client_ID
*/ */
public int getAD_Client_ID(); public int getAD_Client_ID();
/** /**
* User logged in * User logged in
* Called before preferences are set * Called before preferences are set
* @param AD_Org_ID org * @param AD_Org_ID org
* @param AD_Role_ID role * @param AD_Role_ID role
@ -139,10 +176,10 @@ public interface ModelValidator
*/ */
public String login (int AD_Org_ID, int AD_Role_ID, int AD_User_ID); public String login (int AD_Org_ID, int AD_Role_ID, int AD_User_ID);
/** /**
* Model Change of a monitored Table. * Model Change of a monitored Table.
* Called after PO.beforeSave/PO.beforeDelete * Called after PO.beforeSave/PO.beforeDelete
* when you called addModelChange for the table * when you called addModelChange for the table
* @param po persistent object * @param po persistent object
* @param type TYPE_ * @param type TYPE_
@ -151,18 +188,18 @@ public interface ModelValidator
*/ */
public String modelChange (PO po, int type) throws Exception; public String modelChange (PO po, int type) throws Exception;
/** /**
* Validate Document. * Validate Document.
* Called as first step of DocAction.prepareIt * Called as first step of DocAction.prepareIt
* or at the end of DocAction.completeIt * or at the end of DocAction.completeIt
* when you called addDocValidate for the table. * when you called addDocValidate for the table.
* Note that totals, etc. may not be correct before the prepare stage. * Note that totals, etc. may not be correct before the prepare stage.
* @param po persistent object * @param po persistent object
* @param timing see TIMING_ constants * @param timing see TIMING_ constants
* @return error message or null - * @return error message or null -
* if not null, the document will be marked as Invalid. * if not null, the document will be marked as Invalid.
*/ */
public String docValidate (PO po, int timing); public String docValidate (PO po, int timing);
} // ModelValidator } // ModelValidator

View File

@ -41,6 +41,8 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import org.adempiere.base.event.EventManager;
import org.adempiere.base.event.IEventTopics;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
import org.adempiere.exceptions.DBException; import org.adempiere.exceptions.DBException;
import org.compiere.Adempiere; import org.compiere.Adempiere;
@ -57,6 +59,7 @@ import org.compiere.util.SecureEngine;
import org.compiere.util.Trace; import org.compiere.util.Trace;
import org.compiere.util.Trx; import org.compiere.util.Trx;
import org.compiere.util.ValueNamePair; import org.compiere.util.ValueNamePair;
import org.osgi.service.event.Event;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
@ -2219,6 +2222,11 @@ public abstract class PO
// OK // OK
if (success) if (success)
{ {
//post osgi event
String topic = newRecord ? IEventTopics.PO_POST_CREATE : IEventTopics.PO_POST_UPADTE;
Event event = EventManager.newEvent(topic, this);
EventManager.getInstance().postEvent(event);
if (s_docWFMgr == null) if (s_docWFMgr == null)
{ {
try try
@ -3053,6 +3061,10 @@ public abstract class PO
// Reset // Reset
if (success) if (success)
{ {
//osgi event handler
Event event = EventManager.newEvent(IEventTopics.PO_POST_DELETE, this);
EventManager.getInstance().postEvent(event);
m_idOld = 0; m_idOld = 0;
int size = p_info.getColumnCount(); int size = p_info.getColumnCount();
m_oldValues = new Object[size]; m_oldValues = new Object[size];

View File

@ -19,8 +19,8 @@
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc}"/> <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc}"/>
<stringAttribute key="pde.version" value="3.3"/> <stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.adempiere.server.server_product"/> <stringAttribute key="product" value="org.adempiere.server.server_product"/>
<stringAttribute key="selected_target_plugins" value="com.springsource.org.apache.commons.logging@default:default,org.eclipse.equinox.app@default:default,com.springsource.javax.mail@default:default,com.springsource.org.apache.commons.collections@default:default,org.eclipse.equinox.registry@default:default,com.springsource.javax.servlet@default:default,com.springsource.org.apache.activemq@default:default,org.eclipse.core.contenttype@default:default,com.springsource.javax.xml.rpc@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.preferences@default:default,org.restlet@default:default,com.springsource.javax.management.j2ee@default:default,com.springsource.org.apache.poi@default:default,com.springsource.javax.activation@default:default,org.eclipse.core.variables@default:default,com.springsource.org.apache.kahadb@default:default,com.springsource.javax.xml.soap@default:default,com.springsource.org.junit@default:default,com.springsource.javax.ejb@default:default,org.apache.ant@default:default,org.eclipse.osgi@-1:true,org.eclipse.core.jobs@default:default,org.eclipse.core.runtime@default:true,org.eclipse.ant.core@default:default,com.springsource.javax.jms@default:default,com.springsource.org.apache.commons.net@default:default,com.springsource.net.sf.cglib@default:default"/> <stringAttribute key="selected_target_plugins" value="com.springsource.javax.xml.rpc@default:default,com.springsource.org.apache.poi@default:default,com.springsource.javax.jms@default:default,org.eclipse.equinox.preferences@default:default,com.springsource.javax.ejb@default:default,com.springsource.org.junit@default:default,com.springsource.javax.activation@default:default,org.eclipse.core.variables@default:default,com.springsource.org.apache.commons.collections@default:default,com.springsource.org.apache.kahadb@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.osgi@-1:true,com.springsource.javax.xml.soap@default:default,com.springsource.javax.servlet@default:default,org.eclipse.core.contenttype@default:default,org.apache.ant@default:default,org.eclipse.equinox.app@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.runtime@default:true,com.springsource.org.apache.commons.logging@default:default,org.restlet@default:default,com.springsource.javax.mail@default:default,org.eclipse.equinox.common@2:true,com.springsource.net.sf.cglib@default:default,org.eclipse.ant.core@default:default,com.springsource.org.apache.commons.net@default:default,com.springsource.org.apache.activemq@default:default,com.springsource.javax.management.j2ee@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="org.adempiere.extend@default:false,org.apache.ecs@default:default,org.compiere.db.postgresql.provider@default:default,org.adempiere.install@default:true,org.compiere.db.oracle.provider@default:default,org.adempiere.base@default:default"/> <stringAttribute key="selected_workspace_plugins" value="org.adempiere.base@default:default,org.adempiere.extend@default:false,org.apache.ecs@default:default,org.compiere.db.oracle.provider@default:default,org.compiere.db.postgresql.provider@default:default,org.adempiere.install@default:true"/>
<booleanAttribute key="show_selected_only" value="false"/> <booleanAttribute key="show_selected_only" value="false"/>
<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/> <stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
<booleanAttribute key="tracing" value="false"/> <booleanAttribute key="tracing" value="false"/>

View File

@ -19,8 +19,8 @@
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc}"/> <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc}"/>
<stringAttribute key="pde.version" value="3.3"/> <stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.adempiere.server.server_product"/> <stringAttribute key="product" value="org.adempiere.server.server_product"/>
<stringAttribute key="selected_target_plugins" value="com.springsource.org.apache.commons.logging@default:default,org.eclipse.equinox.app@default:default,com.springsource.javax.mail@default:default,com.springsource.org.apache.commons.collections@default:default,org.eclipse.equinox.registry@default:default,com.springsource.javax.servlet@default:default,com.springsource.org.apache.activemq@default:default,org.eclipse.core.contenttype@default:default,com.springsource.javax.xml.rpc@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.preferences@default:default,org.restlet@default:default,com.springsource.javax.management.j2ee@default:default,com.springsource.org.apache.poi@default:default,com.springsource.javax.activation@default:default,org.eclipse.core.variables@default:default,com.springsource.org.apache.kahadb@default:default,com.springsource.javax.xml.soap@default:default,com.springsource.org.junit@default:default,com.springsource.javax.ejb@default:default,org.apache.ant@default:default,org.eclipse.osgi@-1:true,org.eclipse.core.jobs@default:default,org.eclipse.core.runtime@default:true,org.eclipse.ant.core@default:default,com.springsource.javax.jms@default:default,com.springsource.org.apache.commons.net@default:default,com.springsource.net.sf.cglib@default:default"/> <stringAttribute key="selected_target_plugins" value="com.springsource.javax.servlet@default:default,org.eclipse.core.runtime@default:true,com.springsource.javax.xml.soap@default:default,com.springsource.javax.jms@default:default,com.springsource.org.junit@default:default,com.springsource.org.apache.poi@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.equinox.preferences@default:default,com.springsource.org.apache.commons.net@default:default,org.eclipse.core.variables@default:default,org.eclipse.equinox.registry@default:default,com.springsource.net.sf.cglib@default:default,org.eclipse.ant.core@default:default,org.eclipse.equinox.app@default:default,com.springsource.javax.management.j2ee@default:default,com.springsource.org.apache.commons.collections@default:default,org.eclipse.core.jobs@default:default,com.springsource.javax.activation@default:default,com.springsource.org.apache.commons.logging@default:default,org.restlet@default:default,com.springsource.org.apache.activemq@default:default,org.apache.ant@default:default,com.springsource.javax.xml.rpc@default:default,org.eclipse.equinox.common@2:true,com.springsource.javax.mail@default:default,org.eclipse.osgi@-1:true,com.springsource.org.apache.kahadb@default:default,com.springsource.javax.ejb@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="org.adempiere.extend@default:false,org.apache.ecs@default:default,org.compiere.db.postgresql.provider@default:default,org.adempiere.install@default:true,org.compiere.db.oracle.provider@default:default,org.adempiere.base@default:default"/> <stringAttribute key="selected_workspace_plugins" value="org.compiere.db.postgresql.provider@default:default,org.adempiere.install@default:true,org.apache.ecs@default:default,org.adempiere.extend@default:false,org.compiere.db.oracle.provider@default:default,org.adempiere.base@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/> <booleanAttribute key="show_selected_only" value="false"/>
<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/> <stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
<booleanAttribute key="tracing" value="false"/> <booleanAttribute key="tracing" value="false"/>

View File

@ -33,6 +33,7 @@
</features> </features>
<configurations> <configurations>
<plugin id="org.adempiere.base" autoStart="true" startLevel="4" />
<plugin id="org.adempiere.install" autoStart="true" startLevel="4" /> <plugin id="org.adempiere.install" autoStart="true" startLevel="4" />
<plugin id="org.adempiere.replication.server" autoStart="true" startLevel="4" /> <plugin id="org.adempiere.replication.server" autoStart="true" startLevel="4" />
<plugin id="org.adempiere.report.jasper.webapp" autoStart="true" startLevel="4" /> <plugin id="org.adempiere.report.jasper.webapp" autoStart="true" startLevel="4" />
@ -41,11 +42,12 @@
<plugin id="org.adempiere.webstore" autoStart="true" startLevel="4" /> <plugin id="org.adempiere.webstore" autoStart="true" startLevel="4" />
<plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="4" /> <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="4" />
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" /> <plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="4" /> <plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="3" />
<plugin id="org.eclipse.equinox.event" autoStart="true" startLevel="3" />
<plugin id="org.eclipse.gemini.web.core" autoStart="true" startLevel="4" /> <plugin id="org.eclipse.gemini.web.core" autoStart="true" startLevel="4" />
<plugin id="org.eclipse.gemini.web.extender" autoStart="true" startLevel="4" /> <plugin id="org.eclipse.gemini.web.extender" autoStart="true" startLevel="4" />
<plugin id="org.eclipse.gemini.web.tomcat" autoStart="true" startLevel="4" /> <plugin id="org.eclipse.gemini.web.tomcat" autoStart="true" startLevel="4" />
<plugin id="org.eclipse.osgi.services" autoStart="true" startLevel="4" /> <plugin id="org.eclipse.osgi.services" autoStart="true" startLevel="3" />
<plugin id="org.restlet" autoStart="true" startLevel="3" /> <plugin id="org.restlet" autoStart="true" startLevel="3" />
</configurations> </configurations>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -31,6 +31,10 @@
</features> </features>
<configurations> <configurations>
<plugin id="org.adempiere.base" autoStart="true" startLevel="4" />
<plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="3" />
<plugin id="org.eclipse.equinox.event" autoStart="true" startLevel="3" />
<plugin id="org.eclipse.osgi.services" autoStart="true" startLevel="3" />
<plugin id="org.restlet" autoStart="true" startLevel="0" /> <plugin id="org.restlet" autoStart="true" startLevel="0" />
<plugin id="org.restlet.ext.net" autoStart="true" startLevel="0" /> <plugin id="org.restlet.ext.net" autoStart="true" startLevel="0" />
</configurations> </configurations>

View File

@ -21,8 +21,8 @@
<stringAttribute key="pde.version" value="3.3"/> <stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.adempiere.ui.swing.client_product"/> <stringAttribute key="product" value="org.adempiere.ui.swing.client_product"/>
<stringAttribute key="productFile" value="/org.adempiere.ui.swing-feature/swingclient.product"/> <stringAttribute key="productFile" value="/org.adempiere.ui.swing-feature/swingclient.product"/>
<stringAttribute key="selected_target_plugins" value="org.eclipse.equinox.preferences@default:default,org.apache.ant@default:default,org.eclipse.ecf.provider.filetransfer.httpclient@default:default,org.springframework.context@default:default,com.springsource.javax.management.j2ee@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,com.springsource.javax.transaction@default:default,com.springsource.org.apache.poi@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,com.springsource.net.sf.cglib@default:default,com.springsource.javax.activation@default:default,org.eclipse.equinox.p2.core@default:default,org.sat4j.core@default:default,org.eclipse.osgi@-1:true,org.eclipse.ecf.ssl@default:false,org.restlet@default:true,org.eclipse.equinox.p2.repository@default:default,org.springframework.core@default:default,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.equinox.p2.publisher@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.equinox.app@default:default,com.springsource.javax.el@default:default,org.apache.commons.logging@default:default,com.springsource.org.apache.xmlcommons@default:default,com.springsource.javax.xml.soap@default:default,com.springsource.javax.mail@default:default,org.eclipse.core.jobs@default:default,org.sat4j.pb@default:default,com.springsource.org.apache.commons.logging@default:default,org.eclipse.equinox.p2.ql@default:default,com.springsource.javax.servlet@default:default,org.eclipse.equinox.p2.director@default:default,org.springframework.aop@default:default,org.eclipse.osgi.services@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,com.springsource.javax.xml.rpc@default:default,com.springsource.org.apache.commons.collections@default:default,org.eclipse.equinox.simpleconfigurator@1:true,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:default,com.springsource.org.apache.commons.net@default:default,org.eclipse.equinox.frameworkadmin@default:default,com.springsource.org.apache.xml.resolver@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.springframework.beans@default:default,com.springsource.org.apache.xerces@default:false,org.eclipse.ant.core@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.ecf.provider.filetransfer.httpclient.ssl@default:false,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.p2.engine@default:default,org.restlet.ext.net@default:true,com.springsource.javax.persistence@default:default,org.eclipse.equinox.http.registry@default:default,org.eclipse.core.variables@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.ecf@default:default,com.springsource.javax.ejb@default:default,org.apache.commons.httpclient@default:default,org.eclipse.ecf.identity@default:default,org.apache.commons.codec@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.security@default:default,org.eclipse.core.runtime@default:true,org.eclipse.equinox.util@default:default,com.springsource.org.apache.kahadb@default:default,org.eclipse.equinox.launcher.gtk.linux.x86@default:false,com.springsource.javax.jms@default:default,com.springsource.org.junit@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.common@2:true,com.springsource.org.apache.xml.serializer@default:default,com.springsource.org.apache.activemq@default:default,com.springsource.org.aopalliance@default:default,javax.xml@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.equinox.p2.console@default:default"/> <stringAttribute key="selected_target_plugins" value="com.springsource.javax.servlet@default:default,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.core.runtime@default:true,javax.xml@default:default,com.springsource.javax.xml.soap@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,com.springsource.javax.jms@default:default,org.sat4j.pb@default:default,org.eclipse.equinox.http.registry@default:default,com.springsource.org.apache.xml.resolver@default:default,com.springsource.org.junit@default:default,org.eclipse.equinox.p2.publisher@default:default,com.springsource.org.apache.poi@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.sat4j.core@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.apache.commons.codec@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.equinox.ds@3:true,com.springsource.org.apache.xmlcommons@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.p2.engine@default:default,com.springsource.org.apache.commons.net@default:default,org.eclipse.core.variables@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.util@default:default,com.springsource.net.sf.cglib@default:default,org.springframework.beans@default:default,org.eclipse.ecf.provider.filetransfer.httpclient.ssl@default:false,org.eclipse.ant.core@default:default,org.eclipse.equinox.launcher@default:default,com.springsource.org.apache.xerces@default:false,org.eclipse.equinox.app@default:default,org.eclipse.ecf.provider.filetransfer.httpclient@default:default,com.springsource.javax.management.j2ee@default:default,org.eclipse.ecf.ssl@default:false,com.springsource.org.apache.commons.collections@default:default,org.springframework.context@default:default,org.apache.commons.logging@default:default,org.eclipse.core.jobs@default:default,org.restlet.ext.net@default:true,com.springsource.javax.activation@default:default,com.springsource.javax.persistence@default:default,com.springsource.org.apache.commons.logging@default:default,org.eclipse.equinox.security@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.equinox.event@3:default,com.springsource.org.apache.xml.serializer@default:default,org.restlet@default:true,org.eclipse.osgi.services@3:true,com.springsource.org.apache.activemq@default:default,org.springframework.aop@default:default,org.eclipse.equinox.p2.metadata@default:default,org.apache.commons.httpclient@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.apache.ant@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.equinox.p2.ql@default:default,com.springsource.javax.xml.rpc@default:default,com.springsource.javax.el@default:default,org.eclipse.ecf@default:default,org.eclipse.equinox.simpleconfigurator@1:true,org.eclipse.equinox.p2.core@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.equinox.p2.director@default:default,com.springsource.org.aopalliance@default:default,org.eclipse.equinox.common@2:true,com.springsource.javax.mail@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.launcher.gtk.linux.x86@default:false,org.eclipse.equinox.frameworkadmin.equinox@default:default,org.eclipse.osgi@-1:true,com.springsource.org.apache.kahadb@default:default,com.springsource.javax.transaction@default:default,org.springframework.core@default:default,com.springsource.javax.ejb@default:default,org.eclipse.equinox.p2.console@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="org.adempiere.payment.processor@default:default,org.adempiere.base.process@default:default,org.adempiere.base@default:default,org.adempiere.report.jasper.swing@default:default,org.adempiere.plugin.utils@default:default,org.adempiere.extend@default:false,org.adempiere.ui@default:default,org.compiere.db.postgresql.provider@default:default,org.adempiere.pipo.handlers@default:default,org.compiere.db.oracle.provider@default:default,org.adempiere.report.jasper@default:default,org.adempiere.install@default:default,org.adempiere.base.callout@default:default,org.adempiere.pipo@default:default,org.adempiere.report.jasper.library@default:default,org.apache.ecs@default:default,org.adempiere.ui.swing@default:default,org.adempiere.replication@default:default"/> <stringAttribute key="selected_workspace_plugins" value="org.compiere.db.postgresql.provider@default:default,org.adempiere.report.jasper@default:default,org.adempiere.report.jasper.library@default:default,org.adempiere.install@default:default,org.adempiere.base.callout@default:default,org.adempiere.base.process@default:default,org.apache.ecs@default:default,org.adempiere.payment.processor@default:default,org.adempiere.extend@default:false,org.adempiere.ui@default:default,org.adempiere.report.jasper.swing@default:default,org.adempiere.replication@default:default,org.compiere.db.oracle.provider@default:default,org.adempiere.plugin.utils@default:default,org.adempiere.pipo.handlers@default:default,org.adempiere.pipo@default:default,org.adempiere.ui.swing@default:default,org.adempiere.base@4:true"/>
<booleanAttribute key="show_selected_only" value="false"/> <booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/> <booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/> <booleanAttribute key="useCustomFeatures" value="false"/>