[jboss-svn-commits] JBL Code SVN: r6346 - in labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status: common plugins plugins/codelines plugins/productization plugins/productization/docs plugins/productization/forums plugins/productization/support tools

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Sep 21 15:10:33 EDT 2006


Author: wrzep
Date: 2006-09-21 15:10:24 -0400 (Thu, 21 Sep 2006)
New Revision: 6346

Added:
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/ProductizationPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/docs/
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/docs/DifferentDocumentationSourcesPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/docs/DocumentationPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/docs/DocumentationTypePlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/forums/
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/forums/DifferentForumsPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/forums/ForumTypePlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/forums/ForumsPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/support/
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/support/DifferentSupportServicesPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/support/SupportServicesPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/support/SupportTypePlugin.java
Modified:
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/common/Constants.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/common/Tags.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/Tools.java
Log:
http://jira.jboss.org/jira/browse/JBLAB-756
docs, forums and support availability metrics

Pawel


Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/common/Constants.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/common/Constants.java	2006-09-21 17:19:36 UTC (rev 6345)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/common/Constants.java	2006-09-21 19:10:24 UTC (rev 6346)
@@ -22,8 +22,8 @@
 
 	public static final long DEFAULT_PLUGIN_VALUE		 = 0;
 
-	public static final long CACHE_INTERVAL 			= 15*60*1000; /* milliseconds */
-						   /* Check for new scores every 15 minutes */
+	public static final long CACHE_INTERVAL 			= 3*60*1000; /* milliseconds */
+						   /* Check for new scores every 3 minutes */
 	
 	public static final long SCORES_UPDATE_INTERVAL  = 4*60*60*1000; /* milliseconds */
 	 								  /* Perform update every 4 hours */

Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/common/Tags.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/common/Tags.java	2006-09-21 17:19:36 UTC (rev 6345)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/common/Tags.java	2006-09-21 19:10:24 UTC (rev 6346)
@@ -63,22 +63,28 @@
 	/* plugins.xml tags */
 	
 		/* plugin element*/
-	public final static String PLUGIN_ELEMENT				= "plugin";
+	public final static String PLUGIN_ELEMENT					= "plugin";
 	
-	public final static String PLUGIN_ID_ELEMENT 			= "id";
+	public final static String PLUGIN_ID_ELEMENT 				= "id";
 	public final static String PLUGIN_CLASS_ELEMENT 			= "class";
-	public final static String PLUGIN_PROPERTIES_ELEMENT 	= "properties";
+	public final static String PLUGIN_PROPERTIES_ELEMENT 		= "properties";
 	
 		/* kosmos plugins */
-	public static final String JIRA_SERVICE_PROPERTY 		= "jira-service";
+	public static final String JIRA_SERVICE_PROPERTY 			= "jira-service";
 	public static final String SVN_SERVICE_PROPERTY			= "svn-service";
 	public static final String CC_SERVICE_PROPERTY 			= "cc-service";
 	
-	public static final String CC_ADRESS_TAG 				= "cc-address";
+	public static final String CC_ADRESS_TAG 					= "cc-address";
 	
+		/* productization plugins */
+	public static final String FORUM_TYPE_TAG 				= "forum-type";
+	public static final String DOC_TYPE_TAG 					= "doc-type";
+	public static final String SUPPORT_TYPE_TAG = "support-type";
+	
 		/* other plugins */
 	public static final String DAYS_TAG						= "days";
 	public static final String PLUGIN_TAG 					= "plugin";
+	
 
 	/**
 	 * This class cannot be instatiated.

Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java	2006-09-21 17:19:36 UTC (rev 6345)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java	2006-09-21 19:10:24 UTC (rev 6346)
@@ -123,7 +123,7 @@
 	 * @see org.jboss.forge.status.Plugin#getValue(java.lang.String)
 	 */
 	@Override
-	public long getPluginValue(String projectId) {
+	protected long getPluginValue(String projectId) {
 		
 		if (!projectServices.containsKey(projectId)) {
 			projectServices.put(projectId, getProjectServices(projectId));

Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesPlugin.java	2006-09-21 17:19:36 UTC (rev 6345)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesPlugin.java	2006-09-21 19:10:24 UTC (rev 6346)
@@ -78,7 +78,7 @@
 				cl = getPluginValue(url, userName, password);
 				
 				log.info("Project: " + projectId  + " plugin: " + id + 
-															"score: " + cl);
+															" score: " + cl);
 				
 				cachedValues.put(projectId, new Long(cl));
 			}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/ProductizationPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/ProductizationPlugin.java	2006-09-21 17:19:36 UTC (rev 6345)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/ProductizationPlugin.java	2006-09-21 19:10:24 UTC (rev 6346)
@@ -0,0 +1,43 @@
+
+/*
+ * 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.plugins.productization;
+
+import org.jboss.forge.common.projects.test.Project;
+
+import org.jboss.forge.status.plugins.Plugin;
+import org.jboss.forge.status.tools.Tools;
+
+
+/**
+ * @author Pawel Wrzeszcz (pawel . wrzeszcz @ jboss . com)
+ * 
+ * Superclass for plugins providing productization metrics.
+ */
+public abstract class ProductizationPlugin extends Plugin {
+
+	protected Project getProject(String projectId) {
+		
+		return Tools.getProject(projectId);
+	}
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/docs/DifferentDocumentationSourcesPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/docs/DifferentDocumentationSourcesPlugin.java	2006-09-21 17:19:36 UTC (rev 6345)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/docs/DifferentDocumentationSourcesPlugin.java	2006-09-21 19:10:24 UTC (rev 6346)
@@ -0,0 +1,58 @@
+
+/*
+ * 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.plugins.productization.docs;
+
+import java.util.EnumSet;
+import java.util.List;
+import org.jboss.forge.common.projects.test.Documentation;
+import org.jboss.forge.common.projects.test.DocumentationType;
+
+
+/**
+ * @author Pawel Wrzeszcz (pawel . wrzeszcz @ jboss . com)
+ * 
+ * Evaluates number of different documentation types available for project.
+ */
+public class DifferentDocumentationSourcesPlugin extends DocumentationPlugin {
+
+	@Override
+	protected long getPluginValue(String projectId) {
+		
+		List<Documentation> docs = getDocumentation(projectId);
+		
+		if (docs == null) {
+			return 0;
+		}
+		
+		EnumSet<DocumentationType> docTypes =
+									EnumSet.noneOf(DocumentationType.class);
+		
+		for (Documentation d : docs) {
+			
+			docTypes.add(d.getType());
+		}
+		
+		return docTypes.size();
+	}
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/docs/DocumentationPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/docs/DocumentationPlugin.java	2006-09-21 17:19:36 UTC (rev 6345)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/docs/DocumentationPlugin.java	2006-09-21 19:10:24 UTC (rev 6346)
@@ -0,0 +1,47 @@
+
+/*
+ * 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.plugins.productization.docs;
+
+import java.util.List;
+
+import org.jboss.forge.common.projects.test.Documentation;
+import org.jboss.forge.common.projects.test.Project;
+import org.jboss.forge.status.plugins.productization.ProductizationPlugin;
+
+/**
+ * @author Pawel Wrzeszcz (pawel . wrzeszcz @ jboss . com)
+ */
+public abstract class DocumentationPlugin extends ProductizationPlugin {
+
+	protected List<Documentation> getDocumentation(String projectId) {
+		
+		Project project = getProject(projectId);
+		
+		if (project == null) {
+			return null;
+		}
+		
+		return project.getDocumentation();
+	}	
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/docs/DocumentationTypePlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/docs/DocumentationTypePlugin.java	2006-09-21 17:19:36 UTC (rev 6345)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/docs/DocumentationTypePlugin.java	2006-09-21 19:10:24 UTC (rev 6346)
@@ -0,0 +1,110 @@
+
+/*
+ * 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.plugins.productization.docs;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.jboss.forge.common.projects.Projects;
+import org.jboss.forge.common.projects.test.Documentation;
+import org.jboss.forge.common.projects.test.DocumentationType;
+
+import org.jboss.forge.status.common.Tags;
+import org.jboss.forge.status.exceptions.InvalidPluginPropertiesException;
+import org.jboss.forge.status.service.ScoresManager;
+import org.jboss.forge.status.tools.Plugins;
+
+
+/**
+ * @author Pawel Wrzeszcz (pawel . wrzeszcz @ jboss . com)
+ */
+public class DocumentationTypePlugin extends DocumentationPlugin {
+
+	
+	private DocumentationType docType;
+	
+	@Override
+	public void init(String id, String portalName, Projects projects,
+			Plugins plugins, Properties properties, ScoresManager scoresManager)
+								throws InvalidPluginPropertiesException {
+		
+		if (properties == null) {
+			throw new InvalidPluginPropertiesException(
+												"Missing plugin property.");
+		}
+		
+		String docTypeString = properties.getProperty(Tags.DOC_TYPE_TAG);
+		if (docTypeString == null) {
+			throw new InvalidPluginPropertiesException(
+							"Missing " + Tags.DOC_TYPE_TAG + " property.");
+		}
+		
+		docType = getDocType(docTypeString);
+		if (docType == null) {
+			throw new InvalidPluginPropertiesException(
+						"No such decumentation type: " + docTypeString + ".");
+		}
+				
+		super.init(id, portalName, projects, plugins, properties, scoresManager);
+	}
+
+	
+	@Override
+	protected long getPluginValue(String projectId) {
+		
+		List<Documentation> docs = getDocumentation(projectId);
+		
+		if (docs == null) {
+			return 0;
+		}
+		
+		int counter = 0;
+		
+		for (Documentation d : docs) {
+			
+			if (d.getType().equals(docType)) {
+				counter++;
+			}
+		}
+		
+		return counter;
+	}
+
+
+	private DocumentationType getDocType(String docTypeString) {
+		
+		DocumentationType docType = null;
+		
+		try {
+		
+			docType = DocumentationType.fromValue(docTypeString);
+			
+		} catch (IllegalArgumentException e) {
+			
+			// Do nothing
+		}
+		
+		return docType;
+	}
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/forums/DifferentForumsPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/forums/DifferentForumsPlugin.java	2006-09-21 17:19:36 UTC (rev 6345)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/forums/DifferentForumsPlugin.java	2006-09-21 19:10:24 UTC (rev 6346)
@@ -0,0 +1,57 @@
+
+/*
+ * 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.plugins.productization.forums;
+
+import java.util.EnumSet;
+import java.util.List;
+
+import org.jboss.forge.common.projects.test.Forum;
+import org.jboss.forge.common.projects.test.ForumType;
+
+/**
+ * @author Pawel Wrzeszcz (pawel . wrzeszcz @ jboss . com)
+ * 
+ * Evaluates number of different forum types available for project.
+ */
+public class DifferentForumsPlugin extends ForumsPlugin {
+
+	@Override
+	protected long getPluginValue(String projectId) {
+		
+		List<Forum> forums = getForums(projectId);
+		
+		if (forums == null) {
+			return 0;
+		}
+		
+		EnumSet<ForumType> forumTypes = EnumSet.noneOf(ForumType.class);
+		
+		for (Forum f : forums) {
+			
+			forumTypes.add(f.getType());
+		}
+		
+		return forumTypes.size();
+	}
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/forums/ForumTypePlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/forums/ForumTypePlugin.java	2006-09-21 17:19:36 UTC (rev 6345)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/forums/ForumTypePlugin.java	2006-09-21 19:10:24 UTC (rev 6346)
@@ -0,0 +1,109 @@
+
+/*
+ * 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.plugins.productization.forums;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.jboss.forge.common.projects.Projects;
+import org.jboss.forge.common.projects.test.Forum;
+import org.jboss.forge.common.projects.test.ForumType;
+import org.jboss.forge.status.common.Tags;
+import org.jboss.forge.status.exceptions.InvalidPluginPropertiesException;
+import org.jboss.forge.status.service.ScoresManager;
+import org.jboss.forge.status.tools.Plugins;
+
+
+/**
+ * @author Pawel Wrzeszcz (pawel . wrzeszcz @ jboss . com)
+ */
+public class ForumTypePlugin extends ForumsPlugin {
+
+	
+	private ForumType forumType;
+	
+	@Override
+	public void init(String id, String portalName, Projects projects,
+			Plugins plugins, Properties properties, ScoresManager scoresManager)
+								throws InvalidPluginPropertiesException {
+		
+		if (properties == null) {
+			throw new InvalidPluginPropertiesException(
+												"Missing plugin property.");
+		}
+		
+		String forumTypeString = properties.getProperty(Tags.FORUM_TYPE_TAG);
+		if (forumTypeString == null) {
+			throw new InvalidPluginPropertiesException(
+							"Missing " + Tags.FORUM_TYPE_TAG + " property.");
+		}
+		
+		forumType = getForumType(forumTypeString);
+		if (forumType == null) {
+			throw new InvalidPluginPropertiesException(
+							"No such forum type: " + forumTypeString + ".");
+		}
+				
+		super.init(id, portalName, projects, plugins, properties, scoresManager);
+	}
+
+	
+	@Override
+	protected long getPluginValue(String projectId) {
+		
+		List<Forum> forums = getForums(projectId);
+		
+		if (forums == null) {
+			return 0;
+		}
+		
+		int counter = 0;
+		
+		for (Forum f : forums) {
+			
+			if (f.getType().equals(forumType)) {
+				counter++;
+			}
+		}
+		
+		return counter;
+	}
+
+
+	private ForumType getForumType(String forumTypeString) {
+		
+		ForumType forumType = null;
+		
+		try {
+		
+			forumType = ForumType.fromValue(forumTypeString);
+			
+		} catch (IllegalArgumentException e) {
+			
+			// Do nothing
+		}
+		
+		return forumType;
+	}
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/forums/ForumsPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/forums/ForumsPlugin.java	2006-09-21 17:19:36 UTC (rev 6345)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/forums/ForumsPlugin.java	2006-09-21 19:10:24 UTC (rev 6346)
@@ -0,0 +1,47 @@
+
+/*
+ * 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.plugins.productization.forums;
+
+import java.util.List;
+
+import org.jboss.forge.common.projects.test.Forum;
+import org.jboss.forge.common.projects.test.Project;
+import org.jboss.forge.status.plugins.productization.ProductizationPlugin;
+
+/**
+ * @author Pawel Wrzeszcz (pawel . wrzeszcz @ jboss . com)
+ */
+public abstract class ForumsPlugin extends ProductizationPlugin {
+
+	protected List<Forum> getForums(String projectId) {
+		
+		Project project = getProject(projectId);
+		
+		if (project == null) {
+			return null;
+		}
+		
+		return project.getForums();
+	}
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/support/DifferentSupportServicesPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/support/DifferentSupportServicesPlugin.java	2006-09-21 17:19:36 UTC (rev 6345)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/support/DifferentSupportServicesPlugin.java	2006-09-21 19:10:24 UTC (rev 6346)
@@ -0,0 +1,57 @@
+
+/*
+ * 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.plugins.productization.support;
+
+import java.util.EnumSet;
+import java.util.List;
+
+import org.jboss.forge.common.projects.test.SupportService;
+import org.jboss.forge.common.projects.test.SupportType;
+
+/**
+ * @author Pawel Wrzeszcz (pawel . wrzeszcz @ jboss . com)
+ * 
+ * Evaluates number of different support service types available for project.
+ */
+public class DifferentSupportServicesPlugin extends SupportServicesPlugin {
+
+	@Override
+	protected long getPluginValue(String projectId) {
+		
+		List<SupportService> supportServices = getSupportServices(projectId);
+		
+		if (supportServices == null) {
+			return 0;
+		}
+		
+		EnumSet<SupportType> supportTypes = EnumSet.noneOf(SupportType.class);
+		
+		for (SupportService s : supportServices) {
+			
+			supportTypes.add(s.getType());
+		}
+		
+		return supportTypes.size();
+	}
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/support/SupportServicesPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/support/SupportServicesPlugin.java	2006-09-21 17:19:36 UTC (rev 6345)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/support/SupportServicesPlugin.java	2006-09-21 19:10:24 UTC (rev 6346)
@@ -0,0 +1,48 @@
+
+/*
+ * 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.plugins.productization.support;
+
+import java.util.List;
+
+import org.jboss.forge.common.projects.test.Project;
+import org.jboss.forge.common.projects.test.SupportService;
+
+import org.jboss.forge.status.plugins.productization.ProductizationPlugin;
+
+/**
+ * @author Pawel Wrzeszcz (pawel . wrzeszcz @ jboss . com)
+ */
+public abstract class SupportServicesPlugin extends ProductizationPlugin {
+
+	protected List<SupportService> getSupportServices(String projectId) {
+		
+		Project project = getProject(projectId);
+		
+		if (project == null) {
+			return null;
+		}
+		
+		return project.getSupportServices();
+	}
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/support/SupportTypePlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/support/SupportTypePlugin.java	2006-09-21 17:19:36 UTC (rev 6345)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/productization/support/SupportTypePlugin.java	2006-09-21 19:10:24 UTC (rev 6346)
@@ -0,0 +1,110 @@
+
+/*
+ * 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.plugins.productization.support;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.jboss.forge.common.projects.Projects;
+import org.jboss.forge.common.projects.test.SupportService;
+import org.jboss.forge.common.projects.test.SupportType;
+
+import org.jboss.forge.status.common.Tags;
+import org.jboss.forge.status.exceptions.InvalidPluginPropertiesException;
+import org.jboss.forge.status.service.ScoresManager;
+import org.jboss.forge.status.tools.Plugins;
+
+
+/**
+ * @author Pawel Wrzeszcz (pawel . wrzeszcz @ jboss . com)
+ */
+public class SupportTypePlugin extends SupportServicesPlugin {
+
+	
+	private SupportType supportType;
+	
+	@Override
+	public void init(String id, String portalName, Projects projects,
+			Plugins plugins, Properties properties, ScoresManager scoresManager)
+								throws InvalidPluginPropertiesException {
+		
+		if (properties == null) {
+			throw new InvalidPluginPropertiesException(
+												"Missing plugin property.");
+		}
+		
+		String supportTypeString = properties.getProperty(Tags.SUPPORT_TYPE_TAG);
+		if (supportTypeString == null) {
+			throw new InvalidPluginPropertiesException(
+							"Missing " + Tags.SUPPORT_TYPE_TAG + " property.");
+		}
+		
+		supportType = getSupportType(supportTypeString);
+		if (supportType == null) {
+			throw new InvalidPluginPropertiesException(
+							"No such support type: " + supportTypeString + ".");
+		}
+				
+		super.init(id, portalName, projects, plugins, properties, scoresManager);
+	}
+
+	
+	@Override
+	protected long getPluginValue(String projectId) {
+		
+		List<SupportService> supportServices = getSupportServices(projectId);
+		
+		if (supportServices == null) {
+			return 0;
+		}
+		
+		int counter = 0;
+		
+		for (SupportService s : supportServices) {
+			
+			if (s.getType().equals(supportType)) {
+				counter++;
+			}
+		}
+		
+		return counter;
+	}
+
+
+	private SupportType getSupportType(String supportTypeString) {
+		
+		SupportType supportType = null;
+		
+		try {
+		
+			supportType = SupportType.fromValue(supportTypeString);
+			
+		} catch (IllegalArgumentException e) {
+			
+			// Do nothing
+		}
+		
+		return supportType;
+	}
+}

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-09-21 17:19:36 UTC (rev 6345)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/Tools.java	2006-09-21 19:10:24 UTC (rev 6346)
@@ -38,6 +38,7 @@
 	private static Logger log = Logger.getLogger(Tools.class);
 	
 	public static synchronized StatusDescriptor getDesc(final String portalName) {
+		
 		return conf.get(portalName);
 	}
 	
@@ -47,7 +48,6 @@
 		cal.set(Calendar.MINUTE, 0);
 		cal.set(Calendar.SECOND, 0);
 		cal.set(Calendar.MILLISECOND, 0);
-		
 	}
 
 	public static List<String> getCommaSeparatedStrings(String s) {




More information about the jboss-svn-commits mailing list