[jboss-svn-commits] JBL Code SVN: r6124 - in labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status: . plugins plugins/math

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Sep 8 11:28:37 EDT 2006


Author: wrzep
Date: 2006-09-08 11:28:32 -0400 (Fri, 08 Sep 2006)
New Revision: 6124

Added:
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/LastNDaysStatusPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/RandomPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/WeightedScorePlugin.java
Removed:
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/LastNDaysStatusPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/RandomPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/WeightedScorePlugin.java
Modified:
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java
Log:
JBLAB-599
'math' package for plugins that are not metrics themselves but provide
basic math operations.

Pawel


Modified: 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-09-08 14:15:01 UTC (rev 6123)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java	2006-09-08 15:28:32 UTC (rev 6124)
@@ -196,7 +196,7 @@
 			col.fillContext(context, projects);
 			
 			colMap.put(col.getId(), context);
-		}
+		} 
 		
 		return colMap;
 	}

Deleted: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/LastNDaysStatusPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/LastNDaysStatusPlugin.java	2006-09-08 14:15:01 UTC (rev 6123)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/LastNDaysStatusPlugin.java	2006-09-08 15:28:32 UTC (rev 6124)
@@ -1,99 +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.plugins;
-
-import java.util.Calendar;
-import java.util.Properties;
-
-import org.jboss.forge.common.projects.Projects;
-import org.jboss.forge.status.common.Tags;
-import org.jboss.forge.status.exceptions.InvalidPluginPropertiesException;
-import org.jboss.forge.status.exceptions.GetScoresException;
-import org.jboss.forge.status.service.ScoresManager;
-import org.jboss.forge.status.tools.Plugins;
-
-/**
-* @author Pawel Wrzeszcz (pawel.wrzeszcz at gmail.com)
-* This plugin measures deltas in other plugin scores in a 7 days time.
-*/
-
-public class LastNDaysStatusPlugin extends Plugin {
-	
-	private Plugin insidePlugin;
-	private int days;
-	
-	@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 insidePluginId = properties.getProperty(Tags.PLUGIN_TAG);
-		if (insidePluginId == null) {
-			throw new InvalidPluginPropertiesException(
-									"Missing \"plugin\" property.");
-		}
-		
-		insidePlugin = plugins.get(insidePluginId);
-		
-		if (insidePlugin == null) {
-			throw new InvalidPluginPropertiesException(
-								"Plugin " + insidePluginId + " not found.");
-		}
-		
-		String daysString = properties.getProperty(Tags.DAYS_TAG);
-		if (daysString == null) {
-			throw new InvalidPluginPropertiesException(
-									"Missing \"days\" property.");
-		}
-		days = Integer.parseInt(daysString);
-		
-		super.init(id, portalName, projects, plugins, properties, scoresManager);
-	}
-
-	@Override
-	public long getValue(String projectId) {
-		
-		long currentValue = insidePlugin.getValue(projectId);
-		long prevValue = 0;
-	
-		Calendar now = Calendar.getInstance();
-		
-		Calendar cal = Calendar.getInstance();
-		cal.add(Calendar.DAY_OF_MONTH,-days);
-		
-		try {
-			prevValue = scoresManager.getValue(
-					insidePlugin.getId(), projectId, cal, now);
-		} catch (GetScoresException e) {
-			return 0;
-		}
-		
-		//return Math.max(currentValue - prevValue, 0);
-		return (currentValue - prevValue); //debug
-	}
-}

Deleted: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/RandomPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/RandomPlugin.java	2006-09-08 14:15:01 UTC (rev 6123)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/RandomPlugin.java	2006-09-08 15:28:32 UTC (rev 6124)
@@ -1,65 +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.plugins;
-
-import java.util.Properties;
-import java.util.Random;
-
-import org.jboss.forge.common.projects.Projects;
-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 at gmail.com)
-*/
-
-public class RandomPlugin extends Plugin {
-	
-	private int maxValue;
-	private Random random;
-	
-	private static final int RANDOM_DEFAULT_MAX_VALUE = 1024;
-	
-	@Override
-	public void init(String id, String portalName, Projects projects,
-			Plugins plugins, Properties properties, ScoresManager scoresManager)
-								throws InvalidPluginPropertiesException {
-		
-		maxValue = RANDOM_DEFAULT_MAX_VALUE;
-		
-		if ((properties != null) && (properties.containsKey("max-value"))) {
-			maxValue = Integer.parseInt(properties.getProperty("max-value"));
-		}
-		
-		random = new Random();
-		
-		super.init(id, portalName, projects, plugins, properties, scoresManager);
-	}
-
-	@Override
-	public long getValue(String projectId) {
-		
-		return random.nextInt(maxValue);
-	}
-}

Deleted: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/WeightedScorePlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/WeightedScorePlugin.java	2006-09-08 14:15:01 UTC (rev 6123)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/WeightedScorePlugin.java	2006-09-08 15:28:32 UTC (rev 6124)
@@ -1,91 +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.plugins;
-
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-import org.jboss.forge.common.projects.Projects;
-import org.jboss.forge.status.exceptions.InvalidPluginPropertiesException;
-import org.jboss.forge.status.service.ScoresManager;
-import org.jboss.forge.status.tools.Plugins;
-
-/**
- * This plugin gets weights from xml configuration file
- * and sumarizes all the stats multiplying them firstly by those weights.
- * 
- * @author Ryszard Kozmik
- * @author Pawel Wrzeszcz (pawel.wrzeszcz at gmail.com)
- *
- */
-public class WeightedScorePlugin extends Plugin {
-	
-	private Map<String,Float> properties;
-	
-	public WeightedScorePlugin() {
-		super();
-	}
-	
-	@Override
-	public void init(String id, String portalName, Projects projects,
-			Plugins plugins, Properties props, ScoresManager scoresManager)
-								throws InvalidPluginPropertiesException {
-		
-		super.init(id, portalName, projects, plugins, props, scoresManager);
-
-		properties = new Hashtable<String,Float>(props.size());
-		
-		for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
-			
-			String key = (String) iter.next();
-			
-			try {
-				Float value = Float.parseFloat(props.getProperty(key));
-				properties.put((String) key,value);
-			} catch (NumberFormatException e) {
-				throw new InvalidPluginPropertiesException(
-						"Incorrect weight format in xml descriptor: "
-						+ props.get(key));
-			}
-		}
-	}
-
-	public long getValue(String projectId) {
-		
-		int total = 0;
-		
-		for (String pluginName : plugins.getPluginIds()) {
-			
-			Plugin plugin = plugins.get(pluginName);
-			
-			if (properties.containsKey(pluginName)) {
-				total += plugin.getValue(projectId)*properties.get(pluginName);
-			}
-		}
-		
-		return total; 
-	}
-	
-}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/LastNDaysStatusPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/LastNDaysStatusPlugin.java	2006-09-08 14:15:01 UTC (rev 6123)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/LastNDaysStatusPlugin.java	2006-09-08 15:28:32 UTC (rev 6124)
@@ -0,0 +1,100 @@
+/*
+ * 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.math;
+
+import java.util.Calendar;
+import java.util.Properties;
+
+import org.jboss.forge.common.projects.Projects;
+import org.jboss.forge.status.common.Tags;
+import org.jboss.forge.status.exceptions.InvalidPluginPropertiesException;
+import org.jboss.forge.status.exceptions.GetScoresException;
+import org.jboss.forge.status.plugins.Plugin;
+import org.jboss.forge.status.service.ScoresManager;
+import org.jboss.forge.status.tools.Plugins;
+
+/**
+* @author Pawel Wrzeszcz (pawel.wrzeszcz at gmail.com)
+* This plugin measures deltas in other plugin scores in a 7 days time.
+*/
+
+public class LastNDaysStatusPlugin extends Plugin {
+	
+	private Plugin insidePlugin;
+	private int days;
+	
+	@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 insidePluginId = properties.getProperty(Tags.PLUGIN_TAG);
+		if (insidePluginId == null) {
+			throw new InvalidPluginPropertiesException(
+									"Missing \"plugin\" property.");
+		}
+		
+		insidePlugin = plugins.get(insidePluginId);
+		
+		if (insidePlugin == null) {
+			throw new InvalidPluginPropertiesException(
+								"Plugin " + insidePluginId + " not found.");
+		}
+		
+		String daysString = properties.getProperty(Tags.DAYS_TAG);
+		if (daysString == null) {
+			throw new InvalidPluginPropertiesException(
+									"Missing \"days\" property.");
+		}
+		days = Integer.parseInt(daysString);
+		
+		super.init(id, portalName, projects, plugins, properties, scoresManager);
+	}
+
+	@Override
+	public long getValue(String projectId) {
+		
+		long currentValue = insidePlugin.getValue(projectId);
+		long prevValue = 0;
+	
+		Calendar now = Calendar.getInstance();
+		
+		Calendar cal = Calendar.getInstance();
+		cal.add(Calendar.DAY_OF_MONTH,-days);
+		
+		try {
+			prevValue = scoresManager.getValue(
+					insidePlugin.getId(), projectId, cal, now);
+		} catch (GetScoresException e) {
+			return 0;
+		}
+		
+		//return Math.max(currentValue - prevValue, 0);
+		return (currentValue - prevValue); //debug
+	}
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/RandomPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/RandomPlugin.java	2006-09-08 14:15:01 UTC (rev 6123)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/RandomPlugin.java	2006-09-08 15:28:32 UTC (rev 6124)
@@ -0,0 +1,66 @@
+/*
+ * 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.math;
+
+import java.util.Properties;
+import java.util.Random;
+
+import org.jboss.forge.common.projects.Projects;
+import org.jboss.forge.status.exceptions.InvalidPluginPropertiesException;
+import org.jboss.forge.status.plugins.Plugin;
+import org.jboss.forge.status.service.ScoresManager;
+import org.jboss.forge.status.tools.Plugins;
+
+/**
+* @author Pawel Wrzeszcz (pawel.wrzeszcz at gmail.com)
+*/
+
+public class RandomPlugin extends Plugin {
+	
+	private int maxValue;
+	private Random random;
+	
+	private static final int RANDOM_DEFAULT_MAX_VALUE = 1024;
+	
+	@Override
+	public void init(String id, String portalName, Projects projects,
+			Plugins plugins, Properties properties, ScoresManager scoresManager)
+								throws InvalidPluginPropertiesException {
+		
+		maxValue = RANDOM_DEFAULT_MAX_VALUE;
+		
+		if ((properties != null) && (properties.containsKey("max-value"))) {
+			maxValue = Integer.parseInt(properties.getProperty("max-value"));
+		}
+		
+		random = new Random();
+		
+		super.init(id, portalName, projects, plugins, properties, scoresManager);
+	}
+
+	@Override
+	public long getValue(String projectId) {
+		
+		return random.nextInt(maxValue);
+	}
+}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/WeightedScorePlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/WeightedScorePlugin.java	2006-09-08 14:15:01 UTC (rev 6123)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/WeightedScorePlugin.java	2006-09-08 15:28:32 UTC (rev 6124)
@@ -0,0 +1,92 @@
+/*
+ * 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.math;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import org.jboss.forge.common.projects.Projects;
+import org.jboss.forge.status.exceptions.InvalidPluginPropertiesException;
+import org.jboss.forge.status.plugins.Plugin;
+import org.jboss.forge.status.service.ScoresManager;
+import org.jboss.forge.status.tools.Plugins;
+
+/**
+ * This plugin gets weights from xml configuration file
+ * and sumarizes all the stats multiplying them firstly by those weights.
+ * 
+ * @author Ryszard Kozmik
+ * @author Pawel Wrzeszcz (pawel.wrzeszcz at gmail.com)
+ *
+ */
+public class WeightedScorePlugin extends Plugin {
+	
+	private Map<String,Float> properties;
+	
+	public WeightedScorePlugin() {
+		super();
+	}
+	
+	@Override
+	public void init(String id, String portalName, Projects projects,
+			Plugins plugins, Properties props, ScoresManager scoresManager)
+								throws InvalidPluginPropertiesException {
+		
+		super.init(id, portalName, projects, plugins, props, scoresManager);
+
+		properties = new Hashtable<String,Float>(props.size());
+		
+		for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
+			
+			String key = (String) iter.next();
+			
+			try {
+				Float value = Float.parseFloat(props.getProperty(key));
+				properties.put((String) key,value);
+			} catch (NumberFormatException e) {
+				throw new InvalidPluginPropertiesException(
+						"Incorrect weight format in xml descriptor: "
+						+ props.get(key));
+			}
+		}
+	}
+
+	public long getValue(String projectId) {
+		
+		int total = 0;
+		
+		for (String pluginName : plugins.getPluginIds()) {
+			
+			Plugin plugin = plugins.get(pluginName);
+			
+			if (properties.containsKey(pluginName)) {
+				total += plugin.getValue(projectId)*properties.get(pluginName);
+			}
+		}
+		
+		return total; 
+	}
+	
+}




More information about the jboss-svn-commits mailing list