diff --git a/.project b/.project index 1a8c3a7..7f61960 100644 --- a/.project +++ b/.project @@ -5,6 +5,11 @@ + + org.eclipse.wst.common.project.facet.core.builder + + + org.eclipse.jdt.core.javabuilder @@ -19,5 +24,6 @@ org.maven.ide.eclipse.maven2Nature org.eclipse.jdt.core.javanature + org.eclipse.wst.common.project.facet.core.nature diff --git a/pom.xml b/pom.xml index ff15294..5e4608b 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.idcanet -foei +foei-main jar 0.8-SNAPSHOT foei @@ -99,6 +99,17 @@ + + + maven-source-plugin + + + attach-sources + jar + + + + maven-site-plugin diff --git a/src/main/java/com/idcanet/foei/components/lang/Filter.java b/src/main/java/com/idcanet/foei/components/lang/Filter.java index bc1b6cf..34c342a 100644 --- a/src/main/java/com/idcanet/foei/components/lang/Filter.java +++ b/src/main/java/com/idcanet/foei/components/lang/Filter.java @@ -83,16 +83,27 @@ public class Filter extends AbstractEventObjectStepController { */ @Override public Object processEventSteps(Object object) { - Object o = object; + if (object==null) { + return null; + } + if (getEventSteps().isEmpty()) { + return object; // no steps so no filtering + } + Object result = null; + Object resultOld = null; for (int i=0;i0) { + boolean op = e.getEventStepOperand().execute(result!=null, resultOld!=null); + if (op==false) { + return null; + } } - o = e.processObject(object); + resultOld = result; } // Check for for last(or only) EventStep - if(o==null) { + if(result==null) { return null; } return object; diff --git a/src/main/java/com/idcanet/foei/components/lang/GetBeanProperty.java b/src/main/java/com/idcanet/foei/components/lang/GetBeanProperty.java index dd08f7a..e958f01 100644 --- a/src/main/java/com/idcanet/foei/components/lang/GetBeanProperty.java +++ b/src/main/java/com/idcanet/foei/components/lang/GetBeanProperty.java @@ -31,7 +31,7 @@ import com.idcanet.foei.event.AbstractEventObject; import com.idcanet.foei.event.EventInput; import com.idcanet.foei.event.EventPort; import com.idcanet.foei.event.IllegalEventPortNameException; -import com.idcanet.x4o.impl.DefaultElementParameterHelper; +import com.idcanet.x4o.impl.DefaultElementObjectPropertyValue; /** * Gets the property of an Bean @@ -51,7 +51,7 @@ public class GetBeanProperty extends AbstractEventObject { //private Object propertyValue = null; - private DefaultElementParameterHelper helper = null; + private DefaultElementObjectPropertyValue helper = null; /** * Creates an SetBeanProperty @@ -60,7 +60,7 @@ public class GetBeanProperty extends AbstractEventObject { addInputPort(EventPort.INPUT,Object.class); //addInputPort(PROPERTY,Object.class); addOutputPort(EventPort.OUTPUT); - helper = new DefaultElementParameterHelper(); + helper = new DefaultElementObjectPropertyValue(); } /** @@ -78,7 +78,7 @@ public class GetBeanProperty extends AbstractEventObject { return; } try { - object = helper.getParameter(object,property); // todo: fix error this wil only return String !!!!!!!!!!!!!!!!! + object = helper.getProperty(object,property); // todo: fix error this wil only return String !!!!!!!!!!!!!!!!! } catch (Exception e) { e.printStackTrace(); return; diff --git a/src/main/java/com/idcanet/foei/components/lang/SetBeanProperty.java b/src/main/java/com/idcanet/foei/components/lang/SetBeanProperty.java index 445ef75..7651a32 100644 --- a/src/main/java/com/idcanet/foei/components/lang/SetBeanProperty.java +++ b/src/main/java/com/idcanet/foei/components/lang/SetBeanProperty.java @@ -31,7 +31,7 @@ import com.idcanet.foei.event.AbstractEventObject; import com.idcanet.foei.event.EventInput; import com.idcanet.foei.event.EventPort; import com.idcanet.foei.event.IllegalEventPortNameException; -import com.idcanet.x4o.impl.DefaultElementParameterHelper; +import com.idcanet.x4o.impl.DefaultElementObjectPropertyValue; /** * Sets an property of an bean which is set on the propery input port. @@ -50,7 +50,7 @@ public class SetBeanProperty extends AbstractEventObject { private Object propertyValue = null; - private DefaultElementParameterHelper helper = null; + private DefaultElementObjectPropertyValue helper = null; /** * Creates an SetBeanProperty @@ -59,7 +59,7 @@ public class SetBeanProperty extends AbstractEventObject { addInputPort(EventPort.INPUT,Object.class); addInputPort(PROPERTY,Object.class); addOutputPort(EventPort.OUTPUT); - helper = new DefaultElementParameterHelper(); + helper = new DefaultElementObjectPropertyValue(); } /** @@ -77,7 +77,7 @@ public class SetBeanProperty extends AbstractEventObject { return; } try { - helper.setParameter(object,property,propertyValue); + helper.setProperty(object,property,propertyValue); } catch (Exception e) { e.printStackTrace(); return; diff --git a/src/main/java/com/idcanet/foei/components/steps/lang/GetBeanPropertyStep.java b/src/main/java/com/idcanet/foei/components/steps/lang/GetBeanPropertyStep.java index eb9b90b..a9a5f35 100644 --- a/src/main/java/com/idcanet/foei/components/steps/lang/GetBeanPropertyStep.java +++ b/src/main/java/com/idcanet/foei/components/steps/lang/GetBeanPropertyStep.java @@ -27,7 +27,7 @@ package com.idcanet.foei.components.steps.lang; import com.idcanet.foei.event.AbstractEventStepController; -import com.idcanet.x4o.impl.DefaultElementParameterHelper; +import com.idcanet.x4o.impl.DefaultElementObjectPropertyValue; /** * Gets the property of an java bean. @@ -42,10 +42,10 @@ public class GetBeanPropertyStep extends AbstractEventStepController { /** Holds the key which contains the object in the map. */ private String property = null; - private DefaultElementParameterHelper helper = null; + private DefaultElementObjectPropertyValue helper = null; public GetBeanPropertyStep() { - helper = new DefaultElementParameterHelper(); + helper = new DefaultElementObjectPropertyValue(); } //----------- get/set functions @@ -70,7 +70,7 @@ public class GetBeanPropertyStep extends AbstractEventStepController { } Object result = null; try { - result = helper.getParameter(object,property); + result = helper.getProperty(object,property); } catch (Exception e) { //logger.log(Level.WARNING,"property:"+property+" is not an property of object: "+object.getClass().getName(),e); e.printStackTrace(); diff --git a/src/main/java/com/idcanet/foei/core/impl/FoeiEventBindingRuleHandler.java b/src/main/java/com/idcanet/foei/core/impl/FoeiEventBindingRuleHandler.java index 4971889..17d7f3b 100644 --- a/src/main/java/com/idcanet/foei/core/impl/FoeiEventBindingRuleHandler.java +++ b/src/main/java/com/idcanet/foei/core/impl/FoeiEventBindingRuleHandler.java @@ -8,7 +8,7 @@ import com.idcanet.foei.event.EventStep; import com.idcanet.foei.event.EventStepController; import com.idcanet.x4o.element.AbstractElementBindingHandler; import com.idcanet.x4o.element.Element; -import com.idcanet.x4o.element.ElementBindingException; +import com.idcanet.x4o.element.ElementBindingHandlerException; /** * @@ -66,7 +66,7 @@ public class FoeiEventBindingRuleHandler extends AbstractElementBindingHandler { * @param object2 * @throws ClassCastException */ - public void doBind(Element element) throws ElementBindingException { + public void doBind(Element element) throws ElementBindingHandlerException { Object parent = element.getParent().getElementObject(); Object child = element.getElementObject(); if(parent==null) { diff --git a/src/main/java/com/idcanet/foei/core/impl/FoeiProcessImpl.java b/src/main/java/com/idcanet/foei/core/impl/FoeiProcessImpl.java index 1a8080a..c2ead5b 100644 --- a/src/main/java/com/idcanet/foei/core/impl/FoeiProcessImpl.java +++ b/src/main/java/com/idcanet/foei/core/impl/FoeiProcessImpl.java @@ -40,7 +40,6 @@ import java.util.List; import java.util.Queue; import java.util.Set; import java.util.concurrent.LinkedBlockingQueue; -import java.util.logging.Level; import java.util.logging.Logger; import javax.naming.Context; diff --git a/src/main/java/com/idcanet/foei/core/impl/X2OExecutorImpl.java b/src/main/java/com/idcanet/foei/core/impl/X2OExecutorImpl.java index ccd03dc..308b261 100644 --- a/src/main/java/com/idcanet/foei/core/impl/X2OExecutorImpl.java +++ b/src/main/java/com/idcanet/foei/core/impl/X2OExecutorImpl.java @@ -26,8 +26,6 @@ package com.idcanet.foei.core.impl; -import com.idcanet.foei.core.FoeiProcess; -import com.idcanet.foei.core.FoeiProcessFactory; import com.idcanet.foei.core.X2OExecutor; import com.idcanet.x4o.core.X4OParser; @@ -65,15 +63,9 @@ public class X2OExecutorImpl implements X2OExecutor { try { // config parser - FoeiProcess foeiProcess = FoeiProcessFactory.getFoeiProcess(); + //FoeiProcess foeiProcess = FoeiProcessFactory.getFoeiProcess(); X4OParser parser = new X4OParser("foei"); - - for (String key:foeiProcess.getFoeiContext().getStartProperties().keySet()) { - String value = foeiProcess.getFoeiContext().getStartProperties().get(key); - parser.setProperty(key, value); - } - - + logger.info("Executing X2O Parsing."); if(parseFileName!=null) { diff --git a/src/main/java/com/idcanet/foei/core/x4o/BindAttributeHandler.java b/src/main/java/com/idcanet/foei/core/x4o/BindAttributeHandler.java index e954d38..a942052 100644 --- a/src/main/java/com/idcanet/foei/core/x4o/BindAttributeHandler.java +++ b/src/main/java/com/idcanet/foei/core/x4o/BindAttributeHandler.java @@ -31,7 +31,7 @@ import com.idcanet.foei.core.FoeiProcessFactory; import com.idcanet.foei.event.EventInput; import com.idcanet.foei.event.EventOutput; import com.idcanet.foei.event.EventPort; -import com.idcanet.x4o.element.AbstractElementParameterHandler; +import com.idcanet.x4o.element.AbstractElementAttributeHandler; import com.idcanet.x4o.element.Element; import com.idcanet.x4o.element.ElementConfiguratorException; import com.idcanet.x4o.element.ElementException; @@ -42,14 +42,14 @@ import com.idcanet.x4o.element.ElementException; * @author Willem Cazander * @version 1.0 Apr 15, 2006 */ -public class BindAttributeHandler extends AbstractElementParameterHandler { +public class BindAttributeHandler extends AbstractElementAttributeHandler { /** - * @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#doParameter(java.lang.Object, java.lang.String) + * @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#doConfigElement(java.lang.Object, java.lang.String) */ @Override public void doConfigElement(Element element) throws ElementConfiguratorException { - String parameterValue = element.getAttributes().get(getParameterName()); + String parameterValue = element.getAttributes().get(getAttributeName()); String[] port = parameterValue.split(":"); if(port.length!=2) { return; diff --git a/src/main/java/com/idcanet/foei/core/x4o/EventStepBindRuleHandler.java b/src/main/java/com/idcanet/foei/core/x4o/EventStepBindRuleHandler.java index f4a690f..acb9e9d 100644 --- a/src/main/java/com/idcanet/foei/core/x4o/EventStepBindRuleHandler.java +++ b/src/main/java/com/idcanet/foei/core/x4o/EventStepBindRuleHandler.java @@ -30,7 +30,7 @@ import com.idcanet.foei.event.EventStep; import com.idcanet.foei.event.EventStepController; import com.idcanet.x4o.element.AbstractElementBindingHandler; import com.idcanet.x4o.element.Element; -import com.idcanet.x4o.element.ElementBindingException; +import com.idcanet.x4o.element.ElementBindingHandlerException; /** * @@ -58,7 +58,7 @@ public class EventStepBindRuleHandler extends AbstractElementBindingHandler { /** * @see com.idca.foei.xml.x2o.eld.BindingRuleHandler#doBind(java.lang.Object, java.lang.Object) */ - public void doBind(Element element) throws ElementBindingException { + public void doBind(Element element) throws ElementBindingHandlerException { Object parent = element.getParent().getElementObject(); Object child = element.getElementObject(); ((EventStepController)parent).addEventStep((EventStep)child); diff --git a/src/main/java/com/idcanet/foei/core/x4o/IdAttributeHandler.java b/src/main/java/com/idcanet/foei/core/x4o/IdAttributeHandler.java index 5d6eed9..9fa7d98 100644 --- a/src/main/java/com/idcanet/foei/core/x4o/IdAttributeHandler.java +++ b/src/main/java/com/idcanet/foei/core/x4o/IdAttributeHandler.java @@ -29,7 +29,7 @@ package com.idcanet.foei.core.x4o; import com.idcanet.foei.core.FoeiBindingException; import com.idcanet.foei.core.FoeiProcess; import com.idcanet.foei.core.FoeiProcessFactory; -import com.idcanet.x4o.element.AbstractElementParameterHandler; +import com.idcanet.x4o.element.AbstractElementAttributeHandler; import com.idcanet.x4o.element.Element; import com.idcanet.x4o.element.ElementConfiguratorException; @@ -39,15 +39,15 @@ import com.idcanet.x4o.element.ElementConfiguratorException; * @author Willem Cazander * @version 1.0 Jul 8, 2006 */ -public class IdAttributeHandler extends AbstractElementParameterHandler { +public class IdAttributeHandler extends AbstractElementAttributeHandler { /** - * @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#doParameter(java.lang.Object, java.lang.String) + * @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#doConfigElement(java.lang.Object, java.lang.String) */ @Override public void doConfigElement(Element element) throws ElementConfiguratorException { // add to objext context - String parameterValue = element.getAttributes().get(getParameterName()); + String parameterValue = element.getAttributes().get(getAttributeName()); if(element.getElementObject()==null | "".equals(parameterValue)) { parameterValue= "auto."+Integer.toHexString(element.getElementObject().hashCode()); //logger.finest("Generated auto id: "+parameterValue); diff --git a/src/main/java/com/idcanet/foei/event/AbstractEventStep.java b/src/main/java/com/idcanet/foei/event/AbstractEventStep.java index e71d01b..f0b1eb6 100644 --- a/src/main/java/com/idcanet/foei/event/AbstractEventStep.java +++ b/src/main/java/com/idcanet/foei/event/AbstractEventStep.java @@ -34,4 +34,19 @@ package com.idcanet.foei.event; */ abstract public class AbstractEventStep implements EventStep { + private EventStepOperand eventStepOperand = null; + + /** + * @return the eventStepOperand + */ + public EventStepOperand getEventStepOperand() { + return eventStepOperand; + } + + /** + * @param eventStepOperand the eventStepOperand to set + */ + public void setEventStepOperand(EventStepOperand eventStepOperand) { + this.eventStepOperand = eventStepOperand; + } } \ No newline at end of file diff --git a/src/main/java/com/idcanet/foei/event/EventStep.java b/src/main/java/com/idcanet/foei/event/EventStep.java index 29e1566..0393f22 100644 --- a/src/main/java/com/idcanet/foei/event/EventStep.java +++ b/src/main/java/com/idcanet/foei/event/EventStep.java @@ -36,6 +36,30 @@ import java.io.Serializable; */ public interface EventStep extends Serializable { + public enum EventStepOperand { + AND,NAND, + OR,NOR,XOR; + + public boolean execute(boolean A,boolean B) { + if (this==AND) { + return A&B; + } + if (this==NAND) { + return !A&!B; + } + if (this==OR) { + return A|B; + } + if (this==NOR) { + return !A|!B; + } + if (this==XOR) { + return A^B; + } + throw new IllegalStateException("Can execute unknow EventStepOperand: "+this.name()); + } + } + /** * Process an object and gives it back. * @@ -43,4 +67,8 @@ public interface EventStep extends Serializable { * @returns An object or null if not succesfull. */ public Object processObject(Object object) throws ClassCastException; + + + public void setEventStepOperand(EventStepOperand operand); + public EventStepOperand getEventStepOperand(); } \ No newline at end of file