[jboss-svn-commits] JBL Code SVN: r31209 - labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jan 25 17:47:46 EST 2010


Author: baunax
Date: 2010-01-25 17:47:46 -0500 (Mon, 25 Jan 2010)
New Revision: 31209

Modified:
   labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine.java
Log:
Added methods:
	- getMethodType
	- getFactNameFromType

Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine.java	2010-01-25 22:46:23 UTC (rev 31208)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine.java	2010-01-25 22:47:46 UTC (rev 31209)
@@ -153,10 +153,8 @@
     private Map<String, List<MethodInfo>> methodInfos            = new HashMap<String, List<MethodInfo>>();
 
 
-    private Map<String,ModelField[]> modelFields = new TreeMap<String, ModelField[]>();
+    private Map<String, ModelField[]> modelFields = new TreeMap<String, ModelField[]>();
 
-
-
     public SuggestionCompletionEngine() {
 
     }
@@ -470,7 +468,7 @@
         this.methodInfos.put( factName,
                               methodInfos );
     }
-
+    
     public List<String> getMethodFields(String factName,
                                         String methodNameWithParams) {
         if ( methodInfos.get( factName ) != null ) {
@@ -499,6 +497,21 @@
         return methodList;
     }
     
+    public String getMethodType(String factName, String methodFullName) {
+    	List<MethodInfo> infos = methodInfos.get( factName );
+        List<String> methodList = new ArrayList<String>();
+
+        if ( infos != null ) {
+            for ( MethodInfo info : infos ) {
+                if (methodFullName.equals(methodFullName)) {
+                	return info.getReturnType();
+                }
+            }
+        }
+
+        return null;
+    }
+    
     public List<String> getMethodFullNames(String factName) {
         List<MethodInfo> infos = methodInfos.get( factName );
         List<String> methodList = new ArrayList<String>();
@@ -511,8 +524,28 @@
 
         return methodList;
     }    
+
+    /**
+     * Returns fact's name from class type
+     *  
+     * @param type
+     * @return
+     */
+    public String getFactNameFromType(String type) {
+    	if (modelFields.containsKey(type)) {
+    		return type;
+    	}
+    	for (Map.Entry<String, ModelField[]> entry : modelFields.entrySet()) {
+			for (ModelField mf : entry.getValue()) {
+				if ("this".equals(mf.getName()) && type.equals(mf.getClassName())) {
+					return entry.getKey();
+				}
+			}
+		}
+    	return null;
+    }
     
-    /*
+    /**
      * returns the type of parametric class
      * List<String> a in a class called Toto
      * key =   "Toto.a"
@@ -547,8 +580,6 @@
         return toStringArray( this.globalTypes.keySet() );
     }
 
-
-
     public void setModifiers(Map<String,String[]> map){
         this.modifiers = map;
     }
@@ -557,8 +588,6 @@
         return this.modifiers.get(name);
     }
 
-
-
     public void setGlobalCollections(String[] globalCollections){
         this.globalCollections = globalCollections;
     }
@@ -567,9 +596,6 @@
         return this.globalCollections;
     }
 
-
-
-
     public String[] getDataEnumList(String type){
         return this.dataEnumLists.get(type);
     }



More information about the jboss-svn-commits mailing list