Author: wrzep Date: 2006-04-21 13:14:54 -0400 (Fri, 21 Apr 2006) New Revision: 3890 Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/PluginConfImpl.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/PluginValuesImpl.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/PluginsValuesImpl.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/ScoresServiceImpl.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/PluginConf.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/PluginValues.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/PluginsValues.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/ScoresService.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/ScoresServiceLocal.java Removed: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresService.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceImpl.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceLocal.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/PluginConf.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/PluginValues.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/PluginsValues.java 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/templates/CellTemplate.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/Column.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/Columns.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/MatrixTemplate.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/MetricTemplate.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/RowTemplate.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/Plugins.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ProjectsByScoreComparator.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManager.java Log: JBLAB-599 more flexible ejb3 service based on interfaces instead of fixed classes 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-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -39,11 +39,12 @@ import org.jboss.forge.status.exceptions.InvalidPluginsConfigurationException; import org.jboss.forge.status.exceptions.GetScoresException; import org.jboss.forge.status.exceptions.ScoresSaveException; +import org.jboss.forge.status.service.impl.PluginConfImpl; +import org.jboss.forge.status.service.model.PluginConf; +import org.jboss.forge.status.service.model.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.PluginConf; -import org.jboss.forge.status.tools.PluginsValues; import org.jboss.forge.status.tools.ScoresManager; import org.jboss.forge.status.tools.Tags; @@ -137,7 +138,7 @@ } try { - PluginConf pluginConf = new PluginConf(pluginNode); + PluginConfImpl pluginConf = new PluginConfImpl(pluginNode); pluginsConfList.add(pluginConf); } catch (InvalidPluginsConfigurationException e) { log.warn(e); Deleted: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresService.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresService.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresService.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -1,49 +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.service; - -import java.util.Date; -import java.util.List; - -import org.jboss.forge.common.projects.Projects; -import org.jboss.forge.status.exceptions.GetScoresException; -import org.jboss.forge.status.exceptions.ScoresSaveException; -import org.jboss.forge.status.tools.PluginConf; -import org.jboss.forge.status.tools.PluginValues; -import org.jboss.forge.status.tools.PluginsValues; - - -/** -* @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com) -*/ -public interface ScoresService { - - public PluginsValues getPluginsValues(String portalName, - Date date) throws GetScoresException; - - public void save(Projects projects, List<PluginConf> pluginsConf, - String portalName) throws ScoresSaveException; - - public PluginValues get(String portalName, String pluginId, Date date) - throws GetScoresException; -} \ No newline at end of file Deleted: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceImpl.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceImpl.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceImpl.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -1,341 +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.service; - -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.OutputStream; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.ejb.Local; - -import org.jboss.annotation.ejb.LocalBinding; -import org.jboss.annotation.ejb.Management; -import org.jboss.annotation.ejb.Service; - -import org.jboss.forge.common.projects.Projects; - -import org.jboss.forge.status.exceptions.GetScoresException; -import org.jboss.forge.status.exceptions.ScoresSaveException; -import org.jboss.forge.status.tools.PluginConf; -import org.jboss.forge.status.tools.PluginValues; -import org.jboss.forge.status.tools.Plugins; -import org.jboss.forge.status.tools.PluginsValues; -import org.jboss.forge.status.tools.Tools; - -import org.jboss.logging.Logger; -import org.jboss.shotoku.ContentManager; -import org.jboss.shotoku.Directory; -import org.jboss.shotoku.Node; -import org.jboss.shotoku.aop.Inject; -import org.jboss.shotoku.exceptions.RepositoryException; -import org.jboss.shotoku.exceptions.ResourceDoesNotExist; -import org.jboss.shotoku.exceptions.SaveException; - -/** -* @author Pawel Wrzeszcz (paw...@gm...) -*/ - -@Service(objectName=Tools.STATUS_SERVICE_NAME) -@Management(ScoresService.class) -@Local(ScoresServiceLocal.class) -@LocalBinding(jndiBinding="Status/ScoresService") -public class ScoresServiceImpl implements ScoresService, ScoresServiceLocal { - - private static Logger log = Logger.getLogger(ScoresServiceImpl.class); - - private Map<String,PluginsValues> values = new HashMap<String,PluginsValues>(); - - @Inject - private ContentManager cm; - - /** - * Saves current plugin values. - * - * @param projects Projects for which plugin values will be saved - * @param plugins Plugins for which values will be saved - * @param portalName - * @return true iff saving was successful - */ - public void save(Projects projects, List<PluginConf> pluginsConf, - String portalName) throws ScoresSaveException { - - // Get plugins from conf - Plugins plugins = new Plugins(pluginsConf, portalName, projects); - - // Get directory where we store historical scores - Directory rootDir = cm.getRootDirectory(); - String dirName = Tools.getShotokuStatusPath(portalName); - Directory dir = getDir(rootDir, dirName); - - // Get plugin values and save them in proper node - PluginsValues pluginsValues = new PluginsValues(projects, plugins); - - // Get node to store scores - String nodeName = getCurrentNodeName(); - Node node = null; - - try { - node = dir.getNode(nodeName); - } catch (RepositoryException e) { - log.error("Error while getting shotoku node: " + - dir.getFullName() + "/" + nodeName, e); - throw new ScoresSaveException(e); - } catch (ResourceDoesNotExist e) { - node = createNode(dir, nodeName); - } - - // Save values and store then in cache - values.put(getCurrentNodeName(), pluginsValues); - save(node, pluginsValues); - } - - /** - * Saves plugins values in the given Directory. - * - * @param dir Directory to save values - * @param pluginsValues PluginsValues to save - * @return true iff saving was successful - */ - private boolean save(Node node, PluginsValues pluginsValues) { - - try { - OutputStream os = node.getOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(os); - oos.writeObject((PluginsValues) pluginsValues); - oos.close(); - node.save("update"); /* os is closed inside save() */ - } catch (IOException e) { - e.printStackTrace();//TODO error messages - return false; - } catch (RepositoryException e) { - e.printStackTrace(); - return false; - } catch (SaveException e) { - e.printStackTrace(); - return false; - } - - return true; - } - - /** - * Returns historical scores from the given <code>date</code> in the past. - * - * Notice that only year, month and day matter in passed dates. - * - * @return scores from the given date - * @throws GetScoresException - */ - public PluginsValues getPluginsValues(String portalName, Date date) - throws GetScoresException { - - // null date means today - if (date == null) { - Calendar cal = Calendar.getInstance(); - date = cal.getTime(); - } - - String key = getNodeName(date); - PluginsValues v = values.get(key); - - if (v == null) { // Not in cache => get value and store it - - Directory rootDir = cm.getRootDirectory(); - - Directory dir; - try { - dir = rootDir.getDirectory(Tools.getShotokuStatusPath(portalName)); - } catch (RepositoryException e) { - throw new GetScoresException(e); - } catch (ResourceDoesNotExist e) { - throw new GetScoresException(e); - } - - if (dir != null) { - v = getPluginsValues(dir, date); - values.put(key,v); - } - } - - return v; - } - - /** - * Returns historical scores from the specified directory. - * - * @param dir Directory to read scores from - * @return - * @throws GetScoresException - */ - private PluginsValues getPluginsValues(Directory dir, Date date) - throws GetScoresException { - - // Get appropriate node - Node node = null; - String nodeName = getNodeName(date); - - try { - node = dir.getNode(nodeName); - } catch (Exception e) { - log.error("Error while getting shotoku node " + - dir.getFullName() + "/" + nodeName); - throw new GetScoresException(e); - } - - // Restore values - PluginsValues values = null; - try { - InputStream is = node.getContentInputStream(); - ObjectInputStream ois = new ObjectInputStream(is); - values = (PluginsValues) ois.readObject(); - ois.close(); - is.close(); - } catch (Exception e) { - log.error("Error while restoring scores from shotoku node " + - dir.getFullName() + "/" + nodeName); - throw new GetScoresException(e); - } - - return values; - } - - /** - * Creates new shotoku Node. - * - * @param dir Directory in which new Node will be created - * @param nodeName name of new Node - * @return Node - * @throws ScoresSaveException - */ - private Node createNode(Directory dir, String nodeName) - throws ScoresSaveException { - - Node node = null; - - try { - node = dir.newNode(nodeName); - node.save("create"); - } catch (Exception e) { - log.error("Error while creating shotoku node: " + - dir.getFullName() + "/" + nodeName, e); - throw new ScoresSaveException(e); - } - - return node; - } - - /** - * Gets shotoku Directory with name <code>dirName</code> - * from specified shotoku Directory. - * If requested Directory does not exist it is created. - * - * @param rootDir Directory where search will be performed - * @param dirName name of searched Directory - * @return Directory with the given name - * or null when creating Directory failed. - * @throws ScoresSaveException - */ - private Directory getDir(Directory rootDir, String dirName) - throws ScoresSaveException { - - Directory dir = null; - - try { - dir = rootDir.getDirectory(dirName); - } catch (RepositoryException e) { - log.error("Error while getting shotoku directory " + - rootDir.getFullName() + "/" + dirName); - throw new ScoresSaveException(e); - } catch (ResourceDoesNotExist e) { - dir = createDir(rootDir, dirName); - } - - return dir; - } - - /** - * Creates new shotoku Directory. - * - * @param rootDir Directory in which new subdirectory will be created - * @param dirName name of new Directory - * @return Directory or null if errors occured - * @throws ScoresSaveException - */ - private Directory createDir(Directory rootDir, String dirName) - throws ScoresSaveException { - - Directory dir = null; - - try { - dir = rootDir.newDirectory(dirName); - dir.save("create"); - } catch (Exception e) { - log.error("Error while creating shotoku directory: " + - rootDir.getFullName() + "/" + dirName, e); - throw new ScoresSaveException(e); - } - - return dir; - } - - /** - * Gets name of Node containing saved data from specified datestamp. - * Notice that only year, month and day matter in passed <code>date</code>. - * - * @param date datestamp - * @return Node name - */ - private String getNodeName(Date date) { - - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - - return df.format(date); - } - - /** - * @return name of Node containging data saved today - */ - private String getCurrentNodeName() { - - Calendar cal = Calendar.getInstance(); - Date today = cal.getTime(); - - return getNodeName(today); - } - - public PluginValues get(String portalName, String pluginId, Date date) - throws GetScoresException { - - PluginsValues pv = getPluginsValues(portalName, date); - return pv.getPluginValues(pluginId); - } - -} Deleted: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceLocal.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceLocal.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceLocal.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -1,48 +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.service; - -import java.util.Date; -import java.util.List; - -import org.jboss.forge.common.projects.Projects; -import org.jboss.forge.status.exceptions.GetScoresException; -import org.jboss.forge.status.exceptions.ScoresSaveException; -import org.jboss.forge.status.tools.PluginConf; -import org.jboss.forge.status.tools.PluginValues; -import org.jboss.forge.status.tools.PluginsValues; - -/** -* @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com) -*/ -public interface ScoresServiceLocal { - - public PluginsValues getPluginsValues(String portalName, - Date date) throws GetScoresException; - - public void save(Projects projects, List<PluginConf> pluginsConf, - String portalName) throws ScoresSaveException; - - public PluginValues get(String portalName, String pluginId, Date date) - throws GetScoresException; -} \ No newline at end of file Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/PluginConfImpl.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/PluginConfImpl.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/PluginConfImpl.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -0,0 +1,114 @@ +/* + * 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.service.impl; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.jboss.forge.common.XmlTools; +import org.jboss.forge.status.exceptions.InvalidPluginsConfigurationException; +import org.jboss.forge.status.service.model.PluginConf; +import org.jboss.forge.status.tools.Tags; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** +* @author Pawel Wrzeszcz +*/ +public class PluginConfImpl implements PluginConf { + + private static final long serialVersionUID = 8598887068548048511L; + + private Map<String,String> fields = new HashMap<String,String>(); + private Properties properties = new Properties(); + + public PluginConfImpl(Node pluginNode) + throws InvalidPluginsConfigurationException { + + // Parse plugin configuration + parseField(pluginNode, Tags.PLUGIN_ID_ELEMENT); + parseField(pluginNode, Tags.PLUGIN_CLASS_ELEMENT); + + // Parse plugin properties + Node pluginPropertiesNode = + XmlTools.getFirstNodeWithName(pluginNode, + Tags.PLUGIN_PROPERTIES_ELEMENT); + addPluginProperties(pluginPropertiesNode); + } + + public String getFieldValue(String fieldName) { + return fields.get(fieldName); + } + + public Properties getProperties() { + return properties; + } + + private void parseField(Node pluginNode, String fieldName) + throws InvalidPluginsConfigurationException { + + String fieldValue = + XmlTools.getChildNodeValue(pluginNode, fieldName); + + if (fieldValue == null) { + throw new InvalidPluginsConfigurationException( + "Missing field: " + fieldName); + } + + fields.put(fieldName, fieldValue); + } + + /** + * Computes plugin properites from given properties Node. + * + * @param propertiesNode Node containging plugin properties + * @return plugin properties or null if properties are not specified + */ + private void addPluginProperties(Node propertiesNode) { + + if (propertiesNode == null) { + return; + } + + NodeList nodes = propertiesNode.getChildNodes(); + + for (int i = 0; i < nodes.getLength(); i++) { + Node node = nodes.item(i); + + if ((node.getNodeType() == Node.ELEMENT_NODE) + && (node.getNodeName() == "property")){ + + String propertyName = + XmlTools.getChildNodeValue(node, "name"); + String propertyValue = + XmlTools.getChildNodeValue(node, "value"); + + if ((propertyName != null) && (propertyValue != null)) { + properties.setProperty(propertyName, propertyValue); + } + } + } + } + +} \ No newline at end of file Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/PluginValuesImpl.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/PluginValuesImpl.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/PluginValuesImpl.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -0,0 +1,82 @@ +/* + * 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.service.impl; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.jboss.forge.status.plugins.Plugin; +import org.jboss.forge.status.service.model.PluginValues; + +/** +* @author Pawel Wrzeszcz (paw...@gm...) +* A class used to store plugin values in shotoku. +*/ + +public class PluginValuesImpl implements PluginValues { + + private static final long serialVersionUID = 5196364802717262757L; + + private Map<String,Long> values = new HashMap<String,Long>(); + private Map<String,Integer> rates = new HashMap<String,Integer>(); + private Map<String,String> links = new HashMap<String,String>(); + + private String pluginId; + private String linkName; + + public PluginValuesImpl(Plugin plugin, Set<String> projectIds) { + + // Get plugin properties + pluginId = plugin.getId(); + linkName = plugin.getLinkName(); + + // Get plugin values + for (String projectId : projectIds) { + + values.put(projectId, plugin.getValue(projectId)); + rates.put(projectId, new Integer(plugin.getRate(projectId))); + links.put(projectId, plugin.getLink(projectId)); + } + } + + public String getId() { + return pluginId; + } + + public Long getValue(String projectId) { + return values.get(projectId); + } + + public Integer getRate(String projectId) { + return rates.get(projectId); + } + + public String getLink(String projectId) { + return links.get(projectId); + } + + public String getLinkName() { + return linkName; + } +} Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/PluginsValuesImpl.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/PluginsValuesImpl.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/PluginsValuesImpl.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -0,0 +1,117 @@ +/* + * 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.service.impl; + +import java.util.Calendar; +import java.util.Date; +import java.util.Map; +import java.util.HashMap; +import java.util.Set; + +import java.io.Serializable; + +import org.jboss.forge.common.projects.Projects; +import org.jboss.forge.common.projects.permissions.NullPermissionsChecker; + +import org.jboss.forge.status.exceptions.GetScoresException; +import org.jboss.forge.status.plugins.Plugin; +import org.jboss.forge.status.service.model.PluginsValues; +import org.jboss.forge.status.tools.Plugins; + +/** +* @author Pawel Wrzeszcz (paw...@gm...) +* A class used to store plugins values in shotoku. +*/ + +public class PluginsValuesImpl implements PluginsValues { + + private static final long serialVersionUID = -1669515339062166738L; + + /** Map : pluginId -> pluginValue */ + private Map<String,PluginValuesImpl> values; + + /** Creation date */ + private Date date; + + /** + * @param projects Projects present in the Status Matrix + * @param plugins Plugins which values will be stored + */ + public PluginsValuesImpl(Projects projects, Plugins plugins) { + + date = Calendar.getInstance().getTime(); + + values = new HashMap<String,PluginValuesImpl>(); + + Set<String> projectIds = + projects.getProjectIds(new NullPermissionsChecker(), null); + + for (Plugin plugin : plugins.getPlugins()) { + + PluginValuesImpl pluginValues = new PluginValuesImpl(plugin, projectIds); + + values.put(plugin.getId(), pluginValues); + } + } + + /** + * For the given plugin and project ids returns stored value. + * + * @param pluginId plugin id + * @param projectId project id + * @return stored plugin value for specified project + * @throws GetScoresException + * Thrown when requested value was not found + */ + public long getPluginValue(String pluginId, String projectId) + throws GetScoresException { + + Long val = null; + PluginValuesImpl pluginValues = values.get(pluginId); + + if (pluginValues != null) { + val = pluginValues.getValue(projectId); + } + + if (val == null) { + throw new GetScoresException(); + } + + return val; + } + + /** + * @return creation date + */ + public Date getDate() { + return date; + } + + public boolean hasPlugin(String pluginId) { + return values.containsKey(pluginId); + } + + public PluginValuesImpl getPluginValues(String pluginId) { + return values.get(pluginId); + } +} Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/ScoresServiceImpl.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/ScoresServiceImpl.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/ScoresServiceImpl.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -0,0 +1,341 @@ +/* + * 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.service.impl; + +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.ejb.Local; + +import org.jboss.annotation.ejb.LocalBinding; +import org.jboss.annotation.ejb.Management; +import org.jboss.annotation.ejb.Service; + +import org.jboss.forge.common.projects.Projects; + +import org.jboss.forge.status.exceptions.GetScoresException; +import org.jboss.forge.status.exceptions.ScoresSaveException; +import org.jboss.forge.status.service.model.PluginConf; +import org.jboss.forge.status.service.model.ScoresService; +import org.jboss.forge.status.service.model.ScoresServiceLocal; +import org.jboss.forge.status.tools.Plugins; +import org.jboss.forge.status.tools.Tools; + +import org.jboss.logging.Logger; +import org.jboss.shotoku.ContentManager; +import org.jboss.shotoku.Directory; +import org.jboss.shotoku.Node; +import org.jboss.shotoku.aop.Inject; +import org.jboss.shotoku.exceptions.RepositoryException; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; +import org.jboss.shotoku.exceptions.SaveException; + +/** +* @author Pawel Wrzeszcz (paw...@gm...) +*/ + +@Service(objectName=Tools.STATUS_SERVICE_NAME) +@Management(ScoresService.class) +@Local(ScoresServiceLocal.class) +@LocalBinding(jndiBinding="Status/ScoresService") +public class ScoresServiceImpl implements ScoresService, ScoresServiceLocal { + + private static Logger log = Logger.getLogger(ScoresServiceImpl.class); + + private Map<String,PluginsValuesImpl> values = new HashMap<String,PluginsValuesImpl>(); + + @Inject + private ContentManager cm; + + /** + * Saves current plugin values. + * + * @param projects Projects for which plugin values will be saved + * @param plugins Plugins for which values will be saved + * @param portalName + * @return true iff saving was successful + */ + public void save(Projects projects, List<PluginConf> pluginsConf, + String portalName) throws ScoresSaveException { + + // Get plugins from conf + Plugins plugins = new Plugins(pluginsConf, portalName, projects); + + // Get directory where we store historical scores + Directory rootDir = cm.getRootDirectory(); + String dirName = Tools.getShotokuStatusPath(portalName); + Directory dir = getDir(rootDir, dirName); + + // Get plugin values and save them in proper node + PluginsValuesImpl pluginsValues = new PluginsValuesImpl(projects, plugins); + + // Get node to store scores + String nodeName = getCurrentNodeName(); + Node node = null; + + try { + node = dir.getNode(nodeName); + } catch (RepositoryException e) { + log.error("Error while getting shotoku node: " + + dir.getFullName() + "/" + nodeName, e); + throw new ScoresSaveException(e); + } catch (ResourceDoesNotExist e) { + node = createNode(dir, nodeName); + } + + // Save values and store then in cache + values.put(getCurrentNodeName(), pluginsValues); + save(node, pluginsValues); + } + + /** + * Saves plugins values in the given Directory. + * + * @param dir Directory to save values + * @param pluginsValues PluginsValues to save + * @return true iff saving was successful + */ + private boolean save(Node node, PluginsValuesImpl pluginsValues) { + + try { + OutputStream os = node.getOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(os); + oos.writeObject((PluginsValuesImpl) pluginsValues); + oos.close(); + node.save("update"); /* os is closed inside save() */ + } catch (IOException e) { + e.printStackTrace();//TODO error messages + return false; + } catch (RepositoryException e) { + e.printStackTrace(); + return false; + } catch (SaveException e) { + e.printStackTrace(); + return false; + } + + return true; + } + + /** + * Returns historical scores from the given <code>date</code> in the past. + * + * Notice that only year, month and day matter in passed dates. + * + * @return scores from the given date + * @throws GetScoresException + */ + public PluginsValuesImpl getPluginsValues(String portalName, Date date) + throws GetScoresException { + + // null date means today + if (date == null) { + Calendar cal = Calendar.getInstance(); + date = cal.getTime(); + } + + String key = getNodeName(date); + PluginsValuesImpl v = values.get(key); + + if (v == null) { // Not in cache => get value and store it + + Directory rootDir = cm.getRootDirectory(); + + Directory dir; + try { + dir = rootDir.getDirectory(Tools.getShotokuStatusPath(portalName)); + } catch (RepositoryException e) { + throw new GetScoresException(e); + } catch (ResourceDoesNotExist e) { + throw new GetScoresException(e); + } + + if (dir != null) { + v = getPluginsValues(dir, date); + values.put(key,v); + } + } + + return v; + } + + /** + * Returns historical scores from the specified directory. + * + * @param dir Directory to read scores from + * @return + * @throws GetScoresException + */ + private PluginsValuesImpl getPluginsValues(Directory dir, Date date) + throws GetScoresException { + + // Get appropriate node + Node node = null; + String nodeName = getNodeName(date); + + try { + node = dir.getNode(nodeName); + } catch (Exception e) { + log.error("Error while getting shotoku node " + + dir.getFullName() + "/" + nodeName); + throw new GetScoresException(e); + } + + // Restore values + PluginsValuesImpl values = null; + try { + InputStream is = node.getContentInputStream(); + ObjectInputStream ois = new ObjectInputStream(is); + values = (PluginsValuesImpl) ois.readObject(); + ois.close(); + is.close(); + } catch (Exception e) { + log.error("Error while restoring scores from shotoku node " + + dir.getFullName() + "/" + nodeName); + throw new GetScoresException(e); + } + + return values; + } + + /** + * Creates new shotoku Node. + * + * @param dir Directory in which new Node will be created + * @param nodeName name of new Node + * @return Node + * @throws ScoresSaveException + */ + private Node createNode(Directory dir, String nodeName) + throws ScoresSaveException { + + Node node = null; + + try { + node = dir.newNode(nodeName); + node.save("create"); + } catch (Exception e) { + log.error("Error while creating shotoku node: " + + dir.getFullName() + "/" + nodeName, e); + throw new ScoresSaveException(e); + } + + return node; + } + + /** + * Gets shotoku Directory with name <code>dirName</code> + * from specified shotoku Directory. + * If requested Directory does not exist it is created. + * + * @param rootDir Directory where search will be performed + * @param dirName name of searched Directory + * @return Directory with the given name + * or null when creating Directory failed. + * @throws ScoresSaveException + */ + private Directory getDir(Directory rootDir, String dirName) + throws ScoresSaveException { + + Directory dir = null; + + try { + dir = rootDir.getDirectory(dirName); + } catch (RepositoryException e) { + log.error("Error while getting shotoku directory " + + rootDir.getFullName() + "/" + dirName); + throw new ScoresSaveException(e); + } catch (ResourceDoesNotExist e) { + dir = createDir(rootDir, dirName); + } + + return dir; + } + + /** + * Creates new shotoku Directory. + * + * @param rootDir Directory in which new subdirectory will be created + * @param dirName name of new Directory + * @return Directory or null if errors occured + * @throws ScoresSaveException + */ + private Directory createDir(Directory rootDir, String dirName) + throws ScoresSaveException { + + Directory dir = null; + + try { + dir = rootDir.newDirectory(dirName); + dir.save("create"); + } catch (Exception e) { + log.error("Error while creating shotoku directory: " + + rootDir.getFullName() + "/" + dirName, e); + throw new ScoresSaveException(e); + } + + return dir; + } + + /** + * Gets name of Node containing saved data from specified datestamp. + * Notice that only year, month and day matter in passed <code>date</code>. + * + * @param date datestamp + * @return Node name + */ + private String getNodeName(Date date) { + + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + + return df.format(date); + } + + /** + * @return name of Node containging data saved today + */ + private String getCurrentNodeName() { + + Calendar cal = Calendar.getInstance(); + Date today = cal.getTime(); + + return getNodeName(today); + } + + public PluginValuesImpl get(String portalName, String pluginId, Date date) + throws GetScoresException { + + PluginsValuesImpl pv = getPluginsValues(portalName, date); + return pv.getPluginValues(pluginId); + } + +} Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/PluginConf.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/PluginConf.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/PluginConf.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -0,0 +1,38 @@ +/* + * 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.service.model; + +import java.io.Serializable; +import java.util.Properties; + +/** +* @author Pawel Wrzeszcz +*/ +public interface PluginConf extends Serializable { + + //TODO PluginConfImpl has constructor + + public String getFieldValue(String fieldName); + + public Properties getProperties(); +} \ No newline at end of file Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/PluginValues.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/PluginValues.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/PluginValues.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -0,0 +1,44 @@ +/* + * 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.service.model; + +import java.io.Serializable; + +/** +* @author Pawel Wrzeszcz (paw...@gm...) +* A class used to store plugin values in shotoku. +*/ + +public interface PluginValues extends Serializable { + + public String getId(); + + public Long getValue(String projectId); + + public Integer getRate(String projectId); + + public String getLink(String projectId); + + public String getLinkName(); + +} Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/PluginsValues.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/PluginsValues.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/PluginsValues.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -0,0 +1,63 @@ +/* + * 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.service.model; + +import java.util.Date; + +import java.io.Serializable; + +import org.jboss.forge.status.exceptions.GetScoresException; + + +/** +* @author Pawel Wrzeszcz (paw...@gm...) +* A class used to store plugins values in shotoku. +*/ + +public interface PluginsValues extends Serializable { + + + //TODO constructor in impl + + /** + * For the given plugin and project ids returns stored value. + * + * @param pluginId plugin id + * @param projectId project id + * @return stored plugin value for specified project + * @throws GetScoresException + * Thrown when requested value was not found + */ + public long getPluginValue(String pluginId, String projectId) + throws GetScoresException; + + /** + * @return creation date + */ + public Date getDate(); + + public boolean hasPlugin(String pluginId); + + public PluginValues getPluginValues(String pluginId); + +} Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/ScoresService.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/ScoresService.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/ScoresService.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -0,0 +1,45 @@ +/* + * 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.service.model; + +import java.util.Date; +import java.util.List; + +import org.jboss.forge.common.projects.Projects; +import org.jboss.forge.status.exceptions.GetScoresException; +import org.jboss.forge.status.exceptions.ScoresSaveException; + +/** +* @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com) +*/ +public interface ScoresService { + + public PluginsValues getPluginsValues(String portalName, + Date date) throws GetScoresException; + + public void save(Projects projects, List<PluginConf> pluginsConf, + String portalName) throws ScoresSaveException; + + public PluginValues get(String portalName, String pluginId, Date date) + throws GetScoresException; +} \ No newline at end of file Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/ScoresServiceLocal.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/ScoresServiceLocal.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/model/ScoresServiceLocal.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -0,0 +1,45 @@ +/* + * 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.service.model; + +import java.util.Date; +import java.util.List; + +import org.jboss.forge.common.projects.Projects; +import org.jboss.forge.status.exceptions.GetScoresException; +import org.jboss.forge.status.exceptions.ScoresSaveException; + +/** +* @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com) +*/ +public interface ScoresServiceLocal { + + public PluginsValues getPluginsValues(String portalName, + Date date) throws GetScoresException; + + public void save(Projects projects, List<PluginConf> pluginsConf, + String portalName) throws ScoresSaveException; + + public PluginValues get(String portalName, String pluginId, Date date) + throws GetScoresException; +} \ No newline at end of file Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/CellTemplate.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/CellTemplate.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/CellTemplate.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -26,7 +26,7 @@ import java.util.List; import org.jboss.forge.common.XmlTools; -import org.jboss.forge.status.tools.PluginsValues; +import org.jboss.forge.status.service.model.PluginsValues; import org.jboss.forge.status.tools.Tags; import org.jboss.portal.common.context.DelegateContext; Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/Column.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/Column.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/Column.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -28,7 +28,7 @@ import org.jboss.forge.common.projects.Projects; import org.jboss.forge.common.projects.permissions.NullPermissionsChecker; -import org.jboss.forge.status.tools.PluginValues; +import org.jboss.forge.status.service.model.PluginValues; import org.jboss.forge.status.tools.ProjectsByScoreComparator; import org.jboss.logging.Logger; import org.jboss.portal.common.context.DelegateContext; Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/Columns.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/Columns.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/Columns.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -34,8 +34,10 @@ import org.jboss.forge.common.projects.permissions.NullPermissionsChecker; import org.jboss.forge.common.projects.permissions.PermissionsChecker; -import org.jboss.forge.status.tools.PluginValues; -import org.jboss.forge.status.tools.PluginsValues; +import org.jboss.forge.status.service.impl.PluginValuesImpl; +import org.jboss.forge.status.service.impl.PluginsValuesImpl; +import org.jboss.forge.status.service.model.PluginValues; +import org.jboss.forge.status.service.model.PluginsValues; import org.jboss.forge.status.tools.ProjectsByNameComparator; import org.jboss.forge.status.tools.ProjectsByScoreComparator; import org.jboss.forge.status.tools.Tags; Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/MatrixTemplate.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/MatrixTemplate.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/MatrixTemplate.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -27,7 +27,7 @@ import org.jboss.forge.common.XmlTools; import org.jboss.forge.common.projects.Projects; -import org.jboss.forge.status.tools.PluginsValues; +import org.jboss.forge.status.service.model.PluginsValues; import org.jboss.forge.status.tools.Tags; import org.jboss.portal.common.context.DelegateContext; Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/MetricTemplate.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/MetricTemplate.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/MetricTemplate.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -22,8 +22,8 @@ package org.jboss.forge.status.templates; -import org.jboss.forge.status.tools.PluginValues; -import org.jboss.forge.status.tools.PluginsValues; +import org.jboss.forge.status.service.model.PluginValues; +import org.jboss.forge.status.service.model.PluginsValues; import org.jboss.forge.status.tools.Tags; import org.jboss.forge.common.XmlTools; import org.jboss.portal.common.context.DelegateContext; Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/RowTemplate.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/RowTemplate.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/templates/RowTemplate.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -26,7 +26,7 @@ import java.util.ArrayList; import org.jboss.forge.common.XmlTools; -import org.jboss.forge.status.tools.PluginsValues; +import org.jboss.forge.status.service.model.PluginsValues; import org.jboss.forge.status.tools.Tags; import org.jboss.portal.common.context.DelegateContext; Deleted: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/PluginConf.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/PluginConf.java 2006-04-21 16:27:16 UTC (rev 3889) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/PluginConf.java 2006-04-21 17:14:54 UTC (rev 3890) @@ -1,113 +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.tools; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import org.jboss.forge.common.XmlTools; -import org.jboss.forge.status.exceptions.InvalidPluginsConfigurationException; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** -* @author Pawel Wrzeszcz -*/ -public class PluginConf implements Serializable { - - private static final long serialVersionUID = 8598887068548048511L; - - private Map<String,String> fields = new HashMap<String,String>(); - private Properties properties = new Properties(); - - public... [truncated message content] |