[jboss-svn-commits] JBL Code SVN: r19432 - labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/context/variable.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Apr 6 19:48:41 EDT 2008
Author: KrisVerlaenen
Date: 2008-04-06 19:48:41 -0400 (Sun, 06 Apr 2008)
New Revision: 19432
Added:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/context/variable/Variable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/context/variable/VariableScope.java
Log:
JBRULES-1548: ePDL: XML-based process definition language
- Ruleflow processes now stored using nicer XML format
JBRULES-1549: Workflow Context
- Context as the basis for grouping nodes
JBRULES-1550: Workflow timer
- Timer node + service
JBRULES-1551: Workflow human tasks
- Added initial implementation for integration human tasks
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/context/variable/Variable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/context/variable/Variable.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/context/variable/Variable.java 2008-04-06 23:48:41 UTC (rev 19432)
@@ -0,0 +1,81 @@
+package org.drools.process.core.context.variable;
+
+/*
+ * 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.
+ */
+
+import java.io.Serializable;
+
+import org.drools.process.core.context.variable.Variable;
+import org.drools.process.core.datatype.DataType;
+import org.drools.process.core.datatype.impl.type.UndefinedDataType;
+
+/**
+ * Default implementation of a variable.
+ *
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class Variable implements Serializable {
+
+ private static final long serialVersionUID = 400L;
+
+ private String name;
+ private DataType type;
+ private Serializable value;
+
+ public Variable() {
+ this.type = UndefinedDataType.getInstance();
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public DataType getType() {
+ return this.type;
+ }
+
+ public void setType(final DataType type) {
+ if ( type == null ) {
+ throw new IllegalArgumentException( "type is null" );
+ }
+ this.type = type;
+ }
+
+ public Serializable getValue() {
+ return this.value;
+ }
+
+ public void setValue(final Serializable value) {
+ if ( this.type.verifyDataType( value ) ) {
+ this.value = value;
+ } else {
+ final StringBuffer sb = new StringBuffer();
+ sb.append( "Value <" );
+ sb.append( value );
+ sb.append( "> is not valid for datatype: " );
+ sb.append( this.type );
+ throw new IllegalArgumentException( sb.toString() );
+ }
+ }
+
+ public String toString() {
+ return this.name;
+ }
+}
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/context/variable/VariableScope.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/context/variable/VariableScope.java (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/context/variable/VariableScope.java 2008-04-06 23:48:41 UTC (rev 19432)
@@ -0,0 +1,67 @@
+package org.drools.process.core.context.variable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.process.core.Context;
+import org.drools.process.core.context.AbstractContext;
+
+/**
+ *
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class VariableScope extends AbstractContext {
+
+ public static final String VARIABLE_SCOPE = "VariableScope";
+
+ private static final long serialVersionUID = 400L;
+
+ private List<Variable> variables;
+
+ public VariableScope() {
+ this.variables = new ArrayList<Variable>();
+ }
+
+ public String getType() {
+ return VariableScope.VARIABLE_SCOPE;
+ }
+
+ public List<Variable> getVariables() {
+ return this.variables;
+ }
+
+ public void setVariables(final List<Variable> variables) {
+ if ( variables == null ) {
+ throw new IllegalArgumentException( "Variables is null" );
+ }
+ this.variables = variables;
+ }
+
+ public String[] getVariableNames() {
+ final String[] result = new String[this.variables.size()];
+ if (this.variables != null) {
+ for ( int i = 0; i < this.variables.size(); i++ ) {
+ result[i] = ((Variable) this.variables.get( i )).getName();
+ }
+ }
+ return result;
+ }
+
+ public Variable findVariable(String variableName) {
+ for (Variable variable: getVariables()) {
+ if (variable.getName().equals(variableName)) {
+ return variable;
+ }
+ }
+ return null;
+ }
+
+ public Context resolveContext(Object param) {
+ if (param instanceof String) {
+ return findVariable((String) param) == null ? null : this;
+ }
+ throw new IllegalArgumentException(
+ "VariableScopes can only resolve variable names: " + param);
+ }
+
+}
More information about the jboss-svn-commits
mailing list