[jboss-svn-commits] JBL Code SVN: r6699 - in labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status: . portlet portlet/templates tools

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Oct 9 06:21:42 EDT 2006


Author: wrzep
Date: 2006-10-09 06:21:38 -0400 (Mon, 09 Oct 2006)
New Revision: 6699

Added:
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/Status.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/StatusConfWatcher.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/StatusDescriptor.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/StatusPortlet.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/CellTemplate.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/Column.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/Columns.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/MatrixTemplate.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/MetricTemplate.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/RowTemplate.java
Removed:
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusConfWatcher.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusPortlet.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/
Modified:
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/Tools.java
Log:
http://jira.jboss.com/jira/browse/JBLAB-781
Refactoring: everything affecting portlet itself goes to the portlet dir.

Pawel


Deleted: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java	2006-10-08 22:14:34 UTC (rev 6698)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java	2006-10-09 10:21:38 UTC (rev 6699)
@@ -1,219 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.forge.status;
-
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.forge.common.projects.Projects;
-import org.jboss.forge.common.projects.ProjectsHelper;
-import org.jboss.forge.common.projects.permissions.NullPermissionsChecker;
-import org.jboss.forge.common.projects.permissions.PermissionsChecker;
-
-import org.jboss.forge.common.XmlTools;
-
-import org.jboss.forge.status.common.Tags;
-import org.jboss.forge.status.exceptions.GetScoresException;
-import org.jboss.forge.status.exceptions.ScoresException;
-import org.jboss.forge.status.service.ScoresManager;
-import org.jboss.forge.status.service.protocol.PluginsValues;
-import org.jboss.forge.status.templates.Column;
-import org.jboss.forge.status.templates.Columns;
-import org.jboss.forge.status.templates.MatrixTemplate;
-import org.jboss.forge.status.tools.Tools;
-import org.jboss.logging.Logger;
-
-import org.jboss.portal.common.context.DelegateContext;
-
-import org.w3c.dom.Node;
- 
-/**
-* @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com)
-* A class which handles Status Matrix information managment. 
-*/
-public class Status {
-	
-	/** Columns to display on the main page */
-	private Columns mainPageColumns;
-							
-	/** Matrix to display on the project specyfic page */
-	private MatrixTemplate matrixTemplate;
-	
-	/** Projects present in the Status Matrix */
-	private Projects projects;
-	
-	private ScoresManager scoresManager;
-	
-	private Calendar updateDate = null;
-	
-	private Logger log;
-	
-	/**
-	 * @param portalName portal name
-	 * @param statusRoot Node with Matrix properites
-	 * @param scoresManager
-	 */
-	public Status(String portalName, Node statusRoot,
-							ScoresManager scoresManager) 
-												throws ScoresException {
-		
-		log = Logger.getLogger(this.getClass());
-		
-		// Get configuration		
-		projects = ProjectsHelper.getProjects(portalName); 
-	
-		this.scoresManager = scoresManager;
-		
-		// Get columns to display on the main page
-		Node mainPageRoot =
-				XmlTools.getFirstNodeWithName(statusRoot,
-									Tags.MAIN_PAGE_COLUMNS_TAG);
-		mainPageColumns = new Columns(mainPageRoot, projects);
-		
-		// Get matrix to display on the project page
-		Node projectPageRoot =
-				XmlTools.getFirstNodeWithName(statusRoot,
-									Tags.PROJECT_PAGE_COLUMNS_TAG);
-		matrixTemplate =
-				new MatrixTemplate(projectPageRoot, projects);
-	}
-
-	/**
-	 * Fills the given context with the Status Matrix information.
-	 * 
-	 * @param context DelegateContext to fill.
-	 */
-	public void fillContext(DelegateContext context) {
-		
-		if (updateDate == null) {
-			
-			context.next("scoresUnavailable");
-			return;
-		}
-		
-		DelegateContext scoresContext = context.next("scores");
-		scoresContext.put("date", Tools.formatDate(updateDate));
-		
-		mainPageColumns.fillContext(scoresContext);
-	}
-
-	/**
-	 * Returns Map binding project ids with DelegateContexts
-	 * containing project information
-	 * 
-	 * @return Map : project id -> DelegateContext
-	 */
-	public Map<String, DelegateContext> getProjectContexts() {
-		
-		Map<String, DelegateContext> prjMap =
-							new HashMap<String, DelegateContext>();
-		
-		Set<String> projectIdsSet = projects.getProjectIds(
-				(PermissionsChecker) new NullPermissionsChecker(), null);
-		
-		if (updateDate == null) {
-			
-			for (String projectId : projectIdsSet) {
-			
-				DelegateContext context = new DelegateContext();
-				context.next("scoresUnavailable");
-				
-				prjMap.put(projectId, context);
-			}			
-		} else {
-		
-			for (String projectId : projectIdsSet) {
-			
-				DelegateContext context = new DelegateContext();
-				DelegateContext scoresContext = context.next("scores");
-				
-				matrixTemplate.fillContext(scoresContext, projectId);
-				scoresContext.put("date", Tools.formatDate(updateDate));
-			
-				prjMap.put(projectId, context);
-			}
-		}
-		
-		return prjMap;
-	}
-
-	/**
-	 * Returns Map, which has set as a key set.
-	 * For each plugin id the resulting Map contains DelegateContext
-	 * with information about plugin scores for all projects.
-	 * 
-	 * @return Map : plugin id -> DelegateContext
-	 */
-	public Map<String, DelegateContext> getColumnContexts() {
-		
-		Map<String, DelegateContext> colMap
-								= new HashMap<String, DelegateContext>();
-						   
-		if (updateDate == null) {
-			
-			return colMap;			
-		}
-		
-		for (Column  col : mainPageColumns.getColumns()) {
-			
-			DelegateContext context = new DelegateContext();
-			DelegateContext scoresContext = context.next("scores");
-			
-			col.fillContext(scoresContext, projects);
-			scoresContext.put("date", Tools.formatDate(updateDate));
-			
-			colMap.put(col.getId(), context);
-		} 
-		
-		return colMap;
-	}
-
-	public void update() {
-		
-		log.info("Checking for updated scores.");
-		
-		PluginsValues pluginsValues = null;
-		
-		try {
-			pluginsValues = scoresManager.getLatestScores();
-		} catch (GetScoresException e) {
-			log.warn("Failed to get latest scores.", e);
-			return;
-		}
-			
-		refreshScores(pluginsValues);
-		
-		log.info("Refreshed scores.");
-	}
-	
-	private void refreshScores(PluginsValues pluginsValues) {
-		
-		mainPageColumns.update(pluginsValues);
-		matrixTemplate.update(pluginsValues);
-		
-		updateDate = pluginsValues.getDate();
-	}
-
-}
\ No newline at end of file

Deleted: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusConfWatcher.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusConfWatcher.java	2006-10-08 22:14:34 UTC (rev 6698)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusConfWatcher.java	2006-10-09 10:21:38 UTC (rev 6699)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.forge.status;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.forge.status.common.Locations;
-
-import org.jboss.shotoku.cache.ChangeType;
-import org.jboss.shotoku.cache.ShotokuResourceWatcher;
-
-public class StatusConfWatcher extends
-							ShotokuResourceWatcher<String, StatusDescriptor> {
-	
-	public StatusConfWatcher(long interval) {
-		super(interval);
-	}
-	
-	private StatusDescriptor getDesc(String portalName) {
-		return new StatusDescriptor(portalName, getContentManager(portalName));
-	}
-	
-	@Override
-	public StatusDescriptor init(String key) {
-		
-		String portalName = key;
-		
-		addWatchedPath(key, Locations.getXmlCmPath(portalName));
-		addWatchedPath(key, Locations.getXmlStatusPluginsCmPath(portalName));
-		addWatchedPath(key, Locations.getServicePropertiesCmPath(portalName));
-		
-		/* Watch projects.xml file */ 
-		addWatchedPath(key, Locations.getProjectsXmlPath(portalName));
-		
-		/* Watch all project.xml files.
-		 * We assume that they contain entries used by plugins */ 
-		Set<String> projectXmlPathsSet =
-								Locations.getProjectXmlPathsSet(portalName);
-		
-		for (String projectXmlPath : projectXmlPathsSet) {
-			addWatchedPath(key, projectXmlPath);
-		}
-		
-		return getDesc(portalName);
-	}
-
-	@Override
-	/* Called only when some of the watched resources changes. */
-	public void update(String key, StatusDescriptor currentObject,
-											Map<String, ChangeType> changes) {
-		
-		put(key, getDesc(key));
-	}
-	
-	@Override
-	/* Called to check if updated scores are available. */
-	public void update(String key, StatusDescriptor desc) {
-		
-		desc.update();
-	}
-}

Deleted: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java	2006-10-08 22:14:34 UTC (rev 6698)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java	2006-10-09 10:21:38 UTC (rev 6699)
@@ -1,173 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-
-package org.jboss.forge.status;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.forge.common.projects.Projects;
-import org.jboss.forge.common.projects.ProjectsHelper;
-import org.jboss.forge.status.common.Locations;
-import org.jboss.forge.status.service.ScoresManager;
-import org.jboss.forge.status.service.ScoresRepositoryManager;
-import org.jboss.forge.status.service.impl.DBScoresRepositoryManager;
-import org.jboss.forge.status.service.impl.ServiceScoresManager;
-import org.jboss.forge.status.service.impl.protocol.ServiceConfImpl;
-import org.jboss.forge.status.service.impl.protocol.db.DBScoresFactory;
-import org.jboss.forge.status.service.protocol.PluginConf;
-import org.jboss.forge.status.service.protocol.ScoresFactory;
-import org.jboss.forge.status.service.protocol.ServiceConf;
-import org.jboss.forge.status.tools.Tools;
-import org.jboss.logging.Logger;
-import org.jboss.portal.common.context.DelegateContext;
-
-import org.jboss.shotoku.ContentManager;
-import org.w3c.dom.Node;
-
-/**
- * @author Pawel Wrzeszcz
- * A class which handles accessing matrix information.
- */
-public class StatusDescriptor {
-	
-	private DelegateContext context = new DelegateContext();
-	
-	private Map<String,DelegateContext> projectContexts
-								= new HashMap<String,DelegateContext>();
-	private Map<String,DelegateContext> columnContexts
-	 							= new HashMap<String,DelegateContext>();
-	
-	private ScoresRepositoryManager repositoryManager;
-	private ScoresFactory scoresFactory;
-	private ScoresManager scoresManager;
-	
-	private String portalName;
-	private ContentManager cm;
-	
-	private Status status;
-	
-	private Logger log = Logger.getLogger(StatusDescriptor.class);
-	
-	
-	public StatusDescriptor(String portalName, ContentManager cm) {
-		
-		this.portalName = portalName;
-		this.cm = cm;
-				
-		init(portalName);
-		
-		initStatus();
-		
-		update();
-	}
-
-	private void init(String portalName) {
-		
-		try {
-		
-			String servicePath = Locations.
-										getServicePropertiesCmPath(portalName);
-			org.jboss.shotoku.Node serviceNode = cm.getNode(servicePath);
-			ServiceConf serviceConf = new ServiceConfImpl(serviceNode);
-			
-			String pluginsPath = Locations.
-										getXmlStatusPluginsCmPath(portalName);
-			Node pluginsNode = Tools.getRoot(cm, pluginsPath);
-			List<PluginConf> pluginsConf = Tools.getPluginsConfList(pluginsNode);
-			
-			Projects projects = ProjectsHelper.getProjects(portalName);
-			
-			repositoryManager = new DBScoresRepositoryManager();
-
-			scoresFactory = new DBScoresFactory();
-
-			scoresManager = new ServiceScoresManager(portalName,
-										   			 serviceConf,
-										   			 pluginsConf,
-										   			 repositoryManager,
-										   			 scoresFactory, projects);
-			
-		} catch (Exception e) {
-	
-			log.warn("Unable to initialize StatusDescriptor.", e);
-		}
-		
-	}
-
-	private void initStatus() {
-				
-		try {
-			
-			String statusPath = Locations.getXmlCmPath(portalName);
-			Node statusRoot = Tools.getRoot(cm , statusPath);
-			
-			//String pluginsPath = Locations.
-			//							getXmlStatusPluginsCmPath(portalName);
-							
-			status = new Status(portalName, statusRoot, scoresManager);
-			
-		} catch (Exception e) {
-			
-			log.warn("Initialization failed.", e);
-		} 
-	}
-
-	private void fillContext() {
-		
-		if (status != null) {
-			
-			context = new DelegateContext();
-			status.fillContext(context);
-			
-			projectContexts = status.getProjectContexts();
-			columnContexts = status.getColumnContexts();
-		}	
-	}
-
-	public DelegateContext getContext() {
-		
-		return context;
-	}
-
-	public DelegateContext getProjectContext(String id) {
-		return projectContexts.get(id);
-	}
-	
-	public DelegateContext getColumnContext(String id) {
-		return columnContexts.get(id);
-	}
-	
-
-	public synchronized void update() {
-		
-		if (status == null) {
-			initStatus();
-		}
-		
-		status.update();
-		
-		fillContext();
-	}
-	
-}

Deleted: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusPortlet.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusPortlet.java	2006-10-08 22:14:34 UTC (rev 6698)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusPortlet.java	2006-10-09 10:21:38 UTC (rev 6699)
@@ -1,87 +0,0 @@
- /*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-
-package org.jboss.forge.status;
-
-import java.io.IOException;
-
-import javax.portlet.PortletException;
-import javax.portlet.PortletRequestDispatcher;
-
-import org.jboss.forge.common.ForgeHelper;
-import org.jboss.forge.status.common.Constants;
-import org.jboss.forge.status.common.Locations;
-import org.jboss.forge.status.tools.Tools;
-
-import org.jboss.portal.common.context.DelegateContext;
-import org.jboss.portal.core.servlet.jsp.PortalJsp;
-
-import org.jboss.portlet.JBossPortlet;
-import org.jboss.portlet.JBossRenderRequest;
-import org.jboss.portlet.JBossRenderResponse;
-
-/**
- * Podcast portlet.
- * @author Pawel Wrzeszcz
- */
-public class StatusPortlet extends JBossPortlet {
-
-	@Override
-    public void doView(JBossRenderRequest request, JBossRenderResponse response)
-            throws IOException, PortletException {
-        response.setContentType("text/html");
-	
-        // Get the request parameters
-        String portalName = ForgeHelper.getPortalName(request);
-        String action = request.getParameter("action");
-        String id = request.getParameter("id"); 
-        
-        StatusDescriptor desc = Tools.getDesc(portalName);
-
-        // Set the JSP to show and get the appropriate context
-        String jspPath = null;
-        DelegateContext context = null;
-        
-		if ((id != null) && (action.equals(Constants.PROJECT_DETAILS_ACTION))) {
-			jspPath = Locations.getPrjDetailsJspCmPath();
-			context = desc.getProjectContext(id);
-		}
-		
-		if ((id != null) && (action.equals(Constants.COLUMN_DETAILS_ACTION))) {
-			jspPath = Locations.getColumnDetailsJspCmPath();
-			context = desc.getColumnContext(id);
-		}
-		
-		if (id == null) { // Request for main Matrix page
-			jspPath = Locations.getJspCmPath();
-			context = desc.getContext();
-		}
-        
-        // Displaying the JSP
-        request.setAttribute(PortalJsp.CTX_REQUEST, context);
-        
-        PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(
-				ForgeHelper.createRepoAccessPath(portalName, jspPath));
-        rd.include(request, response);
-	
-    }
-}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/Status.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/Status.java	2006-10-08 22:14:34 UTC (rev 6698)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/Status.java	2006-10-09 10:21:38 UTC (rev 6699)
@@ -0,0 +1,219 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.portlet;
+
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.forge.common.projects.Projects;
+import org.jboss.forge.common.projects.ProjectsHelper;
+import org.jboss.forge.common.projects.permissions.NullPermissionsChecker;
+import org.jboss.forge.common.projects.permissions.PermissionsChecker;
+
+import org.jboss.forge.common.XmlTools;
+
+import org.jboss.forge.status.common.Tags;
+import org.jboss.forge.status.exceptions.GetScoresException;
+import org.jboss.forge.status.exceptions.ScoresException;
+import org.jboss.forge.status.portlet.templates.Column;
+import org.jboss.forge.status.portlet.templates.Columns;
+import org.jboss.forge.status.portlet.templates.MatrixTemplate;
+import org.jboss.forge.status.service.ScoresManager;
+import org.jboss.forge.status.service.protocol.PluginsValues;
+import org.jboss.forge.status.tools.Tools;
+import org.jboss.logging.Logger;
+
+import org.jboss.portal.common.context.DelegateContext;
+
+import org.w3c.dom.Node;
+ 
+/**
+* @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com)
+* A class which handles Status Matrix information managment. 
+*/
+public class Status {
+	
+	/** Columns to display on the main page */
+	private Columns mainPageColumns;
+							
+	/** Matrix to display on the project specyfic page */
+	private MatrixTemplate matrixTemplate;
+	
+	/** Projects present in the Status Matrix */
+	private Projects projects;
+	
+	private ScoresManager scoresManager;
+	
+	private Calendar updateDate = null;
+	
+	private Logger log;
+	
+	/**
+	 * @param portalName portal name
+	 * @param statusRoot Node with Matrix properites
+	 * @param scoresManager
+	 */
+	public Status(String portalName, Node statusRoot,
+							ScoresManager scoresManager) 
+												throws ScoresException {
+		
+		log = Logger.getLogger(this.getClass());
+		
+		// Get configuration		
+		projects = ProjectsHelper.getProjects(portalName); 
+	
+		this.scoresManager = scoresManager;
+		
+		// Get columns to display on the main page
+		Node mainPageRoot =
+				XmlTools.getFirstNodeWithName(statusRoot,
+									Tags.MAIN_PAGE_COLUMNS_TAG);
+		mainPageColumns = new Columns(mainPageRoot, projects);
+		
+		// Get matrix to display on the project page
+		Node projectPageRoot =
+				XmlTools.getFirstNodeWithName(statusRoot,
+									Tags.PROJECT_PAGE_COLUMNS_TAG);
+		matrixTemplate =
+				new MatrixTemplate(projectPageRoot, projects);
+	}
+
+	/**
+	 * Fills the given context with the Status Matrix information.
+	 * 
+	 * @param context DelegateContext to fill.
+	 */
+	public void fillContext(DelegateContext context) {
+		
+		if (updateDate == null) {
+			
+			context.next("scoresUnavailable");
+			return;
+		}
+		
+		DelegateContext scoresContext = context.next("scores");
+		scoresContext.put("date", Tools.formatDate(updateDate));
+		
+		mainPageColumns.fillContext(scoresContext);
+	}
+
+	/**
+	 * Returns Map binding project ids with DelegateContexts
+	 * containing project information
+	 * 
+	 * @return Map : project id -> DelegateContext
+	 */
+	public Map<String, DelegateContext> getProjectContexts() {
+		
+		Map<String, DelegateContext> prjMap =
+							new HashMap<String, DelegateContext>();
+		
+		Set<String> projectIdsSet = projects.getProjectIds(
+				(PermissionsChecker) new NullPermissionsChecker(), null);
+		
+		if (updateDate == null) {
+			
+			for (String projectId : projectIdsSet) {
+			
+				DelegateContext context = new DelegateContext();
+				context.next("scoresUnavailable");
+				
+				prjMap.put(projectId, context);
+			}			
+		} else {
+		
+			for (String projectId : projectIdsSet) {
+			
+				DelegateContext context = new DelegateContext();
+				DelegateContext scoresContext = context.next("scores");
+				
+				matrixTemplate.fillContext(scoresContext, projectId);
+				scoresContext.put("date", Tools.formatDate(updateDate));
+			
+				prjMap.put(projectId, context);
+			}
+		}
+		
+		return prjMap;
+	}
+
+	/**
+	 * Returns Map, which has set as a key set.
+	 * For each plugin id the resulting Map contains DelegateContext
+	 * with information about plugin scores for all projects.
+	 * 
+	 * @return Map : plugin id -> DelegateContext
+	 */
+	public Map<String, DelegateContext> getColumnContexts() {
+		
+		Map<String, DelegateContext> colMap
+								= new HashMap<String, DelegateContext>();
+						   
+		if (updateDate == null) {
+			
+			return colMap;			
+		}
+		
+		for (Column  col : mainPageColumns.getColumns()) {
+			
+			DelegateContext context = new DelegateContext();
+			DelegateContext scoresContext = context.next("scores");
+			
+			col.fillContext(scoresContext, projects);
+			scoresContext.put("date", Tools.formatDate(updateDate));
+			
+			colMap.put(col.getId(), context);
+		} 
+		
+		return colMap;
+	}
+
+	public void update() {
+		
+		log.info("Checking for updated scores.");
+		
+		PluginsValues pluginsValues = null;
+		
+		try {
+			pluginsValues = scoresManager.getLatestScores();
+		} catch (GetScoresException e) {
+			log.warn("Failed to get latest scores.", e);
+			return;
+		}
+			
+		refreshScores(pluginsValues);
+		
+		log.info("Refreshed scores.");
+	}
+	
+	private void refreshScores(PluginsValues pluginsValues) {
+		
+		mainPageColumns.update(pluginsValues);
+		matrixTemplate.update(pluginsValues);
+		
+		updateDate = pluginsValues.getDate();
+	}
+
+}
\ No newline at end of file

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/StatusConfWatcher.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/StatusConfWatcher.java	2006-10-08 22:14:34 UTC (rev 6698)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/StatusConfWatcher.java	2006-10-09 10:21:38 UTC (rev 6699)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.forge.status.portlet;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.forge.status.common.Locations;
+
+import org.jboss.shotoku.cache.ChangeType;
+import org.jboss.shotoku.cache.ShotokuResourceWatcher;
+
+public class StatusConfWatcher extends
+							ShotokuResourceWatcher<String, StatusDescriptor> {
+	
+	public StatusConfWatcher(long interval) {
+		super(interval);
+	}
+	
+	private StatusDescriptor getDesc(String portalName) {
+		return new StatusDescriptor(portalName, getContentManager(portalName));
+	}
+	
+	@Override
+	public StatusDescriptor init(String key) {
+		
+		String portalName = key;
+		
+		addWatchedPath(key, Locations.getXmlCmPath(portalName));
+		addWatchedPath(key, Locations.getXmlStatusPluginsCmPath(portalName));
+		addWatchedPath(key, Locations.getServicePropertiesCmPath(portalName));
+		
+		/* Watch projects.xml file */ 
+		addWatchedPath(key, Locations.getProjectsXmlPath(portalName));
+		
+		/* Watch all project.xml files.
+		 * We assume that they contain entries used by plugins */ 
+		Set<String> projectXmlPathsSet =
+								Locations.getProjectXmlPathsSet(portalName);
+		
+		for (String projectXmlPath : projectXmlPathsSet) {
+			addWatchedPath(key, projectXmlPath);
+		}
+		
+		return getDesc(portalName);
+	}
+
+	@Override
+	/* Called only when some of the watched resources changes. */
+	public void update(String key, StatusDescriptor currentObject,
+											Map<String, ChangeType> changes) {
+		
+		put(key, getDesc(key));
+	}
+	
+	@Override
+	/* Called to check if updated scores are available. */
+	public void update(String key, StatusDescriptor desc) {
+		
+		desc.update();
+	}
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/StatusDescriptor.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/StatusDescriptor.java	2006-10-08 22:14:34 UTC (rev 6698)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/StatusDescriptor.java	2006-10-09 10:21:38 UTC (rev 6699)
@@ -0,0 +1,173 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+
+package org.jboss.forge.status.portlet;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.forge.common.projects.Projects;
+import org.jboss.forge.common.projects.ProjectsHelper;
+import org.jboss.forge.status.common.Locations;
+import org.jboss.forge.status.service.ScoresManager;
+import org.jboss.forge.status.service.ScoresRepositoryManager;
+import org.jboss.forge.status.service.impl.DBScoresRepositoryManager;
+import org.jboss.forge.status.service.impl.ServiceScoresManager;
+import org.jboss.forge.status.service.impl.protocol.ServiceConfImpl;
+import org.jboss.forge.status.service.impl.protocol.db.DBScoresFactory;
+import org.jboss.forge.status.service.protocol.PluginConf;
+import org.jboss.forge.status.service.protocol.ScoresFactory;
+import org.jboss.forge.status.service.protocol.ServiceConf;
+import org.jboss.forge.status.tools.Tools;
+import org.jboss.logging.Logger;
+import org.jboss.portal.common.context.DelegateContext;
+
+import org.jboss.shotoku.ContentManager;
+import org.w3c.dom.Node;
+
+/**
+ * @author Pawel Wrzeszcz
+ * A class which handles accessing matrix information.
+ */
+public class StatusDescriptor {
+	
+	private DelegateContext context = new DelegateContext();
+	
+	private Map<String,DelegateContext> projectContexts
+								= new HashMap<String,DelegateContext>();
+	private Map<String,DelegateContext> columnContexts
+	 							= new HashMap<String,DelegateContext>();
+	
+	private ScoresRepositoryManager repositoryManager;
+	private ScoresFactory scoresFactory;
+	private ScoresManager scoresManager;
+	
+	private String portalName;
+	private ContentManager cm;
+	
+	private Status status;
+	
+	private Logger log = Logger.getLogger(StatusDescriptor.class);
+	
+	
+	public StatusDescriptor(String portalName, ContentManager cm) {
+		
+		this.portalName = portalName;
+		this.cm = cm;
+				
+		init(portalName);
+		
+		initStatus();
+		
+		update();
+	}
+
+	private void init(String portalName) {
+		
+		try {
+		
+			String servicePath = Locations.
+										getServicePropertiesCmPath(portalName);
+			org.jboss.shotoku.Node serviceNode = cm.getNode(servicePath);
+			ServiceConf serviceConf = new ServiceConfImpl(serviceNode);
+			
+			String pluginsPath = Locations.
+										getXmlStatusPluginsCmPath(portalName);
+			Node pluginsNode = Tools.getRoot(cm, pluginsPath);
+			List<PluginConf> pluginsConf = Tools.getPluginsConfList(pluginsNode);
+			
+			Projects projects = ProjectsHelper.getProjects(portalName);
+			
+			repositoryManager = new DBScoresRepositoryManager();
+
+			scoresFactory = new DBScoresFactory();
+
+			scoresManager = new ServiceScoresManager(portalName,
+										   			 serviceConf,
+										   			 pluginsConf,
+										   			 repositoryManager,
+										   			 scoresFactory, projects);
+			
+		} catch (Exception e) {
+	
+			log.warn("Unable to initialize StatusDescriptor.", e);
+		}
+		
+	}
+
+	private void initStatus() {
+				
+		try {
+			
+			String statusPath = Locations.getXmlCmPath(portalName);
+			Node statusRoot = Tools.getRoot(cm , statusPath);
+			
+			//String pluginsPath = Locations.
+			//							getXmlStatusPluginsCmPath(portalName);
+							
+			status = new Status(portalName, statusRoot, scoresManager);
+			
+		} catch (Exception e) {
+			
+			log.warn("Initialization failed.", e);
+		} 
+	}
+
+	private void fillContext() {
+		
+		if (status != null) {
+			
+			context = new DelegateContext();
+			status.fillContext(context);
+			
+			projectContexts = status.getProjectContexts();
+			columnContexts = status.getColumnContexts();
+		}	
+	}
+
+	public DelegateContext getContext() {
+		
+		return context;
+	}
+
+	public DelegateContext getProjectContext(String id) {
+		return projectContexts.get(id);
+	}
+	
+	public DelegateContext getColumnContext(String id) {
+		return columnContexts.get(id);
+	}
+	
+
+	public synchronized void update() {
+		
+		if (status == null) {
+			initStatus();
+		}
+		
+		status.update();
+		
+		fillContext();
+	}
+	
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/StatusPortlet.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/StatusPortlet.java	2006-10-08 22:14:34 UTC (rev 6698)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/StatusPortlet.java	2006-10-09 10:21:38 UTC (rev 6699)
@@ -0,0 +1,87 @@
+ /*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+
+package org.jboss.forge.status.portlet;
+
+import java.io.IOException;
+
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+
+import org.jboss.forge.common.ForgeHelper;
+import org.jboss.forge.status.common.Constants;
+import org.jboss.forge.status.common.Locations;
+import org.jboss.forge.status.tools.Tools;
+
+import org.jboss.portal.common.context.DelegateContext;
+import org.jboss.portal.core.servlet.jsp.PortalJsp;
+
+import org.jboss.portlet.JBossPortlet;
+import org.jboss.portlet.JBossRenderRequest;
+import org.jboss.portlet.JBossRenderResponse;
+
+/**
+ * Podcast portlet.
+ * @author Pawel Wrzeszcz
+ */
+public class StatusPortlet extends JBossPortlet {
+
+	@Override
+    public void doView(JBossRenderRequest request, JBossRenderResponse response)
+            throws IOException, PortletException {
+        response.setContentType("text/html");
+	
+        // Get the request parameters
+        String portalName = ForgeHelper.getPortalName(request);
+        String action = request.getParameter("action");
+        String id = request.getParameter("id"); 
+        
+        StatusDescriptor desc = Tools.getDesc(portalName);
+
+        // Set the JSP to show and get the appropriate context
+        String jspPath = null;
+        DelegateContext context = null;
+        
+		if ((id != null) && (action.equals(Constants.PROJECT_DETAILS_ACTION))) {
+			jspPath = Locations.getPrjDetailsJspCmPath();
+			context = desc.getProjectContext(id);
+		}
+		
+		if ((id != null) && (action.equals(Constants.COLUMN_DETAILS_ACTION))) {
+			jspPath = Locations.getColumnDetailsJspCmPath();
+			context = desc.getColumnContext(id);
+		}
+		
+		if (id == null) { // Request for main Matrix page
+			jspPath = Locations.getJspCmPath();
+			context = desc.getContext();
+		}
+        
+        // Displaying the JSP
+        request.setAttribute(PortalJsp.CTX_REQUEST, context);
+        
+        PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(
+				ForgeHelper.createRepoAccessPath(portalName, jspPath));
+        rd.include(request, response);
+	
+    }
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/CellTemplate.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/CellTemplate.java	2006-10-08 22:14:34 UTC (rev 6698)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/CellTemplate.java	2006-10-09 10:21:38 UTC (rev 6699)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.portlet.templates;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.forge.common.XmlTools;
+import org.jboss.forge.status.common.Tags;
+import org.jboss.forge.status.service.protocol.PluginsValues;
+import org.jboss.portal.common.context.DelegateContext;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+* @author Pawel Wrzeszcz
+* Holds information about one cell from project matrix.
+*/
+public class CellTemplate {
+
+	private String name;
+	private List<MetricTemplate> metricTemplates;
+	
+	/**
+	 * @param cellNode root Node specfying cell properties
+	 * @param pluginsValues
+	 */
+	public CellTemplate(Node cellNode) {
+		
+		name = XmlTools.getChildNodeValue(cellNode,
+											    Tags.CELL_NAME_ELEMENT);
+		
+		Node metricsNode = XmlTools.getFirstNodeWithName(cellNode,
+												Tags.METRICS_ELEMENT);
+		metricTemplates = parseMetricTemplates(metricsNode);
+	}
+
+	public void update(PluginsValues pluginsValues) {
+		
+		for (MetricTemplate metric : metricTemplates) {
+			
+			metric.update(pluginsValues);
+		}
+	}
+	
+	/**
+	 * Gets metrics information from the given Node.
+	 * 
+	 * @param metricsNode root Node specyfying metrics
+	 * @return List of metrics defined in <code>metricsNode</code>
+	 */
+	private ArrayList<MetricTemplate> parseMetricTemplates(Node metricsNode) {
+
+		ArrayList<MetricTemplate> rt = new ArrayList<MetricTemplate>();
+		
+		NodeList rowsList = metricsNode.getChildNodes();
+			
+		for (int i = 0; i < rowsList.getLength(); i++) {
+				
+			Node metricNode = rowsList.item(i);
+			
+			if (metricNode.getNodeName().equals(Tags.METRIC_ELEMENT)) {
+			
+				MetricTemplate metricTemplate =
+						new MetricTemplate(metricNode);
+				rt.add(metricTemplate);
+			}
+		}
+				
+		return rt;
+
+	}
+
+	/**
+	 * Fills the given context with cell information for specified project.
+	 * 
+	 * @param cellContext DelegateContext to fill
+	 * @param projectId id of project to fill context for
+	 */
+	public void fillContext(DelegateContext cellContext, String projectId) {
+		
+		cellContext.put("name", name);
+		
+		for (MetricTemplate cellTemplate : metricTemplates) {
+			
+			DelegateContext metricContext = cellContext.next("metric");
+			cellTemplate.fillContext(metricContext, projectId);
+		}
+		
+	}
+	
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/Column.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/Column.java	2006-10-08 22:14:34 UTC (rev 6698)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/Column.java	2006-10-09 10:21:38 UTC (rev 6699)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.portlet.templates;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Set;
+
+import org.jboss.forge.common.projects.Projects;
+import org.jboss.forge.common.projects.permissions.NullPermissionsChecker;
+import org.jboss.forge.status.service.protocol.PluginValues;
+import org.jboss.forge.status.tools.ProjectsByScoreComparator;
+import org.jboss.logging.Logger;
+import org.jboss.portal.common.context.DelegateContext;
+
+/**
+* @author Pawel Wrzeszcz
+* A class holding column information in the Status Matrix.
+*/
+public class Column {
+	
+	/** Column name */
+	String name;
+	
+	/** Plugin values to put in project rows */
+	PluginValues pluginValues;
+	
+	protected Logger log;
+	
+	/**
+	 * @param name Column name
+	 */
+	public Column(String name) {
+		
+		this.name = name;
+		
+		log = Logger.getLogger(this.getClass());
+	}
+
+	public void update(PluginValues pluginValues) {
+		
+		this.pluginValues = pluginValues; 
+	}
+	
+	/**
+	 * Fills the given context with information appropriate for
+	 * the Status Matrix cell, located in the project row and this column.
+	 * 
+	 * @param projectContext context to fill
+	 * @param projectId id of the project to fill value for
+	 */
+	public void fillProjectContext(DelegateContext projectContext, String projectId) {
+		
+		DelegateContext entryContext = projectContext.next("entry");
+		
+		fillHeaderInfo(entryContext);
+		fillValue(entryContext, projectId);
+	}
+	
+	public void fillHeaderInfo(DelegateContext columnContext) {
+		
+		columnContext.put("name", getName());
+		columnContext.put("id", getId());
+		
+		if (pluginValues.getLinkName() != null) {
+			columnContext.next("hasLink");
+			columnContext.put("special-link-name", pluginValues.getLinkName());
+		} else {
+			columnContext.next("hasNotLink");
+		}
+	}
+	
+	public void fillValue(DelegateContext entryContext, String projectId) {
+		
+		try {
+			Long value = pluginValues.getValue(projectId);
+			Integer rate = pluginValues.getRate(projectId);
+			
+			if (value != null) {
+				entryContext.put("value", Long.toString(value));
+				entryContext.put("rate", Integer.toString(rate));
+				
+				if (pluginValues.getLinkName() != null) {
+					entryContext.next("hasLink");
+					entryContext.put("special-link",
+											pluginValues.getLink(projectId));
+					
+					if (pluginValues.getLink(projectId) != null) {
+						entryContext.next("project-hasLink");
+					}
+				} else {
+					entryContext.next("hasNotLink");
+				}
+				
+			}
+		} catch (Exception e) {
+			log.error("Could not get value for plugin: "
+								+ pluginValues.getPluginId()
+								+ "\nCause: " + e.getMessage());
+		}
+	}
+
+	/**
+	 * Fills the given context with column information for given projects.
+	 * 
+	 * @param columnContext context to fill
+	 * @param projects projects to fill context for
+	 */
+	public void fillContext(DelegateContext columnContext, Projects projects) {
+		
+		fillHeaderInfo(columnContext);
+		
+		String[] projectIds = getProjectIdsSorted(projects); 
+		
+		for (String projectId : projectIds) {
+			
+			DelegateContext projectContext = columnContext.next("project");
+			
+			projectContext.put("name", projects.getProjectName(projectId));
+			projectContext.put("link", projects.getProjectLink(projectId));
+			projectContext.put("id", projectId);
+			
+			fillValue(projectContext, projectId);
+		}
+	}
+	
+	private String[] getProjectIdsSorted(Projects projects) {
+		
+		Set<String> projectIdsSet =
+					projects.getProjectIds(new NullPermissionsChecker(), null);
+		String[] ids = new String[projectIdsSet.size()];
+		projectIdsSet.toArray(ids);
+		
+		Comparator<String> projectsComparator =
+								new ProjectsByScoreComparator(pluginValues);
+		Arrays.sort(ids, projectsComparator);
+		
+		return ids;
+	}
+
+	/**
+	 * @return Column plugin id
+	 */
+	public String getId() {
+		return pluginValues.getPluginId();
+	}
+	
+	/**
+	 * @return Column name
+	 */
+	public String getName() {
+		return name;
+	}
+
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/Columns.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/Columns.java	2006-10-08 22:14:34 UTC (rev 6698)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/Columns.java	2006-10-09 10:21:38 UTC (rev 6699)
@@ -0,0 +1,262 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.portlet.templates;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.forge.common.XmlTools;
+import org.jboss.forge.common.projects.Projects;
+import org.jboss.forge.common.projects.permissions.NullPermissionsChecker;
+import org.jboss.forge.common.projects.permissions.PermissionsChecker;
+
+import org.jboss.forge.status.common.Tags;
+import org.jboss.forge.status.service.protocol.PluginValues;
+import org.jboss.forge.status.service.protocol.PluginsValues;
+import org.jboss.forge.status.tools.ProjectsByNameComparator;
+import org.jboss.forge.status.tools.ProjectsByScoreComparator;
+
+import org.jboss.portal.common.context.DelegateContext;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+* @author Pawel Wrzeszcz
+* A class holding information about columns to display on one page.
+*/
+public class Columns {
+
+	/** Status Matrix Columns list (Column order matters). */
+	private Map<String,Column> columns;
+	
+	/** Projects present in the Status Matrix */
+	private Projects projects;
+	
+	private PluginsValues pluginsValues;
+	
+	/** Plugin determining project order in the Matrix. */
+	private String orderPluginId;
+	
+	/**
+	 * @param pageRoot root Node specfying Columns properties
+	 * @param projects Projects present in the Status Matrix
+	 */
+	public Columns(Node pageRoot, Projects projects) {
+		
+		this.projects = projects;
+		
+		// Get the columns
+		columns = new LinkedHashMap<String,Column>();
+		Node columnsRoot = XmlTools.getFirstNodeWithName(pageRoot,
+											  Tags.COLUMNS_ELEMENT);
+		
+		if (columnsRoot != null) {
+			addColumns(columnsRoot);
+		}
+		
+		// Get id of plugin determining projects order
+		orderPluginId = XmlTools.getChildNodeValue(pageRoot,
+				Tags.ORDER_PLUGIN_ELEMENT);
+	}
+	
+	public void update(PluginsValues pluginsValues) {
+		
+		this.pluginsValues = pluginsValues;
+		
+		for (String pluginId : columns.keySet()) {
+			
+			PluginValues pluginValues =
+							pluginsValues.getPluginValues(pluginId);
+			
+			Column column = columns.get(pluginId);
+			column.update(pluginValues);
+		}
+	}
+	
+	/**
+	 * Adds to the columns list columns defined in columnsRoot.
+	 * 
+	 * @param columnsRoot Node defining columns list
+	 */
+	private void addColumns(Node columnsRoot) {
+		
+		NodeList columnsList = columnsRoot.getChildNodes();
+		
+		for (int i = 0; i < columnsList.getLength(); i++) {
+			
+			Node columnNode = columnsList.item(i);
+			
+			if ((columnNode.getNodeType() == Node.ELEMENT_NODE) &&
+				(columnNode.getNodeName().equals(Tags.COLUMN_ELEMENT))) {
+				
+				String name = XmlTools.getChildNodeValue(columnNode,
+											Tags.COLUMN_NAME_ELEMENT);
+			
+				String pluginId = XmlTools.getChildNodeValue(columnNode,
+											Tags.COLUMN_PLUGIN_ELEMENT);
+				
+				Column column = new Column(name);
+				columns.put(pluginId,column);
+			}
+		}
+	}
+
+
+	/**
+	 * Fills the given context with the columns information.
+	 * 
+	 * @param context DelegateContext to fill
+	 */
+	public void fillContext(DelegateContext context) {
+		fillColumnNames(context);
+		fillValues(context);
+	}
+	
+	/**
+	 * Fills the given context with the columns information
+	 * for project with the given id.
+	 * 
+	 * @param context DelegateContext to fill
+	 * @param projectId id of project to fill context for
+	 */
+	public void fillContext(DelegateContext context, String projectId) {
+		fillColumnNames(context);
+		fillProjectContext(context, projectId);
+	}
+	
+	/**
+	 * Fills the given context with column names
+	 * 
+	 * @param context DelegateContext to fill
+	 */
+	private void fillColumnNames(DelegateContext context) {
+		
+		for (Column column : columns.values()) {
+			
+			DelegateContext columnContext = new DelegateContext();
+			column.fillHeaderInfo(columnContext);
+			
+			context.append("column", columnContext);
+		}
+	}
+	
+	/** Fills the given context with cell values.
+	 * Context is filled with values for each project and for each column.
+	 * 
+	 *  @param context DelegateContext to fill
+	 */	
+	private void fillValues(DelegateContext context) {
+		
+		String[] projectIds = getProjectIdsSorted();
+
+		for (int i = 0; i < projectIds.length; i++) {
+			
+			String projectId = projectIds[i];
+			
+			DelegateContext projectContext = context.next("project");
+			projectContext.put("position", i + 1);
+			
+			fillProjectContext(projectContext, projectId);
+		}
+	}
+	
+	/**
+	 * @return String[] with project ids sorted by project scores
+	 */
+	private String[] getProjectIdsSorted() {
+		
+		Set<String> projectIdsSet = projects.getProjectIds(
+				(PermissionsChecker) new NullPermissionsChecker(), null);
+		
+		
+		String[] projectIdsArr = new String[projectIdsSet.size()];
+		projectIdsSet.toArray(projectIdsArr);
+		
+		Comparator<String> projectsComparator = null;
+		
+		PluginValues orderPluginValues =
+						(pluginsValues == null) ? null : 
+								pluginsValues.getPluginValues(orderPluginId);
+		
+		if (orderPluginValues != null) {
+			projectsComparator = new ProjectsByScoreComparator(orderPluginValues);
+		} else {
+			projectsComparator = new ProjectsByNameComparator(projects);
+		}
+		
+		Arrays.sort(projectIdsArr, projectsComparator);
+		
+		return projectIdsArr;
+	}
+
+	/**
+	 * Fills the given context with project information
+	 * 
+	 * @param projectContext DelegateContext to fill
+	 * @param projectId project id
+	 */
+	private void fillProjectContext(DelegateContext projectContext, String projectId) {
+
+			projectContext.put("id", projectId);
+			projectContext.put("name", projects.getProjectName(projectId));
+			projectContext.put("link", projects.getProjectLink(projectId));
+			
+			fillEntries(projectContext, projectId);
+	}
+
+	/**
+	 * Fills the given context with cells information in the project row
+	 * 
+	 * @param projectId specifies project row
+	 * @param projectContext DelegateContext to fill
+	 */
+	private void fillEntries(DelegateContext projectContext, String projectId) {
+		
+		
+		for (Column column : columns.values()) {	
+		
+			column.fillProjectContext(projectContext, projectId);
+		}
+	}
+
+	/**
+	 * Adds columns from <code>columnsToAdd</code> to the columns list.
+	 */
+	public void add(Columns columnsToAdd) {
+		
+		for (String pluginId : columnsToAdd.columns.keySet()) {
+			
+			columns.put(pluginId, columnsToAdd.columns.get(pluginId));
+		}
+	
+	}
+
+	public Collection<Column> getColumns() {
+		
+		return columns.values();
+	}
+}
\ No newline at end of file

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/MatrixTemplate.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/MatrixTemplate.java	2006-10-08 22:14:34 UTC (rev 6698)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/MatrixTemplate.java	2006-10-09 10:21:38 UTC (rev 6699)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.portlet.templates;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import org.jboss.forge.common.XmlTools;
+import org.jboss.forge.common.projects.Projects;
+import org.jboss.forge.status.common.Tags;
+import org.jboss.forge.status.service.protocol.PluginsValues;
+import org.jboss.portal.common.context.DelegateContext;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+* @author Pawel Wrzeszcz
+* A class holding information about content of project matrix.
+*/
+public class MatrixTemplate {
+
+	/** Rows */
+	private List<RowTemplate> rowTemplates;
+	
+	/** Projects present in the matrix */
+	private Projects projects;
+	
+	/**
+	 * @param projectPageRoot root Node specfying matrix properties
+	 * @param projects Projects present in the matrix
+	 */
+	public MatrixTemplate(Node projectPageRoot, Projects projects) {
+		
+		this.projects = projects;
+		
+		Node rowsRoot = XmlTools.getFirstNodeWithName(projectPageRoot,
+													Tags.ROWS_ELEMENT);
+		rowTemplates = parseMatrixTemplate(rowsRoot);
+	}
+
+	public void update(PluginsValues pluginsValues) {
+		
+		for (RowTemplate row : rowTemplates) {
+			
+			row.update(pluginsValues);
+		}
+	}
+	
+	/**
+	 * Gets rows information from the given Node.
+	 * 
+	 * @param rowsNode root Node specyfying rows
+	 * @return List of rows defined in <code>rowsNode</code>
+	 */
+	private List<RowTemplate> parseMatrixTemplate(Node rowsNode) {
+			
+		ArrayList<RowTemplate> mt = new ArrayList<RowTemplate>();
+		
+		NodeList rowsList = rowsNode.getChildNodes();
+			
+		for (int i = 0, rowNumber = 1; i < rowsList.getLength(); i++) {
+				
+			Node rowNode = rowsList.item(i);
+			
+			if (rowNode.getNodeName().equals(Tags.ROW_ELEMENT)) {
+				
+				RowTemplate rowTemplate =
+							new RowTemplate(rowNode, rowNumber);
+				
+				mt.add(rowTemplate);
+				rowNumber++;
+			}
+		}
+				
+		return mt;
+	}
+
+	/**
+	 * Fills the given context with matrix information for specified project.
+	 * 
+	 * @param context DelegateContext to fill
+	 * @param projectId id of project to fill context for
+	 */
+	public void fillContext(DelegateContext context, String projectId) {
+		
+		context.put("projectId", projectId);
+		context.put("name", projects.getProjectName(projectId));
+		context.put("link", projects.getProjectLink(projectId));
+		
+		fillRowsContext(context, projectId);
+	}
+
+	/**
+	 * Fills the given context with rows informaiton.
+	 * 
+	 * @param context DelegateContext to fill
+	 * @param projectId id of project to fill context for
+	 */
+	private void fillRowsContext(DelegateContext context, String projectId) {
+		
+		for (RowTemplate rowTemplate : rowTemplates) {
+			
+			DelegateContext rowContext = context.next("row");
+			rowTemplate.fillContext(rowContext, projectId);
+		}
+	}
+	
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/MetricTemplate.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/MetricTemplate.java	2006-10-08 22:14:34 UTC (rev 6698)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/MetricTemplate.java	2006-10-09 10:21:38 UTC (rev 6699)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.portlet.templates;
+
+import org.jboss.forge.status.common.Tags;
+import org.jboss.forge.status.service.protocol.PluginValues;
+import org.jboss.forge.status.service.protocol.PluginsValues;
+import org.jboss.forge.common.XmlTools;
+import org.jboss.portal.common.context.DelegateContext;
+
+import org.w3c.dom.Node;
+
+/**
+* @author Pawel Wrzeszcz
+* Holds information about one metric in a cell from project matrix.
+*/
+public class MetricTemplate {
+
+	private String name;
+	private String pluginId;
+	private PluginValues pluginValues;
+	private boolean showAsBoolean;
+	
+	/**
+	 * @param cellNode root Node specfying cell properties
+	 */
+	public MetricTemplate(Node cellNode) {
+		
+		name = XmlTools.getChildNodeValue(cellNode,
+										  Tags.METRIC_NAME_ELEMENT);
+		
+		pluginId = XmlTools.getChildNodeValue(cellNode,
+										  Tags.METRIC_PLUGIN_ELEMENT);
+	
+		String booleanString = XmlTools.getChildNodeValue(cellNode,
+										  Tags.METRIC_BOOLEAN_ELEMENT);
+		
+		showAsBoolean = (booleanString == null) ? false :
+												booleanString.equals("true");	
+	}
+	
+	public void update(PluginsValues pluginsValues) {
+		
+		pluginValues = pluginsValues.getPluginValues(pluginId);
+	}
+
+	/**
+	 * Fills the given context with metric information for specified project.
+	 * 
+	 * @param metricContext DelegateContext to fill
+	 * @param projectId id of project to fill context for
+	 */
+	public void fillContext(DelegateContext metricContext, String projectId) {
+		
+		metricContext.put("name", name);
+		
+		if (pluginValues != null) {
+			
+			if (showAsBoolean) {
+			
+				metricContext.put("value",
+					   (pluginValues.getValue(projectId) == 0) ? "no" : "yes");
+				
+				metricContext.next("hasNotRate");
+				
+			} else {
+			
+				metricContext.put("value",
+							Long.toString(pluginValues.getValue(projectId)));
+				
+				metricContext.put("rate",
+							Integer.toString(pluginValues.getRate(projectId)));
+				
+				metricContext.next("hasRate");
+			}
+		}
+	}
+	
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/RowTemplate.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/RowTemplate.java	2006-10-08 22:14:34 UTC (rev 6698)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/portlet/templates/RowTemplate.java	2006-10-09 10:21:38 UTC (rev 6699)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.portlet.templates;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import org.jboss.forge.common.XmlTools;
+import org.jboss.forge.status.common.Tags;
+import org.jboss.forge.status.service.protocol.PluginsValues;
+import org.jboss.portal.common.context.DelegateContext;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+* @author Pawel Wrzeszcz
+* Holds information about cells from one row in the project matrix.
+*/
+public class RowTemplate {
+
+	/** Cells */
+	private List<CellTemplate> cellTemplates;
+	
+	/** Row name */
+	private String name;
+	
+	/** Row number */
+	private int rowNumber;
+	
+	/**
+	 * @param rowNode root Node specfying row properties
+	 * @param rowNumber
+	 */
+	public RowTemplate(Node rowNode, int rowNumber) {
+		
+		name = XmlTools.getChildNodeValue(rowNode,Tags.ROW_NAME_ELEMENT);
+		this.rowNumber = rowNumber;
+		
+		Node cellsNode = XmlTools.getFirstNodeWithName(rowNode,
+													Tags.CELLS_ELEMENT);	
+		cellTemplates = parseRowTemplate(cellsNode);
+	}
+
+	public void update(PluginsValues pluginsValues) {
+		
+		for (CellTemplate cell : cellTemplates) {
+			
+			cell.update(pluginsValues);
+		}
+	}
+	
+	/**
+	 * Gets cells information from the given Node.
+	 * 
+	 * @param cellsNode root Node specyfying cells
+	 * @return List of cells defined in <code>rowsNode</code>
+	 */
+	private ArrayList<CellTemplate> parseRowTemplate(Node cellsNode) {
+
+		ArrayList<CellTemplate> rt = new ArrayList<CellTemplate>();
+		
+		NodeList rowsList = cellsNode.getChildNodes();
+			
+		for (int i = 0; i < rowsList.getLength(); i++) {
+				
+			Node cellNode = rowsList.item(i);
+			
+			if (cellNode.getNodeName().equals(Tags.CELL_ELEMENT)) {
+			
+				CellTemplate cellTemplate =
+									new CellTemplate(cellNode);
+				rt.add(cellTemplate);
+			}
+		}
+				
+		return rt;
+
+	}
+
+	/**
+	 * Fills the given context with row information for specified project.
+	 * 
+	 * @param rowContext DelegateContext to fill
+	 * @param projectId id of project to fill context for
+	 */
+	public void fillContext(DelegateContext rowContext, String projectId) {
+		
+		rowContext.put("name", name);
+		rowContext.put("number",rowNumber);
+		
+		for (CellTemplate cellTemplate : cellTemplates) {
+			
+			DelegateContext cellContext = rowContext.next("cell");
+			cellTemplate.fillContext(cellContext, projectId);
+		}
+		
+	}
+	
+}

Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/Tools.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/Tools.java	2006-10-08 22:14:34 UTC (rev 6698)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/Tools.java	2006-10-09 10:21:38 UTC (rev 6699)
@@ -11,11 +11,11 @@
 
 import org.apache.xerces.parsers.DOMParser;
 import org.jboss.forge.common.projects.test.Project;
-import org.jboss.forge.status.StatusDescriptor;
-import org.jboss.forge.status.StatusConfWatcher;
 import org.jboss.forge.status.common.Constants;
 import org.jboss.forge.status.common.Tags;
 import org.jboss.forge.status.exceptions.InvalidPluginsConfigurationException;
+import org.jboss.forge.status.portlet.StatusConfWatcher;
+import org.jboss.forge.status.portlet.StatusDescriptor;
 import org.jboss.forge.status.service.impl.protocol.PluginConfImpl;
 import org.jboss.forge.status.service.protocol.PluginConf;
 import org.jboss.forge.status.tools.test.TestProject;




More information about the jboss-svn-commits mailing list