[jboss-svn-commits] JBL Code SVN: r36341 - in labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core: datatype and 3 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Dec 10 01:22:37 EST 2010


Author: KrisVerlaenen
Date: 2010-12-10 01:22:36 -0500 (Fri, 10 Dec 2010)
New Revision: 36341

Added:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/ParameterDefinition.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/TypeObject.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Work.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinition.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinitionExtension.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkEditor.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataTypeFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/InstanceDataTypeFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/NewInstanceDataTypeFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/BooleanDataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/EnumDataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/FloatDataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/IntegerDataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ListDataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ObjectDataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/StringDataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/UndefinedDataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ParameterDefinitionImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionExtensionImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkImpl.java
Log:
 - moving work definition back to drools-core

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/ParameterDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/ParameterDefinition.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/ParameterDefinition.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core;
+
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface ParameterDefinition extends TypeObject {
+    
+    String getName();
+    void setName(String name);
+    
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/TypeObject.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/TypeObject.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/TypeObject.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,26 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core;
+
+import org.drools.process.core.datatype.DataType;
+
+public interface TypeObject {
+
+    DataType getType();
+    void setType(DataType type);
+    
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Work.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Work.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Work.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,42 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface Work {
+
+    void setName(String name);
+    String getName();
+    
+    void setParameter(String name, Object value);
+    void setParameters(Map<String, Object> parameters);
+    Object getParameter(String name);
+    Map<String, Object> getParameters();
+    
+    void addParameterDefinition(ParameterDefinition parameterDefinition);
+    void setParameterDefinitions(Set<ParameterDefinition> parameterDefinitions);
+    Set<ParameterDefinition> getParameterDefinitions();
+    String[] getParameterNames();
+    ParameterDefinition getParameterDefinition(String name);
+    
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinition.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinition.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core;
+
+import java.util.Set;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface WorkDefinition {
+    
+    String getName();
+    
+    Set<ParameterDefinition> getParameters();
+    String[] getParameterNames();
+    ParameterDefinition getParameter(String name);
+    
+    Set<ParameterDefinition> getResults();
+    String[] getResultNames();
+    ParameterDefinition getResult(String name);
+    
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinitionExtension.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinitionExtension.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinitionExtension.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface WorkDefinitionExtension {
+    
+    String getDisplayName();
+    
+    String getExplanationText();
+    
+    String getIcon();
+    
+    String getCustomEditor();
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkEditor.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkEditor.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core;
+
+public interface WorkEditor {
+    
+    void setWorkDefinition(WorkDefinition definition);
+    
+    void setWork(Work work);
+    
+    boolean show();
+    
+    Work getWork();
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataType.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,42 @@
+/**
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core.datatype;
+
+import java.io.Externalizable;
+
+/**
+ * Abstract representation of a datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface DataType extends Externalizable {
+
+    /**
+     * Returns true if the given value is a valid value of this data type.
+     */
+    boolean verifyDataType(Object value);
+    
+    String writeValue(Object value);
+    
+    Object readValue(String value);
+    
+    /**
+     * Returns the corresponding Java type of this datatype
+     */
+    String getStringType();
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataTypeFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataTypeFactory.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataTypeFactory.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core.datatype;
+
+import java.io.Serializable;
+
+
+/**
+ * A factory for creating a datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface DataTypeFactory extends Serializable {
+
+    DataType createDataType();
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/InstanceDataTypeFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/InstanceDataTypeFactory.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/InstanceDataTypeFactory.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,55 @@
+/**
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core.datatype.impl;
+
+import org.drools.process.core.datatype.DataType;
+import org.drools.process.core.datatype.DataTypeFactory;
+
+/**
+ * A data type factory that always returns the same instance of a given class.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class InstanceDataTypeFactory implements DataTypeFactory {
+
+    private static final long serialVersionUID = 510l;
+    
+    private Class<?> dataTypeClass;
+    private DataType instance;
+
+    public InstanceDataTypeFactory(final Class<?> dataTypeClass) {
+        this.dataTypeClass = dataTypeClass;
+    }
+
+    public DataType createDataType() {
+        if (this.instance == null) {
+            try {
+                this.instance = (DataType) this.dataTypeClass.newInstance();
+            } catch (final IllegalAccessException e) {
+                throw new RuntimeException(
+                        "Could not create data type for class "
+                                + this.dataTypeClass, e);
+            } catch (final InstantiationException e) {
+                throw new RuntimeException(
+                        "Could not create data type for class "
+                                + this.dataTypeClass, e);
+            }
+        }
+        return this.instance;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/NewInstanceDataTypeFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/NewInstanceDataTypeFactory.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/NewInstanceDataTypeFactory.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,49 @@
+/**
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core.datatype.impl;
+
+import org.drools.process.core.datatype.DataType;
+import org.drools.process.core.datatype.DataTypeFactory;
+
+/**
+ * A data type factory that always returns a new instance of a given class.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class NewInstanceDataTypeFactory implements DataTypeFactory {
+
+    private static final long serialVersionUID = 510l;
+    
+    private Class<? extends DataType> dataTypeClass;
+
+    public NewInstanceDataTypeFactory(final Class<? extends DataType> dataTypeClass) {
+        this.dataTypeClass = dataTypeClass;
+    }
+
+    public DataType createDataType() {
+        try {
+            return this.dataTypeClass.newInstance();
+        } catch (final IllegalAccessException e) {
+            throw new RuntimeException("Could not create data type for class "
+                    + this.dataTypeClass, e);
+        } catch (final InstantiationException e) {
+            throw new RuntimeException("Could not create data type for class "
+                    + this.dataTypeClass, e);
+        }
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/BooleanDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/BooleanDataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/BooleanDataType.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,60 @@
+/**
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core.datatype.impl.type;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * Representation of a boolean datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public final class BooleanDataType
+    implements
+    DataType {
+
+    private static final long serialVersionUID = 510l;
+
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException {
+    }
+
+    public boolean verifyDataType(final Object value) {
+        if ( value instanceof Boolean ) {
+            return true;
+        }
+        return false;
+    }
+
+	public Object readValue(String value) {
+		return new Boolean(value);
+	}
+
+	public String writeValue(Object value) {
+		return (Boolean) value ? "true" : "false";
+	}
+
+	public String getStringType() {
+		return "Boolean";
+	}
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/EnumDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/EnumDataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/EnumDataType.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.drools.process.core.datatype.impl.type;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * Representation of an Enum datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class EnumDataType implements DataType {
+
+    private static final long serialVersionUID = 4L;
+
+    private String className;
+    private transient Map<String, Object> valueMap;
+    
+    public EnumDataType() {
+    }
+
+    public EnumDataType(String className) {
+    	setClassName(className);
+    }
+
+    public String getClassName() {
+        return className;
+    }
+
+    public void setClassName(String className) {
+        this.className = className;
+    }
+
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+    	className = (String) in.readObject();
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException {
+    	out.writeObject(className);
+    }
+
+    public boolean verifyDataType(final Object value) {
+    	if (value == null) {
+        	return true;
+        }
+    	return getValueMap().containsValue(value);
+    }
+    
+	public Object readValue(String value) {
+		return getValueMap().get(value);
+	}
+
+	public String writeValue(Object value) {
+		return value == null ? "" : value.toString();
+	}
+
+	public String getStringType() {
+		return className == null ? "java.lang.Object" : className;
+	}
+	
+	public Object[] getValues() {
+		return getValueMap().values().toArray();
+	}
+	
+	public String[] getValueNames() {
+		return getValueMap().keySet().toArray(new String[0]);
+	}
+	
+	public Map<String, Object> getValueMap() {
+		if (this.valueMap == null) {
+			try {
+				this.valueMap = new HashMap<String, Object>();
+				if (className == null) {
+					return null;
+				}
+				Class<?> clazz = Class.forName(className);
+		        if (!clazz.isEnum()) {
+		        	return null;
+		        }
+		        Object[] values = (Object[]) clazz.getMethod("values", null).invoke(clazz, null);
+		        for (Object value: values) {
+		        	this.valueMap.put(value.toString(), value);
+		        }
+			} catch (ClassNotFoundException e) {
+	            throw new IllegalArgumentException(
+	                "Could not find data type " + className);
+			} catch (IllegalAccessException e) {
+	            throw new IllegalArgumentException(
+	                "IllegalAccessException " + e);
+			} catch (InvocationTargetException e) {
+	            throw new IllegalArgumentException(
+	                "InvocationTargetException " + e);
+			} catch (NoSuchMethodException e) {
+	            throw new IllegalArgumentException(
+	                "NoSuchMethodException " + e);
+			}
+			
+		}
+		return this.valueMap;
+	}
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/FloatDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/FloatDataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/FloatDataType.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,64 @@
+/**
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core.datatype.impl.type;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * Representation of a float datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public final class FloatDataType
+    implements
+    DataType {
+
+    private static final long serialVersionUID = 510l;
+
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException {
+    }
+
+    public boolean verifyDataType(final Object value) {
+        if ( value instanceof Float ) {
+            return true;
+        } else if ( value == null ) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+	public Object readValue(String value) {
+		return new Float(value);
+	}
+
+	public String writeValue(Object value) {
+		Float f = (Float) value;
+		return f == null ? "" : f.toString();
+	}
+
+	public String getStringType() {
+		return "Float";
+	}
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/IntegerDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/IntegerDataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/IntegerDataType.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,65 @@
+/**
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core.datatype.impl.type;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * Representation of an integer datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class IntegerDataType
+    implements
+    DataType {
+
+    private static final long serialVersionUID = 510l;
+
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException {
+    }
+
+    public boolean verifyDataType(final Object value) {
+        if ( value instanceof Integer ) {
+            return true;
+        } else if ( value == null ) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+	public Object readValue(String value) {
+		return new Integer(value);
+	}
+
+	public String writeValue(Object value) {
+		Integer i = (Integer) value;
+		return i == null ? "" : i.toString();
+	}
+
+	public String getStringType() {
+		return "Integer";
+	}
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ListDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ListDataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ListDataType.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,77 @@
+/**
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core.datatype.impl.type;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.List;
+
+import org.drools.process.core.TypeObject;
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * Representation of a list datatype.
+ * All elements in the list must have the same datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ListDataType extends ObjectDataType implements TypeObject {
+
+    private static final long serialVersionUID = 510l;
+
+    private DataType dataType;
+    
+    public ListDataType() {
+    	setClassName("java.util.List");
+    }
+
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        dataType    = (DataType)in.readObject();
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(dataType);
+    }
+    
+    public ListDataType(DataType dataType) {
+    	setType(dataType);
+    }
+
+    public void setType(final DataType dataType) {
+        this.dataType = dataType;
+    }
+
+    public DataType getType() {
+        return this.dataType;
+    }
+
+    public boolean verifyDataType(final Object value) {
+        if (value == null) {
+            return true;
+        }
+        if (value instanceof List) {
+            for (Object o: (List<?>) value) {
+                if (dataType != null && !dataType.verifyDataType(o)) {
+                    return false;
+                }
+            }
+            return true;
+        }
+        return false;
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ObjectDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ObjectDataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ObjectDataType.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,90 @@
+/**
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core.datatype.impl.type;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.drools.process.core.datatype.DataType;
+
+import com.thoughtworks.xstream.XStream;
+
+/**
+ * Representation of an object datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ObjectDataType implements DataType {
+
+    private static final long serialVersionUID = 510l;
+
+    private String className;
+    
+    public ObjectDataType() {
+    }
+
+    public ObjectDataType(String className) {
+    	setClassName(className);
+    }
+
+    public String getClassName() {
+        return className;
+    }
+
+    public void setClassName(String className) {
+        this.className = className;
+    }
+
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+    	className = (String) in.readObject();
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException {
+    	out.writeObject(className);
+    }
+
+    public boolean verifyDataType(final Object value) {
+    	if (value == null) {
+        	return true;
+        }
+        try {
+            Class<?> clazz = Class.forName(className);
+            if (clazz.isInstance(value)) {
+                return true;
+            }
+        } catch (ClassNotFoundException e) {
+            throw new IllegalArgumentException(
+                "Could not find data type " + className);
+        }
+        return false;
+    }
+
+	public Object readValue(String value) {
+		XStream xstream = new XStream();
+		return xstream.fromXML(value);
+	}
+
+	public String writeValue(Object value) {
+		XStream xstream = new XStream();
+		return xstream.toXML(value);
+	}
+
+	public String getStringType() {
+		return className == null ? "java.lang.Object" : className;
+	}
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/StringDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/StringDataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/StringDataType.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,61 @@
+/**
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core.datatype.impl.type;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * Representation of a string datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class StringDataType implements DataType {
+
+    private static final long serialVersionUID = 510l;
+
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException {
+    }
+
+    public boolean verifyDataType(final Object value) {
+        if ( value instanceof String ) {
+            return true;
+        } else if ( value == null ) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+	public Object readValue(String value) {
+		return value;
+	}
+
+	public String writeValue(Object value) {
+		return (String) value;
+	}
+	
+	public String getStringType() {
+		return "String";
+	}
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/UndefinedDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/UndefinedDataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/UndefinedDataType.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core.datatype.impl.type;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * Representation of an undefined datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public final class UndefinedDataType implements DataType {
+
+    private static final long serialVersionUID = 510l;
+    private static UndefinedDataType instance;
+
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException {
+    }
+
+    public static UndefinedDataType getInstance() {
+        if (instance == null) {
+            instance = new UndefinedDataType();
+        }
+        return instance;
+    }
+
+    public boolean verifyDataType(final Object value) {
+        if (value == null) {
+            return true;
+        }
+        return false;
+    }
+
+	public Object readValue(String value) {
+		throw new IllegalArgumentException("Undefined datatype");
+	}
+
+	public String writeValue(Object value) {
+		throw new IllegalArgumentException("Undefined datatype");
+	}
+
+	public String getStringType() {
+		return "Object";
+	}
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ParameterDefinitionImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ParameterDefinitionImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ParameterDefinitionImpl.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core.impl;
+
+import java.io.Serializable;
+
+import org.drools.process.core.ParameterDefinition;
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ParameterDefinitionImpl implements ParameterDefinition, Serializable {
+   
+    private static final long serialVersionUID = 510l;
+   
+    private String name;
+    private DataType type;
+    
+    public ParameterDefinitionImpl() {
+    }
+    
+    public ParameterDefinitionImpl(String name, DataType type) {
+        setName(name);
+        setType(type);
+    }
+    
+    public String getName() {
+        return name;
+    }
+    
+    public void setName(String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("Name cannot be null");
+        }
+        this.name = name;
+    }
+    
+    public DataType getType() {
+        return type;
+    }
+    
+    public void setType(DataType type) {
+        if (type == null) {
+            throw new IllegalArgumentException("Data type cannot be null");
+        }
+        this.type = type;
+    }
+    
+    public String toString() {
+        return name;
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionExtensionImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionExtensionImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionExtensionImpl.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core.impl;
+
+import org.drools.process.core.WorkDefinitionExtension;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class WorkDefinitionExtensionImpl extends WorkDefinitionImpl implements WorkDefinitionExtension {
+    
+    private static final long serialVersionUID = 510l;
+    
+    private String displayName;
+    private String explanationText;
+    private String icon;
+    private String editor;
+    
+    public String getDisplayName() {
+        return displayName;
+    }
+    
+    public void setDisplayName(String displayName) {
+        this.displayName = displayName;
+    }
+
+    public String getExplanationText() {
+        return explanationText;
+    }
+    
+    public void setExplanationText(String explanationText) {
+        this.explanationText = explanationText;
+    }
+
+    public String getIcon() {
+        return icon;
+    }
+    
+    public void setIcon(String icon) {
+        this.icon = icon;
+    }
+
+    public String getCustomEditor() {
+        return editor;
+    }
+    
+    public void setCustomEditor(String editor) {
+        this.editor = editor;
+    }
+    
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionImpl.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,108 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core.impl;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.drools.process.core.ParameterDefinition;
+import org.drools.process.core.WorkDefinition;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class WorkDefinitionImpl implements WorkDefinition, Serializable {
+    
+    private static final long serialVersionUID = 510l;
+    
+    private String name;
+    private Map<String, ParameterDefinition> parameters = new HashMap<String, ParameterDefinition>();
+    private Map<String, ParameterDefinition> results = new HashMap<String, ParameterDefinition>();
+
+    public String getName() {
+        return name;
+    }
+    
+    public void setName(String name) {
+        this.name = name;
+    }
+    
+    public Set<ParameterDefinition> getParameters() {
+    	return new HashSet<ParameterDefinition>(parameters.values());        
+    }
+    
+    public void setParameters(Set<ParameterDefinition> parameters) {
+        this.parameters.clear();
+        Iterator<ParameterDefinition> iterator = parameters.iterator();
+        while (iterator.hasNext()) {
+        	addParameter(iterator.next());
+        }        
+    }
+    
+    public void addParameter(ParameterDefinition parameter) {
+    	parameters.put(parameter.getName(), parameter);
+    }
+    
+    public void removeParameter(String name) {
+        parameters.remove(name);
+    }
+    
+    public String[] getParameterNames() {
+        return parameters.keySet().toArray(new String[parameters.size()]);
+    }
+    
+    public ParameterDefinition getParameter(String name) {
+        return parameters.get(name);
+    }
+    
+    public Set<ParameterDefinition> getResults() {
+    	return new HashSet<ParameterDefinition>(results.values());
+    }
+    
+    public void setResults(Set<ParameterDefinition> results) {
+    	this.results.clear();
+        Iterator<ParameterDefinition> it = results.iterator();
+        while (it.hasNext()) {
+        	addResult(it.next());
+        }   
+    }
+    
+    public void addResult(ParameterDefinition result) {
+        results.put(result.getName(), result);
+    }
+    
+    public void removeResult(String name) {
+        results.remove(name);
+    }
+    
+    public String[] getResultNames() {
+        return results.keySet().toArray(new String[results.size()]);
+    }
+    
+    public ParameterDefinition getResult(String name) {
+        return results.get(name);
+    }
+    
+    public String toString() {
+        return name;
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkImpl.java	2010-12-10 06:22:36 UTC (rev 36341)
@@ -0,0 +1,100 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.process.core.impl;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.drools.process.core.ParameterDefinition;
+import org.drools.process.core.Work;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class WorkImpl implements Work, Serializable {
+    
+    private static final long serialVersionUID = 510l;
+    
+    private String name;
+    private Map<String, Object> parameters = new HashMap<String, Object>();
+    private Map<String, ParameterDefinition> parameterDefinitions = new HashMap<String, ParameterDefinition>();
+    
+    public void setName(String name) {
+        this.name = name;
+    }
+    
+    public String getName() {
+        return name;
+    }
+    
+    public void setParameter(String name, Object value) {
+    	if (name == null) {
+    		throw new NullPointerException("Parameter name is null");
+    	}
+		parameters.put(name, value);
+    }
+    
+    public void setParameters(Map<String, Object> parameters) {
+        if (parameters == null) {
+            throw new NullPointerException();
+        }
+        this.parameters = new HashMap<String, Object>(parameters);
+    }
+    
+    public Object getParameter(String name) {
+        if (name == null) {
+            throw new NullPointerException("Parameter name is null");
+        }
+        return parameters.get(name);
+    }
+    
+    public Map<String, Object> getParameters() {
+        return Collections.unmodifiableMap(parameters);
+    }
+    
+    public String toString() {
+        return "Work " + name;
+    }
+
+    public void setParameterDefinitions(Set<ParameterDefinition> parameterDefinitions) {
+        this.parameterDefinitions.clear();
+        for (ParameterDefinition parameterDefinition: parameterDefinitions) {
+            addParameterDefinition(parameterDefinition);
+        }        
+    }
+
+    public void addParameterDefinition(ParameterDefinition parameterDefinition) {
+        this.parameterDefinitions.put(parameterDefinition.getName(), parameterDefinition);
+    }
+
+    public Set<ParameterDefinition> getParameterDefinitions() {
+        return new HashSet<ParameterDefinition>(parameterDefinitions.values());        
+    }
+
+    public String[] getParameterNames() {
+        return parameterDefinitions.keySet().toArray(new String[parameterDefinitions.size()]);
+    }
+
+    public ParameterDefinition getParameterDefinition(String name) {
+        return parameterDefinitions.get(name);
+    }
+}



More information about the jboss-svn-commits mailing list