portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/browser DatabaseBrowserAction.java
Date Mon, 05 Aug 2002 20:38:40 GMT
taylor      2002/08/05 13:38:40

  Modified:    src/java/org/apache/jetspeed/modules/actions/portlets/browser
                        DatabaseBrowserAction.java
  Log:
  Added name and type parameter to be read from registry for user specified objects.
  If new user specified objects are to be added to the result set vector, the type of class
  as specified by the user is instantiated and added.
  
  Revision  Changes    Path
  1.23      +71 -2     jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/browser/DatabaseBrowserAction.java
  
  Index: DatabaseBrowserAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/browser/DatabaseBrowserAction.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- DatabaseBrowserAction.java	29 Jul 2002 02:25:27 -0000	1.22
  +++ DatabaseBrowserAction.java	5 Aug 2002 20:38:40 -0000	1.23
  @@ -113,6 +113,12 @@
       private static final String START = "start";
       private static final String CUSTOMIZE_TEMPLATE = "customizeTemplate";
       private static final String WINDOW_SIZE = "windowSize";
  +
  +    private static final String USER_OBJECT_NAMES = "user-object-names";
  +    private static final String USER_OBJECT_TYPES = "user-object-types";
  +    private static final String USER_OBJECTS = "user-objects";
  +
  +
       private static final String LINKS_READ = "linksRead";
       private static final String ROW_LINK = "rowLinks";
       private static final String TABLE_LINK = "tableLinks";
  @@ -200,6 +206,7 @@
                   //System.out.println("buildNormalContext SQL: "+sql);
                   if(sql != null )
                   {
  +                    readUserParameters(portlet,rundata,context);
                       getRows(portlet, rundata, sql, windowSize);
                       iterator = getDatabaseBrowserIterator(portlet, rundata);
                   }
  @@ -343,11 +350,22 @@
               ResultSetMetaData rsmd = rs.getMetaData();
               int columnNum = rsmd.getColumnCount();
               /*
  +            get the user object types to be displayed and add them to the
  +            title list as well as the result set list
  +            */
  +            List userObjList = (List)getParameterFromTemp(portlet, rundata, USER_OBJECTS);
  +            int userObjListSize = 0;
  +            if (userObjList != null)
  +            {
  +                userObjListSize = userObjList.size();
  +            }
  +            //System.out.println("User List Size = "+ userObjListSize);
  +            /*
               the array columnDisplayed maintains a boolean value for each
               column index. Only the columns that are set to true are added to
               the resultSetVector, resultSetTitleVector and resultSetTypeVector.
               */
  -            boolean[] columnDisplayed = new boolean [columnNum];
  +            boolean[] columnDisplayed = new boolean [columnNum + userObjListSize];
   
               /*
               this for loop constructs the columnDisplayed array as well as adds
  @@ -369,6 +387,15 @@
                       columnDisplayed[i-1] = false;
                   }
               }
  +
  +            for (int i = columnNum; i < columnNum + userObjListSize; i++)
  +            {
  +                ActionParameter usrObj = (ActionParameter)userObjList.get(i - columnNum);
  +                resultSetTitleVector.add(usrObj.getName());
  +                resultSetTypeVector.add(usrObj.getType());
  +                columnDisplayed[i] = true;
  +                //System.out.println("User List Name = "+ usrObj.getName()+" Type = "+usrObj.getType());
  +            }
               /*
               this while loop adds each row to the resultSetVector
               */
  @@ -387,6 +414,16 @@
                           row.add(obj);
                       }
                   }
  +                for (int i = columnNum; i < columnNum + userObjListSize; i++)
  +                {
  +                    ActionParameter usrObj = (ActionParameter)userObjList.get(i - columnNum);
  +                    if( columnDisplayed[i] )
  +                    {
  +                        Class c = Class.forName(usrObj.getType());
  +                        row.add(c.newInstance());
  +                    }
  +                }
  +
                   resultSetVector.add(row);
               }
               BrowserIterator iterator =
  @@ -631,6 +668,38 @@
       public List getSQLParameters()
       {
           return sqlParameters;
  +    }
  +
  +    protected void readUserParameters(VelocityPortlet portlet, RunData rundata, Context
context)
  +    {
  +        List userObjectList;
  +        Object userObjRead = getParameterFromTemp(portlet, rundata, USER_OBJECTS);
  +        if ( userObjRead != null)
  +        {
  +            context.put(USER_OBJECTS, (List)userObjRead);
  +            //System.out.println("userObjectListSize: "+ ((List)userObjRead).size());
  +        }
  +        else
  +        {
  +            String userObjTypes= getParameterFromRegistry(portlet,USER_OBJECT_TYPES,null);
  +            String userObjNames= getParameterFromRegistry(portlet,USER_OBJECT_NAMES,null);
  +            if( userObjTypes != null && userObjTypes.length() > 0 )
  +            {
  +                userObjectList = new ArrayList();
  +                int userObjectIndex = 0;
  +                StringTokenizer tokenizer1 = new StringTokenizer(userObjNames, ",");
  +                StringTokenizer tokenizer2 = new StringTokenizer(userObjTypes, ",");
  +                while(tokenizer1.hasMoreTokens() && tokenizer2.hasMoreTokens())
  +                {
  +                    userObjectList.add(userObjectIndex,
  +                                       new ActionParameter(tokenizer1.nextToken(), null,
tokenizer2.nextToken()));
  +                    userObjectIndex++;
  +                }
  +                context.put(USER_OBJECTS, userObjectList);
  +                setParameterToTemp(portlet, rundata, USER_OBJECTS, userObjectList);
  +                //System.out.println("readLink: userObjectTypesListSize: "+userObjectList.size());
  +            }
  +        }
       }
   
       protected void readLinkParameters(VelocityPortlet portlet, RunData rundata, Context
context)
  
  
  

--
To unsubscribe, e-mail:   <mailto:jetspeed-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:jetspeed-dev-help@jakarta.apache.org>


Mime
View raw message